Skip to content

プレイグラウンド

このインタラクティブプレイグラウンドで es-toolkit の関数を探索・実験できます。サイドバーから関数を選択してライブサンプルを確認するか、独自のコードを書いてみてください。

  • at
  • cartesianProduct
  • chunk
  • combinations
  • compact
  • countBy
  • difference
  • differenceBy
  • differenceWith
  • drop
  • dropRight
  • dropRightWhile
  • dropWhile
  • fill
  • filterAsync
  • flatMap
  • flatMapAsync
  • flatMapDeep
  • flatten
  • flattenDeep
  • forEachAsync
  • forEachRight
  • groupBy
  • head
  • initial
  • intersection
  • intersectionBy
  • intersectionWith
  • isSubset
  • isSubsetWith
  • keyBy
  • last
  • limitAsync
  • mapAsync
  • maxBy
  • minBy
  • orderBy
  • partition
  • pull
  • pullAt
  • reduceAsync
  • remove
  • sample
  • sampleSize
  • shuffle
  • sortBy
  • tail
  • take
  • takeRight
  • takeRightWhile
  • takeWhile
  • toFilled
  • union
  • unionBy
  • unionWith
  • uniq
  • uniqBy
  • uniqWith
  • unzip
  • unzipWith
  • windowed
  • without
  • xor
  • xorBy
  • xorWith
  • zip
  • zipObject
  • zipWith
関数を選択してください
import { chunk, groupBy, uniq } from 'es-toolkit';

// ============================================
// es-toolkit Playground
// Try any function from the sidebar!
// ============================================

// chunk(arr, size)
// Splits an array into smaller arrays of the given size.
const chunked = chunk([1, 2, 3, 4, 5, 6], 2);
console.log('chunk:', chunked);
// [[1, 2], [3, 4], [5, 6]]

// uniq(arr)
// Returns a new array with duplicates removed.
const unique = uniq([1, 2, 2, 3, 3, 3]);
console.log('uniq:', unique);
// [1, 2, 3]

// groupBy(arr, fn)
// Groups array elements by a key returned from the callback.
const grouped = groupBy(
  [
    { name: 'Alice', age: 25 },
    { name: 'Bob', age: 30 },
    { name: 'Charlie', age: 25 },
  ],
  item => item.age,
);
console.log('groupBy:', grouped);

MIT ライセンスの下で配布されています。