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


TypeScript lodash.isNull函数代码示例

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


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

示例1:

            component.isToggled().then(isToggled => {
                // use option if available, otherwise use detected state
                toggledAtStart = _.isNull(options.toggledAtStart) ? isToggled : options.toggledAtStart;

                // use option if available, otherwise use inverse of toggledAtStart
                toggledAtEnd = _.isNull(options.toggledAtEnd) ? !toggledAtStart : options.toggledAtEnd;
            });
开发者ID:Droogans,项目名称:encore-ui,代码行数:7,代码来源:rxToggleSwitch.exercise.ts

示例2: deepDiff

 deepDiff(one: Object, two: Object, path: string = ''): IDeepDiff[] {
     let result: IDeepDiff[] = [];
     for (var key of _.keys(one)) {
         let concatPath: string = path ? path + '.' + key : key;
         if (_.isPlainObject(one[key])) {
             if (!_.has(two, key)) {
                 result.push(new DeepDiff('deleted', concatPath, one[key], null));
             } 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 (_.get(one, key) !== _.get(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])) {
             result.push(new DeepDiff('array', concatPath, one[key], two[key]));
         } else if (!_.has(two, key)) {
             result.push(new DeepDiff('deleted', concatPath, one[key], null));
         }
     }
     for (var key of _.keys(two)) {
         let concatPath: string = path ? path + '.' + key : key;
         if (!_.has(one, key)) {
             if (_.isPlainObject(two[key]) || _.isBoolean(two[key]) || _.isDate(two[key]) || _.isNumber(two[key])
                 || _.isNull(two[key]) || _.isRegExp(two[key]) || _.isString(two[key]) || _.isArray(two[key])) {
                 result.push(new DeepDiff('created', concatPath, null, two[key]));
             }
         }
     }
     return result;
 }
开发者ID:fyyyyy,项目名称:chrobject,代码行数:34,代码来源:EntryAppService.ts

示例3:

 _.forEach(lines, line => {
     if (!_.isNull(line.match(IMPORT_REGEX))) {
         const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
         if (!_.isNull(dependencyMatch)) {
             const dependencyPath = dependencyMatch[1];
             const basenName = path.basename(dependencyPath);
             dependencies.push(basenName);
         }
     }
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:10,代码来源:compiler.ts

示例4:

  const res = _.reduce(data, (final, item) => {
    if (item.kind === 'E') {
      const isLhsNullOrDash = _.isNull(item.lhs) || item.lhs === '-'
      const isRhsNullOrDash = _.isNull(item.rhs) || item.rhs === '-'
      if (isLhsNullOrDash && isRhsNullOrDash) { return final }
    }

    final.push(item)
    return final
  }, [])
开发者ID:oleksii-honchar,项目名称:ts-es6-node-mocha-playground,代码行数:10,代码来源:diff.helpers.ts

示例5: constructor

 constructor(action: DiffAction, propertyPath: string, oldValue: any, newValue: any) {
     this.action = action;
     this.created = action === 'created' ? true : undefined;
     this.edited = action === 'edited' ? true : undefined;
     this.deleted = action === 'deleted' ? true : undefined;
     this.array = action === 'array' ? true : undefined;
     this.propertyPath = propertyPath;
     this.oldValue =  !_.isNull(oldValue) && !_.isUndefined(oldValue) && action !== 'created' ? oldValue : undefined;
     this.newValue = !_.isNull(newValue) && !_.isUndefined(newValue) && action !== 'deleted' ? newValue : undefined;
     if (action === 'array') {
         this.setArrayDiffs(oldValue, newValue);
     }
 }
开发者ID:hydra-newmedia,项目名称:chrobject,代码行数:13,代码来源:DeepDiff.ts

示例6: q

    return new q(function(resolve, reject) {
      if (!_.isNull(self.process)) {
        timeout = self._timeout(function daemonProcessTimeout() {
          self.process.kill();
          self.process = null;
          reject(new Error(Daemon.debug("Process didnt respond and was killed")));
        }, wait ? wait * 1000 : 5000);

        self
          .call("stop")
          .then(
            function daemonProcessStopSuccess() {
              clearTimeout(timeout);
              self.process = null;
              resolve("Stopped " + self.name);
            },
            function daemonProcessStopFailed(err) {
              clearTimeout(timeout);
              reject(new Error(Daemon.debug(err)));
            }
          )
          .done();
      } else {
        reject(new Error(Daemon.debug("Process wasnt started")));
      }
    });
开发者ID:pocesar,项目名称:node-stratum,代码行数:26,代码来源:daemon.ts

示例7: start

  /**
   * Starts the daemon process.
   * Throws an error if the path doesn't exists.
   *
   * @throws Error
   * @returns {boolean}
   */
  start() {
    var self = this;

    if (_.isNull(this.process)) {
      self._pathExists();

      try {
        self.process = self.spawn(this.opts.path, this.opts.args);

        self.process.on("close", function daemonProcessClose() {
          Daemon.debug("Process closed");
          self.process = null;
          self.emit("close");
        });

        return true;
      } catch (e) {
        self.process = null;
        Daemon.debug(e);

        return false;
      }
    } else {
      return false;
    }
  }
开发者ID:pocesar,项目名称:node-stratum,代码行数:33,代码来源:daemon.ts

示例8: listen

  /**
   * Listen the RPC on the defined port
   *
   * @returns {RPC}
   */
  listen() {
    if (_.isNull(this._server)) {
      RPC.debug("Listening on port " + this.opts.port);

      var func;

      switch (this.opts.mode) {
        case "both":
          func = this.server.listenHybrid;
          break;
        case "http":
          func = this.server.listen;
          break;
        case "tcp":
          func = this.server.listenRaw;
          break;
      }

      this._server = func.call(this.server, this.opts.port, this.opts.host);
    } else {
      throw new Error(
        RPC.debug("Server already listening on port " + this.opts.port)
      );
    }

    return this;
  }
开发者ID:pocesar,项目名称:node-stratum,代码行数:32,代码来源:rpc.ts

示例9: Error

  selectionSet.selections.forEach((selection) => {
    if (selection.kind !== 'Field') {
       throw new Error('Only fields supported so far, not fragments.');
    }

    const field = selection as Field;

    const storeFieldKey = storeKeyNameFromField(field);
    const resultFieldKey = resultKeyNameFromField(field);

    if (! has(storeObj, storeFieldKey)) {
      if (throwOnMissingField) {
        throw new Error(`Can't find field ${storeFieldKey} on object ${storeObj}.`);
      }

      missingSelections.push(field);

      return;
    }

    if (! field.selectionSet) {
      result[resultFieldKey] = storeObj[storeFieldKey];
      return;
    }

    if (isNull(storeObj[storeFieldKey])) {
      // Basically any field in a GraphQL response can be null
      result[resultFieldKey] = null;
      return;
    }

    if (isArray(storeObj[storeFieldKey])) {
      result[resultFieldKey] = storeObj[storeFieldKey].map((id) => {
        const itemDiffResult = diffSelectionSetAgainstStore({
          store,
          throwOnMissingField,
          rootId: id,
          selectionSet: field.selectionSet,
        });

        itemDiffResult.missingSelectionSets.forEach(
          itemSelectionSet => missingSelectionSets.push(itemSelectionSet));
        return itemDiffResult.result;
      });
      return;
    }

    const subObjDiffResult = diffSelectionSetAgainstStore({
      store,
      throwOnMissingField,
      rootId: storeObj[storeFieldKey],
      selectionSet: field.selectionSet,
    });

    // This is a nested query
    subObjDiffResult.missingSelectionSets.forEach(
      subObjSelectionSet => missingSelectionSets.push(subObjSelectionSet));

    result[resultFieldKey] = subObjDiffResult.result;
  });
开发者ID:mquandalle,项目名称:apollo-client,代码行数:60,代码来源:diffAgainstStore.ts

示例10: _onTransactionSentAsync

 private async _onTransactionSentAsync(
     txData: MaybeFakeTxData,
     err: Error | null,
     txHash: string | undefined,
     cb: Callback,
 ): Promise<void> {
     if (!txData.isFakeTransaction) {
         // This transaction is a usual ttransaction. Not a call executed as one.
         // And we don't want it to be executed within a snapshotting period
         await this._lock.acquire();
     }
     if (_.isNull(err)) {
         const toAddress = _.isUndefined(txData.to) || txData.to === '0x0' ? constants.NEW_CONTRACT : txData.to;
         await this._recordTxTraceAsync(toAddress, txData.data, txHash as string);
     } else {
         const payload = {
             method: 'eth_getBlockByNumber',
             params: ['latest', true],
         };
         const jsonRPCResponsePayload = await this.emitPayloadAsync(payload);
         const transactions = jsonRPCResponsePayload.result.transactions;
         for (const transaction of transactions) {
             const toAddress = _.isUndefined(txData.to) || txData.to === '0x0' ? constants.NEW_CONTRACT : txData.to;
             await this._recordTxTraceAsync(toAddress, transaction.data, transaction.hash);
         }
     }
     if (!txData.isFakeTransaction) {
         // This transaction is a usual ttransaction. Not a call executed as one.
         // And we don't want it to be executed within a snapshotting period
         this._lock.release();
     }
     cb();
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:33,代码来源:coverage_subprovider.ts


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