@sullux/fp-light-concat
v0.0.1
Published
A lightweight functional library for functional composition and object composition.
Downloads
2
Readme
fp-light-concat
npm i @sullux/fp-light-concat
source
test
Concatenates values into a single iterable.
concat
concat(...iterables: Array<mixed>): { @@iterator(): Iterator<mixed> }
This function does a shallow concatenation of iterables, objects and values and returns the concatenated iterable. The unit test for the concat function demonstrates how it handles various types of inputs:
const { deepStrictEqual } = require('assert')
const { concat } = require('./concat')
const date = new Date()
describe('concat', () => {
it('should concatenate iterables', () => deepStrictEqual(
[...concat(
[1, 2],
null,
undefined,
{ foo: 42 },
function* () { yield 'bar' },
date,
concat(true, false, [3, 4]),
)],
[1, 2, null, undefined, ['foo', 42], 'bar', date, true, false, 3, 4]
))
})