Have ideas to improve npm?Join in the discussion! »

    property-waterfall

    1.0.0 • Public • Published

    GitHub package.json version GitHub repo size dependencies

    property-waterfall

    Looks for a valid value in an object, iterating over a priority ordered array of keys.

    Installation

    npm i --save property-waterfall

    Usage

    const propertyWaterfall = require('property-waterfall')
     
    // Look for IP in the following keys, in order.
    const order = ['ip', 'x-forwarded-for', 'x-real-ip']
     
    // IP could be in any of this objects, containing `order` keys.
    const object = {
      ...req.headers,
      ...req.query
    }
     
    const ip = propertyWaterfall(object, order)
     
    // If object['ip'] has a valid value, it will be returned,
    // else look for object['x-forwarded-for'],
    // else object['x-real-ip'].
    // According to order array priorities.

    Install

    npm i property-waterfall

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    5.53 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar