How to use the underscore.contains function in underscore

To help you get started, we’ve selected a few underscore 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 jasperla / node-vcard / vcard.js View on Github external
}
		}

		/* XXX: If we run into a line that doesn't start with a field name, figure out what to do. */

		/*
		 * Walk through all the fields, and check if any of the fields aren't listed
		 * as valid or as an extensions.
		 */
		for (var f = data.length-1; f >= 0; f--){
			var field = data[f].replace(/(:|;).*/g, '');
			if (!(u.contains(validFields.singleText, field) ||
			      u.contains(validFields.multipleText, field) ||
			      u.contains(validFields.rfc2425, field) ||
			      u.contains(validFields.singleBinary, field) ||
			      u.contains(validFields.structured, field) ||
			      field.match(/^X-.*/))){
				return 'Invalid field found: `' + field + '`';
			}
		}
	}
github hacksalot / HackMyResume / src / verbs / convert.js View on Github external
dst = dst || []; dst.push( srcs.pop() );
    } else {
      this.err(HMSTATUS.inputOutputParity, { quit: true });
    }
  }

  // Different number of source and dest resumes? Error out.
  if (srcs && dst && srcs.length && dst.length && (srcs.length !== dst.length)) {
    this.err(HMSTATUS.inputOutputParity, { quit: true });
  }

  // Validate the destination format (if specified)
  //const targetVer = null;
  if (opts.format) {
    fmtUp = opts.format.trim().toUpperCase();
    if (!_.contains(['FRESH','FRESCA','JRS','JRS@1','JRS@edge'], fmtUp)) {
      this.err(HMSTATUS.invalidSchemaVersion, {data: opts.format.trim(), quit: true});
    }
  }
    // freshVerRegex = require '../utils/fresh-version-regex'
    // matches = fmtUp.match freshVerRegex()
    // # null
    // # [ 'JRS@1.0', 'JRS', '1.0', index: 0, input: 'FRESH' ]
    // # [ 'FRESH', 'FRESH', undefined, index: 0, input: 'FRESH' ]
    // if not matches
    //   @err HMSTATUS.invalidSchemaVersion, data: opts.format.trim(), quit: true
    // targetSchema = matches[1]
    // targetVer = matches[2] || '1'

  // If any errors have occurred this early, we're done.
  if (this.hasError()) {
    this.reject(this.errorCode);
github OHIF / Viewers / Packages / ohif-viewerbase / client / components / measurements / association / associationModal / associationModal.js View on Github external
// Get the study metaData by checking the row with the template engine Blaze
            const data = Blaze.getData(this);

            // Concatenate the study data to an array, depending on whether is was marked as baseline
            // or follow-up
            if (!studies.hasOwnProperty(timepointType)) {
                studies[timepointType] = [];
            }

            studies[timepointType].push(data);
        });

        const studiesKeys = Object.keys(studies);

        // TODO: REMOVE - Temporary for RSNA
        const hasBaseline = _.contains(studiesKeys, 'baseline');
        if (hasBaseline) {
            const patientId = studies[studiesKeys[0]][0].patientId;
            Timepoints.remove({ patientId });
        }

        studiesKeys.forEach(timepointType => {
            // Get the studies associated with this timepoint
            const relatedStudies = studies[timepointType];

            // Create an array of all the studyInstanceUids for storage in the Timepoint
            const studyInstanceUids = relatedStudies.map(function(study) {
                return study.studyInstanceUid;
            });

            // Create an array of all the studyDates for storage in the Timepoint
            let studyDates = relatedStudies.map(study => moment(study.studyDate).toDate());
github oauthinaction / oauth-in-action-code / exercises / ch-12-ex-1 / authorizationServer.js View on Github external
app.get("/authorize", function(req, res){
	
	var client = getClient(req.query.client_id);
	
	if (!client) {
		console.log('Unknown client %s', req.query.client_id);
		res.render('error', {error: 'Unknown client'});
		return;
	} else if (!__.contains(client.redirect_uris, req.query.redirect_uri)) {
		console.log('Mismatched redirect URI, expected %s got %s', client.redirect_uris, req.query.redirect_uri);
		res.render('error', {error: 'Invalid redirect URI'});
		return;
	} else {
		
		var rscope = req.query.scope ? req.query.scope.split(' ') : undefined;
		var cscope = client.scope ? client.scope.split(' ') : undefined;
		if (__.difference(rscope, cscope).length > 0) {
			var urlParsed = buildUrl(req.query.redirect_uri, {
				error: 'invalid_scope'
			});
			res.redirect(urlParsed);
			return;
		}
		
		var reqid = randomstring.generate(8);
github zoowii / web3dworld / static / js / editor / editor.helper.js View on Github external
helper.filterNotMeshTypeFromSceneModel = function (sceneModel, meshType) {
        if (!_.isArray(meshType)) {
            meshType = [meshType];
        }
        var objects = sceneModel.get('objects');
        var result = [];
        for (var i = 0; i < objects.length; ++i) {
            var object = objects[i];
            if (!_.contains(meshType, object.meshType)) {
                result.push(object);
            }
        }
        return result;
    };
github frnsys / the_founder / app / Manager.js View on Github external
return _.reduce(_.keys(obj), function(o, k) {
    var val = obj[k];
    if (!_.isFunction(val) && !_.contains(ignoreKeys, k)) {
      o[k] = val;
    }
    return o;
  }, {});
}
github ngageoint / mage-server / public / app / admin / devices / device.controller.js View on Github external
function AdminDeviceController($scope, $uibModal, $routeParams, $location, LocalStorageService, DeviceService, UserService, LoginService) {
  $scope.token = LocalStorageService.getToken();

  $scope.hasDeviceEditPermission =  _.contains(UserService.myself.role.permissions, 'UPDATE_DEVICE');
  $scope.hasDeviceDeletePermission =  _.contains(UserService.myself.role.permissions, 'DELETE_DEVICE');

  var filter = {
    device: {id: $routeParams.deviceId}
  };

  $scope.user = {};
  $scope.login = {
    startDateOpened: false,
    endDateOpened: false
  };

  var firstLogin = null;
  $scope.showPrevious = false;
  $scope.showNext = true;
github apache / avro / lang / js / etc / deprecated / validator.js View on Github external
if (_.isString(schema.name)) {
      typeName = schema.name;
    } else if (_.isString(schema.type)) {
      typeName = schema.type;
    }
  } else {
    throw new InvalidSchemaError('unable to determine fully qualified type name from schema ' + JSON.stringify(schema) + ' in namespace ' + namespace);
  }

  if (!_.isString(typeName)) {
    throw new InvalidSchemaError('unable to determine type name from schema ' + JSON.stringify(schema) + ' in namespace ' + namespace);
  }

  if (typeName.indexOf('.') !== -1) {
    return typeName;
  } else if (_.contains(AvroSpec.PrimitiveTypes, typeName)) {
    return typeName;
  } else if (_.isString(namespace)) {
    return namespace + '.' + typeName;
  } else {
    return typeName;
  }
}
github mulesoft / api-notebook / public / scripts / plugins / core / lib / function-returns.js View on Github external
global.Node.prototype.insertBefore,
    ];

    if (_.contains(stringTypes, options.fn)) {
      return '';
    }

    if (_.contains(numberTypes, options.fn)) {
      return 0;
    }

    if (_.contains(booleanTypes, options.fn)) {
      return false;
    }

    if (_.contains(arrayTypes, options.fn)) {
      return new options.global.Array();
    }

    if (_.contains(objectTypes, options.fn)) {
      return new options.global.Object();
    }

    if (_.contains(nodeTypes, options.fn)) {
      return global.Node.prototype;
    }

    if (_.contains(nodeListTypes, options.fn)) {
      return global.NodeList.prototype;
    }

    /**
github volumio / Volumio2 / app / plugins / system_controller / networkfs / index.js View on Github external
mountedFoldersArray.then((data)=>{
        if (_.contains(data, mountFolder)) {
            var mountedFoldersArray = _.without(data, mountFolder);
            self.saveMountedFolder(mountedFoldersArray)
            var clearFolder = mountFolder.replace('/mnt/', '');
            execSync('/usr/bin/mpc update "' + clearFolder + '"', {uid:1000,gid:1000});
            self.logger.info('Scanning removed location : ' + '"' + clearFolder + '"');
        }
})
}