How to use component-type - 9 common examples

To help you get started, we’ve selected a few component-type 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 anthonyshort / deku / lib / helpers / virtual.js View on Github external
export function nodeType (node) {
  var v = type(node)
  if (v === 'null' || node === false) return 'empty'
  if (v !== 'object') return 'text'
  if (type(node.type) === 'string') return 'element'
  return 'component'
}
github eivindfjeldstad / validate / src / validators.js View on Github external
type(value, ctx, name) {
    if (value == null) return true;

    if (typeof name == 'function') {
      return value.constructor === name;
    }

    return typeOf(value) === name;
  },
github segmentstream / digital-data-manager / src / AutoEvents.js View on Github external
this.onPageChange(newPage, oldPage);
        }]);

        this.ddListener.push(['on', 'change:product.id', (newProductId, oldProductId) => {
          this.onProductChange(newProductId, oldProductId);
        }]);

        this.ddListener.push(['on', 'change:transaction.orderId', (newOrderId, oldOrderId) => {
          this.onTransactionChange(newOrderId, oldOrderId);
        }]);
      }

      const trackDOMComponents = this.options.trackDOMComponents;
      if (!!window.jQuery && trackDOMComponents !== false) {
        const options = {};
        if (type(trackDOMComponents) === 'object') {
          options.maxWebsiteWidth = trackDOMComponents.maxWebsiteWidth;
        }
        this.domComponentsTracking = new DOMComponentsTracking(options);
        this.domComponentsTracking.initialize();
      }
    }
  }
github citycide / trilogy / src / util.js View on Github external
export const isType = (value, kind) => {
  if (!kind) return type(value)
  return type(value) === kind.toLowerCase()
}
github anthonyshort / deku / lib / helpers / dom.js View on Github external
export function isValidAttributeValue (value) {
  var valueType = type(value)
  switch (valueType) {
    case 'string':
    case 'number':
      return true
    case 'boolean':
      return value
    default:
      return false
  }
}
github ianstormtaylor / superstruct / src / types.js View on Github external
  array: v => typeOf(v) === 'array',
  boolean: v => typeOf(v) === 'boolean',
github eivindfjeldstad / validate / src / utils.js View on Github external
export function walk(obj, callback, path, prop) {
  const type = typeOf(obj);

  if (type === 'array') {
    obj.forEach((v, i) =>
      walk(v, callback, join(i, path), join('$', prop))
    );
    return;
  }

  if (type !== 'object') {
    return;
  }

  for (const [key, val] of Object.entries(obj)) {
    const newPath = join(key, path);
    const newProp = join(key, prop);
    if (callback(newPath, newProp)) {
github anthonyshort / deku / lib / helpers / virtual.js View on Github external
export function nodeType (node) {
  var v = type(node)
  if (v === 'null' || node === false) return 'empty'
  if (v !== 'object') return 'text'
  if (type(node.type) === 'string') return 'element'
  return 'component'
}
github citycide / trilogy / src / util.js View on Github external
export function map (collection, fn) {
  const kind = type(collection)
  if (kind !== 'object' && kind !== 'array') {
    return collection
  }

  const result = kind === 'array' ? [] : {}
  each(collection, (value, key, collection) => {
    result[key] = fn(value, key, collection)
  })

  return result
}

component-type

Type assertions aka less-broken `typeof`

MIT
Latest version published 1 year ago

Package Health Score

77 / 100
Full package analysis

Popular component-type functions