Ejemplo n.º 1
0
 }).filter(file => {
   switch (storageType) {
     case StorageType.FILE:
       return file.isFile && (!fileExtensions || includes(fileExtensions, extname(file.name)));
     case StorageType.FOLDER:
       return file.isDirectory;
     default: {
       return file.isDirectory || !fileExtensions || includes(fileExtensions, extname(file.name));
     }
   }
 });
Ejemplo n.º 2
0
function schemaValidationErrorToValidationErrorItem(schemaValidationError: SchemaValidationError): ValidationErrorItem {
    if (
        _.includes(
            [
                'type',
                'anyOf',
                'allOf',
                'oneOf',
                'additionalProperties',
                'minProperties',
                'maxProperties',
                'pattern',
                'format',
                'uniqueItems',
                'items',
                'dependencies',
            ],
            schemaValidationError.name,
        )
    ) {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.incorrectFormat,
            reason: schemaValidationError.message,
        };
    } else if (
        _.includes(
            ['minimum', 'maximum', 'minLength', 'maxLength', 'minItems', 'maxItems', 'enum', 'const'],
            schemaValidationError.name,
        )
    ) {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.valueOutOfRange,
            reason: schemaValidationError.message,
        };
    } else if (schemaValidationError.name === 'required') {
        return {
            field: schemaValidationError.argument,
            code: ValidationErrorCodes.requiredField,
            reason: schemaValidationError.message,
        };
    } else if (schemaValidationError.name === 'not') {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.unsupportedOption,
            reason: schemaValidationError.message,
        };
    } else {
        throw new Error(`Unknnown schema validation error name: ${schemaValidationError.name}`);
    }
}
Ejemplo n.º 3
0
        _.keys(one).forEach((key) => {
            let concatPath: string = path ? path + '.' + key : key;
            if (!_.includes(this.options.ignoreProperties, concatPath) && !_.includes(this.options.ignoreSubProperties, concatPath)) {

                unsetIgnoredSubProperties(one[key]);
                unsetIgnoredSubProperties(two[key]);

                let getDeletedProperties = (obj: any, propPath: string = null) => {
                    if (_.isPlainObject(obj)) {
                        for (var objKey of _.keys(obj)) {
                            unsetIgnoredSubProperties(obj[objKey]);
                            getDeletedProperties(obj[objKey], propPath ? propPath + '.' + objKey : objKey);
                        }
                    } else if (_.isBoolean(obj) || _.isDate(obj) || _.isNumber(obj)
                        || _.isNull(obj) || _.isRegExp(obj) || _.isString(obj) || _.isArray(obj)) {
                        result.push(new DeepDiff('deleted', propPath, obj, null));
                    }
                };

                if (_.isPlainObject(one[key])) {
                    if (!_.has(two, key)) {
                        getDeletedProperties(one[key], concatPath);
                    } else {
                        result = _.concat(result, this.deepDiff(one[key], two[key], path ? path + '.' + key : key));
                    }
                } else if (_.isBoolean(one[key]) || _.isDate(one[key]) || _.isNumber(one[key])
                    || _.isNull(one[key]) || _.isRegExp(one[key]) || _.isString(one[key])) {
                    if (!_.has(two, key)) {
                        result.push(new DeepDiff('deleted', concatPath, one[key], null));
                    } else if (_.isDate(one[key]) || _.isDate(two[key])) {
                        if (new Date(one[key]).valueOf() !== new Date(two[key]).valueOf()) {
                            result.push(new DeepDiff('edited', concatPath, new Date(one[key]), new Date(two[key])));
                        }
                    } else if (hash(one[key]) !== hash(two[key])) {
                        result.push(new DeepDiff('edited', concatPath, one[key], two[key]));
                    }
                } else if (_.isArray(one[key]) && _.isArray(two[key]) && !_.isEqual(one[key], two[key])) {
                    for (var i = 0; i < one[key].length; i++) {
                        unsetIgnoredSubProperties(one[key][i]);
                    }
                    for (var i = 0; i < two[key].length; i++) {
                        unsetIgnoredSubProperties(two[key][i]);
                    }
                    if (hash(one[key]) !== hash(two[key])) {
                        result.push(new DeepDiff('array', concatPath, one[key], two[key]));
                    }
                } else if (!_.has(two, key)) {
                    getDeletedProperties(one[key], concatPath);
                }
            }
        });
Ejemplo n.º 4
0
 descriptor.value =  async function(...args: any[]) {
     try {
         const result = await originalMethod.apply(this, args);
         return result;
     } catch (error) {
         if (_.includes(error.message, constants.INVALID_JUMP_PATTERN)) {
             throw new Error(ZeroExError.InvalidJump);
         }
         if (_.includes(error.message, constants.OUT_OF_GAS_PATTERN)) {
             throw new Error(ZeroExError.OutOfGas);
         }
         throw error;
     }
 };
Ejemplo n.º 5
0
export function isConwaySymbol(symbol: string) {
  if (!!platonicMapping.get(symbol) || !!archimedeanMapping.get(symbol)) {
    return true;
  }
  const prefix = symbol[0];
  const number = parseInt(symbol.substring(1), 10);
  if (prefix === 'J' && number >= 0 && number <= 92) {
    return true;
  }
  if (_.includes(['P', 'A'], prefix) && _.includes(polygons, number)) {
    return true;
  }
  return false;
}
Ejemplo n.º 6
0
			items = _.filter(_.uniq(items), (item: BaseModel<any>) => {
				if (_.includes(filters, "node") && item instanceof NodeModel) {
					return true;
				}
				if (_.includes(filters, "link") && item instanceof LinkModel) {
					return true;
				}
				if (_.includes(filters, "port") && item instanceof PortModel) {
					return true;
				}
				if (_.includes(filters, "point") && item instanceof PointModel) {
					return true;
				}
				return false;
			});
Ejemplo n.º 7
0
 let processProject = function (project: ProjectModel, count?: number) {
   let username = project.user;
   let uniqueName = project.unique_name;
   if (!_.includes(newState.userNames, username)) {
     newState.userNames.push(username);
     newState.byUserNames[username] = new UserModel();
   }
   if (!_.includes(newState.byUserNames[username].projects, uniqueName)) {
     newState.byUserNames[username].projects.push(uniqueName);
   }
   if (count != null) {
     newState.byUserNames[username].num_projects = count;
   }
   return newState;
 };
Ejemplo n.º 8
0
export function parseDateMath(mathString, time, roundUp?) {
  var dateTime = time;
  var i = 0;
  var len = mathString.length;

  while (i < len) {
    var c = mathString.charAt(i++);
    var type;
    var num;
    var unit;

    if (c === '/') {
      type = 0;
    } else if (c === '+') {
      type = 1;
    } else if (c === '-') {
      type = 2;
    } else {
      return undefined;
    }

    if (isNaN(mathString.charAt(i))) {
      num = 1;
    } else if (mathString.length === 2) {
      num = mathString.charAt(i);
    } else {
      var numFrom = i;
      while (!isNaN(mathString.charAt(i))) {
        i++;
        if (i > 10) { return undefined; }
      }
      num = parseInt(mathString.substring(numFrom, i), 10);
    }

    if (type === 0) {
      // rounding is only allowed on whole, single, units (eg M or 1M, not 0.5M or 2M)
      if (num !== 1) {
        return undefined;
      }
    }
    unit = mathString.charAt(i++);

    if (!_.includes(units, unit)) {
      return undefined;
    } else {
      if (type === 0) {
        if (roundUp) {
          dateTime.endOf(unit);
        } else {
          dateTime.startOf(unit);
        }
      } else if (type === 1) {
        dateTime.add(num, unit);
      } else if (type === 2) {
        dateTime.subtract(num, unit);
      }
    }
  }
  return dateTime;
}
Ejemplo n.º 9
0
export const isTutke2 = viite => {
    if (viite == null || viite.tutkinnonOsa == null || viite.tutkinnonOsa.tyyppi == null) {
        return false;
    }

    return _.includes(yhteisetTutkinnonOsat, viite.tutkinnonOsa.tyyppi);
};
        _.forEach(virtualStudy.data.studies, study => {

            // check if the study in this virtual study is already in the selected studies list
            // and only add the samples if its not already present
            if (!_.includes(selectedPhysicalStudyIds, study.id)) {
                filteredMutationSamples[study.id] = filteredMutationSamples[study.id] || {};
                filteredCnaSamples[study.id] = filteredCnaSamples[study.id] || {};
                filteredMutationCnaSamples[study.id] = filteredMutationCnaSamples[study.id] || {};
                filteredallSamples[study.id] = filteredallSamples[study.id] || {};

                _.forEach(study.samples, sampleId => {
                    if (mutationSamples[study.id] && mutationSamples[study.id][sampleId]) {
                        filteredMutationSamples[study.id][sampleId] = sampleId;
                    }
                    if (cnaSamples[study.id] && cnaSamples[study.id][sampleId]) {
                        filteredCnaSamples[study.id][sampleId] = sampleId;
                    }
                    if (mutationCnaSamples[study.id] && mutationCnaSamples[study.id][sampleId]) {
                        filteredMutationCnaSamples[study.id][sampleId] = sampleId;
                    }
                    if (allSamples[study.id] && allSamples[study.id][sampleId]) {
                        filteredallSamples[study.id][sampleId] = sampleId;
                    }
                });
            }
        });