MCPcopy
hub / github.com/immutable-js/immutable-js / concatFactory

Function concatFactory

src/Operations.js:690–722  ·  view source on GitHub ↗
(collection, values)

Source from the content-addressed store, hash-verified

688}
689
690export function concatFactory(collection, values) {
691 const isKeyedCollection = isKeyed(collection);
692 const iters = [collection]
693 .concat(values)
694 .map((v) => {
695 if (!isCollection(v)) {
696 v = isKeyedCollection
697 ? keyedSeqFromValue(v)
698 : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
699 } else if (isKeyedCollection) {
700 v = KeyedCollection(v);
701 }
702 return v;
703 })
704 .filter((v) => v.size !== 0);
705
706 if (iters.length === 0) {
707 return collection;
708 }
709
710 if (iters.length === 1) {
711 const singleton = iters[0];
712 if (
713 singleton === collection ||
714 (isKeyedCollection && isKeyed(singleton)) ||
715 (isIndexed(collection) && isIndexed(singleton))
716 ) {
717 return singleton;
718 }
719 }
720
721 return new ConcatSeq(iters);
722}
723
724export function flattenFactory(collection, depth, useKeys) {
725 const flatSequence = makeSequence(collection);

Callers 1

concatFunction · 0.90

Calls 9

isKeyedFunction · 0.90
isCollectionFunction · 0.90
keyedSeqFromValueFunction · 0.90
indexedSeqFromValueFunction · 0.90
KeyedCollectionClass · 0.90
isIndexedFunction · 0.90
filterMethod · 0.65
mapMethod · 0.65
concatMethod · 0.65

Tested by

no test coverage detected