How to use the @serverless/utils.isObject function in @serverless/utils

To help you get started, we’ve selected a few @serverless/utils 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 serverless / components / src / utils / component / defineComponent.js View on Github external
const defineComponent = async (component, state, context) => {
  // TODO BRN: If we ever need to retrigger define (redefine) hydrating state here may be an issue
  if (!isComponent(component)) {
    throw new TypeError(
      `defineComponent expected component parameter to be a component. Instead received ${component}`
    )
  }
  component = hydrateComponent(component, state, context)
  if (isFunction(component.define)) {
    let children = await or(component.define(context), {})
    children = filter(isComponent, map(resolve, children))

    if (isObject(children)) {
      forEach((child) => {
        // TODO BRN: Look for children that already have parents. If this is the case then someone has returned a child from define that was defined by another component (possibly passed along as a variable)
        child.parent = component
        // child = setKey(appendKey(getKey(component), kdx), child)
      }, children)
    } else {
      throw new Error(
        `define() method must return either an object or an array. Instead received ${children} from ${component}.`
      )
    }
    component.children = await map(
      async (child, key) => defineComponent(child, get(['children', key], state), context),
      children
    )
  }
  return component
github serverless / components / src / utils / variable / resolveVariables.js View on Github external
const visitVariables = (value, visited) => {
  value = resolve(value)
  if (value && !visited.has(value)) {
    if (isArray(value)) {
      visited.add(value)
      forEachIndexed((aValue, index) => (value[index] = visitVariables(aValue, visited)), value)
      visited.delete(value)
    } else if (isObject(value)) {
      visited.add(value)
      forEachObjIndexed((oValue, key) => {
        if (key !== 'children' && key !== 'inputTypes') {
          value[key] = visitVariables(oValue, visited)
        }
      }, value)
      visited.delete(value)
    }
  }
  return value
}
github serverless / components / src / utils / component / walkReduceEvaluables.js View on Github external
return (accum, value, keys, iteratee, recur) => {
    let result = accum
    if (isEvaluable(value)) {
      visited.add(value)
      result = iteratee(result, value, keys)
      value = resolve(value)
      if (isComponent(value) || !isObject(value)) {
        return result
      }
    }
    if (isObject(value) && !visited.has(value)) {
      if (isArray(value) || !isNativeObject(value)) {
        visited.add(value)
        forEach((childValue, childKdx) => {
          if (!isComponent(childValue)) {
            const newKeys = concat(keys, [childKdx])
            result = recur(result, childValue, newKeys, iteratee)
          }
        }, value)
      }
    }
    return result
  }
}
github serverless / components / src / utils / component / walkReduceComponentChildrenDepthFirst.js View on Github external
const walkee = (accum, component, keys, iteratee, recur) => {
  let result = accum
  const children = resolve(component.children)
  if (isObject(children)) {
    forEach((child, childKdx) => {
      const newKeys = concat(keys, [childKdx])
      result = recur(result, resolve(child), newKeys, iteratee)
    }, children)
  }
  return iteratee(result, component, keys)
}
github serverless / components / src / plugins / Info / index.js View on Github external
forEach((val, key) => {
      if (isArray(val)) {
        printArray(val, subLog, level + 1)
      } else if (isObject(val)) {
        log(`${key}:`)
        printObj(val, subLog, level + 1)
      } else {
        log(`${key}: ${val}`)
      }
    }, obj)
  }
github serverless / components / src / utils / component / walkReduceEvaluables.js View on Github external
return (accum, value, keys, iteratee, recur) => {
    let result = accum
    if (isEvaluable(value)) {
      visited.add(value)
      result = iteratee(result, value, keys)
      value = resolve(value)
      if (isComponent(value) || !isObject(value)) {
        return result
      }
    }
    if (isObject(value) && !visited.has(value)) {
      if (isArray(value) || !isNativeObject(value)) {
        visited.add(value)
        forEach((childValue, childKdx) => {
          if (!isComponent(childValue)) {
            const newKeys = concat(keys, [childKdx])
            result = recur(result, childValue, newKeys, iteratee)
          }
        }, value)
      }
    }
    return result
  }
github serverless / components / src / utils / component / walkReduceComponentReferences.js View on Github external
return (accum, value, keys, iteratee, recur) => {
    let result = accum
    if (isObject(value) && !visited.has(value)) {
      if (isArray(value) || (!isNativeObject(value) && !isVariable(value))) {
        visited.add(value)
        forEach((childValue, childKdx) => {
          const newKeys = concat(keys, [childKdx])
          if (isComponent(childValue)) {
            visited.add(childValue)
            result = iteratee(result, childValue, newKeys)
          } else {
            result = recur(result, childValue, newKeys, iteratee)
          }
        }, value)
      }
    }
    return result
  }
}
github serverless / components / src / utils / component / walkReduceComponentOwnVariables.js View on Github external
return (accum, value, keys, iteratee, recur) => {
    let result = accum
    if (isObject(value) && !visited.has(value)) {
      if (isVariable(value)) {
        visited.add(value)
        result = iteratee(result, value, keys)
      } else if (isArray(value) || !isNativeObject(value)) {
        visited.add(value)
        forEach((childValue, childKdx) => {
          if (!isComponent(childValue)) {
            const newKeys = concat(keys, [childKdx])
            result = recur(result, childValue, newKeys, iteratee)
          }
        }, value)
      }
    }
    return result
  }
}
github serverless / components / src / utils / type / isTypeConstruct.js View on Github external
const isTypeConstruct = (value) =>
  isString(getProp('type', value)) && isObject(getProp('inputs', value))
github serverless / components / src / utils / component / walkReduceComponentChildren.js View on Github external
const reduceWalkee = (accum, component, keys, iteratee, recur) => {
  let result = iteratee(accum, component, keys)
  const children = resolve(component.children)
  if (isObject(children)) {
    forEach((child, childKdx) => {
      const newKeys = concat(keys, [childKdx])
      result = recur(result, resolve(child), newKeys, iteratee)
    }, children)
  }
  return result
}