• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.toArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _parse_measures

    _parse_measures(name, measures, draw_missing_datapoint_as_zero){
      var dps = [];
      var last_granularity;
      var last_timestamp;
      var last_value;
      // NOTE(sileht): sample are ordered by granularity, then timestamp.
      _.each(_.toArray(measures).reverse(), (metricData) => {
        var granularity = metricData[1];
        var timestamp = moment(metricData[0], moment.ISO_8601);
        var value = metricData[2];

        if (last_timestamp !== undefined){
          // We have a more precise granularity
          if (timestamp.valueOf() >= last_timestamp.valueOf()){
            return;
          }
          if (draw_missing_datapoint_as_zero) {
            var c_timestamp = last_timestamp;
            c_timestamp.subtract(last_granularity, "seconds");
            while (timestamp.valueOf() < c_timestamp.valueOf()) {
              dps.push([0, c_timestamp.valueOf()]);
              c_timestamp.subtract(last_granularity, "seconds");
            }
          }
        }
        last_timestamp = timestamp;
        last_granularity = granularity;
        last_value = value;
        dps.push([last_value, last_timestamp.valueOf()]);
      });
      return { target: name, datapoints: _.toArray(dps).reverse() };
    }
开发者ID:sileht,项目名称:grafana-gnocchi-datasource,代码行数:32,代码来源:datasource.ts


示例2: traverse

 /**
  * Traverse all potential child reflections of this reflection.
  *
  * The given callback will be invoked for all children, signatures and type parameters
  * attached to this reflection.
  *
  * @param callback  The callback function that should be applied for each child reflection.
  */
 traverse(callback: TraverseCallback) {
     for (const child of toArray(this.children)) {
         if (callback(child, TraverseProperty.Children) === false) {
             return;
         }
     }
 }
开发者ID:TypeStrong,项目名称:typedoc,代码行数:15,代码来源:container.ts


示例3: return

    firebase.database().ref(notesIndexRefPath).orderByChild('timestamp').limitToLast(100).on('value', snapshot => {
      const noteIndices: FirebaseNoteIndex[] = lodash.toArray(snapshot.val()); // rename, reshape

      let cachedNotes = this.store.cachedNotes; // Storeに保存してあるcachedNotesを取得する

      /* 更新の必要があるnoteIndexだけを抽出する(noteidとtimestampが同一のnoteは更新の必要がない) */
      let differenceNoteIndices = noteIndices.filter(noteIndex => {
        const compareNotes = cachedNotes.filter(note => note.noteid === noteIndex.noteid);
        return (compareNotes.length > 0 && compareNotes[0].timestamp === noteIndex.timestamp) ? false : true;
      });
      differenceNoteIndices = lodash.orderBy(differenceNoteIndices, ['timestamp'], ['desc']); // timestampの降順で並び替える
      console.log('differenceNoteIndices: ');
      console.log(differenceNoteIndices);

      /* noteIndexに基づいてnoteを取得する。onceメソッドは非同期のため完了は順不同となる。(本当に?) */
      if (differenceNoteIndices.length > 0) {        
        differenceNoteIndices.forEach(noteIndex => {
          const notesRefPath = 'notes/' + noteIndex.noteid;
          firebase.database().ref(notesRefPath).once('value', snapshot => {
            const note: FirebaseNote = snapshot.val(); // rename
            cachedNotes.unshift(note); // cachedNotesの先頭にnoteを追加
            cachedNotes = lodash.uniqBy(cachedNotes, 'noteid'); // noteidの重複をまとめる。(先頭寄りにあるものを生かす)
            cachedNotes = lodash.orderBy(cachedNotes, ['timestamp'], ['desc']); // timestampの降順で並べ替える
            this.notes$.next(cachedNotes);
            this.store.cachedNotes = cachedNotes; // 新しいcachedNotesをStoreのcachedNotesに書き戻す
          });
        });
      } else { // differenceNoteIndices.length === 0
        this.notes$.next(cachedNotes);
      }
    }, err => {
开发者ID:ovrmrw,项目名称:jspm-angular2-sample,代码行数:31,代码来源:note-list.service.ts


示例4: constructor

 constructor(name?: string, opts?: IEnvironmentWorkerOpts) {
     super([], {
         id: idHelper.newId(),
         name: 'iw-env' + (_.isUndefined(name) || name.length === 0 ? '' : '-' + name)
     }, opts);
     var defOpts = {};
     this.opts = this.opts.beAdoptedBy<IEnvironmentWorkerOpts>(defOpts, 'worker');
     this.opts.merge(opts);
     this.genericConnections = this.opts.get<IGenericConnection[]>('genericConnections');
     this.genericConnections = _.isUndefined(this.genericConnections) ? [] : _.toArray(this.genericConnections);
     this.environmentObject = this.opts.get('environmentObject');
     this.environmentObject = _.isUndefined(this.environmentObject) ? process.env : this.environmentObject;
     var serviceConnections = this.opts.get<IServiceConnection[]>('serviceConnections');
     if (!_.isUndefined(serviceConnections)) {
         this.serviceConnections = _.map(serviceConnections, (srvConn: IServiceConnection) => {
             var conn: IServiceConnection = {
                 name: srvConn.name,
                 protocol: srvConn.protocol,
                 host: srvConn.host,
                 port: srvConn.port,
                 endPoints: srvConn.endPoints,
                 token: srvConn.token,
                 url: EnvironmentWorker.getServiceConnectionUrl(srvConn)
             };
             return conn;
         });
     }
 }
开发者ID:ferrous-frameworks,项目名称:ironworks,代码行数:28,代码来源:EnvironmentWorker.ts


示例5: getDataRelativePath

function getDataRelativePath(...paths: string[]) {
    let args = _.toArray(arguments);

    args.unshift(getDataPath());

    return path.join.apply(this, args);
}
开发者ID:yegor-sytnyk,项目名称:contoso-express,代码行数:7,代码来源:pathHelper.ts


示例6: it

    it('has the appropriate DOM structure', function() {
      var labelText = dropdownButton.querySelector('button').textContent;
      assert.equal(labelText, 'adaugă persoană', 'has the appropriate label');

      actionButtons = _.toArray(dropdownButton.querySelectorAll('option-list>button'));
      var actionButtonLablels = actionButtons.map(_.property('textContent'));
      assert.deepEqual(actionButtonLablels, ['debitor', 'persoană terţă'], 'options have the appropriate labels');
    });
开发者ID:gurdiga,项目名称:xo,代码行数:8,代码来源:NewCaseDialogTest.ts


示例7: function

 component.prototype[fnName] = function() {
   const argArray = _.toArray(arguments);
   const returnValue = newFn.apply(this, argArray);
   if (oldFn) {
     oldFn.apply(this, argArray);
   }
   return returnValue;
 };
开发者ID:abe732,项目名称:react-layered-chart,代码行数:8,代码来源:mixinToDecorator.ts


示例8: permutations

/**
 * Generate permutations, in all possible orderings, with no repeat values
 *
 *
 * permutations([1,2,3],2)
 * // => [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]
 *
 * permutations('cat',2)
 * // => [["c","a"],["c","t"],["a","c"],["a","t"],["t","c"],["t","a"]]
 */
function permutations(obj, n){
  if (typeof obj=='string') obj = _.toArray(obj);
  n = n?n:obj.length;
  // make n copies of keys/indices
  for (var j = 0, nInds=[]; j < n; j++) {nInds.push(_.keys(obj)) }
  // get product of the indices, then filter to remove the same key twice
  var arrangements = product(nInds).filter(pair=>pair[0]!==pair[1]);
  return _.map(arrangements,indices=>_.map(indices,i=>obj[i]));
}
开发者ID:mlukasch,项目名称:indigo,代码行数:19,代码来源:permutations.ts


示例9: combinations_with_replacement

/**
 * Generate n combinations with repeat values.
 *
 *
 * combinations_with_replacement([0,1,2,3],2)
 * // => [[0,0],[0,1],[0,2],[0,3],[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
 */
function combinations_with_replacement(obj,n){
  if (typeof obj=='string') obj = _.toArray(obj);
  n = n?n:obj.length;
  // make n copies of keys/indices
  for (var j = 0, nInds=[]; j < n; j++) {nInds.push(_.keys(obj)) }
  // get product of the indices, then filter to keep elements in order
  var arrangements = product(nInds).filter(pair=>pair[0]<=pair[1]);
  return _.map(arrangements,indices=>_.map(indices,i=>obj[i]))
}
开发者ID:mlukasch,项目名称:indigo,代码行数:16,代码来源:permutations.ts


示例10: spy

  return function spy() {
    spy.calls = spy.calls || [];
    spy.calls.push({ args: _.toArray(arguments) });
    spy.executed = true;

    spy.reset = function() {
      spy.calls = [];
      spy.executed = false;
    };
  };
开发者ID:gurdiga,项目名称:xo,代码行数:10,代码来源:helper.ts


示例11: before

  before(function() {
    activities = [
      new InstitutionActivity()
    ];
    activityAdder = createSpy();
    addActivityButton = new AddActivityButton(activities, activityAdder);

    domElement = getWidgetDOMElement(addActivityButton);
    optionButtons = _.toArray(domElement.querySelectorAll('dropdown-button>option-list>button'));
  });
开发者ID:gurdiga,项目名称:xo,代码行数:10,代码来源:AddActivityButtonTest.ts


示例12: postImportRoutine

function postImportRoutine(db) {
    if (db.sequelize.dialect.name === 'postgres') {
        return Promise.resolve(_.toArray(db.models))
            .map(model => {
                return updatePostgresSequence(model, db);
            });
    }

    return Promise.resolve(null);
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:10,代码来源:seederDefault.ts


示例13: it

    it('creates TodoItem widgets for each item in the given array', function() {
      var todoItemData = [{
        id: 'first-item',
        label: 'the first new item'
      }, {
        id: 'second-item',
        label: 'the second new item'
      }];

      todoList.setData(todoItemData);

      var itemElements = _.toArray(domElement.querySelectorAll('ul>li>labeled-checkbox input[type="checkbox"]'));
      assert.equal(itemElements.length, todoItemData.length, 'renders items as <li>s');

      var itemLabels = _.toArray(domElement.querySelectorAll('ul>li>labeled-checkbox'));
      var itemLabelTexts = itemLabels.map(_.property('textContent'));
      var expectedItemLabels = todoItemData.map(_.property('label'));
      assert.deepEqual(itemLabelTexts, expectedItemLabels, 'items have the appropriate label texts');
    });
开发者ID:gurdiga,项目名称:xo,代码行数:19,代码来源:TodoListTest.ts


示例14: traverse

    /**
     * Traverse all potential child reflections of this reflection.
     *
     * The given callback will be invoked for all children, signatures and type parameters
     * attached to this reflection.
     *
     * @param callback  The callback function that should be applied for each child reflection.
     */
    traverse(callback: TraverseCallback) {
        if (this.type instanceof ReflectionType) {
            if (callback(this.type.declaration, TraverseProperty.TypeLiteral) === false) {
                return;
            }
        }

        for (const parameter of toArray(this.typeParameters)) {
            if (callback(parameter, TraverseProperty.TypeParameter) === false) {
                return;
            }
        }

        for (const parameter of toArray(this.parameters)) {
            if (callback(parameter, TraverseProperty.Parameters) === false) {
                return;
            }
        }

        super.traverse(callback);
    }
开发者ID:TypeStrong,项目名称:typedoc,代码行数:29,代码来源:signature.ts


示例15: traverse

    /**
     * Traverse all potential child reflections of this reflection.
     *
     * The given callback will be invoked for all children, signatures and type parameters
     * attached to this reflection.
     *
     * @param callback  The callback function that should be applied for each child reflection.
     */
    traverse(callback: TraverseCallback) {
        for (const parameter of toArray(this.typeParameters)) {
            if (callback(parameter, TraverseProperty.TypeParameter) === false) {
                return;
            }
        }

        if (this.type instanceof ReflectionType) {
            if (callback(this.type.declaration, TraverseProperty.TypeLiteral) === false) {
                return;
            }
        }

        for (const signature of toArray(this.signatures)) {
            if (callback(signature, TraverseProperty.Signatures) === false) {
                return;
            }
        }

        if (this.indexSignature) {
            if (callback(this.indexSignature, TraverseProperty.IndexSignature) === false) {
                return;
            }
        }

        if (this.getSignature) {
            if (callback(this.getSignature, TraverseProperty.GetSignature) === false) {
                return;
            }
        }

        if (this.setSignature) {
            if (callback(this.setSignature, TraverseProperty.SetSignature) === false) {
                return;
            }
        }

        super.traverse(callback);
    }
开发者ID:TypeStrong,项目名称:typedoc,代码行数:47,代码来源:declaration.ts


示例16: _cartesianProductOf

/**
 * Generate all combination of arguments when given arrays or strings
 * e.g. [['Ben','Jade','Darren'],['Smith','Miller']] to [['Ben','Smith'],[..]]
 * e.g. 'the','cat' to [['t', 'c'],['t', 'a'], ...]
 **/
function _cartesianProductOf(args) {
  if (arguments.length>1) args=_.toArray(arguments);

  // strings to arrays of letters
  args=_.map(args, opt=>typeof opt==='string'?_.toArray(opt):opt);

  return _.reduce(args, function(a, b) {
    return _.flatten(_.map(a, function(x) {
      return _.map<any,any>(b, function(y) {
        return _.concat(x,[y]);
      });
    }), true);
  }, [ [] ]);
}
开发者ID:okgreece,项目名称:indigo,代码行数:19,代码来源:permutations.ts


示例17: it

  it('accepts to reset its options', function() {
    var handlerA = createSpy();
    var handlerB = createSpy();
    var newOptions = {
      'labelA': handlerA,
      'labelB': handlerB
    };

    optionList.setOptions(newOptions);

    var optionLabels = _.toArray(domElement.children).map(_.property('textContent'));
    assert.deepEqual(optionLabels, Object.keys(newOptions), 'option buttons have the expected labels');

    var optionA = domElement.children[0];
    optionA.click();
    optionA.click();
    assert.deepEqual(handlerA.calls.length, 2, 'clicking on an option calls its corresponding handler');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:18,代码来源:OptionListTest.ts


示例18: it

  it('has the button to add activities', function() {
    var addActivityButton = domElement.querySelector('dropdown-button');

    var activityListContainer = addActivityButton.previousSibling;
    assert.equal(activityListContainer.getAttribute('name'), 'activity-list-container',
      'activity list container is marked as such for inspectability');

    var toggleButton = addActivityButton.querySelector('button:first-child');
    assert.equal(toggleButton.textContent, 'adaugă acţiune', 'has the appropriate label');

    var options = _.toArray(addActivityButton.querySelectorAll('option-list>button'));
    assert.equal(options.length, 2, 'has the appropriate number of options');

    var optionsLabels = options.map(_.property('textContent'));
    assert.deepEqual(optionsLabels, ['Intentarea', 'Refuz'], 'options have the appropriate labels');

    assert.equal(activityListContainer.children.length, 0, 'activity list is initially empty');
    options[0].click();
    assert.equal(activityListContainer.children.length, 1, 'adds one activity');
    assert.equal(activityListContainer.children[0].getAttribute('widget-name'),
      'InstitutionActivity', 'the added activity is an InstitutionActivity');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:22,代码来源:ActivitiesSectionTest.ts


示例19:

  (releasesState: ReleasesState, shelvesState: ShelvesState) => {
    let releasesArray = _.toArray(releasesState.items)

    if (shelvesState.currentShelf) {
      const currentShelfIds = shelvesState.shelves[shelvesState.currentShelf]
      releasesArray = _.filter(releasesArray, (release: Release) => {
        return _.includes(currentShelfIds, release.id)
      })
    } else {
      const allShelvedReleaseIds = _.flatten(_.concat(_.values(shelvesState.shelves)))
      releasesArray = _.filter(releasesArray, (release: Release) => {
        return !_.includes(allShelvedReleaseIds, release.id)
      })
    }

    releasesArray = _.sortBy(releasesArray, 'basic_information.title')

    return {
      currentShelf: shelvesState.currentShelf,
      loading: releasesState.loadingPage !== null,
      nextPage: releasesState.nextPage,
      releases: releasesArray
    }
})
开发者ID:rawrmaan,项目名称:blisscogs,代码行数:24,代码来源:selectors.ts


示例20: getFlagsArray

function getFlagsArray(component: OsdFlagsModalComponent) {
  const allFlags = _.cloneDeep(component.allFlags);
  allFlags['purged_snapdirs'].value = true;
  allFlags['pause'].value = true;
  return _.toArray(allFlags);
}
开发者ID:ShiqiCooperation,项目名称:ceph,代码行数:6,代码来源:osd-flags-modal.component.spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.toLower函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.times函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap