Esempio n. 1
2
 app.get('/config', function (req, res) {
   app.debug('sending config...')
   var config = omit(app.configjs, 'port')
   config.twitter = omit(config.twitter, 'auth')
   config.admin = omit(config.admin, ['username', 'password'])
   res.send(config)
 })
Esempio n. 2
1
export function index(_state = null, action) {
  const state = _state === null ? {
    selected: { },
  } : _state;

  switch (action.type) {
    case TOGGLE_SELECTED: {
      const { selected } = action;
      const newSelections = _.omit.apply(this, [
        arrayToSet(selected), ...Object.keys(state.selected),
      ]);
      const persistentSelections = _.omit.apply(this, [
        state.selected, ...selected,
      ]);
      return {
        ...state,
        selected: {
          ...persistentSelections,
          ...newSelections,
        },
      };
    }
    default:
      return state;
  }
}
Esempio n. 3
1
test('returns non empty objects for missing cat names', t => {
  const allErrors = validate({
    ...validValues,

    deeply: {
      nested: [
        {
          list: {
            cats: [
              {}, { name: '' },
            ],
          },
        },
      ],
    },
  });

  const [catOneErrors, catTwoErrors] = allErrors.deeply.nested[0].list.cats;

  t.is(Object.keys(catOneErrors).length, 1);
  t.is(typeof catOneErrors.name, 'string');
  t.true(catOneErrors.name.length > 1);

  t.is(Object.keys(catTwoErrors).length, 1);
  t.is(typeof catTwoErrors.name, 'string');
  t.true(catTwoErrors.name.length > 1);

  t.deepEqual(
    omit(allErrors, 'deeply'),
    omit(validResult, 'deeply')
  );
});
Esempio n. 4
0
  _extractTokenInfo: function _extractTokenInfo(query) {
    var tokenKeys = [
      'access_token',
      'expires_in',
      'token_type',
      'refresh_token',
      'refresh_token_expires_in'
    ];

    query.state = querystring.parse(base64.fromBase64url(query.state));

    this._verifySecurityToken(query.state.csrf_token);

    var token = pick(query, tokenKeys);
    token.expires_in = parseInt(token.expires_in);
    token.refresh_token_expires_in = parseInt(token.refresh_token_expires_in);
    var auth = new Authorization(token);
    this._pushAuthorization(auth);

    query = omit(query, tokenKeys);
    query.state = omit(query.state, 'csrf_token');
    if (Object.keys(query.state).length === 0) {
      delete query.state;
    }
    else {
      query.state = base64.toBase64Url(querystring.stringify(query.state));
    }

    return query;
  },
Esempio n. 5
0
  render: function () {
    var other = omit(this.props, 'preset');
    other = omit(other, 'elType');
    other = omit(other, 'options');

    return React.createElement(this.props.elType, other);
  }
Esempio n. 6
0
    it("prepares a publicKey with missing values", function() {
      var props,
          actual,
          expected;

      props = omit(keyProps, "n", "e");
      actual = JWK.RSA.config.publicKey(props);
      expected = {
        "kty": "RSA"
      };
      assert.deepEqual(actual, expected);

      props = omit(keyProps, "n");
      actual = JWK.RSA.config.publicKey(props);
      expected = {
        "kty": "RSA"
      };
      assert.deepEqual(actual, expected);

      props = omit(keyProps, "e");
      actual = JWK.RSA.config.publicKey(props);
      expected = {
        "kty": "RSA"
      };
      assert.deepEqual(actual, expected);
    });
Esempio n. 7
0
test('returns non empty object with error messages for invalid contact fields', t => {
  const allErrors = validate({
    ...validValues,

    contact: {
      name: '1234',
      age: 'abc',
    },

    otherContact: {
      name: '1234',
    },
  });

  const contactErrors = allErrors.contact;

  t.is(Object.keys(contactErrors).length, 2);

  t.is(typeof contactErrors.name, 'string');
  t.is(typeof contactErrors.age, 'string');

  t.true(contactErrors.name.length > 1);
  t.true(contactErrors.age.length > 1);

  t.deepEqual(
    omit(allErrors, 'contact'),
    omit(validResult, 'contact')
  );
});
Esempio n. 8
0
export function index(_state = null, action) {
  const state = _state === null ? {
    view: getStorage('linodes/view') || 'grid',
    selected: { },
  } : _state;

  switch (action.type) {
    case CHANGE_VIEW: {
      const { view } = action;
      setStorage('linodes/view', view);
      return { ...state, view };
    }
    case TOGGLE_SELECTED: {
      const { selected } = action;
      const newSelections = _.omit.apply(this, [
        arrayToSet(selected), ...Object.keys(state.selected),
      ]);
      const persistentSelections = _.omit.apply(this, [
        state.selected, ...selected,
      ]);
      return {
        ...state,
        selected: {
          ...persistentSelections,
          ...newSelections,
        },
      };
    }
    default:
      return state;
  }
}
Esempio n. 9
0
test('returns error value for shallow prop if invalid', t => {
  const allErrors = validate({ ...validValues, shallow: '123' });

  t.is(typeof allErrors.shallow, 'string');
  t.true(allErrors.shallow.length > 1);

  t.deepEqual(
    omit(allErrors, 'shallow'),
    omit(validResult, 'shallow')
  );
});
Esempio n. 10
0
    convertProps(props) {
      // Create a non-immutable working copy
      let workingProps = { ...props };

      // Do string-to-int conversion for all timing-related props
      const timingPropNames = [
        'duration', 'delay', 'staggerDurationBy', 'staggerDelayBy'
      ];

      timingPropNames.forEach(
        prop => workingProps[prop] = convertToInt(workingProps[prop], prop)
      );

      // Convert the children to a React.Children array.
      // This is to ensure we're always working with an array, and not
      // an only child. There's some weirdness with this.
      // See: https://github.com/facebook/react/pull/3650/files
      workingProps.children = React.Children.toArray(this.props.children);

      // Convert an enterLeave preset to the real thing
      workingProps.enterAnimation = this.convertAnimationProp(
        workingProps.enterAnimation, enterPresets
      );
      workingProps.leaveAnimation = this.convertAnimationProp(
        workingProps.leaveAnimation, leavePresets
      );

      // Accept `disableAnimations`, but add a deprecation warning
      if ( typeof props.disableAnimations !== 'undefined' ) {
        console.warn("Warning, via react-flip-move: `disableAnimations` is deprecated. Please switch to use `disableAllAnimations`. This will become a silent error in future versions.");
        workingProps.disableAnimations = undefined;
        workingProps.disableAllAnimations = props.disableAnimations;
      }

      // Gather any additional props; they will be delegated to the
      // ReactElement created.
      const primaryPropKeys = Object.keys(Converter.propTypes);
      const delegatedProps = omit(this.props, primaryPropKeys);

      // The FlipMove container element needs to have a non-static position.
      // We use `relative` by default, but it can be overridden by the user.
      // Now that we're delegating props, we need to merge this in.
      delegatedProps.style = {
        position: 'relative',
        ...delegatedProps.style
      };

      workingProps = omit(workingProps, delegatedProps);
      workingProps.delegated = delegatedProps;

      return workingProps;
    }
Esempio n. 11
0
test('recongises the name prop and renders the correct children', ({ plan, deepEqual }) => {
  plan(1);

  const name = 'Brian';
  const expected = <span>hello {name}</span>;

  const shallowRenderer = ReactTestUtils.createRenderer();
  shallowRenderer.render(<Component name={name} />);
  const renderedCmp = shallowRenderer.getRenderOutput();
  const actual = renderedCmp.props.children;

  deepEqual(_omit(actual, '_owner'), _omit(expected, '_owner'));
});
Esempio n. 12
0
exports.create = function(tokens) {
  const source = first(tokens);

  return source == null ?
    null :
    omit(source, ['col', 'line', 'lineBreaks', 'text', 'toString']);
};
Esempio n. 13
0
  render() {
    const { strokeClassName, fillClassName, ...rest } = omit(
      this.props,
      excludeProperties
    );

    return (
      <svg {...rest} viewBox="0 0 18 18">
        <polygon
          className={cx(strokeClassName, fillClassName)}
          points="15 12 13 10 15 8 15 12"
        />
        <line
          className={cx(strokeClassName, fillClassName)}
          x1="9"
          x2="5"
          y1="4"
          y2="4"
        />
        <path className={fillClassName} d="M5,3A3,3,0,0,0,5,9H6V3H5Z" />
        <rect className={fillClassName} height="11" width="1" x="5" y="4" />
        <rect className={fillClassName} height="11" width="1" x="7" y="4" />
      </svg>
    );
  }
Esempio n. 14
0
  applyNodeProps: function(oldProps, props, transaction) {
    var propKeys = Object.keys(props);
    if (propKeys.length === 0) {
      return;
    }
    var noChangeProps = propKeys.filter(function(k){
      return props[k] === oldProps[k];
    });

    props = omit(props, noChangeProps);
    propKeys = Object.keys(props);
    if (propKeys.length === 0) {
      return;
    }

    if (this.formatProps) {
      props = this.formatProps(props, oldProps);
    }

    console.log('applying props', this, props);

    // wire up event listeners
    // TODO: remove old ones from oldProps
    // TODO: move this to a different fn?
    propKeys.filter(function(k){
      return !!registrationNameModules[k] && props[k] != null;
    })
    .forEach(function(k){
      putListener(this._rootNodeID, k, props[k], transaction);
    }, this);

    if (this.setOptions) {
      this.setOptions(props);
    }
  }
Esempio n. 15
0
 args.forEach(function processArg(def) {
     if (def.dataTypes) {
         forEach(def.dataTypes, function (def, name) {
             child.prototype._dataTypes[name] = def;
         });
     }
     if (def.props) {
         forEach(def.props, function (def, name) {
             createPropertyDefinition(child.prototype, name, def);
         });
     }
     if (def.session) {
         forEach(def.session, function (def, name) {
             createPropertyDefinition(child.prototype, name, def, true);
         });
     }
     if (def.derived) {
         forEach(def.derived, function (def, name) {
             createDerivedProperty(child.prototype, name, def);
         });
     }
     if (def.collections) {
         forEach(def.collections, function (constructor, name) {
             child.prototype._collections[name] = constructor;
         });
     }
     if (def.children) {
         forEach(def.children, function (constructor, name) {
             child.prototype._children[name] = constructor;
         });
     }
     assign(child.prototype, omit(def, omitFromExtend));
 });
Esempio n. 16
0
File: Task.js Progetto: nopnop/stask
  /**
   * Read form a json (flat or not) object
   * @param  {Object} data Json
   * @return {Task} this instance
   */
  fromJSON (data) {
    this.id = normalizeId(data.id)
    this.prefix = getIdPrefix(this.id)
    this.index = getIdIndex(this.id)
    this.filepath = data.filepath ? path.resolve(process.cwd(), data.filepath) : null
    this.updated = data.updated || new Date()
    this.created = data.created || new Date()
    this.label = data.label
    this.description = data.description
    this.meta = data.meta || {}

    this.meta = Object.assign({}, data.meta || {}, omit(data, [
      'id',
      'filepath',
      'prefix',
      'index',
      'updated',
      'created',
      'meta',
      'label',
      'description'
    ]))

    return this
  }
  render() {
    const { fillClassName, transparentClassName, ...rest } = omit(
      this.props,
      excludeProperties
    );

    return (
      <svg {...rest} viewBox="0 0 18 18">
        <g className={cx(fillClassName, transparentClassName)}>
          <rect height="10" rx="1" ry="1" width="4" x="2" y="6" />
          <rect height="10" rx="1" ry="1" width="4" x="12" y="6" />
        </g>
        <rect
          className={fillClassName}
          height="8"
          rx="1"
          ry="1"
          width="4"
          x="7"
          y="2"
        />
        <path
          className={fillClassName}
          d="M9.707,13l1.146-1.146a0.5,0.5,0,0,0-.707-0.707L9,12.293,7.854,11.146a0.5,0.5,0,0,0-.707.707L8.293,13,7.146,14.146a0.5,0.5,0,1,0,.707.707L9,13.707l1.146,1.146a0.5,0.5,0,0,0,.707-0.707Z"
        />
      </svg>
    );
  }
Esempio n. 18
0
export function error (...args) {
  let [err, errorData = {}, ...otherArgs] = args;

  if (err instanceof Error) {
    // pass the error stack as the first parameter to logger.error
    let stack = err.stack || err.message || err;

    if (isPlainObject(errorData) && !errorData.fullError) {
      // If the error object has interesting data (not only httpCode, message and name from the CustomError class)
      // add it to the logs
      if (err instanceof CustomError) {
        let errWithoutCommonProps = omit(err, ['name', 'httpCode', 'message']);

        if (Object.keys(errWithoutCommonProps).length > 0) {
          errorData.fullError = errWithoutCommonProps;
        }
      } else {
        errorData.fullError = err;
      }
    }

    let loggerArgs = [stack, errorData, ...otherArgs];

    // Treat 4xx errors that are handled as warnings, 5xx and uncaught errors as serious problems
    if (!errorData || !errorData.isHandledError || errorData.httpCode >= 500) {
      logger.error(...loggerArgs);
    } else {
      logger.warn(...loggerArgs);
    }
  } else {
    logger.error(...args);
  }
}
Esempio n. 19
0
    .then(function(response) {
      if (_this.context.camelize) {
        response.body = humps.camelizeKeys(response.body);
      }

      var collectionRange = response.header['x-collection-range'];
      if (collectionRange !== undefined) {
        var rangeAndCount = collectionRange.split('/');
        var rangeStartAndEnd = rangeAndCount[0].split('-');
        var collectionStart = Number(rangeStartAndEnd[0]);
        var collectionEnd = Number(rangeStartAndEnd[1]);
        var collectionCount = Number(rangeAndCount[1]);
        var collectionLimit = Number(collectionEnd - collectionStart + 1);

        queryParams = queryParams || {};

        response.body = {
          items: response.body,
          offset: collectionStart,
          limit: collectionLimit,
          count: collectionCount,
          page: Math.ceil((collectionEnd + 1) / queryParams.limit) || 1,
          lastPage: Math.ceil(collectionCount / queryParams.limit) || 1,
          query: omit(queryParams, 'offset')
        };
      }

      resolve(response);
    }).catch(camelizeResponse.bind(_this, reject));
Esempio n. 20
0
 self.scopeObj.where = self.scopeObj.where.map(function(scopeObj) {
   if (!Array.isArray(scopeObj) && typeof scopeObj === "object") {
     return lodash.omit.apply(undefined, [scopeObj].concat(scopeKeys))
   } else {
     return scopeObj
   }
 }).filter(function(scopeObj) {
Esempio n. 21
0
let getArgs = () => {
  let remoteArgv = remote.getGlobal('process').argv
  let argv = yargs(remoteArgv).argv
  let paths = argv._.slice(2)
  let opts = omit(argv, '_', '$0')
  return [paths, opts]
}
			paths.forEach(path => {
				const mount = mounts[path];

				if (!mount.reducer) {
					// if `mount` has been called for a path, but the corresponding
					// mounted store creator *not* called, then no reducer will be
					// registered, so skip that path
					return;
				}

				updateMountCache(path);

				const newMergedState =
					mount.reducer.call(null, mount.cache.mergedState, action);

				if (newMergedState !== mount.cache.mergedState) {
					// FIXME: check that viewed state is not modified
					// FIXME: test that asserts that removed viewedState is reapplied
					mount.cache.mergedState =
						_merge(newMergedState, mount.cache.viewedState);
					mount.cache.ownState =
						_omit(newMergedState, Object.keys(mount.viewedStateSpec));
					newState = immutable.set(newState, path, mount.cache.ownState);
				}
			});
Esempio n. 23
0
  render() {
    const { strokeClassName, fillClassName, ...rest } = omit(
      this.props,
      excludeProperties
    );

    return (
      <svg {...rest} viewBox="0 0 18 18">
        <polygon
          className={cx(strokeClassName, fillClassName)}
          points="3 11 5 9 3 7 3 11"
        />
        <line
          className={cx(strokeClassName, fillClassName)}
          x1="15"
          x2="11"
          y1="4"
          y2="4"
        />
        <path className={fillClassName} d="M11,3a3,3,0,0,0,0,6h1V3H11Z" />
        <rect className={fillClassName} height="11" width="1" x="11" y="4" />
        <rect className={fillClassName} height="11" width="1" x="13" y="4" />
      </svg>
    );
  }
Esempio n. 24
0
  _getExtraFields(obj) {
    if (isPlainObject(obj)) {
      return omit(obj, Object.assign({}, this.errorFieldNames, ["tags"]));
    }

    return {};
  }
Esempio n. 25
0
  render() {
    const { fillClassName, ...rest } = omit(this.props, excludeProperties);

    return (
      <svg {...rest} viewBox="0 0 18 18">
        <path
          className={fillClassName}
          d="M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z"
        />
        <rect
          className={fillClassName}
          height="1.6"
          rx="0.8"
          ry="0.8"
          width="5"
          x="5.15"
          y="6.2"
        />
        <path
          className={fillClassName}
          d="M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z"
        />
      </svg>
    );
  }
Esempio n. 26
0
function plugin(opts){
  opts = opts || {};
  if ('string' == typeof opts) opts = { engine: opts };
  if (!opts.engine) throw new Error('"engine" option required');

  var engine = opts.engine;
  var dir = opts.directory || 'templates';
  var pattern = opts.pattern;
  var inPlace = opts.inPlace;
  var def = opts.default;
  var params = omit(opts, settings);

  return function(files, metalsmith, done){
    var metadata = metalsmith.metadata();

    function check(file){
      var data = files[file];
      var tmpl = data.template || def;
      if (pattern && !match(file, pattern)[0]) return false;
      if (!inPlace && !tmpl) return false;
      return true;
    }

    Object.keys(files).forEach(function(file){
      if (!check(file)) return;
      debug('stringifying file: %s', file);
      var data = files[file];
      data.contents = data.contents.toString();
      data.moment = require('moment');
    });

    each(Object.keys(files), convert, done);

    function convert(file, done){
      if (!check(file)) return done();
      debug('converting file: %s', file);
      var data = files[file];
      var clone = extend({}, params, metadata, data);
      var str;
      var render;


      if (inPlace) {
        str = clone.contents;
        render = consolidate[engine].render;
      } else {
        str = metalsmith.path(dir, data.template || def);
        render = consolidate[engine];
      }

      render(str, clone, function(err, str){
        if (err) return done(err);
        data.contents = new Buffer(str);
        debug('converted file: %s', file);
        done();
      });
    }
  };
}
Esempio n. 27
0
  it('should generate violations for incorrect code', () => {
    const source = path.join(__dirname, 'fixtures', 'incorrect.js');
    const rules = omit(config, ['additionalRules', 'excludeFiles']);

    return linter.checkPath(source)
      .then(results => {
        results[0].getErrorList().map(error => error.rule).should.containDeep(Object.keys(rules));
      });
  });
Esempio n. 28
0
		complexOption("controls").forEach(function(control) {
			var controlName = control;
			var controlOptions = {};
			if (typeof control === "object") {
				controlName = control.name;
				controlOptions = omit(control, "name");
			}
			L.control[controlName](controlOptions).addTo(map);
		});
Esempio n. 29
0
test('returns non empty object with error message for missing contact name', t => {
  const allErrors = validate({
    ...validValues,
    contact: {},
    otherContact: {},
  });

  const contactErrors = allErrors.contact;

  t.is(Object.keys(contactErrors).length, 1);
  t.is(typeof contactErrors.name, 'string');
  t.true(contactErrors.name.length > 1);

  t.deepEqual(
    omit(allErrors, 'contact'),
    omit(validResult, 'contact')
  );
});
Esempio n. 30
0
test('validates otherContact name not matching contact name', t => {
  const allErrors = validate({
    ...validValues,
    contact: { name: 'Jeremy' },
    otherContact: { name: 'John' },
  });

  const otherContactErrors = allErrors.otherContact;

  t.is(Object.keys(otherContactErrors).length, 1);
  t.is(typeof otherContactErrors.name, 'string');
  t.true(otherContactErrors.name.length > 1);

  t.deepEqual(
    omit(allErrors, 'otherContact'),
    omit(validResult, 'otherContact')
  );
});