當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.isDate函數代碼示例

本文整理匯總了TypeScript中lodash.isDate函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isDate函數的具體用法?TypeScript isDate怎麽用?TypeScript isDate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isDate函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: unsetIgnoredSubProperties

        _.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);
                }
            }
        });
開發者ID:hydra-newmedia,項目名稱:chrobject,代碼行數:51,代碼來源:EntryAppService.ts

示例3: parse

export function parse(text, roundUp?) {
  if (!text) { return undefined; }
  if (moment.isMoment(text)) { return text; }
  if (_.isDate(text)) { return moment(text); }

  var time;
  var mathString = '';
  var index;
  var parseString;

  if (text.substring(0, 3) === 'now') {
    time = moment();
    mathString = text.substring('now'.length);
  } else {
    index = text.indexOf('||');
    if (index === -1) {
      parseString = text;
      mathString = ''; // nothing else
    } else {
      parseString = text.substring(0, index);
      mathString = text.substring(index + 2);
    }
    // We're going to just require ISO8601 timestamps, k?
    time = moment(parseString);
  }

  if (!mathString.length) {
    return time;
  }

  return parseDateMath(mathString, time, roundUp);
}
開發者ID:eddawley,項目名稱:grafana,代碼行數:32,代碼來源:datemath.ts

示例4: function

  format: function(date, mask) {
    assert(_.isDate(date),
      'DateFormatting.format: the first argument is required and has to be a JS Date instance');
    assert(_.isString(mask),
      'DateFormatting.format: the second argument is required and has to be a string representing the date format mask to represent date as');

    return moment(date).format(mask);
  },
開發者ID:gurdiga,項目名稱:xo,代碼行數:8,代碼來源:DateFormatting.ts

示例5: it

    it('works for the happy path', function() {
      assert(_.isDate(date),
        'parses the string given as the first argument according' +
        ' to the string mask passed in the second argument and returns a date object');

      assert.equal(date.getDate(), 7, 'returned date has the appropriate date');
      assert.equal(date.getMonth(), 5, 'returned date has the appropriate month');
      assert.equal(date.getFullYear(), 2015, 'returned date has the appropriate year');
    });
開發者ID:gurdiga,項目名稱:xo,代碼行數:9,代碼來源:DateFormattingTest.ts

示例6: CompletionLabel

export function CompletionLabel(completionTime) {
  assert(_.isDate(completionTime), 'CompletionLabel expects the completionTime argument to be a Date object');

  var domElement = createElement();
  WidgetRole.apply(this, [domElement]);

  addContent(domElement, completionTime);

  this.getData = delegateTo(completionTime, 'toISOString');
}
開發者ID:gurdiga,項目名稱:xo,代碼行數:10,代碼來源:CompletionLabel.ts

示例7: Date

app.get('/',(req,res)=>{
    var q = req.query.q;

    var ss = _.isDate(new Date());

    console.log("ss:",ss);

    var md5Value = utility.md5(q);
    res.send(md5Value);
});
開發者ID:wangyibu,項目名稱:node-lessons,代碼行數:10,代碼來源:app.ts

示例8:

      val.forEach((v: any) => {
        if (isObject(v)) {
          if (isDate(v)) {
            v = (v as Date).toISOString();
          } else {
            v = JSON.stringify(v);
          }
        }

        parts.push(`${UrlBuilderUtils.encodeUriQuery(key)}=${UrlBuilderUtils.encodeUriQuery(v)}`);
      });
開發者ID:mizzy,項目名稱:deck,代碼行數:11,代碼來源:urlBuilder.service.ts

示例9: it

 it('takes two date for range.', () => {
     const d1 = new Date(1999, 1, 1);
     const d2 = new Date(2000, 3, 22);
     const d3 = date.choose({ start: d1, end: d2 }).random;
     const inRange = () => {
         const t1 = d1.getTime();
         const t2 = d2.getTime();
         const t3 = d3.getTime();
         return t1 <= t3 && t3 <= t2;
     };
     return isDate(d3) && inRange();
 });
開發者ID:hychen,項目名稱:hycheck,代碼行數:12,代碼來源:datetime.test.ts


注:本文中的lodash.isDate函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。