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

TypeScript lodash.clone函数代码示例

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

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



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

示例1: regimenSerializer

export function regimenSerializer(input: Regimen): ApiRegimen {
    const regimen = _.clone<Regimen>(input);
    const regimen_items = regimen
        .regimen_items
        .map<ApiRegimenItem>(function wow(r) {
            if (r && r.sequence && r.sequence.id) {
                return {
                    time_offset: r.time_offset,
                    sequence_id: r.sequence.id
                };
            } else {
                throw new Error(`Array regimen.regimen_items may only contain
                           objects with an "id" property.`);
            }
        });

    return {
        name: regimen.name,
        color: regimen.color,
        regimen_items
    };
};
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:22,代码来源:serializers.ts


示例2: beforeEach

  beforeEach(() => {
    testBed = TestUtils.configureProviderTestingModule([
      { provide: BwcProvider, useClass: BwcProviderMock },
      { provide: PersistenceProvider, useClass: PersistenceProviderMock }
    ]);
    profileProvider = testBed.get(ProfileProvider);
    actionSheetProvider = testBed.get(ActionSheetProvider);
    configProvider = testBed.get(ConfigProvider);
    popupProvider = testBed.get(PopupProvider);
    replaceParametersProvider = testBed.get(ReplaceParametersProvider);
    platformProvider = testBed.get(PlatformProvider);
    txFormatProvider = testBed.get(TxFormatProvider);

    profileProvider.wallet = _.clone(walletMock);
    profileProvider.profile = Profile.create();

    events = testBed.get(Events);
    eventsPublishSpy = spyOn(events, 'publish');
    spyOn(events, 'subscribe').and.returnValue({
      walletId: 'id1'
    });
  });
开发者ID:bitpay,项目名称:copay,代码行数:22,代码来源:profile.spec.ts


示例3: function

 _.forEach(filtered, function(ot: any) {
     ot.koodiUri = ot.koodiUri || null;
     ot.koodiArvo = ot.koodiUri || null;
     var koodiUriKaytossa = _.any($scope.osatutkinnot, function(toinen: any) {
         return ot !== toinen && ot.koodiUri && toinen.koodiUri === ot.koodiUri;
     });
     if (koodiUriKaytossa) {
         ot.$syy = ["excel-ei-kahta-samaa"];
     } else {
         var cop = _.clone(ot);
         cop.tavoitteet = {};
         cop.tila = "luonnos";
         cop.osanTyyppi = "tutkinnonosa";
         cop.$laajuus = cop.laajuus;
         delete cop.laajuus;
         PerusteTutkinnonosat.save(
             {
                 perusteId: $scope.haettuPeruste.id,
                 suoritustapa: $scope.suoritustapa || $scope.haettuPeruste.suoritustavat[0].suoritustapakoodi
             },
             {
                 tutkinnonOsa: cop,
                 laajuus: cop.$laajuus
             },
             function(re) {
                 ot.$ladattu = 0;
                 ot.id = re._tutkinnonOsa;
                 doneSuccess();
             },
             function(err) {
                 if (err) {
                     ot.$syy = [err.data.syy];
                     ot.$ladattu = 1;
                 }
             }
         );
     }
 });
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:38,代码来源:excel.ts


示例4: it

    it('should call showDesktopNotifications and go through NewTxProposal path', async () => {
      let newWalletClient = _.clone(walletClientMock);
      newWalletClient.copayerId = 'copayerId1';
      newWalletClient.credentials.m = 2;
      newWalletClient.credentials.n = 2;

      spyOn(BwcProviderMock.prototype, 'getClient').and.returnValue(
        newWalletClient
      );

      onEventNotificationType = 'NewTxProposal';
      const replaceSpy = spyOn(
        replaceParametersProvider,
        'replace'
      ).and.returnValue('body1');

      // Using importWallet just to test showDesktopNotifications private function
      await profileProvider.importWallet(str, opts).catch(err => {
        expect(err).not.toBeDefined();
      });

      expect(replaceSpy).toHaveBeenCalledTimes(1);
    });
开发者ID:bitpay,项目名称:copay,代码行数:23,代码来源:profile.spec.ts


示例5:

  $onInit() {
    this.searchGatewayInstances = '';
    this.instances = this.startedInstances = _.clone(_.filter(this.instances, { 'state': 'started'}));
    this._displayEmptyMode = this.startedInstances.length === 0;

    this.$scope.displayAllInstances = false;

    this.$scope.switchDisplayInstances = () => {
      this.$scope.displayAllInstances = !this.$scope.displayAllInstances;

      if (this.$scope.displayAllInstances) {
        this._displayEmptyMode = this.instances.length === 0;
        if (this.allInstances) {
          this.instances = this.allInstances;
        } else {
          this.InstancesService.list(true).then(response => this.instances = this.allInstances = response.data);
        }
      } else {
        this._displayEmptyMode = this.startedInstances.length === 0;
        this.instances = this.startedInstances;
      }
    };
  }
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:23,代码来源:instances.controller.ts


示例6: SystemStatusReducer

export default function SystemStatusReducer(state: SystemStatus = defaultStatus, action: any = { type: "" }) {
    /**
     *
     *
     * DO NOT UNCOMMENTS
     *     CAUSING INFINITE LOOP
     *
     *
     *
     *
     */
    const newstate = _.clone(state);
    if (action.type.startsWith("App/")) {

        newstate.currentAction = action.type;
    }
    if (action.type.endsWith("_ERROR")) {
        Log.info("SystemStatusReducer", "canged sfetch Status to action.payload.error.message");
        newstate.fetchStatus = action.payload.error.message;
    }
    return newstate;
    //return state;
}
开发者ID:,项目名称:,代码行数:23,代码来源:


示例7: return

  return (dispatch, getState) => {
    const {
      edit: { article },
    } = getState()
    let data = {}

    if (typeof key === "object") {
      // extend article with an object of key
      data = key
    } else {
      const nestedObject = key.split(".")

      if (nestedObject.length > 1) {
        // change a nested object value
        const existingValue = clone(article[nestedObject[0]]) || {}
        data = set(existingValue, key, value)
      } else {
        // change a single key's value
        data[key] = value
      }
    }
    dispatch(changeArticle(data))
  }
开发者ID:artsy,项目名称:positron,代码行数:23,代码来源:articleActions.ts


示例8: configureAxisOptions

      function configureAxisOptions(data, options) {
        var defaults = {
          position: 'left',
          show: panel.yaxes[0].show,
          index: 1,
          logBase: panel.yaxes[0].logBase || 1,
          max: 100, // correct later
        };

        options.yaxes.push(defaults);

        if (_.find(data, {yaxis: 2})) {
          var secondY = _.clone(defaults);
          secondY.index = 2;
          secondY.show = panel.yaxes[1].show;
          secondY.logBase = panel.yaxes[1].logBase || 1;
          secondY.position = 'right';
          options.yaxes.push(secondY);
          configureAxisMode(options.yaxes[1], panel.percentage && panel.stack ? "percent" : panel.yaxes[1].format);
        }

        applyLogScale(options.yaxes[0], data);
        configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format);
      }
开发者ID:sis-labs,项目名称:grafana,代码行数:24,代码来源:graph.ts


示例9: it

    it('sort movies by year descending, runtime ascending, id', () => {
      var testdata = makeMovies();
      var original = _.clone(testdata);

      testdata.sort(jsonCompare([
        '-year',
        '+runtime',
        'id'
      ]));
      original.sort(function (a, b) {
        var result = (b.year | 0) - (a.year | 0);
        if (result === 0) {
          result = (a.runtime | 0) - (b.runtime | 0);
          if (result === 0) {
            result = a.id.localeCompare(b.id);
          }
        }
        return result;
      });

      for (var j = 0; j < testdata.length; ++j) {
        assert.equal(testdata[j], original[j], 'order at #' + j);
      }
    })
开发者ID:relution-io,项目名称:relution-sdk,代码行数:24,代码来源:SortOrderComparator.spec.ts


示例10: get

 const setComponentValue = () => {
   const uriValue = get(URIStorageName, false);
   const currentValue = this[propertyName];
   // if uriValue is undefined, we will ensure that the property has the
   // default value
   if (uriValue === undefined) {
     let valueToSet: T;
     // if we are using localStorage, we will set the value to the value
     // from localStorage. Then, the corresponding observer will proxy
     // the localStorage value into URI storage.
     // in this way, localStorage takes precedence over the default val
     // but not over the URI value.
     if (useLocalStorage) {
       const useLocalStorageValue = get(URIStorageName, true);
       valueToSet = useLocalStorageValue === undefined ?
           defaultVal :
           useLocalStorageValue;
     } else {
       valueToSet = defaultVal;
     }
     if (!_.isEqual(currentValue, valueToSet)) {
       // If we don't have an explicit URI value, then we need to ensure
       // the property value is equal to the default value.
       // We will assign a clone rather than the canonical default, because
       // the component receiving this property may mutate it, and we need
       // to keep a pristine copy of the default.
       this[propertyName] = _.clone(valueToSet);
     }
     // In this case, we have an explicit URI value, so we will ensure that
     // the component has an equivalent value.
   } else {
     if (!_.isEqual(uriValue, currentValue)) {
       this[propertyName] = uriValue;
     }
   }
 };
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:36,代码来源:storage.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.cloneDeep函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.clamp函数代码示例发布时间: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