How to use is-plain-obj - 9 common examples

To help you get started, we’ve selected a few is-plain-obj 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 staeco / iris-ql / src / Aggregation / parse.js View on Github external
value: a.value,
      message: 'Missing value!'
    })
    throw error // dont even bother continuing
  }

  try {
    agg = new QueryValue(a.value, {
      ...opt,
      context: [ ...context, 'value' ]
    }).value()
  } catch (err) {
    error.add(err)
  }

  if (a.filters && !isObject(a.filters) && !Array.isArray(a.filters)) {
    error.add({
      path: [ ...context, 'filters' ],
      value: a.filters,
      message: 'Must be an object or array.'
    })
  }
  try {
    parsedFilters = a.filters && new Filter(a.filters, {
      ...opt,
      context: [ ...context, 'filters' ]
    }).value()
  } catch (err) {
    error.add(err)
  }
  if (!error.isEmpty()) throw error
  return [
github staeco / iris-ql / src / types / functions.js View on Github external
const getGeoReturnType = (raw) => {
  let o
  try {
    o = JSON.parse(raw)
  } catch (err) {
    return 'geometry'
  }
  if (!isObject(o)) return 'geometry'

  // FeatureCollection
  if (Array.isArray(o.features)) return 'geometry'
  // Feature
  if (o.geometry) return getGeoReturnType(JSON.stringify(o.geometry))
  // Regular types
  if (point.check(o)) return 'point'
  if (line.check(o)) return 'line'
  if (multiline.check(o)) return 'multiline'
  if (polygon.check(o)) return 'polygon'
  if (multipolygon.check(o)) return 'multipolygon'
  return 'geometry'
}
github staeco / iris-ql / src / Query / parse.js View on Github external
}
      if (ymaxIssue !== true) {
        error.add({
          path: [ ...context, 'within', 'ymax' ],
          value: ymax,
          message: ymaxIssue
        })
      }
      const box = srid(fn('ST_MakeEnvelope', actualXMin, actualYMin, actualXMax, actualYMax))
      out.where.push(intersects(box, { model }))
    }
  }

  // if they defined a point
  if (query.intersects) {
    if (!isObject(query.intersects)) {
      error.add({
        path: [ ...context, 'intersects' ],
        value: query.intersects,
        message: 'Must be an object.'
      })
    } else {
      const { x, y } = query.intersects
      const actualX = parseIffyNumber(x)
      const actualY = parseIffyNumber(y)
      const latIssue = lat(actualY)
      const lonIssue = lon(actualX)
      if (lonIssue !== true) {
        error.add({
          path: [ ...context, 'intersects', 'x' ],
          value: x,
          message: lonIssue
github cerebral / overmind / packages / node_modules / overmind / src / utils.ts View on Github external
return Object.keys(obj).reduce((aggr: any, key) => {
      if (key === '__esModule') {
        return aggr
      }

      const originalDescriptor = Object.getOwnPropertyDescriptor(obj, key)
      const isAGetter = originalDescriptor && 'get' in originalDescriptor
      const value = obj[key]

      if (isPlainObject(value) && !isAGetter) {
        aggr[key] = deepCopy(value)
      } else {
        Object.defineProperty(aggr, key, originalDescriptor as any)
      }

      return aggr
    }, {})
  } else if (Array.isArray(obj)) {
github cerebral / overmind / packages / node_modules / overmind / src / utils.ts View on Github external
export function deepCopy(obj) {
  if (isPlainObject(obj)) {
    return Object.keys(obj).reduce((aggr: any, key) => {
      if (key === '__esModule') {
        return aggr
      }

      const originalDescriptor = Object.getOwnPropertyDescriptor(obj, key)
      const isAGetter = originalDescriptor && 'get' in originalDescriptor
      const value = obj[key]

      if (isPlainObject(value) && !isAGetter) {
        aggr[key] = deepCopy(value)
      } else {
        Object.defineProperty(aggr, key, originalDescriptor as any)
      }

      return aggr
github staeco / iris-ql / src / types / index.js View on Github external
const getBasicGeoJSONIssues = (v, type) => {
  if (!isObject(v)) return 'Not a valid object'
  if (v.type !== type) return `Not a valid type value (Expected ${type} not ${v.type})`
}
github cerebral / overmind / packages / node_modules / overmind / src / index.ts View on Github external
private scopeValue(value: any, tree: TTree) {
    if (!value) {
      return value
    }
    if (value[IS_PROXY]) {
      return this.proxyStateTree.rescope(value, tree)
    } else if (isPlainObject(value)) {
      return Object.assign(
        {},
        ...Object.keys(value).map((key) => ({
          [key]: this.proxyStateTree.rescope(value[key], tree),
        }))
      )
    } else {
      return value
    }
  }
  private addExecutionMutation(mutation: IMutation) {
github bjrmatos / json-schema-sugar / src / array.js View on Github external
let generatedSchema = itemType.generate({ obj: true });

            if (Object.keys(generatedSchema).length > 0) {
              itemsSchema.push(generatedSchema);
            }
          }
        });

        if (itemsSchema.length > 0) {
          schema.items = itemsSchema;
        }
      } else if (isPlainObj(opts.items) || opts.items instanceof MixedSchema) {
        let itemsType = opts.items,
            generatedSchema;

        if (isPlainObj(itemsType)) {
          itemsType = new ObjectSchema().keys(itemsType);
        }

        generatedSchema = itemsType.generate({ obj: true });

        if (Object.keys(generatedSchema).length > 0) {
          schema.items = generatedSchema;
        }
      }
    }

    if (opts.additionalItems != null) {
      schema.additionalItems = opts.additionalItems;
    }

    if (opts.minItems != null) {
github tinajs / tina / src / adapters / data / plain.js View on Github external
static isData (data) {
    return isPlainObject(data)
  }

is-plain-obj

Check if a value is a plain object

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Popular is-plain-obj functions