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


TypeScript lodash.property函數代碼示例

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


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

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

示例2: it

  it('has the appropriate DOM structure', function() {
    assert.equal(domElement.tagName, 'DROPDOWN-BUTTON', 'is implemented with a DropdownButton');

    var toggleButton = domElement.firstChild;
    assert.equal(toggleButton.textContent, 'adaugă acţiune', 'has the appropriate label');
    assert.equal(optionButtons.length, activities.length, 'has one option button for every activity');

    var optionButtonLabels = optionButtons.map(_.property('textContent'));
    assert.deepEqual(optionButtonLabels, ['Intentarea'], 'has the action descriptions as labels for action buttons');
  });
開發者ID:gurdiga,項目名稱:xo,代碼行數:10,代碼來源:AddActivityButtonTest.ts

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

示例4: it

    it('has the appropriate options', function() {
      var optionList = domElement.querySelector('option-list');
      var expectedOptionLabels = Object.keys(options);
      var expectedOptionCount = expectedOptionLabels.length;

      var optionButtons = optionList.querySelectorAll('button');
      assert.equal(optionButtons.length, expectedOptionCount, 'has the appropriate number of options');

      var optionButtonLabels = _.map(optionButtons, _.property('textContent'));
      assert.deepEqual(optionButtonLabels, expectedOptionLabels, 'options have the appropriate labels');
    });
開發者ID:gurdiga,項目名稱:xo,代碼行數:11,代碼來源:DropdownButtonTest.ts

示例5: it

  it('properly normalizes a nested array with IDs', () => {
    const fragment = `
      fragment Item on ItemType {
        id,
        stringField,
        numberField,
        nullField,
        nestedArray {
          id,
          stringField,
          numberField,
          nullField
        }
      }
    `;

    const result = {
      id: 'abcd',
      stringField: 'This is a string!',
      numberField: 5,
      nullField: null,
      nestedArray: [
        {
          id: 'abcde',
          stringField: 'This is a string too!',
          numberField: 6,
          nullField: null,
        },
        {
          id: 'abcdef',
          stringField: 'This is a string also!',
          numberField: 7,
          nullField: null,
        },
      ],
    };

    assert.deepEqual(writeFragmentToStore({
      fragment,
      result: _.cloneDeep(result),
      dataIdFromObject: getIdField,
    }), {
      [result.id]: _.assign({}, _.assign({}, _.omit(result, 'nestedArray')), {
        nestedArray: result.nestedArray.map(_.property('id')),
      }),
      [result.nestedArray[0].id]: result.nestedArray[0],
      [result.nestedArray[1].id]: result.nestedArray[1],
    });
  });
開發者ID:WilliamHolmes,項目名稱:apollo-client,代碼行數:49,代碼來源:writeToStore.ts

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

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

示例8: it

 it('value', () => {
     let f = _.property('name');
     expect(f({ name: 'Alex' })).toEqual('Alex');
 });
開發者ID:richie5um,項目名稱:TESTLodash,代碼行數:4,代碼來源:index.spec.ts

示例9: getSongInfo

async function getSongInfo(
  files: IndexingInputFile[],
  options?: {
    cache?: {
      get(md5: string): OutputFileInfo
      put(md5: string, info: OutputFileInfo): void
    }
    extra?: any
    onProgress?: any
    onError?: (error: Error, name: string) => void
    getFileInfo?: typeof getFileInfo
  }
): Promise<OutputSongInfo> {
  options = options || {}
  var warnings: string[] = []
  var cache = options.cache || undefined
  var extra = options.extra || {}
  var report = options.onProgress || function() {}
  var onError =
    options.onError ||
    function(e, name) {
      if (global.console && console.error) {
        console.error('Error while parsing ' + name, e)
      }
    }
  var processed = 0
  var doGetFileInfo = options.getFileInfo || getFileInfo
  const results: OutputChart[][] = await Bluebird.map(
    files,
    async function(file): Promise<OutputChart[]> {
      var name = file.name
      var fileData = file.data
      var hash = createHash('md5')
      hash.update(fileData)
      var md5Hash = hash.digest('hex')
      try {
        const cached = await Promise.resolve(cache && cache.get(md5Hash))
        if (cached) {
          return [{ ...cached, file: name }]
        } else {
          var meta = { name: name, md5: md5Hash }
          const info = await Promise.resolve(doGetFileInfo(fileData, meta))
          if (cache) cache.put(md5Hash, info)
          return [{ ...info, file: name }]
        }
      } catch (e) {
        onError(e, name)
        warnings.push('Unable to parse ' + name + ': ' + e)
        return []
      } finally {
        processed += 1
        report(processed, files.length, name)
      }
    },
    { concurrency: 2 }
  )
  const charts = _.flatten(results)
  if (charts.length === 0) {
    warnings.push('No usable charts found!')
  }
  var song: Partial<OutputSongInfo> = {
    title: common(charts, _.property('info.title')),
    artist: common(charts, _.property('info.artist')),
    genre: common(charts, _.property('info.genre')),
    bpm: median(charts, _.property('bpm.median')),
  }
  assign(song, getSongVideoFromCharts(charts))
  assign(song, extra)
  song.charts = charts
  song.warnings = warnings
  return song as OutputSongInfo
}
開發者ID:bemusic,項目名稱:bemuse,代碼行數:72,代碼來源:index.ts


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