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