當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。