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


TypeScript Immutable.OrderedSet函数代码示例

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


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

示例1: OrderedSet

    (() => {
      let expectedResult = OrderedSet([
        List([1, 1, 1, 1]),
        List([1, 1, 2]),
        List([2, 2]),
        List([1, 3])]);

      expect((new Knapsack(OrderedSet([1, 2, 3]), 4)).getResults()).toEqual(expectedResult);
    })();
开发者ID:Ethan826,项目名称:tablexi-coding-challenge,代码行数:9,代码来源:knapsack.spec.ts

示例2: it

  it("correctly computes the supplied problem", () => {
    let expectedResultGiven = OrderedSet([
      List([215, 215, 215, 215, 215, 215, 215]),
      List([215, 355, 355, 580])
    ]);

    let menuItems = OrderedSet([215, 275, 335, 355, 420, 580]);

    expect((new Knapsack(menuItems, 1505)).getResults()).toEqual(expectedResultGiven);
  });
开发者ID:Ethan826,项目名称:tablexi-coding-challenge,代码行数:10,代码来源:knapsack.spec.ts

示例3: it

  it('it should extract keys for each path in a nested complex array', () => {
    let schema = {
      type: 'object',
      properties: {
        anArray: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              anObject: {
                type: 'object',
                properties: {
                  prop1: {
                    type: 'string'
                  },
                  prop2: {
                    type: 'string'
                  }
                }
              },
              aString: {
                type: 'string'
              },
              innerArray: {
                type: 'array',
                items: {
                  type: 'object',
                  properties: {
                    prop1: {
                      type: 'string'
                    },
                    prop2: {
                      type: 'string'
                    }
                  }
                }
              }
            }
          }
        }
      }
    };
    let expectedMap = {
      '': OrderedSet(['anArray']),
      '.anArray': OrderedSet(['anObject', 'aString', 'innerArray']),
      '.anArray.anObject': OrderedSet(['prop1', 'prop2']),
      '.anArray.innerArray': OrderedSet(['prop1', 'prop2'])
    };

    service.buildSchemaKeyStore(schema);
    Object.keys(service.schemaKeyStoreMap)
      .forEach(key => {
        expect(service.schemaKeyStoreMap[key]).toEqual(expectedMap[key]);
      });
  });
开发者ID:inspirehep,项目名称:record-editor,代码行数:55,代码来源:schema-keys-store.service.spec.ts

示例4: it

 it('supports React elements {min: false}', () => {
   const reactElement = React.createElement('Mouse', null, 'Hello World');
   expect(Immutable.OrderedSet([reactElement, reactElement])).toPrettyPrintTo(
     'Immutable.OrderedSet [\n  <Mouse>\n    Hello World\n  </Mouse>,\n]',
     {min: false},
   );
 });
开发者ID:Volune,项目名称:jest,代码行数:7,代码来源:Immutable.test.ts

示例5: switch

export const uiReducer = (state = INITIAL_STATE, action: Actions) => {
  switch (action.type) {
    case 'EDITOR_ADD_VIEW':
      return addView(state, action.payload.id);
    case 'EDITOR_REMOVE_VIEW':
      return removeView(state, action.payload.id);
    case 'INVENTORY_SELECT_ITEMS':
      return state.set('selectedItems', OrderedSet(action.payload.ids));
    case 'EDITOR_SET_ACTIVE_VIEW':
      return state.set('activeEditorView', action.payload.id);
    case 'INVENTORY_TOGGLE_SELECT':
      return toggleSelect(state, action);
    case 'INVENTORY_TOGGLE_EXPAND':
      return toggleExpand(state, action);
    case 'INVENTORY_EXPAND_ITEMS':
      return expandItems(state, action);
    case 'SET_STATE':
      return setState(state, action);
    case 'SOCKET_STATUS':
      return state.set('alert', ALERTS[action.payload.status]);
    case 'PLAYER_SET_ACTIVE_VIEW':
      return state.set('activePlayerView', action.payload.name);
    case 'RESIZE_PANEL':
      return state.set(action.payload.property, action.payload.size);
    default:
      return state;
  }
};
开发者ID:threehams,项目名称:reverie-client,代码行数:28,代码来源:uiReducer.ts

示例6: genKey

const createContentBlock = ( blockData: DraftEntityInstance, contentState: ContentState) => {
  const {key, type, text, data, inlineStyles, entityData} = blockData;
  let blockSpec = {
    type: type != null ? type : 'unstyled',
    text: text != null ? text : '',
    key: key != null ? key : genKey(),
    data: null,
    characterList: List([]),
  };

  if (data) {
    blockSpec.data = fromJS(data)
  }

  if (inlineStyles || entityData) {
    let entityKey;
    if (entityData) {
      const {type, mutability, data} = entityData;
      contentState.createEntity(type, mutability, data);
      entityKey = contentState.getLastCreatedEntityKey();
    } else {
      entityKey = null
    }
    const style = OrderedSet(inlineStyles || [])
    const charData = CharacterMetadata.create({style, entityKey} as CharacterMetadataConfig)
    blockSpec.characterList = List(Repeat(charData, text.length))
  }
  return new ContentBlock(blockSpec)
}
开发者ID:react-component,项目名称:editor-core,代码行数:29,代码来源:customHTML2Content.ts

示例7: List

      return prices.flatMap((price: number) => {
        let newBudget = budget - price; // If we buy this item, what is our new budget?

        // Remove items that are more than our budget and more than the item
        // under consideration.
        let newMenuItems = prices.filter(c => {
          let priceCeiling = Math.min(newBudget, price);
          return c <= priceCeiling;
        }) as OrderedSet<number>; // Should remain an OrderedSet after filter

        // No recursion if the item under consideration exactly zeroes our
        // budget.
        if (newBudget === 0) {
          let results = List([List([price])]);
          this.memo[hashed] = results;
          return results;
        };

        // Recursive call
        let recursive = this.computeHelper(newMenuItems, newBudget);

        // If recursion returned results, concat the item under consideration
        // onto each result and return that. If recursion didn't return results
        // return empty set.
        let results = recursive
          ? recursive.map((e: List<number>) => e.concat(price)).toSet()
          : OrderedSet([]);

        this.memo[hashed] = results;
        return results;
      });
开发者ID:Ethan826,项目名称:tablexi-coding-challenge,代码行数:31,代码来源:knapsack.ts

示例8: attachBibData

    private attachBibData(filterData:{[k:string]:Array<FilterResponseValue>}) {
        const attrObj = this.textTypesStore.getAttribute(this.bibliographyAttribute);
        const newBibData = filterData[this.bibliographyAttribute];

        // set the data iff server data are full-fledget (i.e. including unique 'ident')
        if (newBibData.length > 0 && !!newBibData[0].ident) {
            this.bibliographyIds = this.bibliographyIds.union(Immutable.OrderedSet<string>(newBibData.map(v => v.ident)));
        }
        this.textTypesStore.setExtendedInfoSupport(
            this.bibliographyAttribute,
            (ident:string) => {
                if (this.bibliographyIds.contains(ident)) {
                    return this.loadBibInfo(ident).then(
                        (serverData:ServerBibData) => {
                            this.textTypesStore.setExtendedInfo(this.bibliographyAttribute,
                                    ident, Immutable.OrderedMap<string, any>(serverData.bib_data));

                        }
                    ).catch(
                        (err:any) => {
                            this.pluginApi.showMessage('error', err);
                        }
                    );

                } else {
                    return new RSVP.Promise<any>((resolve:()=>void, reject:(err)=>void) => {
                        reject(new Error('Item not found'));
                    })
                }
            }
        );
    }
开发者ID:tomachalek,项目名称:kontext,代码行数:32,代码来源:store.ts


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