├── .babelrc ├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── .travis.yml ├── CONTRIBUTING.md ├── COPYRIGHT ├── LICENSE ├── README.md ├── docs ├── API.md ├── CNAME ├── FAQ.md ├── README.md └── index.html ├── examples ├── chain-immutable-setters.js ├── chunk-immutable.js ├── compose-immutable-setters.js ├── find-immutable.js └── set.example.js ├── fp └── index.js ├── gulpfile.babel.js ├── index.js ├── package.json ├── src ├── core │ ├── __tests__ │ │ ├── assign.test.js │ │ ├── assoc.test.js │ │ ├── assocWith.test.js │ │ ├── at.test.js │ │ ├── chain.test.js │ │ ├── chunk.test.js │ │ ├── compose.test.js │ │ ├── concat.test.js │ │ ├── delete.test.js │ │ ├── difference.test.js │ │ ├── drop.test.js │ │ ├── dropRight.test.js │ │ ├── dropRightWhile.test.js │ │ ├── dropWhile.test.js │ │ ├── find.test.js │ │ ├── findIndex.test.js │ │ ├── flow.test.js │ │ ├── forEach.test.js │ │ ├── forEachRight.test.js │ │ ├── get.test.js │ │ ├── groupBy.test.js │ │ ├── has.test.js │ │ ├── includes.test.js │ │ ├── isEqual.test.js │ │ ├── isImmutable.test.js │ │ ├── isImmutableIndexedSeq.test.js │ │ ├── isImmutableIterable.test.js │ │ ├── isImmutableKeyedSeq.test.js │ │ ├── isImmutableList.test.js │ │ ├── isImmutableMap.test.js │ │ ├── isImmutableOrderedMap.test.js │ │ ├── isImmutableOrderedSet.test.js │ │ ├── isImmutableSeq.test.js │ │ ├── isImmutableSet.test.js │ │ ├── isImmutableSetSeq.test.js │ │ ├── isImmutableStack.test.js │ │ ├── isIndexed.test.js │ │ ├── isIterable.test.js │ │ ├── isShallowEqual.test.js │ │ ├── map.test.js │ │ ├── memoize.test.js │ │ ├── omit.test.js │ │ ├── pick.test.js │ │ ├── pickBy.test.js │ │ ├── pop.test.js │ │ ├── pull.test.js │ │ ├── push.test.js │ │ ├── pushAt.test.js │ │ ├── recompose │ │ │ ├── createFactory.js │ │ │ ├── createHelper.js │ │ │ ├── getDisplayName.js │ │ │ ├── index.js │ │ │ ├── withHintConvert.js │ │ │ ├── withHintSameType.js │ │ │ ├── withMultipleTypeInputs.js │ │ │ └── wrapDisplayName.js │ │ ├── reduce.test.js │ │ ├── reduceRight.test.js │ │ ├── set.test.js │ │ ├── shared │ │ │ ├── index.js │ │ │ ├── reduceTests.js │ │ │ └── uniqTests.js │ │ ├── slice.test.js │ │ ├── splice.test.js │ │ ├── symbol.test.js │ │ ├── tests │ │ │ ├── immutableArgsTest.js │ │ │ ├── immutableTest.js │ │ │ ├── index.js │ │ │ └── iterationCountTest.js │ │ ├── toImmutable.test.js │ │ ├── toImmutableIndexedSeq.test.js │ │ ├── toImmutableIterable.test.js │ │ ├── toImmutableKeyedSeq.test.js │ │ ├── toImmutableList.test.js │ │ ├── toImmutableMap.test.js │ │ ├── toImmutableOrderedMap.test.js │ │ ├── toImmutableOrderedSet.test.js │ │ ├── toImmutableSeq.test.js │ │ ├── toImmutableSet.test.js │ │ ├── toImmutableSetSeq.test.js │ │ ├── toImmutableStack.test.js │ │ ├── types │ │ │ ├── associative.js │ │ │ ├── index.js │ │ │ ├── indexed.js │ │ │ ├── indexedWithoutStack.js │ │ │ ├── keyed.js │ │ │ └── stack.js │ │ ├── uniq.test.js │ │ ├── update.test.js │ │ ├── util │ │ │ ├── clone.js │ │ │ ├── compose.js │ │ │ ├── createTest.js │ │ │ ├── createTests.js │ │ │ ├── expectAllExactEqual.js │ │ │ ├── expectEqual.js │ │ │ ├── expectImmutableChange.js │ │ │ ├── expectImmutableResult.js │ │ │ ├── getType.js │ │ │ ├── getTypeFactory.js │ │ │ ├── hintConvert.js │ │ │ ├── hintSameType.js │ │ │ ├── index.js │ │ │ ├── isImmutable.js │ │ │ ├── runTest.js │ │ │ ├── runTests.js │ │ │ ├── setupTest.js │ │ │ ├── toArgs.js │ │ │ ├── toImmutable.js │ │ │ └── toMutable.js │ │ └── values │ │ │ ├── arrays.js │ │ │ ├── booleans.js │ │ │ ├── immutables.js │ │ │ ├── index.js │ │ │ ├── nils.js │ │ │ ├── numbers.js │ │ │ ├── objects.js │ │ │ ├── primitives.js │ │ │ ├── strings.js │ │ │ └── symbols.js │ ├── apply.js │ ├── array │ │ ├── arrayFilter.js │ │ ├── arrayLikeKeys.js │ │ ├── arrayPush.js │ │ ├── arraySlice.js │ │ ├── arraySome.js │ │ └── index.js │ ├── assign.js │ ├── assoc.js │ ├── assocWith.js │ ├── at.js │ ├── base │ │ ├── baseAssignValue.js │ │ ├── baseClone.js │ │ ├── baseDelete.js │ │ ├── baseDifference.js │ │ ├── baseEach.js │ │ ├── baseEachRight.js │ │ ├── baseEqualArrays.js │ │ ├── baseEqualByTag.js │ │ ├── baseEqualObjects.js │ │ ├── baseFindIndex.js │ │ ├── baseFlatten.js │ │ ├── baseFor.js │ │ ├── baseForOwn.js │ │ ├── baseForOwnRight.js │ │ ├── baseForRight.js │ │ ├── baseGet.js │ │ ├── baseGetAllKeys.js │ │ ├── baseHas.js │ │ ├── baseIncludes.js │ │ ├── baseIncludesWith.js │ │ ├── baseIndexOf.js │ │ ├── baseIndexOfWith.js │ │ ├── baseIsEqual.js │ │ ├── baseIsEqualDeep.js │ │ ├── baseIsMatch.js │ │ ├── baseIsNaN.js │ │ ├── baseIsNative.js │ │ ├── baseIteratee.js │ │ ├── baseKeys.js │ │ ├── baseLastIndexOf.js │ │ ├── baseLastIndexOfWith.js │ │ ├── baseMatches.js │ │ ├── baseMatchesProperty.js │ │ ├── baseOmit.js │ │ ├── baseOmitBy.js │ │ ├── basePick.js │ │ ├── basePickBy.js │ │ ├── baseProperty.js │ │ ├── basePropertyDeep.js │ │ ├── basePropertyOf.js │ │ ├── basePropertyOfDeep.js │ │ ├── basePullAll.js │ │ ├── baseReduce.js │ │ ├── baseSet.js │ │ ├── baseTimes.js │ │ ├── baseUnary.js │ │ ├── baseUniq.js │ │ ├── baseUpdate.js │ │ ├── baseWalk.js │ │ ├── baseWhile.js │ │ ├── baseWrapperValue.js │ │ └── index.js │ ├── batch.js │ ├── butLast.js │ ├── cache │ │ ├── Hash.js │ │ ├── ListCache.js │ │ ├── MapCache.js │ │ ├── SetCache.js │ │ ├── Stack.js │ │ ├── cacheHas.js │ │ ├── getMapData.js │ │ └── index.js │ ├── call.js │ ├── chunk.js │ ├── circ.js │ ├── circCopy.js │ ├── circularShift.js │ ├── clone.js │ ├── cloneDeep.js │ ├── cloneDeepWith.js │ ├── cloneWith.js │ ├── compact.js │ ├── compose.js │ ├── concat.js │ ├── constants │ │ ├── constants.js │ │ └── index.js │ ├── contains.js │ ├── context │ │ ├── context.js │ │ ├── contextFuncToString.js │ │ ├── contextHasOwnProperty.js │ │ ├── contextPropertyIsEnumerable.js │ │ ├── contextSplice.js │ │ ├── contextSymbolIsConcatSpreadable.js │ │ ├── contextSymbolIterator.js │ │ ├── contextSymbolToStringTag.js │ │ └── index.js │ ├── count.js │ ├── customizers │ │ ├── arg2.js │ │ ├── deepClone.js │ │ └── index.js │ ├── defn.js │ ├── defprotocol.js │ ├── deftype.js │ ├── delete.js │ ├── deleteKey.js │ ├── difference.js │ ├── differenceBy.js │ ├── differenceWith.js │ ├── dissoc.js │ ├── drop.js │ ├── dropRight.js │ ├── dropRightWhile.js │ ├── dropWhile.js │ ├── each.js │ ├── eq.js │ ├── every.js │ ├── executeAction.js │ ├── extend.js │ ├── filter.js │ ├── filterNot.js │ ├── find.js │ ├── findIndex.js │ ├── findLastIndex.js │ ├── first.js │ ├── flatten.js │ ├── flattenDeep.js │ ├── flattenDepth.js │ ├── flow.js │ ├── flowRight.js │ ├── forEach.js │ ├── forEachRight.js │ ├── free │ │ ├── free.js │ │ └── index.js │ ├── get.js │ ├── getKey.js │ ├── getPrototype.js │ ├── groupBy.js │ ├── has.js │ ├── hasKey.js │ ├── hasKeyIn.js │ ├── head.js │ ├── helpers │ │ ├── index.js │ │ ├── mapImmutable.js │ │ └── mapMutable.js │ ├── hint.js │ ├── hintConvert.js │ ├── hints │ │ ├── hintArgs.js │ │ ├── hintIm.js │ │ └── index.js │ ├── identity.js │ ├── im.js │ ├── immutable.js │ ├── includes.js │ ├── includesWith.js │ ├── index.js │ ├── indexOf.js │ ├── isArray.js │ ├── isArrayLike.js │ ├── isAssociative.js │ ├── isBatchable.js │ ├── isBoolean.js │ ├── isClass.js │ ├── isEmpty.js │ ├── isEqual.js │ ├── isEqualWith.js │ ├── isFlattenable.js │ ├── isFunction.js │ ├── isGenerator.js │ ├── isGeneratorFunction.js │ ├── isIm.js │ ├── isImIndexedSeq.js │ ├── isImIterable.js │ ├── isImKeyedSeq.js │ ├── isImList.js │ ├── isImMap.js │ ├── isImOrderedMap.js │ ├── isImOrderedSet.js │ ├── isImSeq.js │ ├── isImSet.js │ ├── isImSetSeq.js │ ├── isImStack.js │ ├── isImmutable.js │ ├── isImmutableIndexedSeq.js │ ├── isImmutableIterable.js │ ├── isImmutableKeyedSeq.js │ ├── isImmutableList.js │ ├── isImmutableMap.js │ ├── isImmutableOrderedMap.js │ ├── isImmutableOrderedSet.js │ ├── isImmutableSeq.js │ ├── isImmutableSet.js │ ├── isImmutableSetSeq.js │ ├── isImmutableStack.js │ ├── isIndex.js │ ├── isIndexed.js │ ├── isIterable.js │ ├── isIterateeCall.js │ ├── isKey.js │ ├── isKeyable.js │ ├── isKeyed.js │ ├── isLength.js │ ├── isMatch.js │ ├── isMutable.js │ ├── isNative.js │ ├── isNil.js │ ├── isNumber.js │ ├── isObject.js │ ├── isObjectLike.js │ ├── isOrdered.js │ ├── isPrototype.js │ ├── isShallowEqual.js │ ├── isString.js │ ├── isSymbol.js │ ├── iterable.js │ ├── iteratee.js │ ├── iterator.js │ ├── join.js │ ├── keys.js │ ├── last.js │ ├── lastIndexOf.js │ ├── map.js │ ├── matches.js │ ├── matchesProperty.js │ ├── memoize.js │ ├── merge.js │ ├── mergeAt.js │ ├── mu.js │ ├── mutable.js │ ├── mutations │ │ ├── index.js │ │ ├── mutationPush.js │ │ └── mutationPushAll.js │ ├── native │ │ ├── index.js │ │ ├── native.js │ │ ├── nativeCreate.js │ │ ├── nativeDefineProperty.js │ │ ├── nativeFuncToString.js │ │ ├── nativeGetSymbols.js │ │ ├── nativeKeys.js │ │ ├── nativeMax.js │ │ ├── nativeMin.js │ │ ├── nativeObjectToString.js │ │ ├── nativeSymbolToString.js │ │ └── nativeSymbolValueOf.js │ ├── negate.js │ ├── node │ │ ├── index.js │ │ ├── node.js │ │ └── util │ │ │ ├── index.js │ │ │ └── nodeUtil.js │ ├── object │ │ ├── index.js │ │ ├── objectKeys.js │ │ └── objectToString.js │ ├── omit.js │ ├── omitBy.js │ ├── overArg.js │ ├── path.js │ ├── pick.js │ ├── pickBy.js │ ├── pop.js │ ├── predicates │ │ ├── falsy.js │ │ ├── index.js │ │ └── truthy.js │ ├── property.js │ ├── propertyOf.js │ ├── protocols │ │ ├── Associative.js │ │ ├── Concatable.js │ │ ├── Counted.js │ │ ├── Extendable.js │ │ ├── IPersistentCollection.js │ │ ├── IPersistentList.js │ │ ├── IPersistentMap.js │ │ ├── IPersistentSet.js │ │ ├── IPersistentStack.js │ │ ├── Indexed.js │ │ ├── Inheriter.js │ │ ├── Keyed.js │ │ ├── Reducable.js │ │ ├── Sliceable.js │ │ ├── Stacked.js │ │ ├── __tests__ │ │ │ └── Keyed.test.js │ │ └── index.js │ ├── pull.js │ ├── pullAll.js │ ├── pullAllBy.js │ ├── pullAllRight.js │ ├── pullAllWith.js │ ├── pullRight.js │ ├── push.js │ ├── pushAt.js │ ├── reduce.js │ ├── reduceReducers.js │ ├── reduceReducersRight.js │ ├── reduceRight.js │ ├── regex │ │ ├── index.js │ │ ├── reEscapeChar.js │ │ ├── reHasUnicode.js │ │ ├── reIsBadHex.js │ │ ├── reIsBinary.js │ │ ├── reIsDeepProp.js │ │ ├── reIsHostCtor.js │ │ ├── reIsNative.js │ │ ├── reIsOctal.js │ │ ├── reIsPlainProp.js │ │ ├── reIsUint.js │ │ ├── reLeadingDot.js │ │ ├── rePropName.js │ │ ├── reRegExpChar.js │ │ ├── reTrim.js │ │ └── reUnicode.js │ ├── reject.js │ ├── reverse.js │ ├── satisfies.js │ ├── select.js │ ├── set.js │ ├── setKey.js │ ├── setWith.js │ ├── shift.js │ ├── size.js │ ├── slice.js │ ├── some.js │ ├── sortBy.js │ ├── splice.js │ ├── strict │ │ ├── index.js │ │ ├── strictIndexOf.js │ │ └── strictLastIndexOf.js │ ├── stubArray.js │ ├── stubFalse.js │ ├── stubImmutableIndexedSeq.js │ ├── stubImmutableIterable.js │ ├── stubImmutableKeyedSeq.js │ ├── stubImmutableList.js │ ├── stubImmutableMap.js │ ├── stubImmutableOrderedMap.js │ ├── stubImmutableOrderedSet.js │ ├── stubImmutableSeq.js │ ├── stubImmutableSet.js │ ├── stubImmutableSetSeq.js │ ├── stubImmutableStack.js │ ├── stubObject.js │ ├── stubString.js │ ├── stubTrue.js │ ├── sym.js │ ├── symbol.js │ ├── tail.js │ ├── take.js │ ├── takeLast.js │ ├── takeRight.js │ ├── takeRightWhile.js │ ├── takeWhile.js │ ├── toArray.js │ ├── toFinite.js │ ├── toIm.js │ ├── toImIndexedSeq.js │ ├── toImIterable.js │ ├── toImKeyedSeq.js │ ├── toImList.js │ ├── toImMap.js │ ├── toImOrderedMap.js │ ├── toImOrderedSet.js │ ├── toImSeq.js │ ├── toImSet.js │ ├── toImSetSeq.js │ ├── toImStack.js │ ├── toImmutable.js │ ├── toImmutableIndexedSeq.js │ ├── toImmutableIterable.js │ ├── toImmutableKeyedSeq.js │ ├── toImmutableList.js │ ├── toImmutableMap.js │ ├── toImmutableOrderedMap.js │ ├── toImmutableOrderedSet.js │ ├── toImmutableSeq.js │ ├── toImmutableSet.js │ ├── toImmutableSetSeq.js │ ├── toImmutableStack.js │ ├── toIndexed.js │ ├── toInteger.js │ ├── toIterable.js │ ├── toKey.js │ ├── toMutable.js │ ├── toNumber.js │ ├── toObject.js │ ├── toSource.js │ ├── types │ │ ├── Array.js │ │ ├── Boolean.js │ │ ├── Function.js │ │ ├── List.js │ │ ├── Map.js │ │ ├── Number.js │ │ ├── Object.js │ │ ├── String.js │ │ └── index.js │ ├── uniq.js │ ├── uniqBy.js │ ├── uniqWith.js │ ├── unset.js │ ├── unsetKey.js │ ├── update.js │ ├── updateWith.js │ ├── util │ │ ├── asciiSize.js │ │ ├── assignValue.js │ │ ├── assocIndexOf.js │ │ ├── castFunction.js │ │ ├── castPath.js │ │ ├── copyObject.js │ │ ├── createSet.js │ │ ├── getAllKeys.js │ │ ├── getIteratee.js │ │ ├── getMatchData.js │ │ ├── getNative.js │ │ ├── getRawTag.js │ │ ├── getSymbols.js │ │ ├── getTag.js │ │ ├── getValue.js │ │ ├── hasUnicode.js │ │ ├── index.js │ │ ├── isForEachable.js │ │ ├── isMaskable.js │ │ ├── isMasked.js │ │ ├── isStrictComparable.js │ │ ├── mapToArray.js │ │ ├── matchesStrictComparable.js │ │ ├── memoizeCapped.js │ │ ├── setToArray.js │ │ ├── stringSize.js │ │ ├── stringToPath.js │ │ └── unicodeSize.js │ ├── values.js │ ├── walk.js │ ├── walkees │ │ ├── depthFirst.js │ │ └── index.js │ ├── with │ │ ├── index.js │ │ ├── withComparatorValue.js │ │ ├── withDeepClone.js │ │ ├── withEqValue.js │ │ ├── withFor.js │ │ ├── withKeyIn.js │ │ └── withMutations.js │ ├── withMutations.js │ ├── wrapperValue.js │ ├── xor.js │ └── xorPartition.js └── index.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-1", "stage-2"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | end_of_line = lf 4 | indent_size = 2 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | 8 | [*.md] 9 | max_line_length = 0 10 | trim_trailing_whitespace = false 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build 2 | dist 3 | 4 | # config 5 | config/config.json 6 | config/config-dev.json 7 | 8 | # IntelliJ resources 9 | .idea/ 10 | *.iml 11 | *.ipr 12 | *.iws 13 | 14 | # mac 15 | .DS_Store 16 | 17 | # node 18 | node_modules/ 19 | npm-debug.log 20 | .env 21 | .npmrc 22 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | #development 2 | .babelrc 3 | .editorconfig 4 | .eslintrc.json 5 | .reciperc 6 | .travis.yml 7 | __tests__ 8 | config 9 | docs 10 | examples 11 | gulpfile.* 12 | src 13 | 14 | # IntelliJ resources 15 | .idea/ 16 | *.iml 17 | *.ipr 18 | *.iws 19 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Brian Neisler. https://brianneisler.com 2 | 3 | mudash may be freely distributed under the MIT license. 4 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | mudash.org -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mudash - lodash wrapper providing immutable JS support 6 | 7 | 8 |

mudash - lodash wrapper providing immutable JS support

9 |

Website coming soon

10 |

For now, can find the project on github

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/chain-immutable-setters.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import _ from '../' 3 | import Immutable from 'immutable' 4 | 5 | const result = _.chain(Immutable.Map({})) 6 | .set('a', 1) 7 | .set('b', 2) 8 | .set('c', 3) 9 | .value() 10 | 11 | console.log(result) // Map { "a": 1, "b": 2, "c": 3 } 12 | -------------------------------------------------------------------------------- /examples/chunk-immutable.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import _ from '../' 3 | import fp from '../fp' 4 | import Immutable from 'immutable' 5 | 6 | const list = Immutable.fromJS([1, 2, 3, 4]) 7 | 8 | const result = _.chunk(list, 2) //List [ List [ 1, 2 ], List [ 3, 4 ] ] 9 | console.log(result) 10 | 11 | const result2 = fp.chunk(2)(list) //List [ List [ 1, 2 ], List [ 3, 4 ] ] 12 | console.log(result2) 13 | -------------------------------------------------------------------------------- /examples/compose-immutable-setters.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import _ from '../' 3 | import fp from '../fp' 4 | import Immutable from 'immutable' 5 | 6 | const set = _.compose( 7 | fp.set('a', 1), 8 | fp.set('b', 2), 9 | fp.set('c', 3) 10 | ) 11 | const result = set(Immutable.Map({})) 12 | console.log(result) // Map { a: 1, b: 2, c: 3 } 13 | -------------------------------------------------------------------------------- /examples/find-immutable.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | import _ from '../' 3 | import fp from '../fp' 4 | import Immutable from 'immutable' 5 | 6 | const users = Immutable.fromJS([ 7 | { 'user': 'barney', 'age': 36, 'active': true }, 8 | { 'user': 'fred', 'age': 40, 'active': false }, 9 | { 'user': 'pebbles', 'age': 1, 'active': true } 10 | ]) 11 | 12 | const result = _.find(users, { 'age': 1, 'active': true }) //Map { 'user': 'pebbles', 'age': 1, 'active': true } 13 | console.log(result) 14 | 15 | const result2 = fp.find({ 'age': 1, 'active': true })(users) //Map { 'user': 'pebbles', 'age': 1, 'active': true } 16 | console.log(result2) 17 | -------------------------------------------------------------------------------- /examples/set.example.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | /* eslint-disable no-undef */ 3 | import _ from 'mudash' 4 | 5 | describe('set', () => { 6 | example('setting an existing array index', () => { 7 | const array = ['a', 'b', 'c'] 8 | const result = _.set(array, 2, 'd') 9 | console.log(array) // ['a', 'b', 'c'] 10 | console.log(result) // ['a', 'b', 'd'] 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /fp/index.js: -------------------------------------------------------------------------------- 1 | var convert = require('lodash/fp/convert') //eslint-disable-line no-var 2 | var lodash = require('lodash') //eslint-disable-line no-var 3 | var mudash = require('../dist') //eslint-disable-line no-var 4 | var _ = lodash.runInContext() //eslint-disable-line no-var 5 | var extensions = _.mixin(mudash) //eslint-disable-line no-var 6 | module.exports = lodash.reduce(extensions, (result, ext, name) => { 7 | if (lodash.isFunction(ext)) { 8 | return lodash.set(result, name, convert(name, ext, { 9 | 'cap': true, 10 | 'curry': true, 11 | 'fixed': true, 12 | 'immutable': false, 13 | 'rearg': true 14 | })) 15 | } 16 | return lodash.set(result, name, ext) 17 | }, {}) 18 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./dist') 2 | -------------------------------------------------------------------------------- /src/core/__tests__/chain.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/chain.test.js -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableIterable.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableIterable } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableIterable', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableIterable(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableKeyedSeq.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableKeyedSeq } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableKeyedSeq', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableKeyedSeq(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableList.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableList } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableList', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableList(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableMap.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableMap } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableMap', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableMap(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableOrderedMap.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableOrderedMap } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableOrderedMap', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableOrderedMap(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableOrderedSet.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableOrderedSet } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableOrderedSet', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableOrderedSet(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableSeq.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableSeq } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableSeq', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableSeq(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableSet.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableSet } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableSet', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableSet(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableSetSeq.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableSetSeq } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableSetSeq', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableSetSeq(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/isImmutableStack.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { isImmutableStack } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('isImmutableStack', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return false for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | expect(isImmutableStack(value)).to.be.false 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /src/core/__tests__/pick.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import { pick } from '../' 4 | import Immutable from 'immutable' 5 | 6 | const object = { 'a': 1, 'b': 2, 'c': 3 } 7 | 8 | describe('pick', function () { 9 | it('should create an object composed of object properties', function () { 10 | const result = pick(object, ['a', 'c']) 11 | expect(object).to.not.equal(result) 12 | expect(object).to.deep.equal({ 'a': 1, 'b': 2, 'c': 3 }) 13 | expect(result).to.deep.equal({'a': 1, 'c': 3}) 14 | }) 15 | 16 | it('should create an immutable map composed of object properties', function () { 17 | const map = Immutable.fromJS(object) 18 | const result = pick(map, ['a', 'c']) 19 | expect(Immutable.Map.isMap(result)).to.be.true // returns an immutable map 20 | expect(result.toJS()).to.deep.equal({'a': 1, 'c': 3}) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /src/core/__tests__/pickBy.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import { pickBy } from '../' 4 | import Immutable from 'immutable' 5 | 6 | const object = { 'a': 1, 'b': 2, 'c': 3 } 7 | 8 | describe('pickBy', function () { 9 | it('should create an object composed of object properties `predicate` returns truthy', function () { 10 | const result = pickBy(object, n => n % 2) 11 | expect(result).to.deep.equal({'a': 1, 'c': 3}) 12 | }) 13 | 14 | it('should create an immutable map composed of object properties `predicate` returns truthy', function () { 15 | const map = Immutable.fromJS(object) 16 | const result = pickBy(map, n => n % 2) 17 | expect(Immutable.Map.isMap(result)).to.be.true // returns an immutable map 18 | expect(result.toJS()).to.deep.equal({'a': 1, 'c': 3}) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/createFactory.js: -------------------------------------------------------------------------------- 1 | const createFactory = baseFunc => { 2 | //TODO BRN: Can this be memoized? 3 | return (props, ...rest) => baseFunc(props, ...rest) 4 | } 5 | 6 | export default createFactory 7 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/createHelper.js: -------------------------------------------------------------------------------- 1 | import compose from '../util/compose' 2 | import wrapDisplayName from './wrapDisplayName' 3 | 4 | const createHelper = (func, helperName, setDisplayName = true, noArgs = false) => { 5 | if (process.env.NODE_ENV !== 'production' && setDisplayName) { 6 | if (noArgs) { 7 | return compose( 8 | func, 9 | wrapDisplayName(helperName) 10 | ) 11 | } 12 | 13 | return (...args) => compose( 14 | func(...args), 15 | wrapDisplayName(helperName) 16 | ) 17 | } 18 | return func 19 | } 20 | 21 | export default createHelper 22 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/getDisplayName.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | 3 | const getDisplayName = result => { 4 | if (_.isString(result)) { 5 | return result 6 | } 7 | 8 | if (!result) { 9 | return undefined 10 | } 11 | 12 | return result.displayName || result.name || 'Test' 13 | } 14 | 15 | export default getDisplayName 16 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/index.js: -------------------------------------------------------------------------------- 1 | export { default as createFactory } from './createFactory' 2 | export { default as createHelper } from './createHelper' 3 | export { default as getDisplayName } from './getDisplayName' 4 | export { default as withHintConvert } from './withHintConvert' 5 | export { default as withHintSameType } from './withHintSameType' 6 | export { default as withMultipleTypeInputs } from './withMultipleTypeInputs' 7 | export { default as wrapDisplayName } from './wrapDisplayName' 8 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/withHintConvert.js: -------------------------------------------------------------------------------- 1 | import * as util from '../util' 2 | import createFactory from './createFactory' 3 | import createHelper from './createHelper' 4 | 5 | const withHintConvert = baseFunc => { 6 | const factory = createFactory(baseFunc) 7 | return (props, ...rest) => factory({ 8 | ...props, 9 | expected: util.hintConvert(props.inputs.data, props.expected) 10 | }, ...rest) 11 | } 12 | export default createHelper(withHintConvert, 'withHintConvert', true, true) 13 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/withHintSameType.js: -------------------------------------------------------------------------------- 1 | import * as util from '../util' 2 | import createFactory from './createFactory' 3 | import createHelper from './createHelper' 4 | 5 | const withHintSameType = baseFunc => { 6 | const factory = createFactory(baseFunc) 7 | return (props, ...rest) => factory({ 8 | ...props, 9 | expected: util.hintSameType(props.inputs.data, props.expected) 10 | }, ...rest) 11 | } 12 | export default createHelper(withHintSameType, 'withHintSameType', true, true) 13 | -------------------------------------------------------------------------------- /src/core/__tests__/recompose/wrapDisplayName.js: -------------------------------------------------------------------------------- 1 | import createFactory from './createFactory' 2 | import getDisplayName from './getDisplayName' 3 | 4 | const wrapDisplayName = displayName => baseFunc => { 5 | const factory = createFactory(baseFunc) 6 | return (props, ...rest) => { 7 | const result = factory(props, ...rest) 8 | if (result) { 9 | result.displayName = `${displayName}(${getDisplayName(result)})` 10 | } 11 | return result 12 | } 13 | } 14 | 15 | export default wrapDisplayName 16 | -------------------------------------------------------------------------------- /src/core/__tests__/shared/index.js: -------------------------------------------------------------------------------- 1 | export { default as reduceTests } from './reduceTests' 2 | export * from './uniqTests' 3 | -------------------------------------------------------------------------------- /src/core/__tests__/shared/uniqTests.js: -------------------------------------------------------------------------------- 1 | import { clone, expectImmutableChange } from '../util' 2 | import mudash from '../../../' 3 | 4 | export function testUniqueValues(methodName, data, expected, displayName) { 5 | const func = mudash[methodName] 6 | it(`should return unique values of ${displayName}`, function() { 7 | const dataExpected = clone(data) 8 | const result = func(data) 9 | expectImmutableChange(data, result, dataExpected, expected) 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /src/core/__tests__/symbol.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import { symbol } from '../' 4 | 5 | describe('symbol', function() { 6 | 7 | it('symbol acts as an ES6 Symbol', function() { 8 | const data = {} 9 | const sym = symbol('test') 10 | data[sym] = 'value' 11 | data['test'] = 'value2' 12 | expect(data[sym]).to.equal('value') 13 | expect(data['test']).to.equal('value2') 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /src/core/__tests__/tests/immutableArgsTest.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import expectEqual from '../util/expectEqual' 3 | import expectImmutableResult from '../util/expectImmutableResult' 4 | 5 | export default function immutableArgsTest(testMethod) { 6 | return ({ name, inputs, expectedInputs, expected }) => { 7 | it(name, function() { 8 | const result = testMethod(inputs) 9 | expectImmutableResult(inputs.data, result, expected) 10 | _.each(expectedInputs, (expectedInput, key) => { 11 | if (key === 'args') { 12 | _.each(expectedInput, (expectedArg, i) => expectEqual(inputs.args[i], expectedArg)) 13 | } else { 14 | expectEqual(inputs[key], expectedInput) 15 | } 16 | }) 17 | }) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/core/__tests__/tests/immutableTest.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import expectEqual from '../util/expectEqual' 3 | import expectImmutableResult from '../util/expectImmutableResult' 4 | 5 | export default function immutableTest(testMethod) { 6 | return ({ name, inputs, expectedInputs, expected }) => { 7 | it(name, function() { 8 | const result = testMethod(inputs) 9 | expectImmutableResult(inputs.data, result, expected) 10 | _.each(expectedInputs, (expectedInput, key) => expectEqual(inputs[key], expectedInput)) 11 | }) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/core/__tests__/tests/index.js: -------------------------------------------------------------------------------- 1 | export { default as immutableArgsTest } from './immutableArgsTest' 2 | export { default as immutableTest } from './immutableTest' 3 | -------------------------------------------------------------------------------- /src/core/__tests__/tests/iterationCountTest.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import expectEqual from '../util/expectEqual' 3 | import expectImmutableResult from '../util/expectImmutableResult' 4 | 5 | export default function iterationCountTest(testMethod) { 6 | return ({ name, inputs, expectedInputs, expected }) => { 7 | it(name, function() { 8 | const result = testMethod(inputs) 9 | expectImmutableResult(inputs.data, result, expected) 10 | _.each(expectedInputs, (expectedInput, key) => expectEqual(inputs[key], expectedInput)) 11 | }) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/core/__tests__/toImmutable.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import _ from 'lodash' 4 | import { toImmutable } from '../' 5 | import { primitives } from './values' 6 | import { setupTest } from './util' 7 | 8 | describe('toImmutable', function() { 9 | const testContext = setupTest() 10 | 11 | it('should return same value for primitives', function() { 12 | const values = primitives(testContext) 13 | _.each(values, (value) => { 14 | if (_.isNaN(value)) { 15 | expect(toImmutable(value)).to.be.NaN 16 | } else { 17 | expect(toImmutable(value)).to.equal(value) 18 | } 19 | }) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableIndexedSeq.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import Immutable from 'immutable' 4 | import _ from 'lodash' 5 | import { toImmutableIndexedSeq } from '../' 6 | import { primitives } from './values' 7 | import { setupTest } from './util' 8 | 9 | describe('toImmutableIndexedSeq', function() { 10 | const testContext = setupTest() 11 | 12 | it('should return empty Immutable.Seq.Indexed for primitives', function() { 13 | const values = primitives(testContext, ['booleans', 'booleanObjects', 'nils', 'nilObjects', 'numbers', 'numberObjects', 'symbols']) 14 | _.each(values, (value) => { 15 | expect(Immutable.is(toImmutableIndexedSeq(value), Immutable.Seq.Indexed())).to.be.true 16 | }) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableIterable.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableIterable.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableKeyedSeq.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableKeyedSeq.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableList.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableList.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableMap.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableMap.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableOrderedMap.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableOrderedMap.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableOrderedSet.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableOrderedSet.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableSeq.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableSeq.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableSet.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableSet.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableSetSeq.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableSetSeq.test.js -------------------------------------------------------------------------------- /src/core/__tests__/toImmutableStack.test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/toImmutableStack.test.js -------------------------------------------------------------------------------- /src/core/__tests__/types/associative.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/types/associative.js -------------------------------------------------------------------------------- /src/core/__tests__/types/index.js: -------------------------------------------------------------------------------- 1 | export { default as indexed } from './indexed' 2 | export { default as indexedWithoutStack } from './indexedWithoutStack' 3 | export { default as keyed } from './keyed' 4 | export { default as stack } from './stack' 5 | -------------------------------------------------------------------------------- /src/core/__tests__/types/indexed.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | import _ from 'lodash' 3 | 4 | export default function indexed() { 5 | return { 6 | 'an array': _.toArray, 7 | 'an Immutable.List': Immutable.List, 8 | 'an Immutable.Stack': Immutable.Stack, 9 | 'an Immutable.Seq': Immutable.Seq 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/core/__tests__/types/indexedWithoutStack.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | import _ from 'lodash' 3 | 4 | export default function indexed() { 5 | return { 6 | 'an array': _.toArray, 7 | 'an Immutable.List': Immutable.List, 8 | 'an Immutable.Seq': Immutable.Seq 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/core/__tests__/types/keyed.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | 3 | export default function keyed() { 4 | return { 5 | 'an object': Object, 6 | 'an Immutable.Map': Immutable.Map, 7 | 'an Immutable.OrderedMap': Immutable.OrderedMap, 8 | 'an Immutable.Seq': Immutable.Seq 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/core/__tests__/types/stack.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | 3 | export default function indexed() { 4 | return { 5 | 'an Immutable.Stack': Immutable.Stack 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/util/clone.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function clone(data) { 5 | return isImmutable(data) 6 | ? data 7 | : _.clone(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/__tests__/util/compose.js: -------------------------------------------------------------------------------- 1 | export default function compose(...funcs) { 2 | if (funcs.length === 0) { 3 | return arg => arg 4 | } 5 | 6 | if (funcs.length === 1) { 7 | return funcs[0] 8 | } 9 | 10 | const last = funcs[funcs.length - 1] 11 | const rest = funcs.slice(0, -1) 12 | return (...args) => rest.reduceRight((composed, func) => func(composed), last(...args)) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/__tests__/util/createTest.js: -------------------------------------------------------------------------------- 1 | import runTest from './runTest' 2 | export default function createTest(description, context, factory) { 3 | return () => runTest(description, context, factory) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/__tests__/util/createTests.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import createTest from './createTest' 3 | 4 | export default function createTests(descriptions, context, factory) { 5 | return _.reduce(descriptions, (tests, description, name) => { 6 | if (_.isFunction(description)) { 7 | description = description() 8 | } 9 | description = { 10 | ...description, 11 | name 12 | } 13 | tests.push(createTest(description, context, factory)) 14 | return tests 15 | }, []) 16 | } 17 | -------------------------------------------------------------------------------- /src/core/__tests__/util/expectAllExactEqual.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import getType from './getType' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function expectAllExactEqual(data, result, expected) { 6 | expect(result).to.equal(data) 7 | expect(getType(data)).to.equal(getType(expected)) 8 | expect(getType(result)).to.equal(getType(expected)) 9 | if (isImmutable(expected)) { 10 | expect(data.toJS()).to.deep.equal(expected.toJS()) 11 | expect(result.toJS()).to.deep.equal(expected.toJS()) 12 | } else { 13 | expect(data).to.deep.equal(expected) 14 | expect(result).to.deep.equal(expected) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/core/__tests__/util/expectEqual.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import getType from './getType' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function expectEqual(data, expected) { 6 | expect(getType(data)).to.equal(getType(expected)) 7 | if (isImmutable(expected)) { 8 | expect(data.toJS()).to.deep.equal(expected.toJS()) 9 | } else { 10 | expect(data).to.deep.equal(expected) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/core/__tests__/util/expectImmutableChange.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import expectEqual from './expectEqual' 3 | 4 | export default function expectImmutableChange(data, result, dataExpected, resultExpected) { 5 | expect(result).to.not.equal(data) 6 | expectEqual(data, dataExpected) 7 | expectEqual(result, resultExpected) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/__tests__/util/expectImmutableResult.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai' 2 | import expectEqual from './expectEqual' 3 | 4 | export default function expectImmutableResult(data, result, expected) { 5 | expect(result).to.not.equal(data) 6 | expectEqual(result, expected) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/util/getType.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { List, Map, OrderedMap, OrderedSet, Seq, Set, Stack } from 'immutable' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function getType(data) { 6 | if (isImmutable(data)) { 7 | if (OrderedMap.isOrderedMap(data)) { 8 | return 'Immutable.OrderedMap' 9 | } else if (OrderedSet.isOrderedSet(data)) { 10 | return 'Immutable.OrderedSet' 11 | } else if (Stack.isStack(data)) { 12 | return 'Immutable.Stack' 13 | } else if (Set.isSet(data)) { 14 | return 'Immutable.Set' 15 | } else if (Map.isMap(data)) { 16 | return 'Immutable.Map' 17 | } else if (List.isList(data)) { 18 | return 'Immutable.List' 19 | } else if (Seq.isSeq(data)) { 20 | return 'Immutable.Seq' 21 | } 22 | } 23 | if (_.isArray(data)) { 24 | return 'array' 25 | } 26 | return typeof data 27 | } 28 | -------------------------------------------------------------------------------- /src/core/__tests__/util/getTypeFactory.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { List, Map, OrderedMap, OrderedSet, Seq, Set, Stack } from 'immutable' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function getTypeFactory(data) { 6 | if (isImmutable(data)) { 7 | if (OrderedMap.isOrderedMap(data)) { 8 | return OrderedMap 9 | } else if (OrderedSet.isOrderedSet(data)) { 10 | return OrderedSet 11 | } else if (Stack.isStack(data)) { 12 | return Stack 13 | } else if (Set.isSet(data)) { 14 | return Set 15 | } else if (Map.isMap(data)) { 16 | return Map 17 | } else if (List.isList(data)) { 18 | return List 19 | } else if (Seq.isSeq(data)) { 20 | return Seq 21 | } 22 | } 23 | return _.identity 24 | } 25 | -------------------------------------------------------------------------------- /src/core/__tests__/util/hintConvert.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | import toImmutable from './toImmutable' 3 | import toMutable from './toMutable' 4 | 5 | export default function hintConvert(data, value) { 6 | return isImmutable(data) 7 | ? toImmutable(value) 8 | : toMutable(value) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/__tests__/util/hintSameType.js: -------------------------------------------------------------------------------- 1 | import getTypeFactory from './getTypeFactory' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function hintSameType(data, value) { 5 | return isImmutable(data) 6 | ? getTypeFactory(data)(value) 7 | : value 8 | } 9 | -------------------------------------------------------------------------------- /src/core/__tests__/util/isImmutable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | export default function isImmutable(data) { 3 | return Iterable.isIterable(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/__tests__/util/runTest.js: -------------------------------------------------------------------------------- 1 | export default function runTest(props, context, factory) { 2 | return factory(props, context) 3 | } 4 | -------------------------------------------------------------------------------- /src/core/__tests__/util/runTests.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import createTests from './createTests' 3 | export default function runTests(tests, context, factory) { 4 | _.each(createTests(tests, context, factory), (test) => test()) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/__tests__/util/toArgs.js: -------------------------------------------------------------------------------- 1 | export default function toArgs(array) { 2 | return (function() { return arguments }.apply(undefined, array)) 3 | } 4 | -------------------------------------------------------------------------------- /src/core/__tests__/util/toImmutable.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | import isImmutable from './isImmutable' 3 | export default function toImmutable(data) { 4 | return !isImmutable(data) 5 | ? Immutable.fromJS(data) 6 | : data 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/util/toMutable.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | export default function toMutable(data) { 3 | return isImmutable(data) 4 | ? data.toJS() 5 | : data 6 | } 7 | -------------------------------------------------------------------------------- /src/core/__tests__/values/arrays.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/values/arrays.js -------------------------------------------------------------------------------- /src/core/__tests__/values/booleans.js: -------------------------------------------------------------------------------- 1 | export function booleans() { 2 | return [ true, false ] 3 | } 4 | 5 | export function booleanObjects({ Object: _Object }) { 6 | return [ _Object(true), _Object(false) ] 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/values/immutables.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { Iterable, List, Map, OrderedMap, OrderedSet, Seq, Set, Stack } from 'immutable' 3 | 4 | // export default function immutables() { 5 | // return [ 6 | // Iterable(), 7 | // List(), 8 | // Map(), 9 | // OrderedMap(), 10 | // OrderedSet(), 11 | // Seq(), 12 | // Seq.Indexed(), 13 | // Seq.Keyed(), 14 | // Seq.Set(), 15 | // Set(), 16 | // Stack() 17 | // ] 18 | // } 19 | 20 | const typeMap = { 21 | Iterable, List, Map, OrderedMap, OrderedSet, Seq, Set, Stack 22 | } 23 | export default function immutables(context, selected = ['List', 'Map', 'OrderedMap', 'OrderedSet', 'Seq', 'Seq.Indexed', 'Seq.Keyed', 'Seq.Set', 'Set', 'Stack']) { 24 | return _.flatten( 25 | _.map(selected, path => _.get(typeMap, path)()) 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /src/core/__tests__/values/index.js: -------------------------------------------------------------------------------- 1 | export { default as arrays } from './arrays' 2 | export * from './booleans' 3 | export { default as immutables } from './immutables' 4 | export * from './nils' 5 | export * from './numbers' 6 | export { default as objects } from './objects' 7 | export { default as primitives } from './primitives' 8 | export * from './strings' 9 | export { default as symbols } from './symbols' 10 | -------------------------------------------------------------------------------- /src/core/__tests__/values/nils.js: -------------------------------------------------------------------------------- 1 | export function nils() { 2 | return [ NaN, null, undefined] 3 | } 4 | 5 | export function nilObjects({ Object: _Object }) { 6 | return [ _Object(NaN)] 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/values/numbers.js: -------------------------------------------------------------------------------- 1 | export function numbers() { 2 | return [ 0, -0, 1, -1, 1.1, -1.1, Infinity, -Infinity ] 3 | } 4 | 5 | export function numberObjects({ Object: _Object }) { 6 | return [ _Object(0), _Object(-0), _Object(1), _Object(-1), _Object(1.1), _Object(-1.1), _Object(Infinity), _Object(-Infinity)] 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/values/objects.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/__tests__/values/objects.js -------------------------------------------------------------------------------- /src/core/__tests__/values/primitives.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { booleans, booleanObjects } from './booleans' 3 | import { nils, nilObjects } from './nils' 4 | import { numbers, numberObjects } from './numbers' 5 | import { strings, stringObjects } from './strings' 6 | import symbols from './symbols' 7 | 8 | const typeMap = { 9 | booleans, 10 | booleanObjects, 11 | nils, 12 | nilObjects, 13 | numbers, 14 | numberObjects, 15 | strings, 16 | stringObjects, 17 | symbols 18 | } 19 | export default function primitives(context, selected = ['booleans', 'booleanObjects', 'nils', 'nilObjects', 'numbers', 'numberObjects', 'strings', 'stringObjects', 'symbols']) { 20 | return _.flatten( 21 | _.map(_.pick(typeMap, selected), type => type(context)) 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /src/core/__tests__/values/strings.js: -------------------------------------------------------------------------------- 1 | export function strings() { 2 | return ['', 'a', 'abc' ] 3 | } 4 | 5 | export function stringObjects({ Object: _Object }) { 6 | return [_Object(''), _Object('a'), _Object('abc')] 7 | } 8 | -------------------------------------------------------------------------------- /src/core/__tests__/values/symbols.js: -------------------------------------------------------------------------------- 1 | export default function symbols({ Symbol: _Symbol }) { 2 | const symbol1 = _Symbol ? _Symbol('a') : true 3 | const symbol2 = _Symbol ? _Symbol('b') : false 4 | return [ symbol1, symbol2 ] 5 | } 6 | -------------------------------------------------------------------------------- /src/core/apply.js: -------------------------------------------------------------------------------- 1 | import isFunction from './isFunction' 2 | 3 | export default function apply(method, args) { 4 | return isFunction(method) ? method.apply(null, args) : null 5 | } 6 | -------------------------------------------------------------------------------- /src/core/array/arrayFilter.js: -------------------------------------------------------------------------------- 1 | export default function arrayFilter(array, predicate) { 2 | let index = -1 3 | const length = array == null ? 0 : array.length 4 | let resIndex = 0 5 | const result = [] 6 | 7 | while (++index < length) { 8 | const value = array[index] 9 | if (predicate(value, index, array)) { 10 | result[resIndex++] = value 11 | } 12 | } 13 | return result 14 | } 15 | -------------------------------------------------------------------------------- /src/core/array/arrayPush.js: -------------------------------------------------------------------------------- 1 | export default function arrayPush(array, values) { 2 | let index = -1 3 | const length = values.length 4 | const offset = array.length 5 | 6 | while (++index < length) { 7 | array[offset + index] = values[index] 8 | } 9 | return array 10 | } 11 | -------------------------------------------------------------------------------- /src/core/array/arraySlice.js: -------------------------------------------------------------------------------- 1 | export default function arraySlice(array, start, end) { 2 | let index = -1 3 | let length = array.length 4 | 5 | if (start < 0) { 6 | start = -start > length ? 0 : (length + start) 7 | } 8 | end = end > length ? length : end 9 | if (end < 0) { 10 | end += length 11 | } 12 | length = start > end ? 0 : ((end - start) >>> 0) 13 | start >>>= 0 14 | 15 | const result = Array(length) 16 | while (++index < length) { 17 | result[index] = array[index + start] 18 | } 19 | return result 20 | } 21 | -------------------------------------------------------------------------------- /src/core/array/arraySome.js: -------------------------------------------------------------------------------- 1 | export default function arraySome(array, predicate) { 2 | let index = -1 3 | const length = array == null ? 0 : array.length 4 | 5 | while (++index < length) { 6 | if (predicate(array[index], index, array)) { 7 | return true 8 | } 9 | } 10 | return false 11 | } 12 | -------------------------------------------------------------------------------- /src/core/array/index.js: -------------------------------------------------------------------------------- 1 | export { default as arrayFilter } from './arrayFilter' 2 | export { default as arrayLikeKeys } from './arrayLikeKeys' 3 | export { default as arrayPush } from './arrayPush' 4 | export { default as arraySlice } from './arraySlice' 5 | export { default as arraySome } from './arraySome' 6 | -------------------------------------------------------------------------------- /src/core/assign.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import { mapImmutable, mapMutable } from './helpers' 4 | 5 | export default function assign(data, ...args) { 6 | return isImmutable(data) 7 | ? data.merge(...mapImmutable(args)) 8 | : _.assign(data, ...mapMutable(args)) 9 | } 10 | 11 | // Conceptual idea on how to get context working again 12 | // import { branchIm, compose, hintConvertRest } from '../recompose' 13 | // 14 | // const enhance = compose( 15 | // withLodash(), 16 | // hintConvertRest() 17 | // branchIm( 18 | // imAssign, 19 | // muAssign 20 | // ) 21 | // ) 22 | // 23 | // const imAssign = () => (data, ...args) => data.merge(...args) 24 | // const muAssign = ({ _ }) => (data, ...args) => _.assign(data, ...args) 25 | // 26 | // const assign = enhance() 27 | // export default assign 28 | -------------------------------------------------------------------------------- /src/core/assoc.js: -------------------------------------------------------------------------------- 1 | import { baseSet } from './base' 2 | import forEach from './forEach' 3 | import isString from './isString' 4 | import setKey from './setKey' 5 | 6 | export default function assoc(data, path, value) { 7 | if (isString(path)) { 8 | data = baseSet(data, path, value, setKey) 9 | } else { 10 | //TODO BRN: Improve this so that it uses withMutations when making multiple modifications 11 | forEach(path, (pathValue, pathKey) => { 12 | data = baseSet(data, pathKey, pathValue, setKey) 13 | }) 14 | } 15 | return data 16 | } 17 | -------------------------------------------------------------------------------- /src/core/at.js: -------------------------------------------------------------------------------- 1 | import { mutationPush } from './mutations' 2 | import { withMutations } from './with' 3 | import flatten from './flatten' 4 | import get from './get' 5 | import getKey from './getKey' 6 | import hintConvert from './hintConvert' 7 | import isAssociative from './isAssociative' 8 | import size from './size' 9 | 10 | const atPaths = withMutations((result, data, paths) => { 11 | let index = -1 12 | const skip = !isAssociative(data) 13 | const length = size(paths) 14 | 15 | while (++index < length) { 16 | result = mutationPush(result, skip ? undefined : get(data, getKey(paths, index))) 17 | } 18 | return result 19 | }) 20 | 21 | export default function at(data, ...paths) { 22 | const result = hintConvert(data, []) 23 | return atPaths(result, data, flatten(paths)) 24 | } 25 | -------------------------------------------------------------------------------- /src/core/base/baseAssignValue.js: -------------------------------------------------------------------------------- 1 | import nativeDefineProperty from '../native/nativeDefineProperty' 2 | 3 | export default function baseAssignValue(object, key, value) { 4 | if (key == '__proto__' && nativeDefineProperty) { 5 | nativeDefineProperty(object, key, { 6 | 'configurable': true, 7 | 'enumerable': true, 8 | 'value': value, 9 | 'writable': true 10 | }) 11 | } else { 12 | object[key] = value 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/core/base/baseClone.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from '../isImmutable' 3 | 4 | export default function baseClone(data) { 5 | return isImmutable(data) 6 | ? data 7 | : _.clone(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/base/baseDelete.js: -------------------------------------------------------------------------------- 1 | import castPath from '../util/castPath' 2 | import getKey from '../getKey' 3 | import isObject from '../isObject' 4 | import toKey from '../toKey' 5 | 6 | export default function baseDelete(data, path, deleteFunc, setFunc) { 7 | path = castPath(path) 8 | const index = 0 9 | return composeRecurPathDelete(path, deleteFunc, setFunc)(data, index) 10 | } 11 | 12 | function composeRecurPathDelete(path, deleteFunc, setFunc) { 13 | const length = path.length 14 | const lastIndex = length - 1 15 | 16 | const recurDelete = (data, index) => { 17 | if (!isObject(data)) { 18 | return data 19 | } 20 | const key = toKey(path[index]) 21 | if (index != lastIndex) { 22 | let value = getKey(data, key) 23 | value = recurDelete(value, ++index) 24 | return setFunc(data, key, value) 25 | } 26 | return deleteFunc(data, key) 27 | } 28 | return recurDelete 29 | } 30 | -------------------------------------------------------------------------------- /src/core/base/baseEach.js: -------------------------------------------------------------------------------- 1 | import baseForOwn from './baseForOwn' 2 | import count from '../count' 3 | import getKey from '../getKey' 4 | import isArrayLike from '../isArrayLike' 5 | import { isForEachable } from '../util' 6 | 7 | export default function baseEach(data, iteratee) { 8 | if (data == null) { 9 | return data 10 | } 11 | if (!isArrayLike(data)) { 12 | if (isForEachable(data)) { 13 | data.forEach(iteratee) 14 | return data 15 | } 16 | return baseForOwn(data, iteratee) 17 | } 18 | const size = count(data) 19 | let index = -1 20 | 21 | while (++index < size) { 22 | if (iteratee(getKey(data, index), index, data) === false) { 23 | break 24 | } 25 | } 26 | return data 27 | } 28 | -------------------------------------------------------------------------------- /src/core/base/baseEachRight.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | import isArrayLike from '../isArrayLike' 4 | import baseForOwnRight from './baseForOwnRight' 5 | 6 | export default function baseEachRight(data, iteratee) { 7 | if (data == null) { 8 | return data 9 | } 10 | if (!isArrayLike(data)) { 11 | return baseForOwnRight(data, iteratee) 12 | } 13 | let size = count(data) 14 | 15 | while (size--) { 16 | if (iteratee(getKey(data, size), size, data) === false) { 17 | break 18 | } 19 | } 20 | return data 21 | } 22 | -------------------------------------------------------------------------------- /src/core/base/baseFindIndex.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function baseFindIndex(indexed, predicate, fromIndex, fromRight = false) { 5 | const length = count(indexed) 6 | if (!length) { 7 | return -1 8 | } 9 | if (fromIndex > length) { 10 | fromIndex = length - 1 11 | } 12 | let index = fromIndex + (fromRight ? 1 : -1) 13 | 14 | while ((fromRight ? index-- : ++index < length)) { 15 | if (predicate(getKey(indexed, index), index, indexed)) { 16 | return index 17 | } 18 | } 19 | return -1 20 | } 21 | -------------------------------------------------------------------------------- /src/core/base/baseFor.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function baseFor(iterable, iteratee, keysFunc) { 5 | let index = -1 6 | const props = keysFunc(iterable) 7 | let size = count(props) 8 | 9 | while (size--) { 10 | const key = getKey(props, ++index) 11 | if (iteratee(getKey(iterable, key), key, iterable) === false) { 12 | break 13 | } 14 | } 15 | return iterable 16 | } 17 | -------------------------------------------------------------------------------- /src/core/base/baseForOwn.js: -------------------------------------------------------------------------------- 1 | import baseFor from './baseFor' 2 | import keys from '../keys' 3 | 4 | export default function baseForOwn(data, iteratee) { 5 | return data && baseFor(data, iteratee, keys) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseForOwnRight.js: -------------------------------------------------------------------------------- 1 | import baseForRight from './baseForRight' 2 | import keys from '../keys' 3 | 4 | export default function baseForOwnRight(data, iteratee) { 5 | return data && baseForRight(data, iteratee, keys) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseForRight.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function baseForRight(iterable, iteratee, keysFunc) { 5 | const props = keysFunc(iterable) 6 | let size = count(props) 7 | 8 | while (size--) { 9 | const key = getKey(props, size) 10 | if (iteratee(getKey(iterable, key), key, iterable) === false) { 11 | break 12 | } 13 | } 14 | return iterable 15 | } 16 | -------------------------------------------------------------------------------- /src/core/base/baseGet.js: -------------------------------------------------------------------------------- 1 | import toKey from '../toKey' 2 | 3 | export default function baseGet(associative, path, getKeyFunc) { 4 | let data = associative 5 | let index = 0 6 | const { length } = path 7 | 8 | while (data != null && index < length) { 9 | const key = toKey(path[index++]) 10 | data = getKeyFunc(data, key) 11 | } 12 | return (index && index == length) ? data : undefined 13 | } 14 | -------------------------------------------------------------------------------- /src/core/base/baseGetAllKeys.js: -------------------------------------------------------------------------------- 1 | import arrayPush from '../array/arrayPush' 2 | import isArray from '../isArray' 3 | 4 | export default function baseGetAllKeys(object, keysFunc, symbolsFunc) { 5 | const result = keysFunc(object) 6 | return isArray(object) ? result : arrayPush(result, symbolsFunc(object)) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/base/baseHas.js: -------------------------------------------------------------------------------- 1 | import getKey from '../getKey' 2 | import toKey from '../toKey' 3 | 4 | export default function baseHas(data, path, hasKeyFunc) { 5 | let result = false 6 | let index = -1 7 | const { length } = path 8 | 9 | while (++index < length) { 10 | const key = toKey(path[index]) 11 | if (!(result = hasKeyFunc(data, key))) { 12 | break 13 | } 14 | data = getKey(data, key) 15 | } 16 | return result 17 | } 18 | -------------------------------------------------------------------------------- /src/core/base/baseIncludes.js: -------------------------------------------------------------------------------- 1 | import nativeMax from '../native/nativeMax' 2 | import count from '../count' 3 | import isString from '../isString' 4 | import baseIndexOf from './baseIndexOf' 5 | 6 | 7 | export default function baseIncludes(indexed, value, fromIndex) { 8 | const length = count(indexed) 9 | if (fromIndex < 0) { 10 | fromIndex = nativeMax(length + fromIndex, 0) 11 | } 12 | return isString(indexed) 13 | ? (fromIndex <= length && indexed.indexOf(value, fromIndex) > -1) 14 | : (!!length && baseIndexOf(indexed, value, fromIndex) > -1) 15 | } 16 | -------------------------------------------------------------------------------- /src/core/base/baseIncludesWith.js: -------------------------------------------------------------------------------- 1 | import nativeMax from '../native/nativeMax' 2 | import count from '../count' 3 | import baseIndexOfWith from './baseIndexOf' 4 | 5 | export default function baseIncludesWith(indexed, value, comparator, fromIndex) { 6 | const length = count(indexed) 7 | if (fromIndex < 0) { 8 | fromIndex = nativeMax(length + fromIndex, 0) 9 | } 10 | return baseIndexOfWith(indexed, value, comparator, fromIndex) > -1 11 | } 12 | -------------------------------------------------------------------------------- /src/core/base/baseIndexOf.js: -------------------------------------------------------------------------------- 1 | import withEqValue from '../with/withEqValue' 2 | import baseFindIndex from './baseFindIndex' 3 | 4 | export default function baseIndexOf(data, value, fromIndex) { 5 | return baseFindIndex(data, withEqValue(value), fromIndex) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseIndexOfWith.js: -------------------------------------------------------------------------------- 1 | import withComparatorValue from '../with/withComparatorValue' 2 | import baseFindIndex from './baseFindIndex' 3 | 4 | export default function baseIndexOfWith(data, value, comparator, fromIndex) { 5 | return baseFindIndex(data, withComparatorValue(comparator, value), fromIndex) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseIsEqual.js: -------------------------------------------------------------------------------- 1 | import eq from '../eq' 2 | import isObjectLike from '../isObjectLike' 3 | import baseIsEqualDeep from './baseIsEqualDeep' 4 | 5 | export default function baseIsEqual(value, other, bitmask, customizer, stack) { 6 | if (eq(value, other)) { 7 | return true 8 | } 9 | if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 10 | return false 11 | } 12 | return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/base/baseIsNaN.js: -------------------------------------------------------------------------------- 1 | export default function baseIsNaN(data) { 2 | return data !== data 3 | } 4 | -------------------------------------------------------------------------------- /src/core/base/baseIsNative.js: -------------------------------------------------------------------------------- 1 | import { reIsHostCtor, reIsNative } from '../regex' 2 | import isMasked from '../util/isMasked' 3 | import isFunction from '../isFunction' 4 | import isObject from '../isObject' 5 | import toSource from '../toSource' 6 | 7 | export default function baseIsNative(value) { 8 | if (!isObject(value) || isMasked(value)) { 9 | return false 10 | } 11 | const pattern = isFunction(value) ? reIsNative : reIsHostCtor 12 | return pattern.test(toSource(value)) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/base/baseIteratee.js: -------------------------------------------------------------------------------- 1 | import identity from '../identity' 2 | import isArray from '../isArray' 3 | import baseMatches from './baseMatches' 4 | import baseMatchesProperty from './baseMatchesProperty' 5 | import baseProperty from './baseProperty' 6 | 7 | export default function baseIteratee(value) { 8 | // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 9 | // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 10 | if (typeof value == 'function') { 11 | return value 12 | } 13 | if (value == null) { 14 | return identity 15 | } 16 | if (typeof value == 'object') { 17 | return isArray(value) 18 | ? baseMatchesProperty(value[0], value[1]) 19 | : baseMatches(value) 20 | } 21 | return baseProperty(value) 22 | } 23 | -------------------------------------------------------------------------------- /src/core/base/baseKeys.js: -------------------------------------------------------------------------------- 1 | import arrayLikeKeys from '../array/arrayLikeKeys' 2 | import objectKeys from '../object/objectKeys' 3 | import isArrayLike from '../isArrayLike' 4 | import isImmutable from '../isImmutable' 5 | 6 | export default function baseKeys(data) { 7 | if (isImmutable(data)) { 8 | return data.keySeq() 9 | } else if (isArrayLike(data)) { 10 | return arrayLikeKeys(data) 11 | } 12 | return objectKeys(data) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/base/baseLastIndexOf.js: -------------------------------------------------------------------------------- 1 | import withEqValue from '../with/withEqValue' 2 | import baseFindIndex from './baseFindIndex' 3 | 4 | export default function baseLastIndexOf(data, value, fromIndex) { 5 | return baseFindIndex(data, withEqValue(value), fromIndex, true) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseLastIndexOfWith.js: -------------------------------------------------------------------------------- 1 | import withComparatorValue from '../with/withComparatorValue' 2 | import baseFindIndex from './baseFindIndex' 3 | 4 | export default function baseLastIndexOfWith(data, value, fromIndex, comparator) { 5 | return baseFindIndex(data, withComparatorValue(comparator, value), fromIndex, true) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseMatches.js: -------------------------------------------------------------------------------- 1 | import getMatchData from '../util/getMatchData' 2 | import matchesStrictComparable from '../util/matchesStrictComparable' 3 | import count from '../count' 4 | import getKey from '../getKey' 5 | import baseGet from './baseGet' 6 | import baseIsMatch from './baseIsMatch' 7 | 8 | export default function baseMatches(source) { 9 | const matchData = getMatchData(source) 10 | if (count(matchData) == 1 && baseGet(matchData, [0, 2], getKey)) { 11 | return matchesStrictComparable(baseGet(matchData, [0, 0], getKey), baseGet(matchData, [0, 1], getKey)) 12 | } 13 | return function(object) { 14 | return object === source || baseIsMatch(object, source, matchData) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/core/base/baseMatchesProperty.js: -------------------------------------------------------------------------------- 1 | import { COMPARE_PARTIAL_FLAG, COMPARE_UNORDERED_FLAG } from '../constants' 2 | import isStrictComparable from '../util/isStrictComparable' 3 | import matchesStrictComparable from '../util/matchesStrictComparable' 4 | import has from '../has' 5 | import isKey from '../isKey' 6 | import toKey from '../toKey' 7 | import baseGet from './baseGet' 8 | import baseIsEqual from './baseIsEqual' 9 | 10 | export default function baseMatchesProperty(path, srcValue) { 11 | if (isKey(path) && isStrictComparable(srcValue)) { 12 | return matchesStrictComparable(toKey(path), srcValue) 13 | } 14 | return function(data) { 15 | const dataValue = baseGet(data, path) 16 | return (dataValue === undefined && dataValue === srcValue) 17 | ? has(data, path) 18 | : baseIsEqual(srcValue, dataValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/core/base/baseOmit.js: -------------------------------------------------------------------------------- 1 | import baseOmitBy from './baseOmitBy' 2 | import has from '../has' 3 | 4 | export default function baseOmit(data, paths) { 5 | return baseOmitBy(data, paths, (value, path) => has(data, path)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseOmitBy.js: -------------------------------------------------------------------------------- 1 | import castPath from '../util/castPath' 2 | import withMutations from '../with/withMutations' 3 | import count from '../count' 4 | import deleteKey from '../deleteKey' 5 | import get from '../get' 6 | import getKey from '../getKey' 7 | import setKey from '../setKey' 8 | import baseDelete from './baseDelete' 9 | import baseGet from './baseGet' 10 | 11 | const omitPaths = withMutations((result, data, paths, predicate) => { 12 | const length = count(paths) 13 | let index = -1 14 | 15 | while (++index < length) { 16 | const path = get(paths, index) 17 | const value = baseGet(data, path, getKey) 18 | if (predicate(value, path)) { 19 | result = baseDelete(result, castPath(path, data), deleteKey, setKey) 20 | } 21 | } 22 | 23 | return result 24 | }) 25 | 26 | export default function baseOmitBy(data, paths, predicate) { 27 | return omitPaths(data, data, paths, predicate) 28 | } 29 | -------------------------------------------------------------------------------- /src/core/base/basePick.js: -------------------------------------------------------------------------------- 1 | import basePickBy from './basePickBy' 2 | import has from '../has' 3 | 4 | export default function basePick(data, paths) { 5 | return basePickBy(data, paths, (value, path) => has(data, path)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseProperty.js: -------------------------------------------------------------------------------- 1 | import getKey from '../getKey' 2 | 3 | export default function baseProperty(key) { 4 | return function(data) { 5 | return getKey(data, key) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/core/base/basePropertyDeep.js: -------------------------------------------------------------------------------- 1 | import get from '../get' 2 | export default function basePropertyDeep(path) { 3 | return function(data) { 4 | return get(data, path) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/basePropertyOf.js: -------------------------------------------------------------------------------- 1 | import getKey from '../getKey' 2 | 3 | export default function basePropertyOf(data) { 4 | return function(key) { 5 | return getKey(data, key) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/core/base/basePropertyOfDeep.js: -------------------------------------------------------------------------------- 1 | import get from '../get' 2 | export default function basePropertyOfDeep(data) { 3 | return function(path) { 4 | return get(data, path) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseReduce.js: -------------------------------------------------------------------------------- 1 | export default function baseReduce(data, iteratee, accumulator, initAccum, eachFunc) { 2 | eachFunc(data, (value, index, collection) => { 3 | accumulator = initAccum 4 | ? (initAccum = false, value) 5 | : iteratee(accumulator, value, index, collection) 6 | }) 7 | return accumulator 8 | } 9 | -------------------------------------------------------------------------------- /src/core/base/baseTimes.js: -------------------------------------------------------------------------------- 1 | import { Array } from '../context' 2 | 3 | export default function baseTimes(n, iteratee) { 4 | let index = -1 5 | const result = Array(n) 6 | 7 | while (++index < n) { 8 | result[index] = iteratee(index) 9 | } 10 | return result 11 | } 12 | -------------------------------------------------------------------------------- /src/core/base/baseUnary.js: -------------------------------------------------------------------------------- 1 | export default function baseUnary(func) { 2 | return (value) => func(value) 3 | } 4 | -------------------------------------------------------------------------------- /src/core/base/baseUpdate.js: -------------------------------------------------------------------------------- 1 | import baseGet from './baseGet' 2 | import baseSet from './baseSet' 3 | 4 | export default function baseUpdate(data, path, updater, setKeyFunc, getKeyFunc, options) { 5 | return baseSet(data, path, updater(baseGet(data, path, getKeyFunc)), setKeyFunc, options) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/base/baseWalk.js: -------------------------------------------------------------------------------- 1 | import castPath from '../util/castPath' 2 | import get from '../get' 3 | import isFunction from '../isFunction' 4 | 5 | export default function baseWalk(data, path, iteratee, walkee) { 6 | if (isFunction(path)) { 7 | walkee = iteratee 8 | iteratee = path 9 | path = undefined 10 | } else { 11 | path = castPath(path) 12 | } 13 | const target = path ? get(data, path) : data 14 | return walkee(target, path, iteratee, (...args) => walkee(...args, walkee)) 15 | } 16 | -------------------------------------------------------------------------------- /src/core/base/baseWhile.js: -------------------------------------------------------------------------------- 1 | import getKey from '../getKey' 2 | import size from '../size' 3 | import slice from '../slice' 4 | 5 | export default function baseWhile(data, predicate, isDrop, fromRight) { 6 | const length = size(data) 7 | let index = fromRight ? length : -1 8 | 9 | while (fromRight ? index-- : ++index < length) { 10 | if (!predicate(getKey(data, index), index, data)) { 11 | break 12 | } 13 | } 14 | 15 | return isDrop 16 | ? slice(data, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 17 | : slice(data, (fromRight ? index + 1 : 0), (fromRight ? length : index)) 18 | } 19 | -------------------------------------------------------------------------------- /src/core/base/baseWrapperValue.js: -------------------------------------------------------------------------------- 1 | import batch from '../batch' 2 | import executeAction from '../executeAction' 3 | import isBatchable from '../isBatchable' 4 | import push from '../push' 5 | import reduce from '../reduce' 6 | import size from '../size' 7 | 8 | export default function baseWrapperValue(value, actions) { 9 | let mutations = [] 10 | function processBatch(data) { 11 | if (size(mutations) > 0) { 12 | data = batch(data, mutations) 13 | mutations = [] 14 | } 15 | return data 16 | } 17 | 18 | let result = reduce(actions, (reduction, action) => { 19 | if (isBatchable(action)) { 20 | mutations = push(mutations, action) 21 | return reduction 22 | } 23 | reduction = processBatch(reduction) 24 | return executeAction(reduction, action) 25 | }, value) 26 | result = processBatch(result) 27 | return result 28 | } 29 | -------------------------------------------------------------------------------- /src/core/batch.js: -------------------------------------------------------------------------------- 1 | import executeAction from './executeAction' 2 | import isImmutable from './isImmutable' 3 | import reduce from './reduce' 4 | 5 | export default function batch(data, actions) { 6 | if (isImmutable(data)) { 7 | return data.withMutations(mutable => runBatch(mutable, actions)) 8 | } 9 | return runBatch(data, actions) 10 | } 11 | 12 | function runBatch(data, actions) { 13 | return reduce(actions, (reduction, action) => { 14 | return executeAction(reduction, action) 15 | }, data) 16 | } 17 | -------------------------------------------------------------------------------- /src/core/butLast.js: -------------------------------------------------------------------------------- 1 | export { default } from './dropRight' 2 | -------------------------------------------------------------------------------- /src/core/cache/SetCache.js: -------------------------------------------------------------------------------- 1 | import { HASH_UNDEFINED } from '../constants' 2 | import MapCache from './MapCache' 3 | 4 | export default class SetCache { 5 | 6 | constructor(values) { 7 | let index = -1 8 | const length = values == null ? 0 : values.length 9 | 10 | this.__data__ = new MapCache 11 | while (++index < length) { 12 | this.add(values[index]) 13 | } 14 | } 15 | 16 | add(value) { 17 | this.__data__.set(value, HASH_UNDEFINED) 18 | return this 19 | } 20 | 21 | has(value) { 22 | return this.__data__.has(value) 23 | } 24 | 25 | push(value) { 26 | return this.add(value) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/core/cache/cacheHas.js: -------------------------------------------------------------------------------- 1 | export default function cacheHas(cache, key) { 2 | return cache.has(key) 3 | } 4 | 5 | -------------------------------------------------------------------------------- /src/core/cache/getMapData.js: -------------------------------------------------------------------------------- 1 | import isKeyable from '../isKeyable' 2 | export default function getMapData(map, key) { 3 | const data = map.__data__ 4 | return isKeyable(key) 5 | ? data[typeof key == 'string' ? 'string' : 'hash'] 6 | : data.map 7 | } 8 | -------------------------------------------------------------------------------- /src/core/cache/index.js: -------------------------------------------------------------------------------- 1 | export { default as cacheHas } from './cacheHas' 2 | export { default as getMapData } from './getMapData' 3 | export { default as Hash } from './Hash' 4 | export { default as ListCache } from './ListCache' 5 | export { default as MapCache } from './MapCache' 6 | export { default as SetCache } from './SetCache' 7 | export { default as Stack } from './Stack' 8 | -------------------------------------------------------------------------------- /src/core/call.js: -------------------------------------------------------------------------------- 1 | import apply from './apply' 2 | 3 | export default function call(method, ...args) { 4 | return apply(method, args) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/chunk.js: -------------------------------------------------------------------------------- 1 | import count from './count' 2 | import hintConvert from './hintConvert' 3 | import isIterateeCall from './isIterateeCall' 4 | import push from './push' 5 | import slice from './slice' 6 | import toInteger from './toInteger' 7 | 8 | export default function chunk(data, size, guard) { 9 | if ((guard ? isIterateeCall(data, size, guard) : size === undefined)) { 10 | size = 1 11 | } else { 12 | size = Math.max(toInteger(size), 0) 13 | } 14 | const length = data ? count(data) : 0 15 | if (!length || size < 1) { 16 | return hintConvert(data, []) 17 | } 18 | let index = 0 19 | let result = hintConvert(data, []) 20 | 21 | while (index < length) { 22 | result = push(result, slice(data, index, (index += size))) 23 | } 24 | return result 25 | } 26 | -------------------------------------------------------------------------------- /src/core/circ.js: -------------------------------------------------------------------------------- 1 | import circularShift from './circularShift' 2 | export default function circ(func, number) { 3 | return (...args) => func(circularShift(args, number)) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/circCopy.js: -------------------------------------------------------------------------------- 1 | export default function circCopy(src, srcStart, dest, destStart) { 2 | for (let count = 0; count < length; count += 1) { 3 | dest[destStart + count] = src[srcStart + count] 4 | } 5 | } 6 | // 7 | // if (obj.tail !== obj.head) { 8 | // list = circCopy(obj.list, obj.tail, list, 0) 9 | // return RingBuffer({ 10 | // ...obj, 11 | // tail: 0, 12 | // head: obj.length, 13 | // list 14 | // }) 15 | // } else if (obj.tail > obj.head) { 16 | // list = circCopy(obj.list, obj.tail, list, 0, obj.list.size - obj.tail) 17 | // list = circCopy(obj.list, 0, newArr, this.arr.length - this.tail, this.head) 18 | // this.tail = 0 19 | // this.head = this.length 20 | // this.arr = newArr 21 | // } 22 | -------------------------------------------------------------------------------- /src/core/circularShift.js: -------------------------------------------------------------------------------- 1 | import concat from './concat' 2 | import size from './size' 3 | import slice from './slice' 4 | export default function circularShift(data, number) { 5 | const length = size(data) 6 | if (length === 0 || length === 1) { 7 | return data 8 | } else if (Math.abs(number) > length) { 9 | number = number % length 10 | } 11 | if (number === 0) { 12 | return data 13 | } 14 | if (number < 0) { 15 | number = length + number 16 | } 17 | return concat(slice(data, number, length), slice(data, 0, number)) 18 | } 19 | -------------------------------------------------------------------------------- /src/core/clone.js: -------------------------------------------------------------------------------- 1 | import { baseClone } from './base' 2 | export default function clone(data) { 3 | return baseClone(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/cloneDeep.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { deepClone } from './customizers' 3 | 4 | export default function cloneDeep(data) { 5 | return _.cloneDeepWith(data, deepClone) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/cloneDeepWith.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { withDeepClone } from './with' 3 | 4 | export default function cloneDeepWith(data, customizer) { 5 | return _.cloneDeepWith(data, withDeepClone(customizer)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/cloneWith.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isFunction from './isFunction' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function cloneWith(data, customizer) { 6 | if (isImmutable(data)) { 7 | if (isFunction(customizer)) { 8 | const result = customizer(data) 9 | if (!_.isUndefined(result)) { 10 | return result 11 | } 12 | } 13 | return data 14 | } 15 | return _.cloneWith(data, customizer) 16 | } 17 | -------------------------------------------------------------------------------- /src/core/compact.js: -------------------------------------------------------------------------------- 1 | import { truthy } from './predicates' 2 | import filter from './filter' 3 | 4 | export default function compact(data) { 5 | return filter(data, truthy) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/compose.js: -------------------------------------------------------------------------------- 1 | import first from './first' 2 | import flatten from './flatten' 3 | import identity from './identity' 4 | import last from './last' 5 | import reduceRight from './reduceRight' 6 | import size from './size' 7 | import slice from './slice' 8 | 9 | export default function compose(...funcs) { 10 | funcs = flatten(funcs) 11 | const length = size(funcs) 12 | if (length === 0) { 13 | return identity 14 | } 15 | 16 | if (length === 1) { 17 | return first(funcs) 18 | } 19 | 20 | const lastFunc = last(funcs) 21 | const rest = slice(funcs, 0, -1) 22 | return (...args) => reduceRight(rest, (composed, func) => func(composed), lastFunc(...args)) 23 | } 24 | -------------------------------------------------------------------------------- /src/core/concat.js: -------------------------------------------------------------------------------- 1 | import Concatable from './protocols/Concatable' 2 | import hintConvert from './hintConvert' 3 | 4 | export default function concat(data, ...args) { 5 | if (!Concatable.is(data)) { 6 | data = hintConvert(data, [data]) 7 | } 8 | return data.concat(...args) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/constants/index.js: -------------------------------------------------------------------------------- 1 | export * from './constants' 2 | -------------------------------------------------------------------------------- /src/core/contains.js: -------------------------------------------------------------------------------- 1 | export { default } from './includes' 2 | -------------------------------------------------------------------------------- /src/core/context/contextFuncToString.js: -------------------------------------------------------------------------------- 1 | import { funcProto } from './context' 2 | const { toString: contextFuncToString } = funcProto 3 | export default contextFuncToString 4 | -------------------------------------------------------------------------------- /src/core/context/contextHasOwnProperty.js: -------------------------------------------------------------------------------- 1 | import { objectProto } from './context' 2 | const { hasOwnProperty: contextHasOwnProperty } = objectProto 3 | export default contextHasOwnProperty 4 | -------------------------------------------------------------------------------- /src/core/context/contextPropertyIsEnumerable.js: -------------------------------------------------------------------------------- 1 | import { objectProto } from './context' 2 | const { propertyIsEnumerable: contextPropertyIsEnumerable } = objectProto 3 | export default contextPropertyIsEnumerable 4 | -------------------------------------------------------------------------------- /src/core/context/contextSplice.js: -------------------------------------------------------------------------------- 1 | import { arrayProto } from './context' 2 | const { splice: contextSplice } = arrayProto 3 | export default contextSplice 4 | -------------------------------------------------------------------------------- /src/core/context/contextSymbolIsConcatSpreadable.js: -------------------------------------------------------------------------------- 1 | import { Symbol } from './context' 2 | 3 | const { isConcatSpreadable: contextSymbolIsConcatSpreadable } = Symbol 4 | export default contextSymbolIsConcatSpreadable 5 | -------------------------------------------------------------------------------- /src/core/context/contextSymbolIterator.js: -------------------------------------------------------------------------------- 1 | import { Symbol } from './context' 2 | const contextSymbolIterator = Symbol ? Symbol.iterator : undefined 3 | export default contextSymbolIterator 4 | -------------------------------------------------------------------------------- /src/core/context/contextSymbolToStringTag.js: -------------------------------------------------------------------------------- 1 | import { Symbol } from './context' 2 | 3 | const { toStringTag: contextSymbolToStringTag } = Symbol 4 | export default contextSymbolToStringTag 5 | -------------------------------------------------------------------------------- /src/core/context/index.js: -------------------------------------------------------------------------------- 1 | export { default as contextFuncToString } from './contextFuncToString' 2 | export { default as contextHasOwnProperty } from './contextHasOwnProperty' 3 | export { default as contextPropertyIsEnumerable } from './contextPropertyIsEnumerable' 4 | export { default as contextSplice } from './contextSplice' 5 | export { default as contextSymbolIsConcatSpreadable } from './contextSymbolIsConcatSpreadable' 6 | export { default as contextSymbolIterator } from './contextSymbolIterator' 7 | export { default as contextSymbolToStringTag } from './contextSymbolToStringTag' 8 | export * from './context' 9 | -------------------------------------------------------------------------------- /src/core/count.js: -------------------------------------------------------------------------------- 1 | import { MAP_TAG, SET_TAG } from './constants' 2 | import { Counted } from './protocols' 3 | import { getTag, stringSize } from './util' 4 | import isArrayLike from './isArrayLike' 5 | import isString from './isString' 6 | import keys from './keys' 7 | 8 | export default function count(data) { 9 | if (data == null) { 10 | return 0 11 | } 12 | if (Counted.is(data)) { 13 | return data.count() 14 | } 15 | if (isArrayLike(data)) { 16 | return isString(data) ? stringSize(data) : data.length 17 | } 18 | const tag = getTag(data) 19 | if (tag == MAP_TAG || tag == SET_TAG) { 20 | return data.size 21 | } 22 | return keys(data).length 23 | } 24 | -------------------------------------------------------------------------------- /src/core/customizers/arg2.js: -------------------------------------------------------------------------------- 1 | export default function(arg1, arg2) { 2 | return arg2 3 | } 4 | -------------------------------------------------------------------------------- /src/core/customizers/deepClone.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from '../isImmutable' 3 | 4 | export default function deepClone(data) { 5 | if (isImmutable(data)) { 6 | data.forEach((value, key) => { 7 | data = data.set(key, _.cloneDeepWith(value, deepClone)) 8 | }) 9 | return data 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/core/customizers/index.js: -------------------------------------------------------------------------------- 1 | export { default as arg2 } from './arg2' 2 | export { default as deepClone } from './deepClone' 3 | -------------------------------------------------------------------------------- /src/core/defn.js: -------------------------------------------------------------------------------- 1 | import { curry } from 'lodash' 2 | 3 | export default function defn(func, arity) { 4 | return curry(func, arity) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/delete.js: -------------------------------------------------------------------------------- 1 | import { baseDelete } from './base' 2 | import deleteKey from './deleteKey' 3 | import setKey from './setKey' 4 | 5 | export default function _delete(data, path) { 6 | return data == null ? data : baseDelete(data, path, deleteKey, setKey) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/difference.js: -------------------------------------------------------------------------------- 1 | import { baseDifference, baseFlatten } from './base' 2 | import hintConvert from './hintConvert' 3 | import isIndexed from './isIndexed' 4 | 5 | export default function difference(data, ...values) { 6 | return (isIndexed(data)) 7 | ? baseDifference(data, baseFlatten(values, 1, isIndexed, true)) 8 | : hintConvert(data, []) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/differenceBy.js: -------------------------------------------------------------------------------- 1 | import { baseDifference } from './base' 2 | import { getIteratee } from './util' 3 | import flatten from './flatten' 4 | import hintConvert from './hintConvert' 5 | import isOrdered from './isOrdered' 6 | import last from './last' 7 | 8 | export default function differenceBy(data, ...values) { 9 | let iteratee = last(values) 10 | if (isOrdered(iteratee)) { 11 | iteratee = undefined 12 | } 13 | return (isOrdered(data)) 14 | ? baseDifference(data, flatten(values, 1, isOrdered, true), getIteratee(iteratee, 2)) 15 | : hintConvert(data, []) 16 | } 17 | -------------------------------------------------------------------------------- /src/core/differenceWith.js: -------------------------------------------------------------------------------- 1 | import { baseDifference } from './base' 2 | import flatten from './flatten' 3 | import hintConvert from './hintConvert' 4 | import isOrdered from './isOrdered' 5 | import last from './last' 6 | 7 | export default function differenceWith(data, ...values) { 8 | let comparator = last(values) 9 | if (isOrdered(comparator)) { 10 | comparator = undefined 11 | } 12 | return (isOrdered(data)) 13 | ? baseDifference(data, flatten(values, 1, isOrdered, true), undefined, comparator) 14 | : hintConvert(data, []) 15 | } 16 | -------------------------------------------------------------------------------- /src/core/dissoc.js: -------------------------------------------------------------------------------- 1 | import { baseDelete } from './base' 2 | import deleteKey from './deleteKey' 3 | import forEach from './forEach' 4 | import isString from './isString' 5 | import setKey from './setKey' 6 | 7 | export default function dissoc(data, path) { 8 | if (data == null) { 9 | return data 10 | } 11 | if (isString(path)) { 12 | data = baseDelete(data, path, deleteKey, setKey) 13 | } else { 14 | //TODO BRN: Improve this so that it uses withMutations when making multiple modifications 15 | forEach(path, (pathValue) => { 16 | data = baseDelete(data, pathValue, deleteKey, setKey) 17 | }) 18 | } 19 | return data 20 | } 21 | -------------------------------------------------------------------------------- /src/core/drop.js: -------------------------------------------------------------------------------- 1 | import hintConvert from './hintConvert' 2 | import slice from './slice' 3 | import size from './size' 4 | import toInteger from './toInteger' 5 | 6 | export default function drop(data, n = 1) { 7 | const length = size(data) 8 | if (!length) { 9 | return hintConvert(data, []) 10 | } 11 | n = n === undefined ? 1 : toInteger(n) 12 | return slice(data, n < 0 ? 0 : n, length) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/dropRight.js: -------------------------------------------------------------------------------- 1 | import count from './count' 2 | import hintConvert from './hintConvert' 3 | import slice from './slice' 4 | import toInteger from './toInteger' 5 | 6 | export default function dropRight(data, n = 1) { 7 | const length = count(data) 8 | if (!length) { 9 | return hintConvert(data, []) 10 | } 11 | n = n === undefined ? 1 : toInteger(n) 12 | n = length - n 13 | return slice(data, 0, n < 0 ? 0 : n) 14 | } 15 | -------------------------------------------------------------------------------- /src/core/dropRightWhile.js: -------------------------------------------------------------------------------- 1 | import size from './size' 2 | import hintConvert from './hintConvert' 3 | import getIteratee from './util/getIteratee' 4 | import baseWhile from './base/baseWhile' 5 | 6 | export default function dropRightWhile(data, predicate) { 7 | return (data && size(data)) 8 | ? baseWhile(data, getIteratee(predicate), true, true) 9 | : hintConvert(data, []) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/dropWhile.js: -------------------------------------------------------------------------------- 1 | import size from './size' 2 | import hintConvert from './hintConvert' 3 | import getIteratee from './util/getIteratee' 4 | import baseWhile from './base/baseWhile' 5 | 6 | export default function dropWhile(data, predicate) { 7 | return (data && size(data)) 8 | ? baseWhile(data, getIteratee(predicate), true, false) 9 | : hintConvert(data, []) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/each.js: -------------------------------------------------------------------------------- 1 | export default from './forEach' 2 | -------------------------------------------------------------------------------- /src/core/eq.js: -------------------------------------------------------------------------------- 1 | // TODO BRN: Not sure if this is the right way to go about this. Should this remain string equals even for immutable values? 2 | import Immutable from 'immutable' 3 | import isImmutable from './isImmutable' 4 | export default function eq(value, other) { 5 | return value === other || (value !== value && other !== other) || (isImmutable(value) && isImmutable(other) && Immutable.is(value, other)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/every.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import iteratee from './iteratee' 4 | 5 | export default function every(data, predicate) { 6 | predicate = iteratee(predicate) 7 | return isImmutable(data) 8 | ? data.every(predicate) 9 | : _.every(data, predicate) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/executeAction.js: -------------------------------------------------------------------------------- 1 | import concat from './concat' 2 | export default function executeAction(data, action) { 3 | return action.func.apply(action.thisArg, concat([data], action.args)) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/extend.js: -------------------------------------------------------------------------------- 1 | import Extendable from './protocols/Extendable' 2 | import Inheriter from './protocols/Inheriter' 3 | import Reducable from './protocols/Reducable' 4 | 5 | export default function extend(extendables, def) { 6 | if (!Reducable.is(extendables) || Extendable.is(extendables)) { 7 | extendables = [extendables] 8 | } 9 | const result = extendables.reduce((extendable, inheriter) => { 10 | if (!extendable) { 11 | if (!Extendable.is(inheriter)) { 12 | throw new Error('Expected Extendable data type') 13 | } 14 | return inheriter 15 | } 16 | if (!Inheriter.is(inheriter)) { 17 | throw new Error('Expected Inheriter data type') 18 | } 19 | return inheriter.inherit(extendable) 20 | }) 21 | if (!Extendable.is(result)) { 22 | throw new Error('Expected Extendable data type') 23 | } 24 | return result.extend(def) 25 | } 26 | -------------------------------------------------------------------------------- /src/core/filter.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import iteratee from './iteratee' 4 | 5 | export default function filter(data, predicate) { 6 | predicate = iteratee(predicate) 7 | return isImmutable(data) 8 | ? data.filter(predicate) 9 | : _.filter(data, predicate) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/filterNot.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function filterNot(data, predicate) { 5 | return isImmutable(data) 6 | ? data.filterNot(predicate) 7 | : _.reject(data, predicate) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/find.js: -------------------------------------------------------------------------------- 1 | import each from './each' 2 | import iteratee from './iteratee' 3 | import slice from './slice' 4 | 5 | export default function find(data, predicate, fromIndex = 0) { 6 | predicate = iteratee(predicate) 7 | let found = undefined 8 | each(slice(data, fromIndex), (value) => { 9 | const result = predicate(value) 10 | if (result) { 11 | found = value 12 | return false 13 | } 14 | }) 15 | return found 16 | } 17 | -------------------------------------------------------------------------------- /src/core/findIndex.js: -------------------------------------------------------------------------------- 1 | import { baseFindIndex } from './base' 2 | import { nativeMax } from './native' 3 | import { getIteratee } from './util' 4 | import count from './count' 5 | import isIndexed from './isIndexed' 6 | import isOrdered from './isOrdered' 7 | import toIndexed from './toIndexed' 8 | import toInteger from './toInteger' 9 | 10 | export default function findIndex(data, predicate, fromIndex) { 11 | let indexed = data 12 | if (!isIndexed(data)) { 13 | if (!isOrdered(data)) { 14 | return -1 15 | } 16 | indexed = toIndexed(data) 17 | } 18 | const length = count(data) 19 | let index = fromIndex == null ? 0 : toInteger(fromIndex) 20 | if (index < 0) { 21 | index = nativeMax(length + index, 0) 22 | } 23 | return baseFindIndex(indexed, getIteratee(predicate), index) 24 | } 25 | -------------------------------------------------------------------------------- /src/core/first.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function first(data) { 5 | return isImmutable(data) 6 | ? data.first() 7 | : _.first(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/flatten.js: -------------------------------------------------------------------------------- 1 | import { baseFlatten } from './base' 2 | import hintConvert from './hintConvert' 3 | import isIndexed from './isIndexed' 4 | 5 | export default function flatten(data) { 6 | return isIndexed(data) ? baseFlatten(data, 1) : hintConvert(data, []) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/flattenDeep.js: -------------------------------------------------------------------------------- 1 | import { baseFlatten } from './base' 2 | import { INFINITY } from './constants' 3 | import hintConvert from './hintConvert' 4 | import isIndexed from './isIndexed' 5 | 6 | export default function flattenDeep(data) { 7 | return isIndexed(data) ? baseFlatten(data, INFINITY) : hintConvert(data, []) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/flattenDepth.js: -------------------------------------------------------------------------------- 1 | import { baseFlatten } from './base' 2 | import hintConvert from './hintConvert' 3 | import isIndexed from './isIndexed' 4 | import toInteger from './toInteger' 5 | 6 | export default function flattenDepth(data, depth) { 7 | if (!isIndexed(data)) { 8 | return hintConvert(data, []) 9 | } 10 | depth = depth === undefined ? 1 : toInteger(depth) 11 | return baseFlatten(data, depth) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/flow.js: -------------------------------------------------------------------------------- 1 | import first from './first' 2 | import flatten from './flatten' 3 | import identity from './identity' 4 | import reduce from './reduce' 5 | import size from './size' 6 | import slice from './slice' 7 | 8 | export default function flow(...funcs) { 9 | funcs = flatten(funcs) 10 | const length = size(funcs) 11 | if (length === 0) { 12 | return identity 13 | } 14 | 15 | if (length === 1) { 16 | return first(funcs) 17 | } 18 | 19 | const firstFunc = first(funcs) 20 | const rest = slice(funcs, 1) 21 | return (...args) => reduce(rest, (composed, func) => func(composed), firstFunc(...args)) 22 | } 23 | -------------------------------------------------------------------------------- /src/core/flowRight.js: -------------------------------------------------------------------------------- 1 | export default from './compose' 2 | -------------------------------------------------------------------------------- /src/core/forEach.js: -------------------------------------------------------------------------------- 1 | import { baseEach } from './base' 2 | 3 | export default function forEach(data, iteratee) { 4 | return baseEach(data, iteratee) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/forEachRight.js: -------------------------------------------------------------------------------- 1 | import { baseEachRight } from './base' 2 | 3 | export default function forEachRight(data, iteratee) { 4 | return baseEachRight(data, iteratee) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/free/free.js: -------------------------------------------------------------------------------- 1 | const freeGlobal = typeof global == 'object' && global && global.Object === Object && global 2 | const freeSelf = typeof self == 'object' && self && self.Object === Object && self 3 | const root = freeGlobal || freeSelf || Function('return this')() 4 | const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports 5 | const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module 6 | const moduleExports = freeModule && freeModule.exports === freeExports 7 | const freeProcess = moduleExports && freeGlobal.process 8 | export { 9 | freeExports, 10 | freeGlobal, 11 | freeModule, 12 | freeProcess, 13 | freeSelf, 14 | moduleExports, 15 | root 16 | } 17 | -------------------------------------------------------------------------------- /src/core/free/index.js: -------------------------------------------------------------------------------- 1 | export * from './free' 2 | -------------------------------------------------------------------------------- /src/core/get.js: -------------------------------------------------------------------------------- 1 | import { baseGet } from './base' 2 | import { castPath } from './util' 3 | import getKey from './getKey' 4 | 5 | export default function get(data, maybePath, defaultValue) { 6 | let result = undefined 7 | if (data != null) { 8 | result = baseGet(data, castPath(maybePath, data), getKey) 9 | } 10 | return result === undefined ? defaultValue : result 11 | } 12 | -------------------------------------------------------------------------------- /src/core/getKey.js: -------------------------------------------------------------------------------- 1 | import Keyed from './protocols/Keyed' 2 | 3 | export default function getKey(data, key) { 4 | if (data != null) { 5 | return Keyed.is(data) 6 | ? data.get(key) 7 | : data[key] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/core/getPrototype.js: -------------------------------------------------------------------------------- 1 | import { _Object } from './context' 2 | import overArg from './overArg' 3 | const getPrototype = overArg(_Object.getPrototypeOf, _Object) 4 | export default getPrototype 5 | -------------------------------------------------------------------------------- /src/core/groupBy.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isFunction from './isFunction' 3 | import isImmutable from './isImmutable' 4 | import property from './property' 5 | 6 | export default function groupBy(data, iteratee) { 7 | if (!isFunction(iteratee)) { 8 | iteratee = property(iteratee) 9 | } 10 | return isImmutable(data) 11 | ? data.groupBy(iteratee) 12 | : _.groupBy(data, iteratee) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/has.js: -------------------------------------------------------------------------------- 1 | import { baseHas } from './base' 2 | import { castPath } from './util' 3 | import hasKey from './hasKey' 4 | 5 | export default function has(data, maybePath, hasKeyFunc = hasKey) { 6 | return data == null ? data : baseHas(data, castPath(maybePath), hasKeyFunc) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/hasKey.js: -------------------------------------------------------------------------------- 1 | import { contextHasOwnProperty } from './context' 2 | import Keyed from './protocols/Keyed' 3 | 4 | export default function hasKey(data, key) { 5 | if (data != null) { 6 | if (Keyed.is(data)) { 7 | return data.has(key) 8 | } 9 | return contextHasOwnProperty.call(data, key) 10 | } 11 | return false 12 | } 13 | -------------------------------------------------------------------------------- /src/core/hasKeyIn.js: -------------------------------------------------------------------------------- 1 | import Keyed from './protocols/Keyed' 2 | 3 | export default function hasKeyIn(data, key) { 4 | if (data != null) { 5 | if (Keyed.is(data)) { 6 | return data.has(key) 7 | } 8 | return !!(key in data) 9 | } 10 | return false 11 | } 12 | -------------------------------------------------------------------------------- /src/core/head.js: -------------------------------------------------------------------------------- 1 | export { default } from './first' 2 | -------------------------------------------------------------------------------- /src/core/helpers/index.js: -------------------------------------------------------------------------------- 1 | export { default as mapImmutable } from './mapImmutable' 2 | export { default as mapMutable } from './mapMutable' 3 | -------------------------------------------------------------------------------- /src/core/helpers/mapImmutable.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import immutable from '../immutable' 3 | 4 | const mapImmutable = values => _.map(values, (value) => immutable(value)) 5 | export default mapImmutable 6 | -------------------------------------------------------------------------------- /src/core/helpers/mapMutable.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import mutable from '../mutable' 3 | 4 | const mapMutable = values => _.map(values, (value) => mutable(value)) 5 | export default mapMutable 6 | -------------------------------------------------------------------------------- /src/core/hint.js: -------------------------------------------------------------------------------- 1 | import isFunction from './isFunction' 2 | export default function hint(predicate) { 3 | return (data, success, failure, ...rest) => { 4 | const result = predicate(data) ? success : failure 5 | return isFunction(result) ? result(...rest) : result 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/core/hintConvert.js: -------------------------------------------------------------------------------- 1 | import { hintIm } from './hints' 2 | import immutable from './immutable' 3 | import mutable from './mutable' 4 | 5 | export default function hintConvert(data, value) { 6 | return hintIm( 7 | data, 8 | immutable, 9 | mutable, 10 | value 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/hints/hintArgs.js: -------------------------------------------------------------------------------- 1 | import hintIm from './hintIm' 2 | import mapImmutable from '../helpers/mapImmutable' 3 | import mapMutable from '../helpers/mapImmutable' 4 | 5 | export default function hintArgs(data, args) { 6 | return hintIm( 7 | data, 8 | mapImmutable, 9 | mapMutable, 10 | args 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/hints/hintIm.js: -------------------------------------------------------------------------------- 1 | import isImmutable from '../isImmutable' 2 | import hint from '../hint' 3 | const hintIm = hint(isImmutable) 4 | export default hintIm 5 | -------------------------------------------------------------------------------- /src/core/hints/index.js: -------------------------------------------------------------------------------- 1 | export { default as hintArgs } from './hintArgs' 2 | export { default as hintIm } from './hintIm' 3 | -------------------------------------------------------------------------------- /src/core/identity.js: -------------------------------------------------------------------------------- 1 | export default function identity(value) { 2 | return value 3 | } 4 | -------------------------------------------------------------------------------- /src/core/im.js: -------------------------------------------------------------------------------- 1 | export { default } from './immutable' 2 | -------------------------------------------------------------------------------- /src/core/immutable.js: -------------------------------------------------------------------------------- 1 | import isArray from './isArray' 2 | import isMutable from './isMutable' 3 | import isObjectLike from './isObjectLike' 4 | import toImmutable from './toImmutable' 5 | 6 | export default function immutable(data) { 7 | return isMutable(data) && (isObjectLike(data) || isArray(data)) ? 8 | toImmutable(data) : data 9 | } 10 | -------------------------------------------------------------------------------- /src/core/includes.js: -------------------------------------------------------------------------------- 1 | import { baseIncludes } from './base' 2 | import toIndexed from './toIndexed' 3 | import toInteger from './toInteger' 4 | 5 | export default function includes(data, value, fromIndex) { 6 | const indexed = toIndexed(data) 7 | fromIndex = fromIndex ? toInteger(fromIndex) : 0 8 | return baseIncludes(indexed, value, fromIndex) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/includesWith.js: -------------------------------------------------------------------------------- 1 | import { baseIncludesWith } from './base' 2 | import toIndexed from './toIndexed' 3 | import toInteger from './toInteger' 4 | 5 | export default function includesWith(data, value, comparator, fromIndex) { 6 | const indexed = toIndexed(data) 7 | fromIndex = fromIndex ? toInteger(fromIndex) : 0 8 | return baseIncludesWith(indexed, value, comparator, fromIndex) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/indexOf.js: -------------------------------------------------------------------------------- 1 | import { baseIndexOf } from './base' 2 | import { nativeMax } from './native' 3 | import count from './count' 4 | import isIndexed from './isIndexed' 5 | import isOrdered from './isOrdered' 6 | import toIndexed from './toIndexed' 7 | import toInteger from './toInteger' 8 | 9 | export default function indexOf(data, value, fromIndex) { 10 | let indexed = data 11 | if (!isIndexed(data)) { 12 | if (!isOrdered(data)) { 13 | return -1 14 | } 15 | indexed = toIndexed(data) 16 | } 17 | const length = count(indexed) 18 | let index = fromIndex == null ? 0 : toInteger(fromIndex) 19 | if (index < 0) { 20 | index = nativeMax(length + index, 0) 21 | } 22 | return baseIndexOf(indexed, value, index) 23 | } 24 | -------------------------------------------------------------------------------- /src/core/isArray.js: -------------------------------------------------------------------------------- 1 | import { Array } from './context' 2 | 3 | export default function isArray(data) { 4 | return Array.isArray(data) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isArrayLike.js: -------------------------------------------------------------------------------- 1 | import isLength from './isLength' 2 | 3 | export default function isArrayLike(data) { 4 | return data != null && typeof data != 'function' && isLength(data.length) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isAssociative.js: -------------------------------------------------------------------------------- 1 | import isIndexed from './isIndexed' 2 | import isKeyed from './isKeyed' 3 | 4 | export default function isAssociative(data) { 5 | return isKeyed(data) || isIndexed(data) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/isBatchable.js: -------------------------------------------------------------------------------- 1 | import assign from './assign' 2 | import contains from './contains' 3 | import set from './set' 4 | 5 | const BATCHABLE = [ 6 | assign, 7 | set 8 | ] 9 | export default function isBatchable(action) { 10 | return contains(BATCHABLE, action.func) 11 | } 12 | -------------------------------------------------------------------------------- /src/core/isBoolean.js: -------------------------------------------------------------------------------- 1 | import { BOOL_TAG } from './constants' 2 | import getTag from './util/getTag' 3 | import isObjectLike from './isObjectLike' 4 | 5 | export default function isBoolean(value) { 6 | return value === true || value === false || 7 | (isObjectLike(value) && getTag(value) === BOOL_TAG) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/isClass.js: -------------------------------------------------------------------------------- 1 | export default function isClass(data) { 2 | return typeof data === 'function' && /^\s*class\s+/.test(data.toString()) 3 | } 4 | -------------------------------------------------------------------------------- /src/core/isEmpty.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function isEmpty(data) { 5 | if (isImmutable(data)) { 6 | return data.isEmpty() 7 | } 8 | return _.isEmpty(data) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/isEqual.js: -------------------------------------------------------------------------------- 1 | import { baseIsEqual } from './base' 2 | export default function isEqual(value, other) { 3 | return baseIsEqual(value, other) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isEqualWith.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isEqual from './isEqual' 3 | import isFunction from './isFunction' 4 | 5 | export default function isEqualWith(value, other, customizer) { 6 | if (isFunction(customizer)) { 7 | const result = customizer(value, other) 8 | if (!_.isUndefined(result)) { 9 | return !!result 10 | } 11 | } 12 | return isEqual(value, other) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/isFlattenable.js: -------------------------------------------------------------------------------- 1 | import { contextSymbolIsConcatSpreadable } from './context' 2 | import isIndexed from './isIndexed' 3 | import isString from './isString' 4 | 5 | export default function isFlattenable(data) { 6 | return (isIndexed(data) && !isString(data)) || 7 | !!(contextSymbolIsConcatSpreadable && data && data[contextSymbolIsConcatSpreadable]) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/isFunction.js: -------------------------------------------------------------------------------- 1 | import getTag from './util/getTag' 2 | import isObject from './isObject' 3 | 4 | export default function isFunction(value) { 5 | if (!isObject(value)) { 6 | return false 7 | } 8 | // The use of `Object#toString` avoids issues with the `typeof` operator 9 | // in Safari 9 which returns 'object' for typed arrays and other constructors. 10 | const tag = getTag(value) 11 | return tag == '[object Function]' || tag == '[object AsyncFunction]' || 12 | tag == '[object GeneratorFunction]' || tag == '[object Proxy]' 13 | } 14 | -------------------------------------------------------------------------------- /src/core/isGenerator.js: -------------------------------------------------------------------------------- 1 | export default function isGenerator(data) { 2 | return data && 3 | typeof data.next === 'function' && 4 | typeof data.throw === 'function' 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isGeneratorFunction.js: -------------------------------------------------------------------------------- 1 | export default function isGeneratorFunction(data) { 2 | return typeof data === 'function' && 3 | data.constructor && 4 | data.constructor.name === 'GeneratorFunction' 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isIm.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutable' 2 | -------------------------------------------------------------------------------- /src/core/isImIndexedSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableIndexedSeq' 2 | -------------------------------------------------------------------------------- /src/core/isImIterable.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableIterable' 2 | -------------------------------------------------------------------------------- /src/core/isImKeyedSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableKeyedSeq' 2 | -------------------------------------------------------------------------------- /src/core/isImList.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableList' 2 | -------------------------------------------------------------------------------- /src/core/isImMap.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableMap' 2 | -------------------------------------------------------------------------------- /src/core/isImOrderedMap.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableOrderedMap' 2 | -------------------------------------------------------------------------------- /src/core/isImOrderedSet.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableOrderedSet' 2 | -------------------------------------------------------------------------------- /src/core/isImSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableSeq' 2 | -------------------------------------------------------------------------------- /src/core/isImSet.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableSet' 2 | -------------------------------------------------------------------------------- /src/core/isImSetSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableSetSeq' 2 | -------------------------------------------------------------------------------- /src/core/isImStack.js: -------------------------------------------------------------------------------- 1 | export { default } from './isImmutableStack' 2 | -------------------------------------------------------------------------------- /src/core/isImmutable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | 3 | export default function isImmutable(value) { 4 | return (Iterable.isIterable(value) || (!!value && !!value['@@data'])) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isImmutableIndexedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function isImmutableIndexedSeq(data) { 3 | return data instanceof Seq.Indexed 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableIterable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | 3 | export default function isImmutableIterable(value) { 4 | return Iterable.isIterable(value) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isImmutableKeyedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function isImmutableKeyedSeq(data) { 3 | return data instanceof Seq.Keyed 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableList.js: -------------------------------------------------------------------------------- 1 | import { List } from 'immutable' 2 | export default function isImmutableList(data) { 3 | return List.isList(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableMap.js: -------------------------------------------------------------------------------- 1 | import { Map } from 'immutable' 2 | export default function isImmutableMap(data) { 3 | return Map.isMap(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableOrderedMap.js: -------------------------------------------------------------------------------- 1 | import { OrderedMap } from 'immutable' 2 | export default function isImmutableOrderedMap(data) { 3 | return OrderedMap.isOrderedMap(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableOrderedSet.js: -------------------------------------------------------------------------------- 1 | import { OrderedSet } from 'immutable' 2 | export default function isImmutableOrderedSet(data) { 3 | return OrderedSet.isOrderedSet(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function isImmutableSeq(data) { 3 | return Seq.isSeq(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableSet.js: -------------------------------------------------------------------------------- 1 | import { Set } from 'immutable' 2 | export default function isImmutableSet(data) { 3 | return Set.isSet(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableSetSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function isImmutableSetSeq(data) { 3 | return data instanceof Seq.Set 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isImmutableStack.js: -------------------------------------------------------------------------------- 1 | import { Stack } from 'immutable' 2 | export default function isImmutableStack(data) { 3 | return Stack.isStack(data) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isIndex.js: -------------------------------------------------------------------------------- 1 | import { MAX_SAFE_INTEGER } from './constants' 2 | import { reIsUint } from './regex' 3 | 4 | export default function isIndex(value, length) { 5 | length = length == null ? MAX_SAFE_INTEGER : length 6 | return !!length && 7 | (typeof value == 'number' || reIsUint.test(value)) && 8 | (value > -1 && value % 1 == 0 && value < length) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/isIndexed.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | import hasKey from './hasKey' 3 | import isFunction from './isFunction' 4 | import isImmutable from './isImmutable' 5 | 6 | export default function isIndexed(data) { 7 | return isImmutable(data) 8 | ? Iterable.isIndexed(data) 9 | : hasKey(data, 'length') && !isFunction(data) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/isIterable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | import { contextSymbolIterator } from './context' 3 | import hasKey from './hasKey' 4 | import isImmutable from './isImmutable' 5 | import isObject from './isObject' 6 | 7 | export default function isIterable(data) { 8 | if (isImmutable(data)) { 9 | return Iterable.isIterable(data) 10 | } 11 | return hasKey(data, 'length') || isObject(data) || hasKey(data, contextSymbolIterator) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/isIterateeCall.js: -------------------------------------------------------------------------------- 1 | import get from './get' 2 | import isEqual from './isEqual' 3 | import isObject from './isObject' 4 | 5 | export default function isIterateeCall(value, index, object) { 6 | if (!isObject(object)) { 7 | return false 8 | } 9 | return isEqual(get(object, index), value) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/isKey.js: -------------------------------------------------------------------------------- 1 | import { _Object } from './context' 2 | import { reIsDeepProp, reIsPlainProp } from './regex' 3 | import isArray from './isArray' 4 | import isSymbol from './isSymbol' 5 | 6 | export default function isKey(value, object) { 7 | if (isArray(value)) { 8 | return false 9 | } 10 | const type = typeof value 11 | if (type == 'number' || type == 'symbol' || type == 'boolean' || 12 | value == null || isSymbol(value)) { 13 | return true 14 | } 15 | return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 16 | (object != null && value in _Object(object)) 17 | } 18 | -------------------------------------------------------------------------------- /src/core/isKeyable.js: -------------------------------------------------------------------------------- 1 | export default function isKeyable(value) { 2 | const type = typeof value 3 | return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 4 | ? (value !== '__proto__') 5 | : (value === null) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/isKeyed.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | import isImmutable from './isImmutable' 3 | import isObject from './isObject' 4 | 5 | export default function isKeyed(data) { 6 | return isImmutable(data) 7 | ? Iterable.isKeyed(data) 8 | : isObject(data) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/isLength.js: -------------------------------------------------------------------------------- 1 | import { MAX_SAFE_INTEGER } from './constants' 2 | 3 | export default function isLength(data) { 4 | return typeof data == 'number' && 5 | data > -1 && data % 1 == 0 && data <= MAX_SAFE_INTEGER 6 | } 7 | -------------------------------------------------------------------------------- /src/core/isMatch.js: -------------------------------------------------------------------------------- 1 | import { baseIsMatch } from './base' 2 | import { getMatchData } from './util' 3 | 4 | export default function isMatch(object, source) { 5 | return object === source || baseIsMatch(object, source, getMatchData(source)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/isMutable.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | 3 | export default function isMutable(value) { 4 | return !isImmutable(value) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/isNative.js: -------------------------------------------------------------------------------- 1 | import { baseIsNative } from './base' 2 | import { CORE_ERROR_TEXT } from './constants' 3 | import { isMaskable } from './util' 4 | 5 | export default function isNative(value) { 6 | if (isMaskable(value)) { 7 | throw new Error(CORE_ERROR_TEXT) 8 | } 9 | return baseIsNative(value) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/isNil.js: -------------------------------------------------------------------------------- 1 | export default function isNil(data) { 2 | return data == null 3 | } 4 | -------------------------------------------------------------------------------- /src/core/isNumber.js: -------------------------------------------------------------------------------- 1 | import { NUMBER_TAG } from './constants' 2 | import getTag from './util/getTag' 3 | import isObjectLike from './isObjectLike' 4 | 5 | export default function isNumber(value) { 6 | return typeof value == 'number' || 7 | (isObjectLike(value) && getTag(value) == NUMBER_TAG) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/isObject.js: -------------------------------------------------------------------------------- 1 | export default function isObject(value) { 2 | const type = typeof value 3 | return value != null && (type == 'object' || type == 'function') 4 | } 5 | -------------------------------------------------------------------------------- /src/core/isObjectLike.js: -------------------------------------------------------------------------------- 1 | export default function isObjectLike(value) { 2 | return value != null && typeof value == 'object' 3 | } 4 | -------------------------------------------------------------------------------- /src/core/isOrdered.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | import hasKey from './hasKey' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function isOrdered(data) { 6 | return isImmutable(data) 7 | ? Iterable.isOrdered(data) 8 | : hasKey(data, 'length') 9 | } 10 | -------------------------------------------------------------------------------- /src/core/isPrototype.js: -------------------------------------------------------------------------------- 1 | import { objectProto } from './context' 2 | 3 | export default function isPrototype(data) { 4 | const Ctor = data && data.constructor 5 | const proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto 6 | return data === proto 7 | } 8 | -------------------------------------------------------------------------------- /src/core/isString.js: -------------------------------------------------------------------------------- 1 | import { STRING_TAG } from './constants' 2 | import getTag from './util/getTag' 3 | import isArray from './isArray' 4 | 5 | export default function isString(value) { 6 | const type = typeof value 7 | return type == 'string' || (type == 'object' && value != null && !isArray(value) && getTag(value) == STRING_TAG) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/isSymbol.js: -------------------------------------------------------------------------------- 1 | import { SYMBOL_TAG } from './constants' 2 | import getTag from './util/getTag' 3 | 4 | export default function isSymbol(data) { 5 | const type = typeof data 6 | return type == 'symbol' || (type == 'object' && data != null && getTag(data) === SYMBOL_TAG) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/iterable.js: -------------------------------------------------------------------------------- 1 | import toIterable from './toIterable' 2 | 3 | export default function iterable(data) { 4 | return toIterable(data) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/iteratee.js: -------------------------------------------------------------------------------- 1 | import { baseIteratee } from './base' 2 | import cloneDeep from './cloneDeep' 3 | 4 | export default function iteratee(func) { 5 | return baseIteratee(typeof func == 'function' ? func : cloneDeep(func)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/iterator.js: -------------------------------------------------------------------------------- 1 | import { Symbol } from './context' 2 | import isObject from './isObject' 3 | 4 | const emptyIterator = { next: () => ({done: true})} 5 | 6 | export default function iterator(data) { 7 | return isObject(data) ? data[Symbol.iterator]() : emptyIterator 8 | } 9 | -------------------------------------------------------------------------------- /src/core/join.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function join(data, seperator = ',') { 5 | return isImmutable(data) 6 | ? data.join(seperator) 7 | : _.join(data, seperator) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/keys.js: -------------------------------------------------------------------------------- 1 | import { baseKeys } from './base' 2 | 3 | export default function keys(data) { 4 | return baseKeys(data) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/last.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function last(data) { 5 | return isImmutable(data) 6 | ? data.last() 7 | : _.last(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/lastIndexOf.js: -------------------------------------------------------------------------------- 1 | import { baseLastIndexOf } from './base' 2 | import { nativeMax, nativeMin } from './native' 3 | import count from './count' 4 | import isIndexed from './isIndexed' 5 | import isOrdered from './isOrdered' 6 | import toIndexed from './toIndexed' 7 | import toInteger from './toInteger' 8 | 9 | export default function lastIndexOf(data, value, fromIndex) { 10 | let indexed = data 11 | if (!isIndexed(data)) { 12 | if (!isOrdered(data)) { 13 | return -1 14 | } 15 | indexed = toIndexed(data) 16 | } 17 | const length = count(indexed) 18 | let index = length 19 | if (fromIndex !== undefined) { 20 | index = toInteger(fromIndex) 21 | index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1) 22 | } 23 | return baseLastIndexOf(indexed, value, index) 24 | } 25 | -------------------------------------------------------------------------------- /src/core/map.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import iteratee from './iteratee' 4 | 5 | export default function map(data, _iteratee) { 6 | _iteratee = iteratee(_iteratee) 7 | return isImmutable(data) 8 | ? data.map(_iteratee) 9 | : _.map(data, _iteratee) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/matches.js: -------------------------------------------------------------------------------- 1 | import { baseMatches } from './base' 2 | import cloneDeep from './cloneDeep' 3 | 4 | export default function matches(source) { 5 | return baseMatches(cloneDeep(source)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/matchesProperty.js: -------------------------------------------------------------------------------- 1 | import { baseMatchesProperty } from './base' 2 | import cloneDeep from './cloneDeep' 3 | 4 | export default function matchesProperty(path, srcValue) { 5 | return baseMatchesProperty(path, cloneDeep(srcValue)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/memoize.js: -------------------------------------------------------------------------------- 1 | import { MapCache } from './cache' 2 | import { FUNC_ERROR_TEXT } from './constants' 3 | 4 | export default function memoize(func, resolver, Cache) { 5 | if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 6 | throw new TypeError(FUNC_ERROR_TEXT) 7 | } 8 | const memoized = function(...args) { 9 | const key = resolver ? resolver.apply(this, args) : args[0] 10 | const { cache } = memoized 11 | 12 | if (cache.has(key)) { 13 | return cache.get(key) 14 | } 15 | const result = func.apply(this, args) 16 | memoized.cache = cache.set(key, result) || cache 17 | return result 18 | } 19 | memoized.cache = new (Cache || memoize.Cache || MapCache) 20 | return memoized 21 | } 22 | -------------------------------------------------------------------------------- /src/core/merge.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { mapImmutable, mapMutable } from './helpers' 3 | import isImmutable from './isImmutable' 4 | 5 | export default function merge(data, ...args) { 6 | return isImmutable(data) 7 | ? data.mergeDeep(...mapImmutable(args)) 8 | : _.merge(data, ...mapMutable(args)) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/mergeAt.js: -------------------------------------------------------------------------------- 1 | import get from './get' 2 | import merge from './merge' 3 | import set from './set' 4 | import size from './size' 5 | 6 | export default function mergeAt(data, path, ...args) { 7 | if (size(path > 0)) { 8 | return set(data, path, merge(get(data, path), ...args)) 9 | } 10 | return merge(data, ...args) 11 | } 12 | -------------------------------------------------------------------------------- /src/core/mu.js: -------------------------------------------------------------------------------- 1 | export { default } from './mutable' 2 | -------------------------------------------------------------------------------- /src/core/mutable.js: -------------------------------------------------------------------------------- 1 | import toMutable from './toMutable' 2 | 3 | export default function mutable(data) { 4 | return toMutable(data) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/mutations/index.js: -------------------------------------------------------------------------------- 1 | export { default as mutationPush } from './mutationPush' 2 | export { default as mutationPushAll } from './mutationPushAll' 3 | -------------------------------------------------------------------------------- /src/core/mutations/mutationPush.js: -------------------------------------------------------------------------------- 1 | export default function mutationPush(data, value) { 2 | data.push(value) 3 | return data 4 | } 5 | -------------------------------------------------------------------------------- /src/core/mutations/mutationPushAll.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function mutationPushAll(data, values) { 5 | let index = -1 6 | const length = count(values) 7 | 8 | while (++index < length) { 9 | data.push(getKey(values, index)) 10 | } 11 | return data 12 | } 13 | -------------------------------------------------------------------------------- /src/core/native/index.js: -------------------------------------------------------------------------------- 1 | export { default as nativeCreate } from './nativeCreate' 2 | export { default as nativeDefineProperty } from './nativeDefineProperty' 3 | export { default as nativeFuncToString } from './nativeFuncToString' 4 | export { default as nativeGetSymbols } from './nativeGetSymbols' 5 | export { default as nativeKeys } from './nativeKeys' 6 | export { default as nativeMax } from './nativeMax' 7 | export { default as nativeMin } from './nativeMin' 8 | export { default as nativeObjectToString } from './nativeObjectToString' 9 | export { default as nativeSymbolToString } from './nativeSymbolToString' 10 | export { default as nativeSymbolValueOf } from './nativeSymbolValueOf' 11 | 12 | export * from './native' 13 | -------------------------------------------------------------------------------- /src/core/native/native.js: -------------------------------------------------------------------------------- 1 | import { context, Symbol } from '../context' 2 | import getNative from '../util/getNative' 3 | 4 | const DataView = getNative(context, 'DataView') 5 | const Map = getNative(context, 'Map') 6 | const Promise = getNative(context, 'Promise') 7 | const Set = getNative(context, 'Set') 8 | const WeakMap = getNative(context, 'WeakMap') 9 | 10 | const symbolProto = Symbol ? Symbol.prototype : undefined 11 | 12 | export { 13 | DataView, 14 | Map, 15 | Promise, 16 | Set, 17 | WeakMap, 18 | 19 | symbolProto 20 | } 21 | -------------------------------------------------------------------------------- /src/core/native/nativeCreate.js: -------------------------------------------------------------------------------- 1 | import { _Object } from '../context' 2 | import getNative from '../util/getNative' 3 | 4 | const nativeCreate = getNative(_Object, 'create') 5 | export default nativeCreate 6 | -------------------------------------------------------------------------------- /src/core/native/nativeDefineProperty.js: -------------------------------------------------------------------------------- 1 | import { _Object } from '../context' 2 | import getNative from '../util/getNative' 3 | 4 | const nativeDefineProperty = (function() { 5 | try { 6 | const func = getNative(_Object, 'defineProperty') 7 | func({}, '', {}) 8 | return func 9 | } catch (e) {} // eslint-disable-line no-empty 10 | }()) 11 | export default nativeDefineProperty 12 | -------------------------------------------------------------------------------- /src/core/native/nativeFuncToString.js: -------------------------------------------------------------------------------- 1 | import { funcProto } from '../context' 2 | const { toString: nativeFuncToString } = funcProto 3 | export default nativeFuncToString 4 | -------------------------------------------------------------------------------- /src/core/native/nativeGetSymbols.js: -------------------------------------------------------------------------------- 1 | import { _Object } from '../context' 2 | const nativeGetSymbols = _Object.getOwnPropertySymbols 3 | export default nativeGetSymbols 4 | -------------------------------------------------------------------------------- /src/core/native/nativeKeys.js: -------------------------------------------------------------------------------- 1 | import overArg from '../overArg' 2 | import { _Object } from '../context' 3 | const nativeKeys = overArg(_Object.keys, _Object) 4 | export default nativeKeys 5 | -------------------------------------------------------------------------------- /src/core/native/nativeMax.js: -------------------------------------------------------------------------------- 1 | import { Math } from '../context' 2 | const nativeMax = Math.max 3 | export default nativeMax 4 | -------------------------------------------------------------------------------- /src/core/native/nativeMin.js: -------------------------------------------------------------------------------- 1 | import { Math } from '../context' 2 | const nativeMin = Math.min 3 | export default nativeMin 4 | -------------------------------------------------------------------------------- /src/core/native/nativeObjectToString.js: -------------------------------------------------------------------------------- 1 | import { objectProto } from '../context' 2 | const { toString: nativeObjectToString } = objectProto 3 | export default nativeObjectToString 4 | -------------------------------------------------------------------------------- /src/core/native/nativeSymbolToString.js: -------------------------------------------------------------------------------- 1 | import { symbolProto } from './native' 2 | const nativeSymbolToString = symbolProto ? symbolProto.toString : undefined 3 | export default nativeSymbolToString 4 | -------------------------------------------------------------------------------- /src/core/native/nativeSymbolValueOf.js: -------------------------------------------------------------------------------- 1 | import { symbolProto } from './native' 2 | const nativeSymbolValueOf = symbolProto ? symbolProto.valueOf : undefined 3 | export default nativeSymbolValueOf 4 | -------------------------------------------------------------------------------- /src/core/negate.js: -------------------------------------------------------------------------------- 1 | import { FUNC_ERROR_TEXT } from './constants' 2 | 3 | export default function negate(predicate) { 4 | if (typeof predicate != 'function') { 5 | throw new TypeError(FUNC_ERROR_TEXT) 6 | } 7 | return function(...args) { 8 | return !predicate.apply(this, args) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/core/node/index.js: -------------------------------------------------------------------------------- 1 | export * from './node' 2 | export * as util from './util' 3 | -------------------------------------------------------------------------------- /src/core/node/node.js: -------------------------------------------------------------------------------- 1 | import { freeProcess } from '../free' 2 | 3 | const nodeUtil = (function() { 4 | try { 5 | return freeProcess && freeProcess.binding && freeProcess.binding('util') 6 | } catch (e) {} // eslint-disable-line no-empty 7 | }()) 8 | 9 | /* Node.js helper references. */ 10 | const nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer 11 | const nodeIsDate = nodeUtil && nodeUtil.isDate 12 | const nodeIsMap = nodeUtil && nodeUtil.isMap 13 | const nodeIsRegExp = nodeUtil && nodeUtil.isRegExp 14 | const nodeIsSet = nodeUtil && nodeUtil.isSet 15 | const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray 16 | 17 | export { 18 | nodeUtil, 19 | nodeIsArrayBuffer, 20 | nodeIsDate, 21 | nodeIsMap, 22 | nodeIsRegExp, 23 | nodeIsSet, 24 | nodeIsTypedArray 25 | } 26 | -------------------------------------------------------------------------------- /src/core/node/util/index.js: -------------------------------------------------------------------------------- 1 | export { default as nodeUtil } from './nodeUtil' 2 | -------------------------------------------------------------------------------- /src/core/node/util/nodeUtil.js: -------------------------------------------------------------------------------- 1 | import { freeProcess } from '../../free' 2 | 3 | const nodeUtil = (function() { 4 | try { 5 | return freeProcess && freeProcess.binding && freeProcess.binding('util') 6 | } catch (e) {} // eslint-disable-line no-empty 7 | }()) 8 | export default nodeUtil 9 | -------------------------------------------------------------------------------- /src/core/object/index.js: -------------------------------------------------------------------------------- 1 | export { default as objectKeys } from './objectKeys' 2 | export { default as objectToString } from './objectToString' 3 | -------------------------------------------------------------------------------- /src/core/object/objectKeys.js: -------------------------------------------------------------------------------- 1 | import { _Object, contextHasOwnProperty } from '../context' 2 | import nativeKeys from '../native/nativeKeys' 3 | import isPrototype from '../isPrototype' 4 | 5 | 6 | export default function objectKeys(object) { 7 | if (!isPrototype(object)) { 8 | return nativeKeys(object) 9 | } 10 | const result = [] 11 | for (const key in _Object(object)) { 12 | if (contextHasOwnProperty.call(object, key) && key != 'constructor') { 13 | result.push(key) 14 | } 15 | } 16 | return result 17 | } 18 | -------------------------------------------------------------------------------- /src/core/object/objectToString.js: -------------------------------------------------------------------------------- 1 | import nativeObjectToString from '../native/nativeObjectToString' 2 | 3 | export default function objectToString(object) { 4 | return nativeObjectToString.call(object) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/omit.js: -------------------------------------------------------------------------------- 1 | import { baseOmit } from './base' 2 | import flatten from './flatten' 3 | 4 | export default function omit(data, ...paths) { 5 | return data == null ? {} : baseOmit(data, flatten(paths)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/omitBy.js: -------------------------------------------------------------------------------- 1 | import { getAllKeys } from './util' 2 | import iteratee from './iteratee' 3 | import { baseOmitBy } from './base' 4 | import map from './map' 5 | 6 | export default function omitBy(data, predicate) { 7 | if (data == null) { 8 | return {} 9 | } 10 | 11 | const props = map(getAllKeys(data), (prop) => [prop]) 12 | predicate = iteratee(predicate) 13 | return baseOmitBy(data, props, (value, path) => predicate(value, path[0])) 14 | } 15 | -------------------------------------------------------------------------------- /src/core/overArg.js: -------------------------------------------------------------------------------- 1 | export default function overArg(func, transform) { 2 | return function(arg) { 3 | return func(transform(arg)) 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/core/path.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | export default _.toPath 3 | -------------------------------------------------------------------------------- /src/core/pick.js: -------------------------------------------------------------------------------- 1 | import { basePick } from './base' 2 | import flatten from './flatten' 3 | 4 | export default function pick(data, ...paths) { 5 | return data == null ? {} : basePick(data, flatten(paths)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/pickBy.js: -------------------------------------------------------------------------------- 1 | import { getAllKeys } from './util' 2 | import iteratee from './iteratee' 3 | import { basePickBy } from './base' 4 | import map from './map' 5 | 6 | export default function pickBy(data, predicate) { 7 | if (data == null) { 8 | return {} 9 | } 10 | 11 | const props = map(getAllKeys(data), (prop) => [prop]) 12 | predicate = iteratee(predicate) 13 | return basePickBy(data, props, (value, path) => predicate(value, path[0])) 14 | } 15 | -------------------------------------------------------------------------------- /src/core/pop.js: -------------------------------------------------------------------------------- 1 | import count from './count' 2 | import isOrdered from './isOrdered' 3 | import slice from './slice' 4 | 5 | export default function pop(data) { 6 | if (!isOrdered(data)) { 7 | return data 8 | } 9 | const length = count(data) 10 | const endIndex = length > 0 ? length - 1 : 0 11 | return slice(data, 0, endIndex) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/predicates/falsy.js: -------------------------------------------------------------------------------- 1 | export default function falsy(value) { 2 | return !value 3 | } 4 | -------------------------------------------------------------------------------- /src/core/predicates/index.js: -------------------------------------------------------------------------------- 1 | export { default as falsy } from './falsy' 2 | export { default as truthy } from './truthy' 3 | -------------------------------------------------------------------------------- /src/core/predicates/truthy.js: -------------------------------------------------------------------------------- 1 | export default function truthy(value) { 2 | return !!value 3 | } 4 | -------------------------------------------------------------------------------- /src/core/property.js: -------------------------------------------------------------------------------- 1 | import { baseProperty, basePropertyDeep } from './base' 2 | import isKey from './isKey' 3 | import toKey from './toKey' 4 | 5 | export default function property(path) { 6 | return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/propertyOf.js: -------------------------------------------------------------------------------- 1 | import { basePropertyOfDeep } from './base' 2 | 3 | export default function propertyOf(data) { 4 | return basePropertyOfDeep(data) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/protocols/Associative.js: -------------------------------------------------------------------------------- 1 | import extend from '../extend' 2 | import Function from '../types/Function' 3 | import Keyed from './Keyed' 4 | 5 | const Associative = extend(Keyed, { 6 | delete: Function, 7 | set: Function 8 | }) 9 | 10 | export default Associative 11 | -------------------------------------------------------------------------------- /src/core/protocols/Concatable.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Concatable = defprotocol({ 5 | concat: Function 6 | }) 7 | 8 | export default Concatable 9 | -------------------------------------------------------------------------------- /src/core/protocols/Counted.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Counted = defprotocol({ 5 | count: Function 6 | }) 7 | 8 | export default Counted 9 | -------------------------------------------------------------------------------- /src/core/protocols/Extendable.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Extendable = defprotocol({ 5 | extend: Function 6 | }) 7 | 8 | export default Extendable 9 | -------------------------------------------------------------------------------- /src/core/protocols/IPersistentCollection.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/protocols/IPersistentCollection.js -------------------------------------------------------------------------------- /src/core/protocols/IPersistentList.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const IPersistentList = defprotocol({ 5 | clear: Function, 6 | delete: Function, 7 | get: Function, 8 | has: Function, 9 | insert: Function, 10 | pop: Function, 11 | push: Function, 12 | set: Function, 13 | shift: Function, 14 | unshift: Function 15 | }) 16 | 17 | export default IPersistentList 18 | -------------------------------------------------------------------------------- /src/core/protocols/IPersistentMap.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const IPersistentMap = defprotocol({ 5 | clear: Function, 6 | delete: Function, 7 | entries: Function, 8 | forEach: Function, 9 | get: Function, 10 | has: Function, 11 | keys: Function, 12 | set: Function, 13 | values: Function 14 | }) 15 | 16 | export default IPersistentMap 17 | -------------------------------------------------------------------------------- /src/core/protocols/IPersistentSet.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const IPersistentSet = defprotocol({ 5 | add: Function, 6 | clear: Function, 7 | delete: Function, 8 | entries: Function, 9 | forEach: Function, 10 | has: Function, 11 | keys: Function, 12 | values: Function 13 | }) 14 | 15 | export default IPersistentSet 16 | -------------------------------------------------------------------------------- /src/core/protocols/IPersistentStack.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const IPersistentStack = defprotocol({ 5 | peek: Function, 6 | pop: Function, 7 | push: Function 8 | }) 9 | 10 | export default IPersistentStack 11 | -------------------------------------------------------------------------------- /src/core/protocols/Indexed.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/protocols/Indexed.js -------------------------------------------------------------------------------- /src/core/protocols/Inheriter.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Inheriter = defprotocol({ 5 | inherit: Function 6 | }) 7 | 8 | export default Inheriter 9 | -------------------------------------------------------------------------------- /src/core/protocols/Keyed.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Keyed = defprotocol({ 5 | get: Function, 6 | has: Function 7 | }) 8 | 9 | export default Keyed 10 | -------------------------------------------------------------------------------- /src/core/protocols/Reducable.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Reducable = defprotocol({ 5 | reduce: Function 6 | }) 7 | 8 | export default Reducable 9 | -------------------------------------------------------------------------------- /src/core/protocols/Sliceable.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Sliceable = defprotocol({ 5 | slice: Function 6 | }) 7 | 8 | export default Sliceable 9 | -------------------------------------------------------------------------------- /src/core/protocols/Stacked.js: -------------------------------------------------------------------------------- 1 | import defprotocol from '../defprotocol' 2 | import Function from '../types/Function' 3 | 4 | const Stacked = defprotocol({ 5 | pop: Function, 6 | push: Function 7 | }) 8 | 9 | export default Stacked 10 | -------------------------------------------------------------------------------- /src/core/protocols/__tests__/Keyed.test.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import { expect } from 'chai' 3 | import { Keyed } from '../' 4 | import Immutable from 'immutable' 5 | 6 | describe('Keyed', function() { 7 | 8 | it('is correctly detects values that implement Keyed protocol', function() { 9 | const data = { 10 | get: () => {}, 11 | has: () => {} 12 | } 13 | const dataMissing = { 14 | get: () => {} 15 | } 16 | const map = Immutable.Map({}) 17 | const list = Immutable.List([]) 18 | const set = Immutable.Set([]) 19 | expect(Keyed.is(data)).to.be.true 20 | expect(Keyed.is(dataMissing)).to.be.false 21 | expect(Keyed.is({})).to.be.false 22 | expect(Keyed.is(map)).to.be.true 23 | expect(Keyed.is(list)).to.be.true 24 | expect(Keyed.is(set)).to.be.true 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /src/core/protocols/index.js: -------------------------------------------------------------------------------- 1 | export { default as Associative } from './Associative' 2 | export { default as Concatable } from './Concatable' 3 | export { default as Counted } from './Counted' 4 | export { default as Extendable } from './Extendable' 5 | export { default as Indexed } from './Indexed' 6 | export { default as Inheriter } from './Inheriter' 7 | export { default as IPersistentList } from './IPersistentList' 8 | export { default as IPersistentMap } from './IPersistentMap' 9 | export { default as IPersistentSet } from './IPersistentSet' 10 | export { default as IPersistentStack } from './IPersistentStack' 11 | export { default as Keyed } from './Keyed' 12 | export { default as Reducable } from './Reducable' 13 | export { default as Sliceable } from './Sliceable' 14 | export { default as Stacked } from './Stacked' 15 | -------------------------------------------------------------------------------- /src/core/pull.js: -------------------------------------------------------------------------------- 1 | import pullAll from './pullAll' 2 | export default function pull(data, ...values) { 3 | return pullAll(data, values) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/pullAll.js: -------------------------------------------------------------------------------- 1 | import { basePullAll } from './base' 2 | import { getIteratee } from './util' 3 | import isOrdered from './isOrdered' 4 | 5 | export default function pullAll(data, values, iteratee, comparator) { 6 | //TODO BRN: Seems like values could be anything that has values (array, object, iterable, etc) 7 | return (isOrdered(data) && isOrdered(values)) 8 | ? basePullAll(data, values, iteratee ? getIteratee(iteratee) : undefined, comparator) 9 | : data 10 | } 11 | -------------------------------------------------------------------------------- /src/core/pullAllBy.js: -------------------------------------------------------------------------------- 1 | import pullAll from './pullAll' 2 | export default function pullAllBy(data, values, iteratee) { 3 | return pullAll(data, values, iteratee) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/pullAllRight.js: -------------------------------------------------------------------------------- 1 | import { basePullAll } from './base' 2 | import { getIteratee } from './util' 3 | import isOrdered from './isOrdered' 4 | 5 | export default function pullAllRight(data, values, iteratee, comparator) { 6 | return (isOrdered(data) && isOrdered(values)) 7 | ? basePullAll(data, values, iteratee ? getIteratee(iteratee) : undefined, comparator, true) 8 | : data 9 | } 10 | -------------------------------------------------------------------------------- /src/core/pullAllWith.js: -------------------------------------------------------------------------------- 1 | import pullAll from './pullAll' 2 | export default function pullAllWith(data, values, comparator) { 3 | return pullAll(data, values, undefined, comparator) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/pullRight.js: -------------------------------------------------------------------------------- 1 | import pullAllRight from './pullAllRight' 2 | export default function pullRight(data, ...values) { 3 | return pullAllRight(data, values) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/push.js: -------------------------------------------------------------------------------- 1 | import { Stacked } from './protocols' 2 | import { withMutations } from './with' 3 | import concat from './concat' 4 | import isNil from './isNil' 5 | 6 | const pushValues = withMutations((data, values) => { 7 | data.push(...values) 8 | return data 9 | }) 10 | 11 | export default function push(data, ...values) { 12 | if (isNil(data)) { 13 | data = [] 14 | } 15 | if (Stacked.is(data)) { 16 | return pushValues(data, values) 17 | } 18 | return concat(data, values) 19 | } 20 | -------------------------------------------------------------------------------- /src/core/pushAt.js: -------------------------------------------------------------------------------- 1 | import assoc from './assoc' 2 | import get from './get' 3 | import isImmutable from './isImmutable' 4 | import push from './push' 5 | import toImmutable from './toImmutable' 6 | 7 | export default function pushAt(data, path, value) { 8 | const result = get(data, path, isImmutable(data) ? toImmutable([]) : []) 9 | return assoc(data, path, push(result, value)) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/reduce.js: -------------------------------------------------------------------------------- 1 | import { baseEach, baseReduce } from './base' 2 | import iteratee from './iteratee' 3 | 4 | export default function reduce(data, _iteratee, accumulator) { 5 | const initAccum = arguments.length < 3 6 | return baseReduce(data, iteratee(_iteratee), accumulator, initAccum, baseEach) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/reduceReducers.js: -------------------------------------------------------------------------------- 1 | import reduce from './reduce' 2 | export default function reduceReducers(...reducers) { 3 | return (previous, ...args) => 4 | reduce(reducers, 5 | (current, reducer) => reducer(current, ...args), 6 | previous 7 | ) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/reduceReducersRight.js: -------------------------------------------------------------------------------- 1 | import reduceRight from './reduceRight' 2 | export default function reduceReducersRight(...reducers) { 3 | return (previous, ...args) => 4 | reduceRight(reducers, 5 | (current, reducer) => reducer(current, ...args), 6 | previous 7 | ) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/reduceRight.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import iteratee from './iteratee' 4 | 5 | export default function reduceRight(data, _iteratee, accumulator) { 6 | const initAccum = arguments.length < 3 7 | _iteratee = iteratee(_iteratee) 8 | if (isImmutable(data)) { 9 | return data.reduceRight(_iteratee, accumulator) 10 | } 11 | if (initAccum) { 12 | return _.reduceRight(data, _iteratee) 13 | } 14 | return _.reduceRight(data, _iteratee, accumulator) 15 | } 16 | -------------------------------------------------------------------------------- /src/core/regex/index.js: -------------------------------------------------------------------------------- 1 | export { default as reEscapeChar } from './reEscapeChar' 2 | export { default as reHasUnicode } from './reHasUnicode' 3 | export { default as reIsBadHex } from './reIsBadHex' 4 | export { default as reIsBinary } from './reIsBinary' 5 | export { default as reIsDeepProp } from './reIsDeepProp' 6 | export { default as reIsHostCtor } from './reIsHostCtor' 7 | export { default as reIsNative } from './reIsNative' 8 | export { default as reIsOctal } from './reIsOctal' 9 | export { default as reIsPlainProp } from './reIsPlainProp' 10 | export { default as reIsUint } from './reIsUint' 11 | export { default as reLeadingDot } from './reLeadingDot' 12 | export { default as rePropName } from './rePropName' 13 | export { default as reRegExpChar } from './reRegExpChar' 14 | export { default as reTrim } from './reTrim' 15 | export { default as reUnicode } from './reUnicode' 16 | -------------------------------------------------------------------------------- /src/core/regex/reEscapeChar.js: -------------------------------------------------------------------------------- 1 | const reEscapeChar = /\\(\\)?/g 2 | export default reEscapeChar 3 | -------------------------------------------------------------------------------- /src/core/regex/reHasUnicode.js: -------------------------------------------------------------------------------- 1 | /** Used to compose unicode character classes. */ 2 | const rsAstralRange = '\\ud800-\\udfff' 3 | const rsComboMarksRange = '\\u0300-\\u036f' 4 | const reComboHalfMarksRange = '\\ufe20-\\ufe2f' 5 | const rsComboSymbolsRange = '\\u20d0-\\u20ff' 6 | const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange 7 | const rsVarRange = '\\ufe0e\\ufe0f' 8 | 9 | /** Used to compose unicode capture groups. */ 10 | const rsZWJ = '\\u200d' 11 | 12 | /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 13 | const reHasUnicode = RegExp(`[${rsZWJ + rsAstralRange + rsComboRange + rsVarRange}]`) 14 | 15 | export default reHasUnicode 16 | -------------------------------------------------------------------------------- /src/core/regex/reIsBadHex.js: -------------------------------------------------------------------------------- 1 | const reIsBadHex = /^[-+]0x[0-9a-f]+$/i 2 | export default reIsBadHex 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsBinary.js: -------------------------------------------------------------------------------- 1 | const reIsBinary = /^0b[01]+$/i 2 | export default reIsBinary 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsDeepProp.js: -------------------------------------------------------------------------------- 1 | const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/ 2 | export default reIsDeepProp 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsHostCtor.js: -------------------------------------------------------------------------------- 1 | const reIsHostCtor = /^\[object .+?Constructor\]$/ 2 | export default reIsHostCtor 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsNative.js: -------------------------------------------------------------------------------- 1 | import { RegExp, contextHasOwnProperty } from '../context' 2 | import nativeFuncToString from '../native/nativeFuncToString' 3 | import reRegExpChar from './reRegExpChar' 4 | 5 | const reIsNative = RegExp('^' + 6 | nativeFuncToString.call(contextHasOwnProperty).replace(reRegExpChar, '\\$&') 7 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 8 | ) 9 | export default reIsNative 10 | -------------------------------------------------------------------------------- /src/core/regex/reIsOctal.js: -------------------------------------------------------------------------------- 1 | const reIsOctal = /^0o[0-7]+$/i 2 | export default reIsOctal 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsPlainProp.js: -------------------------------------------------------------------------------- 1 | const reIsPlainProp = /^\w*$/ 2 | export default reIsPlainProp 3 | -------------------------------------------------------------------------------- /src/core/regex/reIsUint.js: -------------------------------------------------------------------------------- 1 | const reIsUint = /^(?:0|[1-9]\d*)$/ 2 | export default reIsUint 3 | -------------------------------------------------------------------------------- /src/core/regex/reLeadingDot.js: -------------------------------------------------------------------------------- 1 | const reLeadingDot = /^\./ 2 | export default reLeadingDot 3 | -------------------------------------------------------------------------------- /src/core/regex/rePropName.js: -------------------------------------------------------------------------------- 1 | const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g 2 | export default rePropName 3 | -------------------------------------------------------------------------------- /src/core/regex/reRegExpChar.js: -------------------------------------------------------------------------------- 1 | const reRegExpChar = /[\\^$.*+?()[\]{}|]/g 2 | export default reRegExpChar 3 | -------------------------------------------------------------------------------- /src/core/regex/reTrim.js: -------------------------------------------------------------------------------- 1 | const reTrim = /^\s+|\s+$/g 2 | export default reTrim 3 | -------------------------------------------------------------------------------- /src/core/reject.js: -------------------------------------------------------------------------------- 1 | export { default } from './filterNot' 2 | -------------------------------------------------------------------------------- /src/core/reverse.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function reverse(data) { 5 | return isImmutable(data) 6 | ? data.reverse() 7 | : _.reverse(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/satisfies.js: -------------------------------------------------------------------------------- 1 | import defn from './defn' 2 | const satisfies = defn((protocol, value) => protocol.is(value)) 3 | export default satisfies 4 | -------------------------------------------------------------------------------- /src/core/select.js: -------------------------------------------------------------------------------- 1 | import at from './at' 2 | export default function select(paths, selector) { 3 | return (data, ...rest) => selector(...at(data, paths), ...rest) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/set.js: -------------------------------------------------------------------------------- 1 | import { baseSet } from './base' 2 | import setKey from './setKey' 3 | 4 | export default function set(data, path, value) { 5 | return data == null ? data : baseSet(data, path, value, setKey) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/setWith.js: -------------------------------------------------------------------------------- 1 | import { baseSet } from './base' 2 | import setKey from './setKey' 3 | 4 | export default function setWith(data, path, value, customizer) { 5 | return data == null ? data : baseSet(data, path, value, setKey, { customizer }) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/shift.js: -------------------------------------------------------------------------------- 1 | import count from './count' 2 | import slice from './slice' 3 | 4 | export default function shift(data, number) { 5 | return slice(data, number, count(data)) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/size.js: -------------------------------------------------------------------------------- 1 | export default from './count' 2 | -------------------------------------------------------------------------------- /src/core/slice.js: -------------------------------------------------------------------------------- 1 | import arraySlice from './array/arraySlice' 2 | import Sliceable from './protocols/Sliceable' 3 | import count from './count' 4 | import isArray from './isArray' 5 | import toInteger from './toInteger' 6 | 7 | export default function slice(data, start, end) { 8 | const length = count(data) 9 | start = start == null ? 0 : toInteger(start) 10 | end = end === undefined ? length : toInteger(end) 11 | if (end === length && start === 0) { 12 | return data 13 | } 14 | if (!length) { 15 | return data 16 | } 17 | if (!isArray(data)) { 18 | if (Sliceable.is(data)) { 19 | return data.slice(start, end) 20 | } 21 | throw new Error('Expected Sliceable data type or Array') 22 | } 23 | return arraySlice(data, start, end) 24 | } 25 | -------------------------------------------------------------------------------- /src/core/some.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import iteratee from './iteratee' 4 | 5 | export default function some(data, predicate) { 6 | predicate = iteratee(predicate) 7 | return isImmutable(data) 8 | ? data.some(predicate) 9 | : _.some(data, predicate) 10 | } 11 | -------------------------------------------------------------------------------- /src/core/sortBy.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isFunction from './isFunction' 3 | import isImmutable from './isImmutable' 4 | import property from './property' 5 | 6 | export default function sortBy(data, iteratee) { 7 | if (!isFunction(iteratee)) { 8 | iteratee = property(iteratee) 9 | } 10 | return isImmutable(data) 11 | ? data.sortBy(iteratee) 12 | : _.sortBy(data, iteratee) 13 | } 14 | -------------------------------------------------------------------------------- /src/core/splice.js: -------------------------------------------------------------------------------- 1 | import concat from './concat' 2 | import count from './count' 3 | import slice from './slice' 4 | import toInteger from './toInteger' 5 | 6 | export default function splice(data, startIndex, removeNum, ...values) { 7 | startIndex = toInteger(startIndex) 8 | if (startIndex < 0) { 9 | startIndex = count(data) + startIndex 10 | } 11 | if (!removeNum || removeNum < 0) { 12 | removeNum = 0 13 | } 14 | return concat( 15 | slice(data, 0, startIndex), 16 | values, 17 | slice(data, startIndex + removeNum) 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /src/core/strict/index.js: -------------------------------------------------------------------------------- 1 | export { default as strictIndexOf } from './strictIndexOf' 2 | export { default as strictLastIndexOf } from './strictLastIndexOf' 3 | -------------------------------------------------------------------------------- /src/core/strict/strictIndexOf.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function strictIndexOf(indexed, value, fromIndex) { 5 | let index = fromIndex - 1 6 | const length = count(indexed) 7 | 8 | while (++index < length) { 9 | if (getKey(indexed, index) === value) { 10 | return index 11 | } 12 | } 13 | return -1 14 | } 15 | -------------------------------------------------------------------------------- /src/core/strict/strictLastIndexOf.js: -------------------------------------------------------------------------------- 1 | import getKey from '../getKey' 2 | 3 | export default function strictLastIndexOf(indexed, value, fromIndex) { 4 | let index = fromIndex + 1 5 | while (index--) { 6 | if (getKey(indexed, index) === value) { 7 | return index 8 | } 9 | } 10 | return index 11 | } 12 | -------------------------------------------------------------------------------- /src/core/stubArray.js: -------------------------------------------------------------------------------- 1 | export default function stubArray() { 2 | return [] 3 | } 4 | -------------------------------------------------------------------------------- /src/core/stubFalse.js: -------------------------------------------------------------------------------- 1 | export default function stubFalse() { 2 | return false 3 | } 4 | -------------------------------------------------------------------------------- /src/core/stubImmutableIndexedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function stubImmutableIndexedSeq() { 3 | return Seq.Indexed([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableIterable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | export default function stubImmutableIterable() { 3 | return Iterable([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableKeyedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function stubImmutableKeyedSeq() { 3 | return Seq.Keyed({}) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableList.js: -------------------------------------------------------------------------------- 1 | import { List } from 'immutable' 2 | export default function stubImmutableList() { 3 | return List([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableMap.js: -------------------------------------------------------------------------------- 1 | import { Map } from 'immutable' 2 | export default function stubImmutableMap() { 3 | return Map({}) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableOrderedMap.js: -------------------------------------------------------------------------------- 1 | import { OrderedMap } from 'immutable' 2 | export default function stubImmutableOrderedMap() { 3 | return OrderedMap({}) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableOrderedSet.js: -------------------------------------------------------------------------------- 1 | import { OrderedSet } from 'immutable' 2 | export default function stubImmutableOrderedSet() { 3 | return OrderedSet([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function stubImmutableSeq() { 3 | return Seq([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableSet.js: -------------------------------------------------------------------------------- 1 | import { Set } from 'immutable' 2 | export default function stubImmutableSet() { 3 | return Set([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableSetSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | export default function stubImmutableSetSeq() { 3 | return Seq.Set([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubImmutableStack.js: -------------------------------------------------------------------------------- 1 | import { Stack } from 'immutable' 2 | export default function stubImmutableStack() { 3 | return Stack([]) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/stubObject.js: -------------------------------------------------------------------------------- 1 | export default function stubObject() { 2 | return {} 3 | } 4 | -------------------------------------------------------------------------------- /src/core/stubString.js: -------------------------------------------------------------------------------- 1 | export default function stubString() { 2 | return '' 3 | } 4 | -------------------------------------------------------------------------------- /src/core/stubTrue.js: -------------------------------------------------------------------------------- 1 | export default function stubTrue() { 2 | return true 3 | } 4 | -------------------------------------------------------------------------------- /src/core/sym.js: -------------------------------------------------------------------------------- 1 | export { default } from './symbol' 2 | -------------------------------------------------------------------------------- /src/core/symbol.js: -------------------------------------------------------------------------------- 1 | import { Symbol } from './context' 2 | export default function symbol(value) { 3 | return Symbol(value) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/tail.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function tail(data) { 5 | return isImmutable(data) 6 | ? data.rest() 7 | : _.tail(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/take.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function take(data, count = 1) { 5 | return isImmutable(data) 6 | ? data.take(count) 7 | : _.take(data, count) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/takeLast.js: -------------------------------------------------------------------------------- 1 | export default from './takeRight' 2 | -------------------------------------------------------------------------------- /src/core/takeRight.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function takeRight(data, count = 1) { 5 | return isImmutable(data) 6 | ? data.takeLast(count) 7 | : _.takeRight(data, count) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/takeRightWhile.js: -------------------------------------------------------------------------------- 1 | //TODO BRN: Figure this out for immutable 2 | -------------------------------------------------------------------------------- /src/core/takeWhile.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function takeWhile(data, predicate = _.identity) { 5 | return isImmutable(data) 6 | ? data.takeWhile(predicate) 7 | : _.takeWhile(data, predicate) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/toArray.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function toArray(data) { 5 | return isImmutable(data) 6 | ? data.toArray() 7 | : _.toArray(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/toFinite.js: -------------------------------------------------------------------------------- 1 | import { INFINITY, MAX_INTEGER } from './constants' 2 | import toNumber from './toNumber' 3 | 4 | export default function toFinite(data) { 5 | if (!data) { 6 | return data === 0 ? data : 0 7 | } 8 | data = toNumber(data) 9 | if (data === INFINITY || data === -INFINITY) { 10 | const sign = (data < 0 ? -1 : 1) 11 | return sign * MAX_INTEGER 12 | } 13 | return data === data ? data : 0 14 | } 15 | -------------------------------------------------------------------------------- /src/core/toIm.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutable' 2 | -------------------------------------------------------------------------------- /src/core/toImIndexedSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableIndexedSeq' 2 | -------------------------------------------------------------------------------- /src/core/toImIterable.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableIterable' 2 | -------------------------------------------------------------------------------- /src/core/toImKeyedSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableKeyedSeq' 2 | -------------------------------------------------------------------------------- /src/core/toImList.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableList' 2 | -------------------------------------------------------------------------------- /src/core/toImMap.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableMap' 2 | -------------------------------------------------------------------------------- /src/core/toImOrderedMap.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableOrderedMap' 2 | -------------------------------------------------------------------------------- /src/core/toImOrderedSet.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableOrderedSet' 2 | -------------------------------------------------------------------------------- /src/core/toImSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableSeq' 2 | -------------------------------------------------------------------------------- /src/core/toImSet.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableSet' 2 | -------------------------------------------------------------------------------- /src/core/toImSetSeq.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableSetSeq' 2 | -------------------------------------------------------------------------------- /src/core/toImStack.js: -------------------------------------------------------------------------------- 1 | export { default } from './toImmutableStack' 2 | -------------------------------------------------------------------------------- /src/core/toImmutable.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | import Immutable from 'immutable' 3 | 4 | export default function toImmutable(data) { 5 | return isImmutable(data) 6 | ? data 7 | : Immutable.fromJS(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/toImmutableIndexedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableIndexedSeq from './isImmutableIndexedSeq' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableSeq from './toImmutableSeq' 8 | 9 | export default function toImmutableIndexedSeq(data) { 10 | if (isImmutableIndexedSeq(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toIndexedSeq() 14 | } else if (isString(data) || isArray(data)) { 15 | return Seq.Indexed(data) 16 | } else if (isObject(data)) { 17 | return toImmutableSeq(data).toIndexedSeq() 18 | } 19 | return Seq.Indexed() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableIterable.js: -------------------------------------------------------------------------------- 1 | import { Iterable } from 'immutable' 2 | import isImmutableIterable from './isImmutableIterable' 3 | 4 | export default function toImmutableIterable(data) { 5 | if (isImmutableIterable(data)) { 6 | return data 7 | } 8 | return Iterable(data) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/toImmutableKeyedSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableKeyedSeq from './isImmutableKeyedSeq' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableSeq from './toImmutableSeq' 8 | 9 | export default function toImmutableKeyedSeq(data) { 10 | if (isImmutableKeyedSeq(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toKeyedSeq() 14 | } else if (isString(data) || isArray(data)) { 15 | return toImmutableSeq(data).toKeyedSeq() 16 | } else if (isObject(data)) { 17 | return Seq.Keyed(data) 18 | } 19 | return Seq.Keyed() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableList.js: -------------------------------------------------------------------------------- 1 | import { List } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableList from './isImmutableList' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableList(data) { 10 | if (isImmutableList(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toList() 14 | } else if (isString(data) || isArray(data)) { 15 | return List(data) 16 | } else if (isObject(data)) { 17 | return toImmutableIterable(data).toList() 18 | } 19 | return List() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableMap.js: -------------------------------------------------------------------------------- 1 | import { Map } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableMap from './isImmutableMap' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableMap(data) { 10 | if (isImmutableMap(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toMap() 14 | } else if (isString(data) || isArray(data)) { 15 | return toImmutableIterable(data).toMap() 16 | } else if (isObject(data)) { 17 | return Map(data) 18 | } 19 | return Map() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableOrderedMap.js: -------------------------------------------------------------------------------- 1 | import { OrderedMap } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableOrderedMap from './isImmutableOrderedMap' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableOrderedMap(data) { 10 | if (isImmutableOrderedMap(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toOrderedMap() 14 | } else if (isString(data) || isArray(data)) { 15 | return toImmutableIterable(data).toOrderedMap() 16 | } else if (isObject(data)) { 17 | return OrderedMap(data) 18 | } 19 | return OrderedMap() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableOrderedSet.js: -------------------------------------------------------------------------------- 1 | import { OrderedSet } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableOrderedSet from './isImmutableOrderedSet' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableOrderedSet(data) { 10 | if (isImmutableOrderedSet(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toOrderedSet() 14 | } else if (isString(data) || isArray(data)) { 15 | return OrderedSet(data) 16 | } else if (isObject(data)) { 17 | return toImmutableIterable(data).toOrderedSet() 18 | } 19 | return OrderedSet() 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | import isImmutable from './isImmutable' 3 | import isImmutableSeq from './isImmutableSeq' 4 | 5 | export default function toImmutableSeq(data) { 6 | if (isImmutableSeq(data)) { 7 | return data 8 | } else if (isImmutable(data)) { 9 | return data.toSeq() 10 | } 11 | return Seq(data) 12 | } 13 | -------------------------------------------------------------------------------- /src/core/toImmutableSet.js: -------------------------------------------------------------------------------- 1 | import { Set } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableSet from './isImmutableSet' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableSet(data) { 10 | if (isImmutableSet(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toSet() 14 | } else if (isString(data) || isArray(data)) { 15 | return Set(data) 16 | } else if (isObject(data)) { 17 | return toImmutableIterable(data).toSet() 18 | } 19 | return Set(data) 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableSetSeq.js: -------------------------------------------------------------------------------- 1 | import { Seq } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableSetSeq from './isImmutableSetSeq' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableSeq from './toImmutableSeq' 8 | 9 | export default function toImmutableSetSeq(data) { 10 | if (isImmutableSetSeq(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toSetSeq() 14 | } else if (isString(data) || isArray(data)) { 15 | return Seq.Indexed(data) 16 | } else if (isObject(data)) { 17 | return toImmutableSeq(data).toSetSeq() 18 | } 19 | return Seq.Set(data) 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toImmutableStack.js: -------------------------------------------------------------------------------- 1 | import { Stack } from 'immutable' 2 | import isArray from './isArray' 3 | import isImmutable from './isImmutable' 4 | import isImmutableStack from './isImmutableStack' 5 | import isObject from './isObject' 6 | import isString from './isString' 7 | import toImmutableIterable from './toImmutableIterable' 8 | 9 | export default function toImmutableStack(data) { 10 | if (isImmutableStack(data)) { 11 | return data 12 | } else if (isImmutable(data)) { 13 | return data.toStack() 14 | } else if (isString(data) || isArray(data)) { 15 | return Stack(data) 16 | } else if (isObject(data)) { 17 | return toImmutableIterable(data).toStack() 18 | } 19 | return Stack(data) 20 | } 21 | -------------------------------------------------------------------------------- /src/core/toIndexed.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | import isIndexed from './isIndexed' 4 | 5 | export default function toIndexed(data) { 6 | if (isIndexed(data)) { 7 | return data 8 | } 9 | if (isImmutable(data)) { 10 | return data.toIndexedSeq() 11 | } 12 | if (_.isObject(data)) { 13 | return _.values(data) 14 | } 15 | return data 16 | } 17 | -------------------------------------------------------------------------------- /src/core/toInteger.js: -------------------------------------------------------------------------------- 1 | import toFinite from './toFinite' 2 | 3 | export default function toInteger(data) { 4 | const result = toFinite(data) 5 | const remainder = result % 1 6 | 7 | return result === result ? (remainder ? result - remainder : result) : 0 8 | } 9 | -------------------------------------------------------------------------------- /src/core/toIterable.js: -------------------------------------------------------------------------------- 1 | export default function toIterable(data) { 2 | return data 3 | } 4 | -------------------------------------------------------------------------------- /src/core/toKey.js: -------------------------------------------------------------------------------- 1 | import { INFINITY } from './constants' 2 | import isSymbol from './isSymbol' 3 | 4 | 5 | export default function toKey(value) { 6 | if (typeof value == 'string' || isSymbol(value)) { 7 | return value 8 | } 9 | const result = (value + '') 10 | return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result 11 | } 12 | -------------------------------------------------------------------------------- /src/core/toMutable.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | 3 | export default function toMutable(data) { 4 | return isImmutable(data) ? data.toJS() : data 5 | } 6 | -------------------------------------------------------------------------------- /src/core/toNumber.js: -------------------------------------------------------------------------------- 1 | import { NAN } from './constants' 2 | import { reIsBadHex, reIsBinary, reIsOctal, reTrim } from './regex' 3 | import isObject from './isObject' 4 | import isSymbol from './isSymbol' 5 | 6 | const freeParseInt = parseInt 7 | 8 | export default function toNumber(data) { 9 | if (typeof data == 'number') { 10 | return data 11 | } 12 | if (isSymbol(data)) { 13 | return NAN 14 | } 15 | if (isObject(data)) { 16 | const other = typeof data.valueOf == 'function' ? data.valueOf() : data 17 | data = isObject(other) ? `${other}` : other 18 | } 19 | if (typeof data != 'string') { 20 | return data === 0 ? data : +data 21 | } 22 | data = data.replace(reTrim, '') 23 | const isBinary = reIsBinary.test(data) 24 | return (isBinary || reIsOctal.test(data)) 25 | ? freeParseInt(data.slice(2), isBinary ? 2 : 8) 26 | : (reIsBadHex.test(data) ? NAN : +data) 27 | } 28 | -------------------------------------------------------------------------------- /src/core/toObject.js: -------------------------------------------------------------------------------- 1 | import isImmutable from './isImmutable' 2 | 3 | export default function toObject(data) { 4 | return isImmutable(data) ? data.toObject() : data 5 | } 6 | -------------------------------------------------------------------------------- /src/core/toSource.js: -------------------------------------------------------------------------------- 1 | import { funcToString } from './context' 2 | 3 | export default function toSource(func) { 4 | if (func != null) { 5 | try { 6 | return funcToString.call(func) 7 | } catch (e) {} // eslint-disable-line no-empty 8 | try { 9 | return (func + '') 10 | } catch (e) {} // eslint-disable-line no-empty 11 | } 12 | return '' 13 | } 14 | -------------------------------------------------------------------------------- /src/core/types/Array.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isArray from '../isArray' 3 | 4 | export default deftype('Array', { 5 | is(value) { 6 | return isArray(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/Boolean.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isBoolean from '../isBoolean' 3 | 4 | export default deftype('Boolean', { 5 | is(value) { 6 | return isBoolean(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/Function.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isFunction from '../isFunction' 3 | 4 | export default deftype('Function', { 5 | is(value) { 6 | return isFunction(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/List.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isImmutableList from '../isImmutableList' 3 | 4 | export default deftype('List', { 5 | is(value) { 6 | return isImmutableList(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/Map.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isImmutableMap from '../isImmutableMap' 3 | 4 | export default deftype('Map', { 5 | is(value) { 6 | return isImmutableMap(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/Number.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isNumber from '../isNumber' 3 | 4 | export default deftype('Number', { 5 | is(value) { 6 | return isNumber(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/Object.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isObject from '../isObject' 3 | 4 | export default deftype('Object', { 5 | is(value) { 6 | return isObject(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/String.js: -------------------------------------------------------------------------------- 1 | import deftype from '../deftype' 2 | import isString from '../isString' 3 | 4 | export default deftype('String', { 5 | is(value) { 6 | return isString(value) 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /src/core/types/index.js: -------------------------------------------------------------------------------- 1 | export { default as Array } from './Array' 2 | export { default as Boolean } from './Boolean' 3 | export { default as Function } from './Function' 4 | export { default as List } from './List' 5 | export { default as Map } from './Map' 6 | export { default as Number } from './Number' 7 | export { default as Object } from './Object' 8 | export { default as String } from './String' 9 | -------------------------------------------------------------------------------- /src/core/uniq.js: -------------------------------------------------------------------------------- 1 | import { baseUniq } from './base' 2 | import isIndexed from './isIndexed' 3 | 4 | export default function uniq(data) { 5 | return isIndexed(data) 6 | ? baseUniq(data) 7 | : [] 8 | } 9 | -------------------------------------------------------------------------------- /src/core/uniqBy.js: -------------------------------------------------------------------------------- 1 | import { baseUniq } from './base' 2 | import { getIteratee } from './util' 3 | import isIndexed from './isIndexed' 4 | 5 | export default function uniqBy(data, iteratee) { 6 | return isIndexed(data) 7 | ? baseUniq(data, getIteratee(iteratee)) 8 | : [] 9 | } 10 | -------------------------------------------------------------------------------- /src/core/uniqWith.js: -------------------------------------------------------------------------------- 1 | import { baseUniq } from './base' 2 | import isFunction from './isFunction' 3 | import isIndexed from './isIndexed' 4 | 5 | export default function uniqWith(data, comparator) { 6 | comparator = isFunction(comparator) ? comparator : undefined 7 | return isIndexed(data) 8 | ? baseUniq(data, undefined, comparator) 9 | : [] 10 | } 11 | -------------------------------------------------------------------------------- /src/core/unset.js: -------------------------------------------------------------------------------- 1 | export { default } from './delete' 2 | -------------------------------------------------------------------------------- /src/core/unsetKey.js: -------------------------------------------------------------------------------- 1 | export { default } from './deleteKey' 2 | -------------------------------------------------------------------------------- /src/core/update.js: -------------------------------------------------------------------------------- 1 | import { baseUpdate } from './base' 2 | import { castFunction, castPath } from './util' 3 | import getKey from './getKey' 4 | import setKey from './setKey' 5 | 6 | export default function update(data, maybePath, updater) { 7 | return data == null ? data : baseUpdate(data, castPath(maybePath, data), castFunction(updater), setKey, getKey) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/updateWith.js: -------------------------------------------------------------------------------- 1 | import { baseUpdate } from './base' 2 | import { castFunction, castPath } from './util' 3 | import getKey from './getKey' 4 | import setKey from './setKey' 5 | 6 | export default function updateWith(data, maybePath, updater, customizer) { 7 | customizer = typeof customizer == 'function' ? customizer : undefined 8 | return data == null ? data : baseUpdate(data, castPath(maybePath, data), castFunction(updater), setKey, getKey, { customizer }) 9 | } 10 | -------------------------------------------------------------------------------- /src/core/util/asciiSize.js: -------------------------------------------------------------------------------- 1 | export default function asciiSize({ length }) { 2 | return length 3 | } 4 | -------------------------------------------------------------------------------- /src/core/util/assignValue.js: -------------------------------------------------------------------------------- 1 | import { contextHasOwnProperty } from '../context' 2 | import baseAssignValue from '../base/baseAssignValue' 3 | import eq from '../eq' 4 | 5 | 6 | export default function assignValue(object, key, value) { 7 | const objValue = object[key] 8 | if (!(contextHasOwnProperty.call(object, key) && eq(objValue, value)) || 9 | (value === undefined && !(key in object))) { 10 | baseAssignValue(object, key, value) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/core/util/assocIndexOf.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import eq from '../eq' 3 | import getKey from '../getKey' 4 | 5 | export default function assocIndexOf(indexedTupple, key) { 6 | let length = count(indexedTupple) 7 | while (length--) { 8 | if (eq(getKey(indexedTupple, length)[0], key)) { 9 | return length 10 | } 11 | } 12 | return -1 13 | } 14 | -------------------------------------------------------------------------------- /src/core/util/castFunction.js: -------------------------------------------------------------------------------- 1 | import identity from '../identity' 2 | import isFunction from '../isFunction' 3 | export default function castFunction(value) { 4 | return isFunction(value) ? value : identity 5 | } 6 | -------------------------------------------------------------------------------- /src/core/util/castPath.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isArray from '../isArray' 3 | import isKey from '../isKey' 4 | import stringToPath from './stringToPath' 5 | 6 | export default function castPath(value, data) { 7 | if (isArray(value)) { 8 | return value 9 | } 10 | return isKey(value, data) ? [value] : stringToPath(_.toString(value)) 11 | } 12 | -------------------------------------------------------------------------------- /src/core/util/copyObject.js: -------------------------------------------------------------------------------- 1 | import baseAssignValue from '../base/baseAssignValue' 2 | import assignValue from './assignValue' 3 | 4 | export default function copyObject(source, props, object, customizer) { 5 | const isNew = !object 6 | object = object || {} 7 | 8 | let index = -1 9 | const length = props.length 10 | 11 | while (++index < length) { 12 | const key = props[index] 13 | 14 | let newValue = customizer 15 | ? customizer(object[key], source[key], key, object, source) 16 | : undefined 17 | 18 | if (newValue === undefined) { 19 | newValue = source[key] 20 | } 21 | if (isNew) { 22 | baseAssignValue(object, key, newValue) 23 | } else { 24 | assignValue(object, key, newValue) 25 | } 26 | } 27 | return object 28 | } 29 | -------------------------------------------------------------------------------- /src/core/util/createSet.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { INFINITY } from '../constants' 3 | import { Set } from '../context' 4 | import setToArray from './setToArray' 5 | 6 | const createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? _.noop : function(values) { //eslint-disable-line no-sparse-arrays 7 | return new Set(values) 8 | } 9 | export default createSet 10 | -------------------------------------------------------------------------------- /src/core/util/getAllKeys.js: -------------------------------------------------------------------------------- 1 | import baseGetAllKeys from '../base/baseGetAllKeys' 2 | import baseKeys from '../base/baseKeys' 3 | import getSymbols from './getSymbols' 4 | export default function getAllKeys(object) { 5 | return baseGetAllKeys(object, baseKeys, getSymbols) 6 | } 7 | -------------------------------------------------------------------------------- /src/core/util/getIteratee.js: -------------------------------------------------------------------------------- 1 | //TODO BRN: This needs to be reworked to include context and overriding of iteratee 2 | import baseIteratee from '../base/baseIteratee' 3 | import iteratee from '../iteratee' 4 | 5 | export default function getIteratee() { 6 | //var result = lodash.iteratee || iteratee; 7 | let result = iteratee 8 | result = result === iteratee ? baseIteratee : result 9 | return arguments.length ? result(arguments[0], arguments[1]) : result 10 | } 11 | -------------------------------------------------------------------------------- /src/core/util/getMatchData.js: -------------------------------------------------------------------------------- 1 | import baseKeys from '../base/baseKeys' 2 | import count from '../count' 3 | import getKey from '../getKey' 4 | import setKey from '../setKey' 5 | import isStrictComparable from './isStrictComparable' 6 | 7 | export default function getMatchData(object) { 8 | let result = baseKeys(object) 9 | let length = count(result) 10 | 11 | while (length--) { 12 | const key = getKey(result, length) 13 | const value = getKey(object, key) 14 | result = setKey(result, length, [key, value, isStrictComparable(value)]) 15 | } 16 | return result 17 | } 18 | -------------------------------------------------------------------------------- /src/core/util/getNative.js: -------------------------------------------------------------------------------- 1 | import baseIsNative from '../base/baseIsNative' 2 | import getValue from './getValue' 3 | 4 | export default function getNative(object, key) { 5 | const value = getValue(object, key) 6 | return baseIsNative(value) ? value : undefined 7 | } 8 | -------------------------------------------------------------------------------- /src/core/util/getRawTag.js: -------------------------------------------------------------------------------- 1 | import { contextHasOwnProperty, contextSymbolToStringTag } from '../context' 2 | import nativeObjectToString from '../native/nativeObjectToString' 3 | 4 | export default function getRawTag(value) { 5 | const isOwn = contextHasOwnProperty.call(value, contextSymbolToStringTag) 6 | const tag = value[contextSymbolToStringTag] 7 | let unmasked 8 | try { 9 | value[contextSymbolToStringTag] = undefined 10 | unmasked = true 11 | } catch (error) {} // eslint-disable-line no-empty 12 | 13 | const result = nativeObjectToString.call(value) 14 | if (unmasked) { 15 | if (isOwn) { 16 | value[contextSymbolToStringTag] = tag 17 | } else { 18 | delete value[contextSymbolToStringTag] 19 | } 20 | } 21 | return result 22 | } 23 | -------------------------------------------------------------------------------- /src/core/util/getSymbols.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { _Object, contextPropertyIsEnumerable } from '../context' 3 | import arrayFilter from '../array/arrayFilter' 4 | import nativeGetSymbols from '../native/nativeGetSymbols' 5 | 6 | const getSymbols = !nativeGetSymbols ? _.stubArray : (object) => { 7 | if (object == null) { 8 | return [] 9 | } 10 | object = _Object(object) 11 | return arrayFilter(nativeGetSymbols(object), (symbol) => 12 | contextPropertyIsEnumerable.call(object, symbol) 13 | ) 14 | } 15 | export default getSymbols 16 | -------------------------------------------------------------------------------- /src/core/util/getTag.js: -------------------------------------------------------------------------------- 1 | import { NULL_TAG, UNDEFINED_TAG } from '../constants' 2 | import { _Object, contextSymbolToStringTag } from '../context' 3 | import objectToString from '../object/objectToString' 4 | import getRawTag from './getRawTag' 5 | 6 | export default function getTag(value) { 7 | if (value == null) { 8 | return value === undefined ? UNDEFINED_TAG : NULL_TAG 9 | } 10 | value = _Object(value) 11 | return (contextSymbolToStringTag && contextSymbolToStringTag in value) 12 | ? getRawTag(value) 13 | : objectToString(value) 14 | } 15 | -------------------------------------------------------------------------------- /src/core/util/getValue.js: -------------------------------------------------------------------------------- 1 | export default function getValue(object, key) { 2 | return object == null ? undefined : object[key] 3 | } 4 | -------------------------------------------------------------------------------- /src/core/util/hasUnicode.js: -------------------------------------------------------------------------------- 1 | import { reHasUnicode } from '../regex' 2 | 3 | export default function hasUnicode(string) { 4 | return reHasUnicode.test(string) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/util/isForEachable.js: -------------------------------------------------------------------------------- 1 | import isFunction from '../isFunction' 2 | export default function isForEachable(data) { 3 | return data && isFunction(data.forEach) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/util/isMaskable.js: -------------------------------------------------------------------------------- 1 | import { coreJsData } from '../context' 2 | import isFunction from '../isFunction' 3 | import stubFalse from '../stubFalse' 4 | const isMaskable = coreJsData ? isFunction : stubFalse 5 | export default isMaskable 6 | -------------------------------------------------------------------------------- /src/core/util/isMasked.js: -------------------------------------------------------------------------------- 1 | import { maskSrcKey } from '../context' 2 | 3 | export default function isMasked(func) { 4 | return !!maskSrcKey && (maskSrcKey in func) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/util/isStrictComparable.js: -------------------------------------------------------------------------------- 1 | import isObject from '../isObject' 2 | 3 | export default function isStrictComparable(value) { 4 | return value === value && !isObject(value) 5 | } 6 | -------------------------------------------------------------------------------- /src/core/util/mapToArray.js: -------------------------------------------------------------------------------- 1 | import { Array } from '../context' 2 | 3 | export default function mapToArray(map) { 4 | let index = -1 5 | const result = Array(map.size) 6 | 7 | map.forEach((value, key) => { 8 | result[++index] = [key, value] 9 | }) 10 | return result 11 | } 12 | -------------------------------------------------------------------------------- /src/core/util/matchesStrictComparable.js: -------------------------------------------------------------------------------- 1 | import { _Object } from '../context' 2 | import getKey from '../getKey' 3 | import hasKeyIn from '../hasKeyIn' 4 | 5 | export default function matchesStrictComparable(key, srcValue) { 6 | return function(object) { 7 | if (object == null) { 8 | return false 9 | } 10 | return getKey(object, key) === srcValue && 11 | (srcValue !== undefined || hasKeyIn(_Object(object), key)) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/core/util/memoizeCapped.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { MAX_MEMOIZE_SIZE } from '../constants' 3 | 4 | export default function memoizeCapped(func) { 5 | const result = _.memoize(func, (key) => { 6 | if (cache.size === MAX_MEMOIZE_SIZE) { 7 | cache.clear() 8 | } 9 | return key 10 | }) 11 | 12 | const cache = result.cache 13 | return result 14 | } 15 | -------------------------------------------------------------------------------- /src/core/util/setToArray.js: -------------------------------------------------------------------------------- 1 | import { Array } from '../context' 2 | 3 | export default function setToArray(set) { 4 | let index = -1 5 | const result = Array(set.size) 6 | 7 | set.forEach(function(value) { 8 | result[++index] = value 9 | }) 10 | return result 11 | } 12 | -------------------------------------------------------------------------------- /src/core/util/stringSize.js: -------------------------------------------------------------------------------- 1 | import asciiSize from './asciiSize' 2 | import hasUnicode from './hasUnicode' 3 | import unicodeSize from './unicodeSize' 4 | 5 | export default function stringSize(string) { 6 | return hasUnicode(string) ? unicodeSize(string) : asciiSize(string) 7 | } 8 | -------------------------------------------------------------------------------- /src/core/util/stringToPath.js: -------------------------------------------------------------------------------- 1 | import reEscapeChar from '../regex/reEscapeChar' 2 | import reLeadingDot from '../regex/reLeadingDot' 3 | import rePropName from '../regex/rePropName' 4 | import memoizeCapped from './memoizeCapped' 5 | 6 | const stringToPath = memoizeCapped((string) => { 7 | const result = [] 8 | if (reLeadingDot.test(string)) { 9 | result.push('') 10 | } 11 | string.replace(rePropName, (match, number, quote, value) => { 12 | result.push(quote ? value.replace(reEscapeChar, '$1') : (number || match)) 13 | }) 14 | return result 15 | }) 16 | export default stringToPath 17 | -------------------------------------------------------------------------------- /src/core/util/unicodeSize.js: -------------------------------------------------------------------------------- 1 | import { reUnicode } from '../regex' 2 | 3 | export default function unicodeSize(string) { 4 | let result = reUnicode.lastIndex = 0 5 | while (reUnicode.test(string)) { 6 | ++result 7 | } 8 | return result 9 | } 10 | -------------------------------------------------------------------------------- /src/core/values.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isImmutable from './isImmutable' 3 | 4 | export default function values(data) { 5 | return isImmutable(data) 6 | ? data.valueSeq() 7 | : _.values(data) 8 | } 9 | -------------------------------------------------------------------------------- /src/core/walk.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import { baseWalk } from './base' 3 | import { depthFirst } from './walkees' 4 | 5 | export function walk(data, path, iteratee = _.identity, walkee = depthFirst) { 6 | baseWalk(data, path, iteratee, walkee) 7 | return data 8 | } 9 | -------------------------------------------------------------------------------- /src/core/walkees/depthFirst.js: -------------------------------------------------------------------------------- 1 | import forEach from '../forEach' 2 | import isArray from '../isArray' 3 | import isObject from '../isObject' 4 | import isObjectLike from '../isObjectLike' 5 | 6 | export default function depthFirst(data, path, iteratee, recur) { 7 | let result = true 8 | if (isObjectLike(data)) { 9 | forEach(data, (value, key) => { 10 | const fullKey = (path).concat([key]).join('.') 11 | result = iteratee(value, fullKey, data) 12 | if (result !== false && (isObject(value) || isArray(value))) { 13 | return recur(value, fullKey, iteratee) 14 | } 15 | return result 16 | }) 17 | } 18 | return result 19 | } 20 | -------------------------------------------------------------------------------- /src/core/walkees/index.js: -------------------------------------------------------------------------------- 1 | export { default as depthFirst } from './depthFirst' 2 | -------------------------------------------------------------------------------- /src/core/with/index.js: -------------------------------------------------------------------------------- 1 | export { default as withComparatorValue } from './withComparatorValue' 2 | export { default as withDeepClone } from './withDeepClone' 3 | export { default as withEqValue } from './withEqValue' 4 | export { default as withFor } from './withFor' 5 | export { default as withKeyIn } from './withKeyIn' 6 | export { default as withMutations } from './withMutations' 7 | -------------------------------------------------------------------------------- /src/core/with/withComparatorValue.js: -------------------------------------------------------------------------------- 1 | const withComparatorValue = (comparator, value) => (data) => comparator(data, value) 2 | export default withComparatorValue 3 | -------------------------------------------------------------------------------- /src/core/with/withDeepClone.js: -------------------------------------------------------------------------------- 1 | import _ from 'lodash' 2 | import isFunction from '../isFunction' 3 | import isImmutable from '../isImmutable' 4 | 5 | export default function withDeepClone(customizer) { 6 | const cloner = (data, key, object) => { 7 | if (isFunction(customizer)) { 8 | const result = customizer(data, key, object) 9 | if (!_.isUndefined(result)) { 10 | return result 11 | } 12 | } 13 | if (isImmutable(data)) { 14 | data.forEach((value, _key) => { 15 | data = data.set(_key, _.cloneDeepWith(value, cloner)) 16 | }) 17 | return data 18 | } 19 | } 20 | return cloner 21 | } 22 | -------------------------------------------------------------------------------- /src/core/with/withEqValue.js: -------------------------------------------------------------------------------- 1 | import baseIsNaN from '../base/baseIsNaN' 2 | import eq from '../eq' 3 | 4 | const withEqValue = (value) => value === value 5 | ? (data) => eq(data, value) 6 | : baseIsNaN 7 | 8 | export default withEqValue 9 | -------------------------------------------------------------------------------- /src/core/with/withFor.js: -------------------------------------------------------------------------------- 1 | import count from '../count' 2 | import getKey from '../getKey' 3 | 4 | export default function baseFor(iterable, iteratee, keysFunc) { 5 | let index = -1 6 | const props = keysFunc(iterable) 7 | let size = count(props) 8 | 9 | while (size--) { 10 | const key = getKey(props, ++index) 11 | if (iteratee(getKey(iterable, key), key, iterable) === false) { 12 | break 13 | } 14 | } 15 | return iterable 16 | } 17 | -------------------------------------------------------------------------------- /src/core/with/withKeyIn.js: -------------------------------------------------------------------------------- 1 | import Immutable from 'immutable' 2 | 3 | export default function withKeyIn(keys) { 4 | const keySet = Immutable.Set(keys) 5 | return (value, key) => { 6 | return keySet.has(key) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/core/with/withMutations.js: -------------------------------------------------------------------------------- 1 | import baseClone from '../base/baseClone' 2 | import isFunction from '../isFunction' 3 | 4 | const withMutations = (method) => (data, ...rest) => isFunction(data.withMutations) 5 | ? data.withMutations((mutableData) => method(mutableData, ...rest)) 6 | : method(baseClone(data), ...rest) 7 | 8 | export default withMutations 9 | -------------------------------------------------------------------------------- /src/core/withMutations.js: -------------------------------------------------------------------------------- 1 | import { withMutations } from './with' 2 | export default function _withMutations(data, mutator, ...args) { 3 | if (data) { 4 | return withMutations(mutator)(data, ...args) 5 | } 6 | return data 7 | } 8 | -------------------------------------------------------------------------------- /src/core/wrapperValue.js: -------------------------------------------------------------------------------- 1 | import { baseWrapperValue } from './base' 2 | export default function wrapperValue() { 3 | return baseWrapperValue(this.__wrapped__, this.__actions__) 4 | } 5 | -------------------------------------------------------------------------------- /src/core/xor.js: -------------------------------------------------------------------------------- 1 | // import { baseXor } from './base' 2 | // import filter from './filter' 3 | // import isIterable 4 | // 5 | // export default function xor(...datas) { 6 | // return baseXor(filter(datas, isIterable)) 7 | // } 8 | -------------------------------------------------------------------------------- /src/core/xorPartition.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianneisler/mudash/243025edaa3c31d04cb83f9b6b36183d231ff71f/src/core/xorPartition.js -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import * as core from './core' 2 | import _ from 'lodash' 3 | const lodash = _.runInContext() 4 | const exports = lodash.mixin(core) 5 | 6 | exports.prototype.valueOf = exports.prototype.toJSON = exports.prototype.value = exports.wrapperValue 7 | exports.types = core.types 8 | exports.protocols = core.protocols 9 | 10 | module.exports = exports 11 | --------------------------------------------------------------------------------