How to use the deep-equal.bind function in deep-equal

To help you get started, we’ve selected a few deep-equal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fortunejs / fortune-json-api / lib / helpers.js View on Github external
`The filter "${filterType}" is not valid.`)
    }
  }

  // Attach include option.
  if (reservedKeys.include in query) {
    request.include = (Array.isArray(query[reservedKeys.include]) ?
      query[reservedKeys.include] :
      query[reservedKeys.include].split(','))
      .map(i => i.split('.').map(x => inflect(x)).slice(0, includeLimit))

    // Manually expand nested includes.
    for (const path of request.include)
      for (let i = path.length - 1; i > 0; i--) {
        const j = path.slice(0, i)
        if (!request.include.some(deepEqual.bind(null, j)))
          request.include.push(j)
      }
  }

  // Attach sort option.
  if (reservedKeys.sort in query)
    request.options.sort = (Array.isArray(query.sort) ?
      query.sort : query.sort.split(','))
      .reduce((sort, field) => {
        if (field.charAt(0) === '-') sort[inflect(field.slice(1))] = false
        else sort[inflect(field)] = true
        return sort
      }, {})

  // Attach offset option.
  if (pageOffset in query)
github fortunejs / fortune / lib / serializer / serializers / json_api / helpers.js View on Github external
value = castString.get(fields[field][keys.type])(value, options)
      request.options.match[field] = value
    }
  }

  // Attach include option.
  if (reservedKeys.include in query) {
    request.include = (Array.isArray(query[reservedKeys.include]) ?
      query[reservedKeys.include] : [ query[reservedKeys.include] ])
      .map(i => i.split('.').slice(0, includeLimit))

    // Manually expand nested includes.
    for (let path of request.include) {
      for (let i = path.length - 1; i > 0; i--) {
        const j = path.slice(0, i)
        if (!request.include.some(deepEqual.bind(null, j)))
          request.include.push(j)
      }
    }
  }

  // Attach sort option.
  if (reservedKeys.sort in query) {
    let sort = query.sort
    if (!Array.isArray(sort)) sort = [ sort ]

    request.options.sort = sort.reduce((sort, field) => {
      const firstChar = field.charAt(0)

      if (firstChar === '-') sort[field.slice(1)] = false
      else sort[field] = true

deep-equal

node's assert.deepEqual algorithm

MIT
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis