Esempio n. 1
0
  function level (contents, key, value, depth) {
    var obj = { depth: depth, name: key }

    if (isobject(value) && value.link) {
      obj.source = value.link
    }

    if (isobject(value) && value.contributors) {
      obj.contributors = isarray(value.contributors) ? value.contributors : [value.contributors]
    }

    if (isobject(value) && !value.file) {
      menu.push(obj)
      iterate(value, depth)
    } else {
      if (isobject(value)) {
        obj.source = value.link
        obj.contributors = isarray(value.contributors) ? value.contributors : [value.contributors]
        value = value.file
      }
      var parsed = parsePath(value)
      obj.key = parsed.name
      obj.link = options.basedir + '/' + obj.key
      menu.push(obj)
    }
    return menu
  }
 componentDidMount: function() {
   if (this.validatorTypes !== undefined && !isObject(this.validatorTypes)) {
     throw Error('invalid `validatorTypes` type');
   }
   if (this.getValidatorData !== undefined && !isObject(this.getValidatorData)) {
     throw Error('invalid `getValidatorData` type');
   }
 },
Esempio n. 3
0
	secureNet.getTransaction = function(data, next) {

		//convenience
		if (!isObject(data)) data = {transactionId: data};

		//validate
		Assert.ok(isObject(data), 'param `data` must be an object.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');
		Assert.ok(isInteger(data.transactionId), 'param `data.transactionId` must be an integer.');

		util.get('/Transactions/' + data.transactionId, null, next);
	};
Esempio n. 4
0
	secureNet.getCustomer = function(data, next) {

		//convenience
		if (!isObject(data)) data = {customerId: data};

		//validate
		Assert.ok(isObject(data), 'param `data` must be an object.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');
		Assert.ok(isInteger(data.customerId), 'param `customerId` or `data.customerId` must be an integer.');

		util.get('/Customers/' + data.customerId, null, next);
	};
Esempio n. 5
0
	secureNet.void = function(data, next) {

		//convenience
		if (!isObject(data)) data = {transactionId: data};

		//validate
		Assert.ok(isObject(data), 'param `data` must be an object.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');
		Assert.ok(isInteger(data.transactionId), 'param `data.transactionId` must be an integer.');

		util.post('/Payments/Void', data, next);
	};
Esempio n. 6
0
	secureNet.getTransactions = function(data, next) {

		//validate
		Assert.ok(isObject(data) || isString(data), 'param `data` must be an object or string.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');

		//validate
		if (isObject(data)) {
			util.post('/Transactions/Search', data, next);
		} else {
			util.get('/Transactions/' + data, null, next);
		}
	};
Esempio n. 7
0
test('make works', t => {
  const icons = {
    js: {
      config: jsConfig,
      type: 'ends',
    },
  }
  const config = make(icons)

  t.truthy(isObject(config), 'config is not an object')
  t.truthy(isObject(config.global), 'global is not an object')
  t.truthy(isObject(config.icons), 'icons is not an object')
  t.truthy(isObject(config.icons.properties.js), 'js is not an object')
})
 selector.keyCodes.forEach(keyCode => {
   //if we get just a number we check the keyCode
   if (!isObject(keyCode) && e.keyCode === keyCode){
     e.preventDefault();
     this.note(tagName);
   } else if(isObject(keyCode)){
     //in the dynamic case we need to check for BOTH the modifier key AND keycode
     var modifier = Object.keys(keyCode)[0];
     if(e[modifier] && e.keyCode === keyCode[modifier]){
       e.preventDefault();
       this.note(tagName);
     }
   }
 });
Esempio n. 9
0
  return reduce(data, (o, v, k) => {
    const rules = schema[k]
    const needsNesting =  isObject(rules) && !isArray(rules)

    if (needsNesting) {
      if (isObject(v)) {
        o[k] = filterWithLens(rules, user, v)
      }
    } else if (isAllowed(rules, user, data)) {
      o[k] = v
    }

    return o
  }, {})
Esempio n. 10
0
  widths.forEach((colWidth, i) => {
    let columnProp = props[colWidth];

    if (!i && columnProp === undefined) {
      columnProp = true;
    }

    delete attributes[colWidth];

    if (!columnProp) {
      return;
    }

    const isXs = !i;
    let colClass;

    if (isobject(columnProp)) {
      const colSizeInterfix = isXs ? '-' : `-${colWidth}-`;
      colClass = getColumnSizeClass(isXs, colWidth, columnProp.size);

      colClasses.push(mapToCssModules(classNames({
        [colClass]: columnProp.size || columnProp.size === '',
        [`push${colSizeInterfix}${columnProp.push}`]: columnProp.push || columnProp.push === 0,
        [`pull${colSizeInterfix}${columnProp.pull}`]: columnProp.pull || columnProp.pull === 0,
        [`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset || columnProp.offset === 0
      })), cssModule);
    } else {
      colClass = getColumnSizeClass(isXs, colWidth, columnProp);
      colClasses.push(colClass);
    }
  });
Esempio n. 11
0
 function bound() {
   var thisBinding = isBind ? thisArg : this;
   if (partialArgs) {
     var args = slice(partialArgs);
     push.apply(args, arguments);
   }
   if (partialRightArgs || isCurry) {
     args || (args = slice(arguments));
     if (partialRightArgs) {
       push.apply(args, partialRightArgs);
     }
     if (isCurry && args.length < arity) {
       bitmask |= 16 & ~32;
       return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]);
     }
   }
   args || (args = arguments);
   if (isBindKey) {
     func = thisBinding[key];
   }
   if (this instanceof bound) {
     thisBinding = baseCreate(func.prototype);
     var result = func.apply(thisBinding, args);
     return isObject(result) ? result : thisBinding;
   }
   return func.apply(thisBinding, args);
 }
Esempio n. 12
0
test('makeIs', t => {
  const icon = makeIconConfig('.travis.yml', [ 'Travis' ], 'Travis-CI')
  const config = makeIs(icon)

  t.truthy(isObject(config), 'config is not an object')
  t.truthy(config.properties.icon.description === 'File name is: .travis.yml')
})
Esempio n. 13
0
  widths.forEach((colWidth, i) => {
    let columnProp = props[colWidth];

    delete attributes[colWidth];

    if (!columnProp && columnProp !== '') {
      return;
    }

    const isXs = !i;

    if (isobject(columnProp)) {
      const colSizeInterfix = isXs ? '-' : `-${colWidth}-`;
      const colClass = getColumnSizeClass(isXs, colWidth, columnProp.size);

      colClasses.push(mapToCssModules(classNames({
        [colClass]: columnProp.size || columnProp.size === '',
        [`order${colSizeInterfix}${columnProp.order}`]: columnProp.order || columnProp.order === 0,
        [`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset || columnProp.offset === 0
      }), cssModule));
    } else {
      const colClass = getColumnSizeClass(isXs, colWidth, columnProp);
      colClasses.push(colClass);
    }
  });
Esempio n. 14
0
function isValidAction(action) {
    const isFunc = isFunction(action);
    const isObj = isObject(action);
    const hasType = isObj && action.hasOwnProperty('type');

    if (!isFunc && isObj && hasType) {
        return true;
    }

    if (process.env.NODE_ENV !== 'production') {
        if (isFunc) {
            console.warn( // eslint-disable-line no-console
                `[redux-storage] ACTION IGNORED! Actions should be objects`
                + ` with a type property but received a function! Your`
                + ` function resolving middleware (e.g. redux-thunk) must be`
                + ` placed BEFORE redux-storage!`
            );
        } else if (!isObj) {
            console.warn( // eslint-disable-line no-console
                `[redux-storage] ACTION IGNORED! Actions should be objects`
                + ` with a type property but received: ${action}`
            );
        } else if (!hasType) {
            console.warn( // eslint-disable-line no-console
                `[redux-storage] ACTION IGNORED! Action objects should have`
                + ` a type property.`
            );
        }
    }

    return false;
}
Esempio n. 15
0
/**
 * Produces a callback bound to an optional `thisArg`. If `func` is a property
 * name the created callback will return the property value for a given element.
 * If `func` is an object the created callback will return `true` for elements
 * that contain the equivalent object properties, otherwise it will return `false`.
 *
 * @static
 * @memberOf _
 * @category Utilities
 * @param {*} [func=identity] The value to convert to a callback.
 * @param {*} [thisArg] The `this` binding of the created callback.
 * @param {number} [argCount] The number of arguments the callback accepts.
 * @returns {Function} Returns a callback function.
 * @example
 *
 * var characters = [
 *   { 'name': 'barney', 'age': 36 },
 *   { 'name': 'fred',   'age': 40 }
 * ];
 *
 * // wrap to create custom callback shorthands
 * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
 *   var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
 *   return !match ? func(callback, thisArg) : function(object) {
 *     return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
 *   };
 * });
 *
 * _.filter(characters, 'age__gt38');
 * // => [{ 'name': 'fred', 'age': 40 }]
 */
function createCallback(func, thisArg, argCount) {
  var type = typeof func;
  if (func == null || type == 'function') {
    return baseCreateCallback(func, thisArg, argCount);
  }
  // handle "_.pluck" style callback shorthands
  if (type != 'object') {
    return property(func);
  }
  var props = keys(func),
      key = props[0],
      a = func[key];

  // handle "_.where" style callback shorthands
  if (props.length == 1 && a === a && !isObject(a)) {
    // fast path the common case of providing an object with a single
    // property containing a primitive value
    return function(object) {
      var b = object[key];
      return a === b && (a !== 0 || (1 / a == 1 / b));
    };
  }
  return function(object) {
    var length = props.length,
        result = false;

    while (length--) {
      if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
        break;
      }
    }
    return result;
  };
}
Esempio n. 16
0
 /**
  * Check the instance for object representation of Geo Point.
  * If representation is null, new object is initialised.
  * If it is not null, warning is logged and point is overwritten.
  * @private
  */
 _checkObjRepr() {
     if (isNil(this._point)) this._point = {};
     else if (!isObject(this._point)) {
         this._warnMixedRepr();
         this._point = {};
     }
 }
Esempio n. 17
0
/**
 * Recursively merges own enumerable properties of the source object(s), that
 * don't resolve to `undefined` into the destination object. Subsequent sources
 * will overwrite property assignments of previous sources. If a callback is
 * provided it will be executed to produce the merged values of the destination
 * and source properties. If the callback returns `undefined` merging will
 * be handled by the method instead. The callback is bound to `thisArg` and
 * invoked with two arguments; (objectValue, sourceValue).
 *
 * @static
 * @memberOf _
 * @category Objects
 * @param {Object} object The destination object.
 * @param {...Object} [source] The source objects.
 * @param {Function} [callback] The function to customize merging properties.
 * @param {*} [thisArg] The `this` binding of `callback`.
 * @returns {Object} Returns the destination object.
 * @example
 *
 * var names = {
 *   'characters': [
 *     { 'name': 'barney' },
 *     { 'name': 'fred' }
 *   ]
 * };
 *
 * var ages = {
 *   'characters': [
 *     { 'age': 36 },
 *     { 'age': 40 }
 *   ]
 * };
 *
 * _.merge(names, ages);
 * // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] }
 *
 * var food = {
 *   'fruits': ['apple'],
 *   'vegetables': ['beet']
 * };
 *
 * var otherFood = {
 *   'fruits': ['banana'],
 *   'vegetables': ['carrot']
 * };
 *
 * _.merge(food, otherFood, function(a, b) {
 *   return _.isArray(a) ? a.concat(b) : undefined;
 * });
 * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }
 */
function merge(object) {
  var args = arguments,
      length = 2;

  if (!isObject(object)) {
    return object;
  }
  // allows working with `_.reduce` and `_.reduceRight` without using
  // their `index` and `collection` arguments
  if (typeof args[2] != 'number') {
    length = args.length;
  }
  if (length > 3 && typeof args[length - 2] == 'function') {
    var callback = baseCreateCallback(args[--length - 1], args[length--], 2);
  } else if (length > 2 && typeof args[length - 1] == 'function') {
    callback = args[--length];
  }
  var sources = slice(arguments, 1, length),
      index = -1,
      stackA = getArray(),
      stackB = getArray();

  while (++index < length) {
    baseMerge(object, sources[index], callback, stackA, stackB);
  }
  releaseArray(stackA);
  releaseArray(stackB);
  return object;
}
Esempio n. 18
0
function search(elems, testStr, keywordGetter, matchFunc) {
  const results = [];
  const _keywordGetter = keywordGetter || _defaultKeywordGetter;

  if (testStr === null || testStr === undefined || testStr.length === 0)
    return results;

  const testStr_norm = testStr.toLowerCase();
  if (Array.isArray(elems)) {
    // array
    for (let i = 0; i < elems.length; ++i) {
      const matchResult = matchFunc(elems[i], testStr_norm, _keywordGetter);
      if (matchResult.score === 0) continue;
      results.push(matchResult);
    }
  } else if (lo_isObject(elems)) {
    // object like { [], [], [], ... }
    for (const prop in elems) {
      const arr = elems[prop];
      for (let i = 0; i < arr.length; ++i) {
        const matchResult = matchFunc(arr[i], testStr_norm, _keywordGetter);
        if (matchResult.score === 0) continue;
        results.push(matchResult);
      }
    }
  } else {
    // can't process
    return results;
  }
  return lo_orderBy(results, ['score', 'length'], ['desc', 'asc']); // stable sort
}
Esempio n. 19
0
test('makePath', t => {
  const icon = makeIconConfig('/test/', [ 'AVA' ], 'Test Files')
  const config = makePath(icon)

  t.truthy(isObject(config), 'config is not an object')
  t.truthy(config.properties.icon.description === 'Path contains: /test/')
})
Esempio n. 20
0
test('makeStarts', t => {
  const icon = makeIconConfig('.eslint', [ 'ESLint' ], 'ESLint')
  const config = makeStarts(icon)

  t.truthy(isObject(config), 'config is not an object')
  t.truthy(config.properties.icon.description === 'File starts with: .eslint')
})
Esempio n. 21
0
  Object.keys(types).forEach(key => {
    const config = types[key]

    t.ok(isObject(config), 'config is not an object')
    t.ok(isString(config.type), 'type is not a string')
    t.ok(~options.indexOf(config.type), 'type is not in options')
  })
Esempio n. 22
0
function fixPaths(value, base) {
  var path;

  if (isString(value)) {
    path = resolvePath(base, value);

    return isPath(path).then(function (isPath) {
      if (isPath) {
        return path;
      }
      return value;
    });
  }

  if (isObject(value)) {
    var promises = map(value, function (item, key) {
      return fixPaths(item, base).then(function (item) {
        value[key] = item;
      });
    });
    return Bluebird.all(promises).return(value);
  }

  return Bluebird.resolve(value);
}
      t.test(curCase.name, co.wrap(function * (t) {
        let core = CurrentAdapter()
        let result, error
        try {
          result = core[adapterMethod](curCase.data)
          t.ok(isPromise(result), 'result to be Promise')
          result = yield result
        } catch (e) {
          error = e
        }

        if (!error) {
          if (curCase.error) {
            t.fail(`Expected error "${curCase.error}" but have result`)
          }
          if (isObject(curCase.result)) {
            t.deepEqual(result, curCase.result, 'action result is equal')
          } else {
            t.equal(result, curCase.result, 'action result is equal')
          }
        } else {
          if (curCase.error) {
            t.equal(error.message, curCase.error,
              `error message is "${curCase.error}"`)
          } else {
            throw error
          }
        }
      }))
Esempio n. 24
0
export function verifyTypes(tiip) {
  for (const k of timestampFields) {
    if (!isUndefined(tiip[k]) && !isISO6801Timestamp(tiip[k])) {
      throw new TypeError(`'${k}' should be a correct ISO 6801 date string (${tiip[k]})`);
    }
  }
  for (const k of stringFields) {
    if (!isUndefined(tiip[k]) && !isString(tiip[k])) {
      throw new TypeError(`'${k}' should be a String`);
    }
  }
  if (!isUndefined(tiip.src)) {
    if (!Array.isArray(tiip.src)) throw new TypeError("'src' should be an Array");
    if (!tiip.src.every(isString)) throw new TypeError("'src' should contain strings");
  }
  if (!isUndefined(tiip.targ)) {
    if (!Array.isArray(tiip.targ)) throw new TypeError("'targ' should be an Array");
    if (!tiip.targ.every(isString)) throw new TypeError("'targ' should contain strings");
  }
  if (!isUndefined(tiip.pl) && !Array.isArray(tiip.pl)) {
    throw new TypeError("'pl' should be an Array");
  }
  if (!isUndefined(tiip.arg) && !isObject(tiip.arg)) {
    throw new TypeError("'arg' should be an Array");
  }
  if (!isUndefined(tiip.ok) && !isBoolean(tiip.ok)) throw new TypeError("'ok' should be an Array");
}
Esempio n. 25
0
test('makeEnds works', t => {
  const icon = jsConfig
  const config = makeEnds(icon)

  t.truthy(isObject(config), 'config is not an object')
  t.truthy(config.properties.icon.description === 'Extensions: .js')
})
Esempio n. 26
0
 foreach(data, function (value, key) {
   if (isobject(data[key])) iterate(value)
   else {
     if (!first) first = key
     lookup[key] = value
   }
 })
Esempio n. 27
0
test('makeConfig works', t => {
  const title = 'JavaScript'
  const description = '.js'
  const enums = [ 'JavaScript', 'ES6' ]
  const config = makeConfig(title, description, enums)

  t.ok(isObject(config), 'config is not an object')
  t.ok(isArray(config.properties.icon.enum), 'enum is not an array')
  t.same(
    config.properties.icon.enum,
    [ 'JavaScript', 'ES6' ],
    'enum is not correct'
  )
  t.ok(isString(config.properties.icon.default), 'default is not a string')
  t.ok(
    config.properties.icon.default === 'JavaScript', 'default is not correct'
  )
  t.ok(
    isString(config.properties.icon.description),
    'description is not a string'
  )
  t.ok(
    config.properties.icon.description === '.js',
    'description is not correct'
  )
  t.ok(isString(config.properties.overlay.title), 'title is not a string')
  t.ok(
    config.properties.overlay.title === 'JavaScript Overlay',
    'overlay title is not correct'
  )
  t.ok(isString(config.title), 'title is not a string')
  t.ok(config.title === 'JavaScript', 'title is not correct')
})
Esempio n. 28
0
	secureNet.createCustomer = function(data, next) {

		//validate
		Assert.ok(isObject(data), 'param `data` must be an object.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');

		util.post('/Customers', data, next);
	};
Esempio n. 29
0
 return function(prototype) {
   if (isObject(prototype)) {
     Object.prototype = prototype;
     var result = new Object;
     Object.prototype = null;
   }
   return result || global.Object();
 };
Esempio n. 30
0
	secureNet.verify = function(data, next) {

		//validate
		Assert.ok(isObject(data), 'param `data` must be an object.');
		Assert.ok(isFunction(next), 'param `next` must be a next ');

		util.post('/Payments/Verify', data, next);
	};