当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.isObject函数代码示例

本文整理汇总了TypeScript中lodash.isObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isObject函数的具体用法?TypeScript isObject怎么用?TypeScript isObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isObject函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setDefaultValue

  /**
   *
   * This method sets default value for a dialog field
   * @memberof DialogDataService
   * @function setDefaultValue
   * @param data {any} This is a object that is all the information for a particular dialog field
   *
   **/
  private setDefaultValue(data): any {
    let defaultValue: any = '';
    const firstOption = 0; // these are meant to help make code more readable
    const fieldValue = 0;

    if (_.isObject(data.values)) {
      defaultValue = data.values[firstOption][fieldValue];
    }

    if (data.type === 'DialogFieldDateControl' || data.type === 'DialogFieldDateTimeControl') {
      defaultValue = data.values ? new Date(data.values) : new Date();
    }

    if (data.default_value) {
      defaultValue = data.default_value;
    }

    if (data.type === 'DialogFieldDropDownList' && data.options.force_multi_value && data.default_value) {
      defaultValue = JSON.parse(data.default_value);
    }

    if (data.type === 'DialogFieldTagControl') {
      // setting the default_value for a tag control's select box
      // In case the default_value is not set for the ng-model of the component, an empty value option is displayed
      let defaultOption = _.find(data.values, { id: null });
      if (defaultOption) {
        defaultOption.id = 0;
        defaultValue = defaultOption.id;
      }
    }

    if (this.checkboxNeedsNewDefaultValue(data)) {
      defaultValue = data.values;
    }

    return defaultValue;
  }
开发者ID:himdel,项目名称:ui-components,代码行数:45,代码来源:dialogData.ts

示例2: retrieveFileFromDb

function retrieveFileFromDb (file) {
	
	assert (_.isObject (file), 'file not an object');
	
	return new Promise (function (resolve, reject) {
	
		// Create a file with a name of the form 'file._id.<ext>', where <ext> is the extension of the original file
		var filepath = __dirname + '/../client-build/' + file._id + '.' + file.filename.substr(file.filename.lastIndexOf('.')+1);

		// Check whether the file already exists
		fs.open (filepath, 'r', function (err, fd) {
			if (!err) {
				// File already exits
				fs.closeSync (fd);
				resolve (null);
			}
			else {
				// File does not exist...create it
				var fs_write_stream = fs.createWriteStream (filepath);

				var gfs = Grid(conn.db);

				//read from mongodb
				var readstream = gfs.createReadStream ({_id: file._id});
				readstream.pipe (fs_write_stream);
				fs_write_stream.on ('close', function () {
					console.log ('file created: ' + filepath);
					resolve (null);
				});
				fs_write_stream.on ('error', function () {
					err = 'file creation error: ' + filepath;
					reject (err);
				});
			}
		});
	});
}
开发者ID:roderickmonk,项目名称:rod-monk-sample-repo,代码行数:37,代码来源:ttcGridFS.ts

示例3: collectFrozenNodes

export function collectFrozenNodes(abstractSyntaxTree: any, nodes?: any[]): any[] {
  nodes = nodes || [];

  if (!_.isArray(abstractSyntaxTree) && _.isObject(abstractSyntaxTree) && abstractSyntaxTree.type && _.isUndefined(abstractSyntaxTree.nodeID)) {
    abstractSyntaxTree.nodeID = nodes.length;
    nodes.push(abstractSyntaxTree);
  }

  Object.freeze(abstractSyntaxTree);
  
  _.forOwn(abstractSyntaxTree, (childNode, i) => {
    if (childNode instanceof Object && !(childNode instanceof Array)) {
      collectFrozenNodes(childNode, nodes);
    } else if (childNode instanceof Array) {
      _.forEach(childNode, (arrayChild) => {
        if (arrayChild instanceof Object && !(arrayChild instanceof Array)) {
          collectFrozenNodes(arrayChild, nodes);
        }
      });
    }
  });

  return nodes;
};
开发者ID:devlucas,项目名称:stryker,代码行数:24,代码来源:parserUtils.ts

示例4: constructor

 constructor(options: ITool<T>) {
     
   _.assign(this, options);
   
   if (_.isUndefined(this.lifecycle)) {
     this.lifecycle = Smithy.Lifecycle.Singleton;
   }
   
   assert(_.isString(this.name), "'name' is required and must be a string");
   assert(!_.isUndefined(this.target), "'target' is required");
   assert(!_.isNull(this.target), "'target' is required");
   
   if (!_.isUndefined(this.bindingArguments)) {
     assert(_.isObject(this.bindingArguments), "'bindingArguments', if defined, must be an object.");
   }
   
   if (!_.isUndefined(this.when)) {
     assert(_.isFunction(this.when), "'when', if defined, must be a function.");
   }
   
   if (!_.isUndefined(this.hint)) {
     assert(_.isString(this.hint), "'hint', if defined, must be a string.");
   }
 }
开发者ID:adamcarr,项目名称:forge-di-smithy,代码行数:24,代码来源:index.ts

示例5: checkPrivilegesForCapability

        (value: boolean | Record<string, boolean>, uiCapability) => {
          if (typeof value === 'boolean') {
            if (!shouldDisableFeatureUICapability(featureId!, uiCapability!)) {
              return value;
            }
            return checkPrivilegesForCapability(value, featureId!, uiCapability!);
          }

          if (isObject(value)) {
            const res = mapValues(value, (enabled, subUiCapability) => {
              return checkPrivilegesForCapability(
                enabled,
                featureId!,
                uiCapability!,
                subUiCapability!
              );
            });
            return res;
          }

          throw new Error(
            `Unexpected UI Capability value. Expected boolean or object, but found ${value}`
          );
        }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例6: function

 var checkInputType = function(scope) {
     scope.isObject = _.isObject(scope.input.model);
     scope.isNumber =
         !scope.options &&
         !scope.isObject &&
         (scope.type === "number" || scope.type === "float" || scope.type === "integer");
     scope.isDate = !scope.options && scope.type === "date";
     scope.isText =
         !scope.options &&
         !scope.isObject &&
         !(scope.type === "number" || scope.type === "float" || scope.type === "integer" || scope.type === "label");
     scope.isMultiText = !scope.options && scope.isObject && scope.type !== "label";
     scope.datePicker = {
         options: YleinenData.dateOptions,
         format: YleinenData.dateFormatDatepicker,
         state: false,
         open: function($event) {
             $event.preventDefault();
             $event.stopPropagation();
             scope.datePicker.state = !scope.datePicker.state;
         }
     };
     scope.isLabel = scope.type === "label";
 };
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:24,代码来源:formfield.ts

示例7: function

        var uusiViesti = function(tyyppi, viesti, ilmanKuvaa = false) {
            if (_.isObject(viesti) && viesti.data && viesti.data.syy) {
                viesti = viesti.data.syy;
            } else if (!viesti) {
                viesti = "";
            }

            if (!_.isEmpty(viestit)) {
                var viimeinenViesti = viestit[_.size(viestit) - 1];
                if (viimeinenViesti.tyyppi === tyyppi && viimeinenViesti.viesti === viesti) {
                    return;
                }
            }

            viestit.push({
                viesti: viesti ? viesti : tyyppi === 1 ? "tallennus-onnistui" : "",
                ilmanKuvaa: ilmanKuvaa,
                tyyppi: tyyppi,
                luotu: new Date()
            });

            $rootScope.$broadcast("update:notifikaatiot");
            refresh();
        };
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:24,代码来源:notifikaatiot.ts

示例8: function

    .service("virheService", function($state) {
        var data = {};

        return {
            setData(d) {
                data = d;
            },

            getData() {
                return data;
            },

            virhe(virhe) {
                if (_.isObject(virhe)) {
                    data = virhe;
                } else {
                    data = { muu: virhe };
                }
                $state.go("root.virhe", {
                    location: "replace"
                });
            }
        };
    });
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:24,代码来源:virhe.ts

示例9: mandatoryFieldValidator

            function mandatoryFieldValidator(fields, target) {
                err = undefined;
                const fieldsf = _.filter(fields || [], function(field) {
                    return (field as any).mandatory;
                });

                $rootScope.$$ekEditing = false;

                if (!target) {
                    return false;
                } else if (_.isString(target)) {
                    return !_.isEmpty(target);
                } else if (_.isObject(target) && !_.isEmpty(target) && !_.isEmpty(fieldsf)) {
                    return _.all(fieldsf, function(field: any) {
                        var valid = Utils.hasLocalizedText(target[field.path]);
                        if (!valid) {
                            err = field.mandatoryMessage;
                        }
                        return valid;
                    });
                } else {
                    return true;
                }
            }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:24,代码来源:editointikontrollit.ts

示例10:

			costs: (costs: any) => {
				let cost;
				const errors: any[] = [];
				for (const fileType of keys(costs)) {
					cost = costs[fileType];
					if (!fileTypes.exists(fileType)) {
						errors.push({
							path: fileType,
							message: 'Invalid file type. Valid file types are: ["' + fileTypes.names.join('", "') + '"].',
							setting: fileType,
						});
					}
					if (!isNumber(cost) && !isObject(cost)) {
						errors.push({
							path: fileType,
							message: 'Cost must be an integer or object.',
							setting: cost,
						});
					}
				}
				if (errors.length > 0) {
					return errors;
				}
			},
开发者ID:freezy,项目名称:node-vpdb,代码行数:24,代码来源:settings.validator.ts


注:本文中的lodash.isObject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。