3.3.2 • Published 12 months ago

@johngw/array v3.3.2

Weekly downloads
3
License
MIT
Repository
-
Last release
12 months ago

@johngw/array

filterMap

Filters and maps an array in 1 loop

filterMap(
  [1, 2, 3, 4, 5, 6, 7, 8, 9],
  (x) as is number => x > 5,
  (x) => `${x} bottles`
)
/*
  [
    '6 bottles',
    '7 bottles',
    '8 bottles',
    '9 bottles',
  ]
*/

filterReduce

Filters and reduces an array in 1 loop

filterReduce(
  [1, 2, 3, 4, 5, 6, 7, 8, 9],
  0,
  (_, x) => x < 5,
  (sum, x) => sum + x
)
// 10

Builder

Performant array builder

This is used internally to build arrays. It performs 3x faster than just appending items to array with undefined length.

const builder = new Builder<number>(10_000)

for (let i = 0; i < 10_000; i++) {
  builder.add(i)
}

builder.finish()
// [0, 1, 2, 3, ..., 9999]
3.3.1

1 year ago

3.3.2

12 months ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.0.0

3 years ago