From cb854cff6d975796e819e568cd79f34c5be3957c Mon Sep 17 00:00:00 2001 From: LinBo Len Date: Fri, 17 May 2024 19:37:57 +0800 Subject: [PATCH] update 2.4.0 --- libs/nanofn/.babelrc | 3 - libs/nanofn/.eslintrc.json | 36 - libs/nanofn/CHANGELOG.md | 23 - libs/nanofn/README.md | 7 - libs/nanofn/index.ts | 8 - libs/nanofn/jest.config.js | 20 - libs/nanofn/ng-package.json | 7 - libs/nanofn/package.json | 16 - libs/nanofn/project.json | 50 -- libs/nanofn/public-api.ts | 330 -------- libs/nanofn/src/_internal/add-map-entry.ts | 19 - libs/nanofn/src/_internal/add-set-entry.ts | 21 - libs/nanofn/src/_internal/array-each-right.ts | 28 - libs/nanofn/src/_internal/array-each.ts | 29 - .../src/_internal/array-includes-with.ts | 30 - libs/nanofn/src/_internal/array-includes.ts | 23 - libs/nanofn/src/_internal/array-like-keys.ts | 49 -- .../src/_internal/array-reduce-right.ts | 29 - libs/nanofn/src/_internal/array-reduce.ts | 31 - libs/nanofn/src/_internal/ascii-size.ts | 18 - libs/nanofn/src/_internal/ascii-to-array.ts | 18 - .../src/_internal/assign-merge-value.ts | 26 - libs/nanofn/src/_internal/assign-value.ts | 33 - libs/nanofn/src/_internal/assoc-index-of.ts | 28 - .../nanofn/src/_internal/base-assign-value.ts | 31 - libs/nanofn/src/_internal/base-at.ts | 29 - libs/nanofn/src/_internal/base-clone.ts | 253 ------ libs/nanofn/src/_internal/base-conforms-to.ts | 33 - libs/nanofn/src/_internal/base-conforms.ts | 22 - libs/nanofn/src/_internal/base-difference.ts | 67 -- libs/nanofn/src/_internal/base-each-right.ts | 36 - libs/nanofn/src/_internal/base-each.ts | 37 - libs/nanofn/src/_internal/base-find-index.ts | 32 - libs/nanofn/src/_internal/base-find-key.ts | 28 - libs/nanofn/src/_internal/base-flatten.ts | 43 - .../src/_internal/base-for-own-right.ts | 22 - libs/nanofn/src/_internal/base-for-own.ts | 22 - libs/nanofn/src/_internal/base-for-right.ts | 31 - libs/nanofn/src/_internal/base-for.ts | 33 - libs/nanofn/src/_internal/base-get.ts | 30 - libs/nanofn/src/_internal/base-in-range.ts | 20 - .../src/_internal/base-index-of-with.ts | 29 - libs/nanofn/src/_internal/base-index-of.ts | 26 - .../nanofn/src/_internal/base-intersection.ts | 78 -- .../src/_internal/base-is-equal-deep.ts | 85 -- libs/nanofn/src/_internal/base-is-equal.ts | 35 - libs/nanofn/src/_internal/base-is-match.ts | 71 -- libs/nanofn/src/_internal/base-is-nan.ts | 18 - .../src/_internal/base-matches-property.ts | 39 - libs/nanofn/src/_internal/base-matches.ts | 26 - libs/nanofn/src/_internal/base-merge-deep.ts | 90 -- libs/nanofn/src/_internal/base-merge.ts | 46 - libs/nanofn/src/_internal/base-order-by.ts | 55 -- libs/nanofn/src/_internal/base-pick-by.ts | 35 - libs/nanofn/src/_internal/base-pick.ts | 23 - .../src/_internal/base-property-deep.ts | 20 - libs/nanofn/src/_internal/base-property-of.ts | 18 - libs/nanofn/src/_internal/base-property.ts | 18 - libs/nanofn/src/_internal/base-pull-all.ts | 50 -- libs/nanofn/src/_internal/base-pull-at.ts | 38 - libs/nanofn/src/_internal/base-range.ts | 30 - libs/nanofn/src/_internal/base-reduce.ts | 29 - libs/nanofn/src/_internal/base-set.ts | 59 -- libs/nanofn/src/_internal/base-sort-by.ts | 27 - .../src/_internal/base-sorted-index-by.ts | 71 -- .../nanofn/src/_internal/base-sorted-index.ts | 46 - libs/nanofn/src/_internal/base-sorted-uniq.ts | 35 - libs/nanofn/src/_internal/base-sum.ts | 27 - libs/nanofn/src/_internal/base-to-number.ts | 30 - libs/nanofn/src/_internal/base-to-string.ts | 39 - libs/nanofn/src/_internal/base-uniq.ts | 79 -- libs/nanofn/src/_internal/base-unset.ts | 26 - libs/nanofn/src/_internal/base-update.ts | 24 - libs/nanofn/src/_internal/base-values.ts | 21 - libs/nanofn/src/_internal/base-while.ts | 31 - libs/nanofn/src/_internal/base-xor.ts | 42 - libs/nanofn/src/_internal/base-zip-object.ts | 29 - libs/nanofn/src/_internal/cache-has.ts | 19 - .../src/_internal/cast-array-like-object.ts | 20 - libs/nanofn/src/_internal/cast-path.ts | 25 - libs/nanofn/src/_internal/cast-slice.ts | 24 - libs/nanofn/src/_internal/chars-end-index.ts | 25 - .../nanofn/src/_internal/chars-start-index.ts | 26 - .../src/_internal/clone-array-buffer.ts | 20 - libs/nanofn/src/_internal/clone-buffer.ts | 29 - libs/nanofn/src/_internal/clone-data-view.ts | 22 - libs/nanofn/src/_internal/clone-reg-exp.ts | 23 - libs/nanofn/src/_internal/clone-symbol.ts | 21 - .../nanofn/src/_internal/clone-typed-array.ts | 22 - .../nanofn/src/_internal/compare-ascending.ts | 51 -- libs/nanofn/src/_internal/compare-multiple.ts | 51 -- .../src/_internal/compose-args-right.ts | 45 - libs/nanofn/src/_internal/compose-args.ts | 44 - libs/nanofn/src/_internal/copy-array.ts | 29 - libs/nanofn/src/_internal/copy-object.ts | 41 - libs/nanofn/src/_internal/copy-symbols-in.ts | 22 - libs/nanofn/src/_internal/copy-symbols.ts | 22 - libs/nanofn/src/_internal/create-assigner.ts | 42 - .../src/_internal/create-math-operation.ts | 41 - libs/nanofn/src/_internal/create-padding.ts | 36 - libs/nanofn/src/_internal/create-range.ts | 32 - libs/nanofn/src/_internal/create-round.ts | 40 - libs/nanofn/src/_internal/create-set.ts | 21 - .../src/_internal/custom-defaults-merge.ts | 34 - libs/nanofn/src/_internal/deburr-letter.ts | 75 -- libs/nanofn/src/_internal/equal-arrays.ts | 95 --- libs/nanofn/src/_internal/equal-by-tag.ts | 116 --- libs/nanofn/src/_internal/equal-objects.ts | 94 --- libs/nanofn/src/_internal/free-global.ts | 8 - libs/nanofn/src/_internal/get-all-keys-in.ts | 27 - libs/nanofn/src/_internal/get-all-keys.ts | 25 - libs/nanofn/src/_internal/get-holder.ts | 19 - libs/nanofn/src/_internal/get-match-data.ts | 29 - libs/nanofn/src/_internal/get-symbols-in.ts | 25 - libs/nanofn/src/_internal/get-symbols.ts | 28 - libs/nanofn/src/_internal/get-tag.ts | 23 - libs/nanofn/src/_internal/has-unicode.ts | 39 - libs/nanofn/src/_internal/hash.ts | 92 -- .../nanofn/src/_internal/init-clone-object.ts | 22 - libs/nanofn/src/_internal/is-flattenable.ts | 24 - libs/nanofn/src/_internal/is-index.ts | 30 - libs/nanofn/src/_internal/is-iteratee-call.ts | 37 - libs/nanofn/src/_internal/is-key.ts | 34 - libs/nanofn/src/_internal/is-prototype.ts | 24 - .../src/_internal/is-strict-comparable.ts | 21 - .../nanofn/src/_internal/iterator-to-array.ts | 24 - libs/nanofn/src/_internal/list-cache.ts | 107 --- libs/nanofn/src/_internal/map-cache.ts | 133 --- libs/nanofn/src/_internal/map-to-array.ts | 24 - .../_internal/matches-strict-comparable.ts | 26 - libs/nanofn/src/_internal/meta-map.ts | 7 - libs/nanofn/src/_internal/node-types.ts | 32 - libs/nanofn/src/_internal/parent.ts | 22 - libs/nanofn/src/_internal/re-escape.ts | 10 - libs/nanofn/src/_internal/re-evaluate.ts | 10 - libs/nanofn/src/_internal/re-interpolate.ts | 10 - libs/nanofn/src/_internal/root.ts | 17 - libs/nanofn/src/_internal/set-cache.ts | 61 -- libs/nanofn/src/_internal/set-to-array.ts | 24 - libs/nanofn/src/_internal/set-to-pairs.ts | 24 - libs/nanofn/src/_internal/set-to-string.ts | 24 - libs/nanofn/src/_internal/stack.ts | 97 --- libs/nanofn/src/_internal/strict-index-of.ts | 29 - .../src/_internal/strict-last-index-of.ts | 27 - libs/nanofn/src/_internal/string-size.ts | 22 - libs/nanofn/src/_internal/string-to-array.ts | 24 - libs/nanofn/src/_internal/string-to-path.ts | 47 -- libs/nanofn/src/_internal/to-key.ts | 27 - libs/nanofn/src/_internal/unicode-size.ts | 57 -- libs/nanofn/src/_internal/unicode-to-array.ts | 54 -- libs/nanofn/src/_internal/unicode-words.ts | 77 -- libs/nanofn/src/arr/chunk.ts | 43 - libs/nanofn/src/arr/compact.ts | 35 - libs/nanofn/src/arr/difference/difference.ts | 97 --- libs/nanofn/src/arr/drop.ts | 120 --- libs/nanofn/src/arr/each.ts | 9 - libs/nanofn/src/arr/every.ts | 39 - libs/nanofn/src/arr/filter.ts | 44 - libs/nanofn/src/arr/find-last-index.ts | 46 - libs/nanofn/src/arr/first.ts | 7 - libs/nanofn/src/arr/flat/flat-map-deep.ts | 35 - libs/nanofn/src/arr/flat/flat-map-depth.ts | 34 - libs/nanofn/src/arr/flat/flat-map.ts | 33 - libs/nanofn/src/arr/flat/flatten-deep.ts | 29 - libs/nanofn/src/arr/flat/flatten-depth.ts | 36 - libs/nanofn/src/arr/flat/flatten.ts | 26 - libs/nanofn/src/arr/from-entries.ts | 30 - libs/nanofn/src/arr/head.ts | 29 - libs/nanofn/src/arr/index-of.ts | 42 - libs/nanofn/src/arr/initial.ts | 25 - libs/nanofn/src/arr/intersection-by.ts | 42 - libs/nanofn/src/arr/intersection-with.ts | 43 - libs/nanofn/src/arr/intersection.ts | 30 - libs/nanofn/src/arr/last-index-of.ts | 45 - libs/nanofn/src/arr/last.ts | 23 - libs/nanofn/src/arr/map.ts | 35 - libs/nanofn/src/arr/nth.ts | 36 - libs/nanofn/src/arr/pull/pull-all-by.ts | 36 - libs/nanofn/src/arr/pull/pull-all-with.ts | 36 - libs/nanofn/src/arr/pull/pull-all.ts | 33 - libs/nanofn/src/arr/pull/pull-at.ts | 43 - libs/nanofn/src/arr/pull/pull.ts | 34 - libs/nanofn/src/arr/remove.ts | 53 -- libs/nanofn/src/arr/sample-size.ts | 45 - libs/nanofn/src/arr/sample.ts | 23 - libs/nanofn/src/arr/shuffle.ts | 38 - libs/nanofn/src/arr/slice.ts | 52 -- libs/nanofn/src/arr/some.ts | 34 - libs/nanofn/src/arr/sort/some-value.ts | 34 - libs/nanofn/src/arr/sort/sorted-index-by.ts | 31 - libs/nanofn/src/arr/sort/sorted-index-of.ts | 34 - libs/nanofn/src/arr/sort/sorted-index.ts | 27 - .../src/arr/sort/sorted-last-index-by.ts | 31 - .../src/arr/sort/sorted-last-index-of.ts | 34 - libs/nanofn/src/arr/sort/sorted-last-index.ts | 28 - libs/nanofn/src/arr/sort/sorted-uniq-by.ts | 28 - libs/nanofn/src/arr/sort/sorted-uniq.ts | 29 - libs/nanofn/src/arr/tail.ts | 27 - libs/nanofn/src/arr/take/take-right-while.ts | 35 - libs/nanofn/src/arr/take/take-right.ts | 39 - libs/nanofn/src/arr/take/take-while.ts | 35 - libs/nanofn/src/arr/take/take.ts | 37 - libs/nanofn/src/arr/union/union-by.ts | 37 - libs/nanofn/src/arr/union/union-with.ts | 37 - libs/nanofn/src/arr/union/union.ts | 29 - libs/nanofn/src/arr/uniq/uniq-by.ts | 32 - libs/nanofn/src/arr/uniq/uniq-with.ts | 34 - libs/nanofn/src/arr/uniq/uniq.ts | 31 - libs/nanofn/src/arr/without.ts | 31 - libs/nanofn/src/arr/xor/xor-by.ts | 36 - libs/nanofn/src/arr/xor/xor-with.ts | 36 - libs/nanofn/src/arr/xor/xor.ts | 29 - libs/nanofn/src/arr/zip/unzip-with.ts | 36 - libs/nanofn/src/arr/zip/unzip.ts | 48 -- libs/nanofn/src/arr/zip/zip-object-deep.ts | 27 - libs/nanofn/src/arr/zip/zip-object.ts | 28 - libs/nanofn/src/arr/zip/zip-with.ts | 32 - libs/nanofn/src/arr/zip/zip.ts | 27 - libs/nanofn/src/case/camel-case.ts | 34 - libs/nanofn/src/case/capitalize.ts | 23 - libs/nanofn/src/case/kebab-case.ts | 34 - libs/nanofn/src/case/lower-case.ts | 36 - libs/nanofn/src/case/lower-first.ts | 28 - libs/nanofn/src/case/snake-case.ts | 37 - libs/nanofn/src/case/start-case.ts | 36 - libs/nanofn/src/case/str-case.ts | 362 -------- libs/nanofn/src/case/upper-case.ts | 33 - libs/nanofn/src/case/upper-first.ts | 24 - libs/nanofn/src/case/words.ts | 43 - libs/nanofn/src/cast/cast-array.ts | 46 - libs/nanofn/src/cast/to-array.ts | 60 -- libs/nanofn/src/cast/to-finite.ts | 45 - libs/nanofn/src/cast/to-integer.ts | 40 - libs/nanofn/src/cast/to-length.ts | 50 -- libs/nanofn/src/cast/to-number.ts | 72 -- libs/nanofn/src/cast/to-path.ts | 34 - libs/nanofn/src/cast/to-plain-object.ts | 37 - libs/nanofn/src/cast/to-safe-integer.ts | 47 -- libs/nanofn/src/cast/to-string.ts | 49 -- libs/nanofn/src/clone/clone-deep-with.ts | 44 - libs/nanofn/src/clone/clone-deep.ts | 33 - libs/nanofn/src/clone/clone-with.ts | 44 - libs/nanofn/src/clone/clone.ts | 40 - libs/nanofn/src/collection/count-by.ts | 47 -- libs/nanofn/src/collection/find-last.ts | 37 - libs/nanofn/src/collection/for-each-right.ts | 30 - libs/nanofn/src/collection/for-each.ts | 38 - libs/nanofn/src/collection/group-by.ts | 41 - libs/nanofn/src/collection/invoke-map.ts | 40 - libs/nanofn/src/collection/key-by.ts | 37 - libs/nanofn/src/collection/order-by.ts | 56 -- libs/nanofn/src/collection/partition.ts | 37 - libs/nanofn/src/collection/reduce-right.ts | 34 - libs/nanofn/src/collection/reduce.ts | 49 -- libs/nanofn/src/collection/reject.ts | 35 - libs/nanofn/src/collection/size.ts | 48 -- libs/nanofn/src/is/is-arguments.ts | 28 - libs/nanofn/src/is/is-array-buffer.ts | 30 - libs/nanofn/src/is/is-array-like-object.ts | 36 - libs/nanofn/src/is/is-array-like.ts | 35 - libs/nanofn/src/is/is-boolean.ts | 29 - libs/nanofn/src/is/is-buffer.ts | 38 - libs/nanofn/src/is/is-date.ts | 30 - libs/nanofn/src/is/is-element.ts | 28 - libs/nanofn/src/is/is-empty.ts | 74 -- libs/nanofn/src/is/is-equal-with.ts | 43 - libs/nanofn/src/is/is-error.ts | 35 - libs/nanofn/src/is/is-function.ts | 37 - libs/nanofn/src/is/is-length.ts | 38 - libs/nanofn/src/is/is-map.ts | 30 - libs/nanofn/src/is/is-match-with.ts | 44 - libs/nanofn/src/is/is-match.ts | 39 - libs/nanofn/src/is/is-native.ts | 41 - libs/nanofn/src/is/is-nil.ts | 28 - libs/nanofn/src/is/is-null.ts | 25 - libs/nanofn/src/is/is-number.ts | 39 - libs/nanofn/src/is/is-object-like.ts | 32 - libs/nanofn/src/is/is-object.ts | 34 - libs/nanofn/src/is/is-plain-object.ts | 49 -- libs/nanofn/src/is/is-reg-exp.ts | 31 - libs/nanofn/src/is/is-set.ts | 30 - libs/nanofn/src/is/is-string.ts | 33 - libs/nanofn/src/is/is-symbol.ts | 29 - libs/nanofn/src/is/is-typed-array.ts | 33 - libs/nanofn/src/is/is-undefined.ts | 25 - libs/nanofn/src/is/is-weak-map.ts | 28 - libs/nanofn/src/is/is-weak-set.ts | 28 - libs/nanofn/src/lang/conforms-to.ts | 35 - libs/nanofn/src/lang/eq-deep.ts | 38 - libs/nanofn/src/lang/eq.ts | 40 - libs/nanofn/src/lang/gt.ts | 35 - libs/nanofn/src/lang/gte.ts | 35 - libs/nanofn/src/lang/lt.ts | 35 - libs/nanofn/src/lang/lte.ts | 35 - libs/nanofn/src/math/add.ts | 22 - libs/nanofn/src/math/ceil.ts | 28 - libs/nanofn/src/math/divide.ts | 23 - libs/nanofn/src/math/floor.ts | 28 - libs/nanofn/src/math/max-by.ts | 45 - libs/nanofn/src/math/mean-by.ts | 33 - libs/nanofn/src/math/mean.ts | 24 - libs/nanofn/src/math/min-by.ts | 45 - libs/nanofn/src/math/multiply.ts | 23 - libs/nanofn/src/math/round.ts | 29 - libs/nanofn/src/math/subtract.ts | 21 - libs/nanofn/src/math/sum-by.ts | 31 - libs/nanofn/src/math/sum.ts | 26 - libs/nanofn/src/num/clamp.ts | 36 - libs/nanofn/src/num/in-range.ts | 53 -- libs/nanofn/src/num/random.ts | 83 -- libs/nanofn/src/obj/at.ts | 24 - libs/nanofn/src/obj/create.ts | 42 - libs/nanofn/src/obj/defaults-deep.ts | 31 - libs/nanofn/src/obj/defaults.ts | 50 -- libs/nanofn/src/obj/every-value.ts | 39 - libs/nanofn/src/obj/filter-object.ts | 39 - libs/nanofn/src/obj/find-key.ts | 43 - libs/nanofn/src/obj/find-last-key.ts | 33 - libs/nanofn/src/obj/for-own-right.ts | 39 - libs/nanofn/src/obj/for-own.ts | 34 - libs/nanofn/src/obj/getter.ts | 37 - libs/nanofn/src/obj/has-in.ts | 29 - libs/nanofn/src/obj/has-path-in.ts | 55 -- libs/nanofn/src/obj/has-path.ts | 58 -- libs/nanofn/src/obj/has.ts | 33 - libs/nanofn/src/obj/invert-by.ts | 41 - libs/nanofn/src/obj/invert.ts | 36 - libs/nanofn/src/obj/invoke.ts | 34 - libs/nanofn/src/obj/keys-in.ts | 37 - libs/nanofn/src/obj/keys.ts | 42 - libs/nanofn/src/obj/map-key.ts | 39 - libs/nanofn/src/obj/map-object.ts | 37 - libs/nanofn/src/obj/map-value.ts | 38 - libs/nanofn/src/obj/merge-with.ts | 40 - libs/nanofn/src/obj/merge.ts | 42 - libs/nanofn/src/obj/pick-by.ts | 34 - libs/nanofn/src/obj/pick.ts | 27 - libs/nanofn/src/obj/result.ts | 58 -- libs/nanofn/src/obj/set-with.ts | 35 - libs/nanofn/src/obj/setter.ts | 39 - libs/nanofn/src/obj/transform.ts | 62 -- libs/nanofn/src/obj/unset.ts | 38 - libs/nanofn/src/obj/update-with.ts | 35 - libs/nanofn/src/obj/update.ts | 35 - libs/nanofn/src/obj/values.ts | 38 - libs/nanofn/src/str/deburr.ts | 51 -- libs/nanofn/src/str/ends-with.ts | 41 - libs/nanofn/src/str/escape-reg-exp.ts | 33 - libs/nanofn/src/str/escape.ts | 52 -- libs/nanofn/src/str/pad.ts | 100 --- libs/nanofn/src/str/parse-int.ts | 41 - libs/nanofn/src/str/repeat.ts | 45 - libs/nanofn/src/str/replace.ts | 29 - libs/nanofn/src/str/split.ts | 47 -- libs/nanofn/src/str/starts-with.ts | 40 - libs/nanofn/src/str/trim-end.ts | 41 - libs/nanofn/src/str/trim-start.ts | 41 - libs/nanofn/src/str/trim.ts | 43 - libs/nanofn/src/str/truncate.ts | 118 --- libs/nanofn/src/str/unescape.ts | 43 - libs/nanofn/src/util/attempt.ts | 35 - libs/nanofn/src/util/cond.ts | 54 -- libs/nanofn/src/util/conforms.ts | 38 - libs/nanofn/src/util/default-to-any.ts | 37 - libs/nanofn/src/util/default-to.ts | 28 - libs/nanofn/src/util/flow-right.ts | 33 - libs/nanofn/src/util/flow.ts | 46 - libs/nanofn/src/util/matches-property.ts | 40 - libs/nanofn/src/util/matches.ts | 42 - libs/nanofn/src/util/method-of.ts | 33 - libs/nanofn/src/util/method.ts | 34 - libs/nanofn/src/util/over-every.ts | 36 - libs/nanofn/src/util/over-some.ts | 36 - libs/nanofn/src/util/over.ts | 30 - libs/nanofn/src/util/property-of.ts | 31 - libs/nanofn/src/util/property.ts | 35 - libs/nanofn/src/util/range-right.ts | 42 - libs/nanofn/src/util/range.ts | 47 -- libs/nanofn/src/util/times.ts | 47 -- libs/nanofn/src/util/unique-id.ts | 38 - libs/nanofn/test-setup.ts | 1 - libs/nanofn/test/Arrays-category-methods.js | 97 --- .../test/Strings-category-methods.test.js | 83 -- libs/nanofn/test/__proto__-property-bugs.js | 87 -- libs/nanofn/test/add.test.js | 15 - libs/nanofn/test/after.test.js | 31 - libs/nanofn/test/ary.js | 91 -- libs/nanofn/test/assign-and-assignIn.js | 88 -- libs/nanofn/test/assignIn.js | 9 - libs/nanofn/test/assignInWith.js | 9 - .../test/assignWith-and-assignInWith.js | 22 - libs/nanofn/test/at.test.js | 124 --- libs/nanofn/test/attempt.test.js | 55 -- libs/nanofn/test/basename.js | 151 ---- libs/nanofn/test/before.js | 31 - libs/nanofn/test/bind.js | 231 ----- libs/nanofn/test/bindAll.js | 74 -- libs/nanofn/test/bindKey.js | 66 -- libs/nanofn/test/camelCase.test.js | 28 - libs/nanofn/test/capitalize.test.js | 10 - libs/nanofn/test/case-methods.test.js | 105 --- libs/nanofn/test/castArray.test.js | 23 - libs/nanofn/test/chain.js | 74 -- libs/nanofn/test/chunk.test.js | 45 - libs/nanofn/test/clamp.js | 58 -- libs/nanofn/test/clone-methods.js | 429 ---------- libs/nanofn/test/compact.js | 42 - libs/nanofn/test/concat.js | 65 -- libs/nanofn/test/cond.js | 65 -- libs/nanofn/test/conforms-methods.js | 153 ---- libs/nanofn/test/conforms.js | 15 - libs/nanofn/test/constant.js | 40 - libs/nanofn/test/countBy.js | 66 -- libs/nanofn/test/create.test.js | 99 --- libs/nanofn/test/curry-methods.js | 52 -- libs/nanofn/test/curry.js | 135 --- libs/nanofn/test/curryRight.js | 136 --- libs/nanofn/test/custom-_.iteratee-methods.js | 270 ------ libs/nanofn/test/debounce-and-throttle.js | 167 ---- libs/nanofn/test/debounce.test.js | 250 ------ libs/nanofn/test/deburr.test.js | 28 - libs/nanofn/test/defaultTo.test.js | 18 - libs/nanofn/test/defaults.test.js | 66 -- libs/nanofn/test/defaultsDeep.js | 101 --- libs/nanofn/test/defer.test.js | 40 - libs/nanofn/test/delay.js | 67 -- libs/nanofn/test/difference-methods.js | 85 -- libs/nanofn/test/differenceBy.js | 23 - libs/nanofn/test/differenceWith.test.js | 26 - libs/nanofn/test/divide.test.js | 15 - libs/nanofn/test/drop.test.js | 62 -- libs/nanofn/test/dropRight.test.js | 62 -- libs/nanofn/test/dropRightWhile.js | 52 -- libs/nanofn/test/dropWhile.js | 67 -- libs/nanofn/test/endsWith.test.js | 49 -- libs/nanofn/test/eq.test.js | 21 - libs/nanofn/test/escape.test.js | 30 - libs/nanofn/test/escapeRegExp.test.js | 28 - libs/nanofn/test/every.js | 74 -- libs/nanofn/test/exit-early.js | 37 - libs/nanofn/test/extremum-methods.js | 64 -- libs/nanofn/test/fill.js | 128 --- libs/nanofn/test/filter-methods.js | 100 --- libs/nanofn/test/filter.test.js | 11 - libs/nanofn/test/find-and-findLast.js | 22 - libs/nanofn/test/find-and-includes.js | 103 --- libs/nanofn/test/find-methods.js | 139 --- libs/nanofn/test/findLast.test.js | 99 --- .../findLastIndex-and-lastIndexOf.test.js | 72 -- libs/nanofn/test/flatMap-methods.js | 72 -- libs/nanofn/test/flatMapDepth.js | 33 - libs/nanofn/test/flatten-methods.js | 106 --- libs/nanofn/test/flattenDepth.js | 21 - libs/nanofn/test/flip.test.js | 14 - libs/nanofn/test/flow-methods.test.js | 53 -- libs/nanofn/test/forEach.test.js | 9 - libs/nanofn/test/forEachRight.test.js | 9 - libs/nanofn/test/forIn-methods.js | 20 - libs/nanofn/test/forOwn-methods.js | 17 - libs/nanofn/test/fromPairs.js | 47 -- libs/nanofn/test/functions.test.js | 22 - libs/nanofn/test/get-and-result.js | 148 ---- libs/nanofn/test/groupBy.js | 68 -- libs/nanofn/test/gt.test.js | 16 - libs/nanofn/test/gte.test.js | 16 - libs/nanofn/test/has-methods.js | 205 ----- libs/nanofn/test/head.js | 62 -- libs/nanofn/test/identity.js | 9 - libs/nanofn/test/inRange.js | 54 -- libs/nanofn/test/includes.js | 95 --- libs/nanofn/test/indexOf-methods.js | 63 -- libs/nanofn/test/indexOf.test.js | 60 -- libs/nanofn/test/initial.js | 61 -- libs/nanofn/test/intersection-methods.js | 91 -- libs/nanofn/test/intersectionBy.js | 23 - libs/nanofn/test/intersectionWith.test.js | 27 - libs/nanofn/test/invert.test.js | 30 - libs/nanofn/test/invertBy.js | 42 - libs/nanofn/test/invoke.js | 71 -- libs/nanofn/test/invokeMap.js | 105 --- libs/nanofn/test/isArguments.test.js | 39 - libs/nanofn/test/isArray.js | 38 - libs/nanofn/test/isArrayBuffer.test.js | 41 - libs/nanofn/test/isArrayLike.test.js | 48 -- libs/nanofn/test/isBoolean.test.js | 43 - libs/nanofn/test/isBuffer.test.js | 41 - libs/nanofn/test/isDate.test.js | 38 - libs/nanofn/test/isElement.test.js | 58 -- libs/nanofn/test/isEmpty.js | 119 --- libs/nanofn/test/isEqual.js | 700 --------------- libs/nanofn/test/isEqualWith.js | 128 --- libs/nanofn/test/isError.test.js | 70 -- libs/nanofn/test/isFinite.js | 48 -- libs/nanofn/test/isFunction.js | 83 -- libs/nanofn/test/isIndex.test.js | 34 - libs/nanofn/test/isInteger-methods.js | 55 -- libs/nanofn/test/isIterateeCall.js | 47 -- libs/nanofn/test/isLength.test.js | 22 - libs/nanofn/test/isMap.test.js | 53 -- libs/nanofn/test/isMatchWith.js | 137 --- libs/nanofn/test/isNaN.js | 43 - libs/nanofn/test/isNative.js | 92 -- libs/nanofn/test/isNil.test.js | 47 -- libs/nanofn/test/isNull.test.js | 41 - libs/nanofn/test/isNumber.test.js | 42 - libs/nanofn/test/isObject.test.js | 53 -- libs/nanofn/test/isObjectLike.test.js | 40 - libs/nanofn/test/isPlainObject.js | 114 --- libs/nanofn/test/isRegExp.test.js | 39 - libs/nanofn/test/isSet.test.js | 53 -- libs/nanofn/test/isString.test.js | 41 - libs/nanofn/test/isSymbol.test.js | 41 - libs/nanofn/test/isType-checks.js | 39 - libs/nanofn/test/isTypedArray.js | 59 -- libs/nanofn/test/isUndefined.test.js | 45 - libs/nanofn/test/isWeakMap.test.js | 53 -- libs/nanofn/test/isWeakSet.test.js | 42 - libs/nanofn/test/iteratee.js | 164 ---- libs/nanofn/test/iteration-methods.js | 340 -------- libs/nanofn/test/join.js | 20 - libs/nanofn/test/keyBy.js | 76 -- libs/nanofn/test/keys-methods.js | 183 ---- libs/nanofn/test/last.js | 51 -- ...-methods-that-return-new-wrapped-values.js | 45 - ...-that-return-the-wrapped-modified-array.js | 22 - ....)-methods-that-return-unwrapped-values.js | 112 --- libs/nanofn/test/lodash(...).commit.js | 21 - libs/nanofn/test/lodash(...).next.js | 74 -- libs/nanofn/test/lodash(...).plant.js | 39 - libs/nanofn/test/lodash(...).pop.js | 31 - libs/nanofn/test/lodash(...).push.js | 27 - libs/nanofn/test/lodash(...).shift.js | 31 - libs/nanofn/test/lodash(...).sort.js | 27 - libs/nanofn/test/lodash(...).splice.js | 31 - libs/nanofn/test/lodash(...).unshift.js | 27 - libs/nanofn/test/lodash(...).value.js | 33 - libs/nanofn/test/lodash-constructor.js | 39 - libs/nanofn/test/lodash-methods.js | 194 ----- libs/nanofn/test/lodash.methodName.js | 75 -- libs/nanofn/test/lowerCase.test.js | 10 - libs/nanofn/test/lowerFirst.test.js | 10 - libs/nanofn/test/lt.test.js | 16 - libs/nanofn/test/lte.test.js | 17 - libs/nanofn/test/map-caches.js | 63 -- libs/nanofn/test/map.js | 122 --- libs/nanofn/test/mapKeys-and-mapValues.js | 36 - libs/nanofn/test/mapKeys.js | 35 - libs/nanofn/test/mapValues.js | 36 - libs/nanofn/test/matches-methods.js | 294 ------- libs/nanofn/test/matches.js | 32 - libs/nanofn/test/matchesProperty.js | 368 -------- libs/nanofn/test/math-operator-methods.js | 56 -- libs/nanofn/test/max.js | 27 - libs/nanofn/test/mean.test.js | 18 - libs/nanofn/test/meanBy.js | 31 - libs/nanofn/test/memoize.test.js | 178 ---- libs/nanofn/test/memoizeCapped.test.js | 21 - libs/nanofn/test/merge.test.js | 350 -------- libs/nanofn/test/mergeWith.js | 64 -- libs/nanofn/test/method.js | 132 --- libs/nanofn/test/methodOf.js | 131 --- .../test/methods-using-createWrapper.js | 198 ----- libs/nanofn/test/min.js | 27 - libs/nanofn/test/mixin.js | 189 ----- libs/nanofn/test/multiply.test.js | 15 - libs/nanofn/test/negate.js | 39 - libs/nanofn/test/noConflict.js | 33 - libs/nanofn/test/now.js | 26 - libs/nanofn/test/nth.js | 69 -- libs/nanofn/test/nthArg.js | 65 -- libs/nanofn/test/number-coercion-methods.js | 248 ------ libs/nanofn/test/object-assignments.js | 180 ---- libs/nanofn/test/omit-methods.js | 114 --- libs/nanofn/test/omit.js | 69 -- libs/nanofn/test/omitBy.js | 14 - libs/nanofn/test/once.test.js | 36 - libs/nanofn/test/orderBy.js | 61 -- libs/nanofn/test/over.js | 58 -- libs/nanofn/test/overArgs.js | 82 -- libs/nanofn/test/overEvery.js | 87 -- libs/nanofn/test/overSome.js | 98 --- libs/nanofn/test/pad-methods.js | 51 -- libs/nanofn/test/pad.js | 35 - libs/nanofn/test/padEnd.js | 34 - libs/nanofn/test/padStart.js | 34 - libs/nanofn/test/parseInt.js | 81 -- libs/nanofn/test/partial-methods.js | 113 --- libs/nanofn/test/partialRight.js | 18 - libs/nanofn/test/partition.js | 48 -- libs/nanofn/test/pick-methods.js | 85 -- libs/nanofn/test/pick.js | 52 -- libs/nanofn/test/pickBy.test.js | 22 - libs/nanofn/test/property.test.js | 122 --- libs/nanofn/test/propertyOf.test.js | 122 --- libs/nanofn/test/pull-methods.js | 49 -- libs/nanofn/test/pullAll.test.js | 11 - libs/nanofn/test/pullAllBy.test.js | 26 - libs/nanofn/test/pullAllWith.test.js | 13 - libs/nanofn/test/pullAt.js | 122 --- libs/nanofn/test/random.js | 104 --- libs/nanofn/test/range-methods.js | 82 -- libs/nanofn/test/rearg.js | 70 -- libs/nanofn/test/reduce-methods.js | 68 -- libs/nanofn/test/reduce.js | 57 -- libs/nanofn/test/reduceRight.js | 56 -- libs/nanofn/test/reject.test.js | 11 - libs/nanofn/test/remove.js | 80 -- libs/nanofn/test/repeat.js | 46 - libs/nanofn/test/replace.test.js | 10 - libs/nanofn/test/rest.js | 49 -- libs/nanofn/test/result.test.js | 33 - libs/nanofn/test/reverse.js | 94 --- libs/nanofn/test/round-methods.js | 82 -- libs/nanofn/test/runInContext.js | 29 - libs/nanofn/test/sample.js | 32 - libs/nanofn/test/sampleSize.js | 76 -- libs/nanofn/test/set-methods.js | 172 ---- libs/nanofn/test/setWith.js | 19 - libs/nanofn/test/shuffle.js | 29 - libs/nanofn/test/size.test.js | 75 -- libs/nanofn/test/slice-and-toArray.js | 43 - libs/nanofn/test/slice.js | 133 --- libs/nanofn/test/some.js | 76 -- libs/nanofn/test/sortBy-methods.js | 87 -- libs/nanofn/test/sortBy.js | 75 -- libs/nanofn/test/sortedIndex-methods.js | 84 -- libs/nanofn/test/sortedIndexBy-methods.js | 59 -- libs/nanofn/test/sortedIndexOf-methods.js | 15 - libs/nanofn/test/sortedUniq.test.js | 13 - libs/nanofn/test/split.js | 35 - libs/nanofn/test/spread.js | 58 -- libs/nanofn/test/startCase.test.js | 10 - libs/nanofn/test/startsWith-and-endsWith.js | 38 - libs/nanofn/test/startsWith.js | 47 -- libs/nanofn/test/strict-mode-checks.js | 22 - libs/nanofn/test/stub-methods.js | 32 - libs/nanofn/test/subtract.test.js | 15 - libs/nanofn/test/sum-methods.js | 36 - libs/nanofn/test/sumBy.js | 32 - libs/nanofn/test/tail.js | 77 -- libs/nanofn/test/take.js | 65 -- libs/nanofn/test/takeRight.js | 65 -- libs/nanofn/test/takeRightWhile.js | 96 --- libs/nanofn/test/takeWhile.js | 102 --- libs/nanofn/test/tap.js | 30 - libs/nanofn/test/template.js | 451 ---------- libs/nanofn/test/throttle.js | 227 ----- libs/nanofn/test/times.js | 62 -- libs/nanofn/test/toArray.test.js | 48 -- libs/nanofn/test/toInteger-methods.js | 25 - libs/nanofn/test/toLength.test.js | 22 - libs/nanofn/test/toLower.js | 10 - libs/nanofn/test/toPairs-methods.js | 61 -- libs/nanofn/test/toPairs.js | 9 - libs/nanofn/test/toPairsIn.js | 9 - libs/nanofn/test/toPath.js | 66 -- libs/nanofn/test/toPlainObject.js | 30 - libs/nanofn/test/toString.test.js | 43 - libs/nanofn/test/toUpper.js | 10 - libs/nanofn/test/transform.js | 205 ----- libs/nanofn/test/trim-methods.js | 83 -- libs/nanofn/test/truncate.js | 64 -- libs/nanofn/test/unary.js | 27 - libs/nanofn/test/uncommon-symbols.js | 170 ---- libs/nanofn/test/unescape.js | 40 - libs/nanofn/test/union-methods.js | 31 - libs/nanofn/test/unionBy.js | 28 - libs/nanofn/test/unionWith.test.js | 24 - libs/nanofn/test/uniq-methods.js | 123 --- libs/nanofn/test/uniq.js | 11 - libs/nanofn/test/uniqBy-methods.js | 74 -- libs/nanofn/test/uniqWith.test.js | 28 - libs/nanofn/test/uniqueId.test.js | 22 - libs/nanofn/test/unset.js | 119 --- libs/nanofn/test/unzip-and-zip.js | 72 -- libs/nanofn/test/unzipWith.js | 39 - libs/nanofn/test/update-methods.js | 25 - libs/nanofn/test/updateWith.js | 19 - libs/nanofn/test/upperCase.test.js | 10 - libs/nanofn/test/upperFirst.test.js | 10 - libs/nanofn/test/utils.js | 799 ------------------ libs/nanofn/test/values-methods.js | 47 -- libs/nanofn/test/without.test.js | 23 - libs/nanofn/test/words.test.js | 117 --- libs/nanofn/test/wrap.js | 46 - libs/nanofn/test/xor-methods.js | 70 -- libs/nanofn/test/xorBy.js | 23 - libs/nanofn/test/xorWith.test.js | 13 - libs/nanofn/test/zipObject-methods.js | 39 - libs/nanofn/test/zipWith.js | 48 -- libs/nanofn/tsconfig.json | 24 - libs/nanofn/tsconfig.lib.json | 16 - libs/nanofn/tsconfig.lib.prod.json | 10 - libs/nanofn/tsconfig.spec.json | 10 - libs/nanofn/tslint.json | 7 - libs/triangle/accordion/ng-package.json | 10 +- libs/triangle/alert/ng-package.json | 10 +- libs/triangle/anchor/ng-package.json | 10 +- libs/triangle/auth/ng-package.json | 10 +- libs/triangle/autocomplete/ng-package.json | 10 +- libs/triangle/avatar/ng-package.json | 10 +- libs/triangle/back-top/ng-package.json | 10 +- libs/triangle/badge/ng-package.json | 10 +- libs/triangle/breadcrumb/ng-package.json | 10 +- libs/triangle/button-toggle/ng-package.json | 10 +- libs/triangle/button/ng-package.json | 10 +- libs/triangle/button/src/button.component.ts | 12 +- libs/triangle/calendar/ng-package.json | 10 +- .../src/calendar-header.component.html | 4 +- libs/triangle/card/ng-package.json | 10 +- libs/triangle/cascader/ng-package.json | 10 +- libs/triangle/checkbox/ng-package.json | 10 +- .../checkbox/src/checkbox-group.component.ts | 2 +- libs/triangle/combobox/ng-package.json | 10 +- .../combobox/src/combobox.component.ts | 14 +- .../src/option-container.component.ts | 10 +- .../combobox/src/option-li.component.ts | 8 +- .../src/select-top-control.component.ts | 26 +- libs/triangle/combobox/src/select.service.ts | 97 ++- libs/triangle/confirm-popup/ng-package.json | 10 +- .../src/confirm-popup.component.ts | 30 +- libs/triangle/core/ng-package.json | 10 +- libs/triangle/data-query/ng-package.json | 10 +- libs/triangle/data-table/ng-package.json | 10 +- .../data-table/src/data-table.component.ts | 2 +- libs/triangle/date-picker/ng-package.json | 10 +- libs/triangle/desc-list/ng-package.json | 10 +- libs/triangle/diagram/ng-package.json | 10 +- .../entities/canvas/canvas-widget.ts | 8 +- .../diagram-core/entities/node/node-widget.ts | 2 +- .../src/diagram-core/x/x-link-point-widget.ts | 4 +- .../triangle/diagram/src/diagram.component.ts | 20 +- libs/triangle/dialog/ng-package.json | 10 +- libs/triangle/divider/ng-package.json | 10 +- libs/triangle/dnd/ng-package.json | 10 +- .../dnd/src/directives/drop-grid-container.ts | 32 +- .../src/drag-drop-ref/dnd-container-ref.ts | 11 +- libs/triangle/dnd/src/utils/client-rect.ts | 22 +- libs/triangle/drag-drop/ng-package.json | 10 +- libs/triangle/draggable/ng-package.json | 10 +- libs/triangle/drawer/ng-package.json | 10 +- libs/triangle/dropdown/ng-package.json | 10 +- libs/triangle/empty/ng-package.json | 10 +- libs/triangle/form-field/ng-package.json | 10 +- libs/triangle/form/ng-package.json | 10 +- libs/triangle/grid-list/ng-package.json | 10 +- libs/triangle/grid/ng-package.json | 10 +- libs/triangle/gridster/ng-package.json | 10 +- .../gridster/src/gridster.component.ts | 4 +- libs/triangle/i18n/ng-package.json | 10 +- libs/triangle/icon/ng-package.json | 10 +- libs/triangle/input-number/ng-package.json | 10 +- .../src/input-number.component.ts | 10 +- libs/triangle/input/ng-package.json | 10 +- libs/triangle/layout/ng-package.json | 10 +- libs/triangle/list/ng-package.json | 10 +- libs/triangle/list/src/list.component.ts | 2 +- libs/triangle/menu/ng-package.json | 10 +- libs/triangle/message/ng-package.json | 10 +- libs/triangle/modal/ng-package.json | 10 +- libs/triangle/navbar/ng-package.json | 10 +- libs/triangle/package.json | 2 +- libs/triangle/pagination/ng-package.json | 10 +- .../pagination/src/pagination.component.ts | 2 +- libs/triangle/popover/ng-package.json | 10 +- .../triangle/popover/src/popover.component.ts | 6 +- libs/triangle/progress/ng-package.json | 10 +- libs/triangle/radio/ng-package.json | 10 +- libs/triangle/rate/ng-package.json | 10 +- libs/triangle/rate/src/rate.component.ts | 17 +- libs/triangle/select/ng-package.json | 10 +- libs/triangle/select/src/select.ts | 2 +- libs/triangle/sidebar/ng-package.json | 10 +- libs/triangle/sidenav/ng-package.json | 10 +- libs/triangle/slider/index.ts | 7 - libs/triangle/slider/ng-package.json | 5 - libs/triangle/slider/public-api.ts | 13 - .../slider/src/slider-handle.component.ts | 93 -- .../slider/src/slider-marks.component.ts | 125 --- .../slider/src/slider-step.component.ts | 80 -- .../slider/src/slider-track.component.ts | 43 - libs/triangle/slider/src/slider.component.ts | 656 -------------- libs/triangle/slider/src/slider.module.ts | 55 -- libs/triangle/slider/src/slider.service.ts | 67 -- libs/triangle/slider/src/slider.types.ts | 10 - libs/triangle/slider/style/_slider-theme.scss | 102 --- libs/triangle/slider/style/slider.scss | 138 --- libs/triangle/spin/ng-package.json | 10 +- libs/triangle/splitter/ng-package.json | 10 +- libs/triangle/steps/ng-package.json | 10 +- libs/triangle/switch/ng-package.json | 10 +- libs/triangle/tab-nav-bar/ng-package.json | 5 - libs/triangle/tab-nav-bar/ng-package.json.bak | 5 + libs/triangle/tabs/ng-package.json | 5 - libs/triangle/tabs/ng-package.json.bak | 5 + .../triangle/tabs/src/paginated-tab-header.ts | 59 +- libs/triangle/tabs/src/tab-group.ts | 6 +- libs/triangle/tabs/src/tab-label-wrapper.ts | 11 +- libs/triangle/tag/ng-package.json | 10 +- libs/triangle/time-picker/ng-package.json | 10 +- libs/triangle/timeline/ng-package.json | 10 +- libs/triangle/tooltip/ng-package.json | 10 +- libs/triangle/tooltip/src/tooltip-base.ts | 2 +- .../tooltip/src/tooltip-component-base.ts | 8 +- .../triangle/tooltip/src/tooltip.component.ts | 5 +- libs/triangle/transfer/ng-package.json | 10 +- .../transfer/src/transfer-list.component.ts | 4 +- libs/triangle/tree-view/ng-package.json | 10 +- .../triangle/tree-view/src/check.directive.ts | 2 +- .../drag-and-drop-editing.directive.ts | 2 +- .../src/drag-and-drop/drag-and-drop-utils.ts | 2 +- .../drag-and-drop/drag-and-drop.directive.ts | 2 +- .../drag-clue/drag-clue.service.ts | 2 +- .../drop-hint/drop-hint.service.ts | 2 +- .../drag-and-drop-asset.service.ts | 2 +- .../editing-services/flat-editing.service.ts | 2 +- .../hierarchy-editing.service.ts | 2 +- libs/triangle/tree-view/src/filtering-base.ts | 2 +- .../tree-view/src/flat-binding.directive.ts | 2 +- .../src/hierarchy-binding.directive.ts | 2 +- .../src/load-more/load-more-utils.ts | 2 +- .../src/load-more/load-more.directive.ts | 2 +- .../src/navigation/navigation-model.ts | 2 +- .../src/navigation/navigation.service.ts | 2 +- .../src/selection/select.directive.ts | 2 +- libs/triangle/tree-view/src/shared.module.ts | 4 - .../tree-view/src/treeview-group.component.ts | 2 +- .../tree-view/src/treeview-item.directive.ts | 2 +- .../tree-view/src/treeview.component.ts | 2 +- libs/triangle/tree-view/src/utils.ts | 2 +- libs/triangle/tree/ng-package.json | 10 +- libs/triangle/tsconfig.json | 3 +- libs/triangle/util/ng-package.json | 10 +- package.json | 2 + tsconfig.base.json | 1 - yarn.lock | 14 + 836 files changed, 623 insertions(+), 39187 deletions(-) delete mode 100644 libs/nanofn/.babelrc delete mode 100644 libs/nanofn/.eslintrc.json delete mode 100644 libs/nanofn/CHANGELOG.md delete mode 100644 libs/nanofn/README.md delete mode 100644 libs/nanofn/index.ts delete mode 100644 libs/nanofn/jest.config.js delete mode 100644 libs/nanofn/ng-package.json delete mode 100644 libs/nanofn/package.json delete mode 100644 libs/nanofn/project.json delete mode 100644 libs/nanofn/public-api.ts delete mode 100644 libs/nanofn/src/_internal/add-map-entry.ts delete mode 100644 libs/nanofn/src/_internal/add-set-entry.ts delete mode 100644 libs/nanofn/src/_internal/array-each-right.ts delete mode 100644 libs/nanofn/src/_internal/array-each.ts delete mode 100644 libs/nanofn/src/_internal/array-includes-with.ts delete mode 100644 libs/nanofn/src/_internal/array-includes.ts delete mode 100644 libs/nanofn/src/_internal/array-like-keys.ts delete mode 100644 libs/nanofn/src/_internal/array-reduce-right.ts delete mode 100644 libs/nanofn/src/_internal/array-reduce.ts delete mode 100644 libs/nanofn/src/_internal/ascii-size.ts delete mode 100644 libs/nanofn/src/_internal/ascii-to-array.ts delete mode 100644 libs/nanofn/src/_internal/assign-merge-value.ts delete mode 100644 libs/nanofn/src/_internal/assign-value.ts delete mode 100644 libs/nanofn/src/_internal/assoc-index-of.ts delete mode 100644 libs/nanofn/src/_internal/base-assign-value.ts delete mode 100644 libs/nanofn/src/_internal/base-at.ts delete mode 100644 libs/nanofn/src/_internal/base-clone.ts delete mode 100644 libs/nanofn/src/_internal/base-conforms-to.ts delete mode 100644 libs/nanofn/src/_internal/base-conforms.ts delete mode 100644 libs/nanofn/src/_internal/base-difference.ts delete mode 100644 libs/nanofn/src/_internal/base-each-right.ts delete mode 100644 libs/nanofn/src/_internal/base-each.ts delete mode 100644 libs/nanofn/src/_internal/base-find-index.ts delete mode 100644 libs/nanofn/src/_internal/base-find-key.ts delete mode 100644 libs/nanofn/src/_internal/base-flatten.ts delete mode 100644 libs/nanofn/src/_internal/base-for-own-right.ts delete mode 100644 libs/nanofn/src/_internal/base-for-own.ts delete mode 100644 libs/nanofn/src/_internal/base-for-right.ts delete mode 100644 libs/nanofn/src/_internal/base-for.ts delete mode 100644 libs/nanofn/src/_internal/base-get.ts delete mode 100644 libs/nanofn/src/_internal/base-in-range.ts delete mode 100644 libs/nanofn/src/_internal/base-index-of-with.ts delete mode 100644 libs/nanofn/src/_internal/base-index-of.ts delete mode 100644 libs/nanofn/src/_internal/base-intersection.ts delete mode 100644 libs/nanofn/src/_internal/base-is-equal-deep.ts delete mode 100644 libs/nanofn/src/_internal/base-is-equal.ts delete mode 100644 libs/nanofn/src/_internal/base-is-match.ts delete mode 100644 libs/nanofn/src/_internal/base-is-nan.ts delete mode 100644 libs/nanofn/src/_internal/base-matches-property.ts delete mode 100644 libs/nanofn/src/_internal/base-matches.ts delete mode 100644 libs/nanofn/src/_internal/base-merge-deep.ts delete mode 100644 libs/nanofn/src/_internal/base-merge.ts delete mode 100644 libs/nanofn/src/_internal/base-order-by.ts delete mode 100644 libs/nanofn/src/_internal/base-pick-by.ts delete mode 100644 libs/nanofn/src/_internal/base-pick.ts delete mode 100644 libs/nanofn/src/_internal/base-property-deep.ts delete mode 100644 libs/nanofn/src/_internal/base-property-of.ts delete mode 100644 libs/nanofn/src/_internal/base-property.ts delete mode 100644 libs/nanofn/src/_internal/base-pull-all.ts delete mode 100644 libs/nanofn/src/_internal/base-pull-at.ts delete mode 100644 libs/nanofn/src/_internal/base-range.ts delete mode 100644 libs/nanofn/src/_internal/base-reduce.ts delete mode 100644 libs/nanofn/src/_internal/base-set.ts delete mode 100644 libs/nanofn/src/_internal/base-sort-by.ts delete mode 100644 libs/nanofn/src/_internal/base-sorted-index-by.ts delete mode 100644 libs/nanofn/src/_internal/base-sorted-index.ts delete mode 100644 libs/nanofn/src/_internal/base-sorted-uniq.ts delete mode 100644 libs/nanofn/src/_internal/base-sum.ts delete mode 100644 libs/nanofn/src/_internal/base-to-number.ts delete mode 100644 libs/nanofn/src/_internal/base-to-string.ts delete mode 100644 libs/nanofn/src/_internal/base-uniq.ts delete mode 100644 libs/nanofn/src/_internal/base-unset.ts delete mode 100644 libs/nanofn/src/_internal/base-update.ts delete mode 100644 libs/nanofn/src/_internal/base-values.ts delete mode 100644 libs/nanofn/src/_internal/base-while.ts delete mode 100644 libs/nanofn/src/_internal/base-xor.ts delete mode 100644 libs/nanofn/src/_internal/base-zip-object.ts delete mode 100644 libs/nanofn/src/_internal/cache-has.ts delete mode 100644 libs/nanofn/src/_internal/cast-array-like-object.ts delete mode 100644 libs/nanofn/src/_internal/cast-path.ts delete mode 100644 libs/nanofn/src/_internal/cast-slice.ts delete mode 100644 libs/nanofn/src/_internal/chars-end-index.ts delete mode 100644 libs/nanofn/src/_internal/chars-start-index.ts delete mode 100644 libs/nanofn/src/_internal/clone-array-buffer.ts delete mode 100644 libs/nanofn/src/_internal/clone-buffer.ts delete mode 100644 libs/nanofn/src/_internal/clone-data-view.ts delete mode 100644 libs/nanofn/src/_internal/clone-reg-exp.ts delete mode 100644 libs/nanofn/src/_internal/clone-symbol.ts delete mode 100644 libs/nanofn/src/_internal/clone-typed-array.ts delete mode 100644 libs/nanofn/src/_internal/compare-ascending.ts delete mode 100644 libs/nanofn/src/_internal/compare-multiple.ts delete mode 100644 libs/nanofn/src/_internal/compose-args-right.ts delete mode 100644 libs/nanofn/src/_internal/compose-args.ts delete mode 100644 libs/nanofn/src/_internal/copy-array.ts delete mode 100644 libs/nanofn/src/_internal/copy-object.ts delete mode 100644 libs/nanofn/src/_internal/copy-symbols-in.ts delete mode 100644 libs/nanofn/src/_internal/copy-symbols.ts delete mode 100644 libs/nanofn/src/_internal/create-assigner.ts delete mode 100644 libs/nanofn/src/_internal/create-math-operation.ts delete mode 100644 libs/nanofn/src/_internal/create-padding.ts delete mode 100644 libs/nanofn/src/_internal/create-range.ts delete mode 100644 libs/nanofn/src/_internal/create-round.ts delete mode 100644 libs/nanofn/src/_internal/create-set.ts delete mode 100644 libs/nanofn/src/_internal/custom-defaults-merge.ts delete mode 100644 libs/nanofn/src/_internal/deburr-letter.ts delete mode 100644 libs/nanofn/src/_internal/equal-arrays.ts delete mode 100644 libs/nanofn/src/_internal/equal-by-tag.ts delete mode 100644 libs/nanofn/src/_internal/equal-objects.ts delete mode 100644 libs/nanofn/src/_internal/free-global.ts delete mode 100644 libs/nanofn/src/_internal/get-all-keys-in.ts delete mode 100644 libs/nanofn/src/_internal/get-all-keys.ts delete mode 100644 libs/nanofn/src/_internal/get-holder.ts delete mode 100644 libs/nanofn/src/_internal/get-match-data.ts delete mode 100644 libs/nanofn/src/_internal/get-symbols-in.ts delete mode 100644 libs/nanofn/src/_internal/get-symbols.ts delete mode 100644 libs/nanofn/src/_internal/get-tag.ts delete mode 100644 libs/nanofn/src/_internal/has-unicode.ts delete mode 100644 libs/nanofn/src/_internal/hash.ts delete mode 100644 libs/nanofn/src/_internal/init-clone-object.ts delete mode 100644 libs/nanofn/src/_internal/is-flattenable.ts delete mode 100644 libs/nanofn/src/_internal/is-index.ts delete mode 100644 libs/nanofn/src/_internal/is-iteratee-call.ts delete mode 100644 libs/nanofn/src/_internal/is-key.ts delete mode 100644 libs/nanofn/src/_internal/is-prototype.ts delete mode 100644 libs/nanofn/src/_internal/is-strict-comparable.ts delete mode 100644 libs/nanofn/src/_internal/iterator-to-array.ts delete mode 100644 libs/nanofn/src/_internal/list-cache.ts delete mode 100644 libs/nanofn/src/_internal/map-cache.ts delete mode 100644 libs/nanofn/src/_internal/map-to-array.ts delete mode 100644 libs/nanofn/src/_internal/matches-strict-comparable.ts delete mode 100644 libs/nanofn/src/_internal/meta-map.ts delete mode 100644 libs/nanofn/src/_internal/node-types.ts delete mode 100644 libs/nanofn/src/_internal/parent.ts delete mode 100644 libs/nanofn/src/_internal/re-escape.ts delete mode 100644 libs/nanofn/src/_internal/re-evaluate.ts delete mode 100644 libs/nanofn/src/_internal/re-interpolate.ts delete mode 100644 libs/nanofn/src/_internal/root.ts delete mode 100644 libs/nanofn/src/_internal/set-cache.ts delete mode 100644 libs/nanofn/src/_internal/set-to-array.ts delete mode 100644 libs/nanofn/src/_internal/set-to-pairs.ts delete mode 100644 libs/nanofn/src/_internal/set-to-string.ts delete mode 100644 libs/nanofn/src/_internal/stack.ts delete mode 100644 libs/nanofn/src/_internal/strict-index-of.ts delete mode 100644 libs/nanofn/src/_internal/strict-last-index-of.ts delete mode 100644 libs/nanofn/src/_internal/string-size.ts delete mode 100644 libs/nanofn/src/_internal/string-to-array.ts delete mode 100644 libs/nanofn/src/_internal/string-to-path.ts delete mode 100644 libs/nanofn/src/_internal/to-key.ts delete mode 100644 libs/nanofn/src/_internal/unicode-size.ts delete mode 100644 libs/nanofn/src/_internal/unicode-to-array.ts delete mode 100644 libs/nanofn/src/_internal/unicode-words.ts delete mode 100644 libs/nanofn/src/arr/chunk.ts delete mode 100644 libs/nanofn/src/arr/compact.ts delete mode 100644 libs/nanofn/src/arr/difference/difference.ts delete mode 100644 libs/nanofn/src/arr/drop.ts delete mode 100644 libs/nanofn/src/arr/each.ts delete mode 100644 libs/nanofn/src/arr/every.ts delete mode 100644 libs/nanofn/src/arr/filter.ts delete mode 100644 libs/nanofn/src/arr/find-last-index.ts delete mode 100644 libs/nanofn/src/arr/first.ts delete mode 100644 libs/nanofn/src/arr/flat/flat-map-deep.ts delete mode 100644 libs/nanofn/src/arr/flat/flat-map-depth.ts delete mode 100644 libs/nanofn/src/arr/flat/flat-map.ts delete mode 100644 libs/nanofn/src/arr/flat/flatten-deep.ts delete mode 100644 libs/nanofn/src/arr/flat/flatten-depth.ts delete mode 100644 libs/nanofn/src/arr/flat/flatten.ts delete mode 100644 libs/nanofn/src/arr/from-entries.ts delete mode 100644 libs/nanofn/src/arr/head.ts delete mode 100644 libs/nanofn/src/arr/index-of.ts delete mode 100644 libs/nanofn/src/arr/initial.ts delete mode 100644 libs/nanofn/src/arr/intersection-by.ts delete mode 100644 libs/nanofn/src/arr/intersection-with.ts delete mode 100644 libs/nanofn/src/arr/intersection.ts delete mode 100644 libs/nanofn/src/arr/last-index-of.ts delete mode 100644 libs/nanofn/src/arr/last.ts delete mode 100644 libs/nanofn/src/arr/map.ts delete mode 100644 libs/nanofn/src/arr/nth.ts delete mode 100644 libs/nanofn/src/arr/pull/pull-all-by.ts delete mode 100644 libs/nanofn/src/arr/pull/pull-all-with.ts delete mode 100644 libs/nanofn/src/arr/pull/pull-all.ts delete mode 100644 libs/nanofn/src/arr/pull/pull-at.ts delete mode 100644 libs/nanofn/src/arr/pull/pull.ts delete mode 100644 libs/nanofn/src/arr/remove.ts delete mode 100644 libs/nanofn/src/arr/sample-size.ts delete mode 100644 libs/nanofn/src/arr/sample.ts delete mode 100644 libs/nanofn/src/arr/shuffle.ts delete mode 100644 libs/nanofn/src/arr/slice.ts delete mode 100644 libs/nanofn/src/arr/some.ts delete mode 100644 libs/nanofn/src/arr/sort/some-value.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-index-by.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-index-of.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-index.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-last-index-by.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-last-index-of.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-last-index.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-uniq-by.ts delete mode 100644 libs/nanofn/src/arr/sort/sorted-uniq.ts delete mode 100644 libs/nanofn/src/arr/tail.ts delete mode 100644 libs/nanofn/src/arr/take/take-right-while.ts delete mode 100644 libs/nanofn/src/arr/take/take-right.ts delete mode 100644 libs/nanofn/src/arr/take/take-while.ts delete mode 100644 libs/nanofn/src/arr/take/take.ts delete mode 100644 libs/nanofn/src/arr/union/union-by.ts delete mode 100644 libs/nanofn/src/arr/union/union-with.ts delete mode 100644 libs/nanofn/src/arr/union/union.ts delete mode 100644 libs/nanofn/src/arr/uniq/uniq-by.ts delete mode 100644 libs/nanofn/src/arr/uniq/uniq-with.ts delete mode 100644 libs/nanofn/src/arr/uniq/uniq.ts delete mode 100644 libs/nanofn/src/arr/without.ts delete mode 100644 libs/nanofn/src/arr/xor/xor-by.ts delete mode 100644 libs/nanofn/src/arr/xor/xor-with.ts delete mode 100644 libs/nanofn/src/arr/xor/xor.ts delete mode 100644 libs/nanofn/src/arr/zip/unzip-with.ts delete mode 100644 libs/nanofn/src/arr/zip/unzip.ts delete mode 100644 libs/nanofn/src/arr/zip/zip-object-deep.ts delete mode 100644 libs/nanofn/src/arr/zip/zip-object.ts delete mode 100644 libs/nanofn/src/arr/zip/zip-with.ts delete mode 100644 libs/nanofn/src/arr/zip/zip.ts delete mode 100644 libs/nanofn/src/case/camel-case.ts delete mode 100644 libs/nanofn/src/case/capitalize.ts delete mode 100644 libs/nanofn/src/case/kebab-case.ts delete mode 100644 libs/nanofn/src/case/lower-case.ts delete mode 100644 libs/nanofn/src/case/lower-first.ts delete mode 100644 libs/nanofn/src/case/snake-case.ts delete mode 100644 libs/nanofn/src/case/start-case.ts delete mode 100644 libs/nanofn/src/case/str-case.ts delete mode 100644 libs/nanofn/src/case/upper-case.ts delete mode 100644 libs/nanofn/src/case/upper-first.ts delete mode 100644 libs/nanofn/src/case/words.ts delete mode 100644 libs/nanofn/src/cast/cast-array.ts delete mode 100644 libs/nanofn/src/cast/to-array.ts delete mode 100644 libs/nanofn/src/cast/to-finite.ts delete mode 100644 libs/nanofn/src/cast/to-integer.ts delete mode 100644 libs/nanofn/src/cast/to-length.ts delete mode 100644 libs/nanofn/src/cast/to-number.ts delete mode 100644 libs/nanofn/src/cast/to-path.ts delete mode 100644 libs/nanofn/src/cast/to-plain-object.ts delete mode 100644 libs/nanofn/src/cast/to-safe-integer.ts delete mode 100644 libs/nanofn/src/cast/to-string.ts delete mode 100644 libs/nanofn/src/clone/clone-deep-with.ts delete mode 100644 libs/nanofn/src/clone/clone-deep.ts delete mode 100644 libs/nanofn/src/clone/clone-with.ts delete mode 100644 libs/nanofn/src/clone/clone.ts delete mode 100644 libs/nanofn/src/collection/count-by.ts delete mode 100644 libs/nanofn/src/collection/find-last.ts delete mode 100644 libs/nanofn/src/collection/for-each-right.ts delete mode 100644 libs/nanofn/src/collection/for-each.ts delete mode 100644 libs/nanofn/src/collection/group-by.ts delete mode 100644 libs/nanofn/src/collection/invoke-map.ts delete mode 100644 libs/nanofn/src/collection/key-by.ts delete mode 100644 libs/nanofn/src/collection/order-by.ts delete mode 100644 libs/nanofn/src/collection/partition.ts delete mode 100644 libs/nanofn/src/collection/reduce-right.ts delete mode 100644 libs/nanofn/src/collection/reduce.ts delete mode 100644 libs/nanofn/src/collection/reject.ts delete mode 100644 libs/nanofn/src/collection/size.ts delete mode 100644 libs/nanofn/src/is/is-arguments.ts delete mode 100644 libs/nanofn/src/is/is-array-buffer.ts delete mode 100644 libs/nanofn/src/is/is-array-like-object.ts delete mode 100644 libs/nanofn/src/is/is-array-like.ts delete mode 100644 libs/nanofn/src/is/is-boolean.ts delete mode 100644 libs/nanofn/src/is/is-buffer.ts delete mode 100644 libs/nanofn/src/is/is-date.ts delete mode 100644 libs/nanofn/src/is/is-element.ts delete mode 100644 libs/nanofn/src/is/is-empty.ts delete mode 100644 libs/nanofn/src/is/is-equal-with.ts delete mode 100644 libs/nanofn/src/is/is-error.ts delete mode 100644 libs/nanofn/src/is/is-function.ts delete mode 100644 libs/nanofn/src/is/is-length.ts delete mode 100644 libs/nanofn/src/is/is-map.ts delete mode 100644 libs/nanofn/src/is/is-match-with.ts delete mode 100644 libs/nanofn/src/is/is-match.ts delete mode 100644 libs/nanofn/src/is/is-native.ts delete mode 100644 libs/nanofn/src/is/is-nil.ts delete mode 100644 libs/nanofn/src/is/is-null.ts delete mode 100644 libs/nanofn/src/is/is-number.ts delete mode 100644 libs/nanofn/src/is/is-object-like.ts delete mode 100644 libs/nanofn/src/is/is-object.ts delete mode 100644 libs/nanofn/src/is/is-plain-object.ts delete mode 100644 libs/nanofn/src/is/is-reg-exp.ts delete mode 100644 libs/nanofn/src/is/is-set.ts delete mode 100644 libs/nanofn/src/is/is-string.ts delete mode 100644 libs/nanofn/src/is/is-symbol.ts delete mode 100644 libs/nanofn/src/is/is-typed-array.ts delete mode 100644 libs/nanofn/src/is/is-undefined.ts delete mode 100644 libs/nanofn/src/is/is-weak-map.ts delete mode 100644 libs/nanofn/src/is/is-weak-set.ts delete mode 100644 libs/nanofn/src/lang/conforms-to.ts delete mode 100644 libs/nanofn/src/lang/eq-deep.ts delete mode 100644 libs/nanofn/src/lang/eq.ts delete mode 100644 libs/nanofn/src/lang/gt.ts delete mode 100644 libs/nanofn/src/lang/gte.ts delete mode 100644 libs/nanofn/src/lang/lt.ts delete mode 100644 libs/nanofn/src/lang/lte.ts delete mode 100644 libs/nanofn/src/math/add.ts delete mode 100644 libs/nanofn/src/math/ceil.ts delete mode 100644 libs/nanofn/src/math/divide.ts delete mode 100644 libs/nanofn/src/math/floor.ts delete mode 100644 libs/nanofn/src/math/max-by.ts delete mode 100644 libs/nanofn/src/math/mean-by.ts delete mode 100644 libs/nanofn/src/math/mean.ts delete mode 100644 libs/nanofn/src/math/min-by.ts delete mode 100644 libs/nanofn/src/math/multiply.ts delete mode 100644 libs/nanofn/src/math/round.ts delete mode 100644 libs/nanofn/src/math/subtract.ts delete mode 100644 libs/nanofn/src/math/sum-by.ts delete mode 100644 libs/nanofn/src/math/sum.ts delete mode 100644 libs/nanofn/src/num/clamp.ts delete mode 100644 libs/nanofn/src/num/in-range.ts delete mode 100644 libs/nanofn/src/num/random.ts delete mode 100644 libs/nanofn/src/obj/at.ts delete mode 100644 libs/nanofn/src/obj/create.ts delete mode 100644 libs/nanofn/src/obj/defaults-deep.ts delete mode 100644 libs/nanofn/src/obj/defaults.ts delete mode 100644 libs/nanofn/src/obj/every-value.ts delete mode 100644 libs/nanofn/src/obj/filter-object.ts delete mode 100644 libs/nanofn/src/obj/find-key.ts delete mode 100644 libs/nanofn/src/obj/find-last-key.ts delete mode 100644 libs/nanofn/src/obj/for-own-right.ts delete mode 100644 libs/nanofn/src/obj/for-own.ts delete mode 100644 libs/nanofn/src/obj/getter.ts delete mode 100644 libs/nanofn/src/obj/has-in.ts delete mode 100644 libs/nanofn/src/obj/has-path-in.ts delete mode 100644 libs/nanofn/src/obj/has-path.ts delete mode 100644 libs/nanofn/src/obj/has.ts delete mode 100644 libs/nanofn/src/obj/invert-by.ts delete mode 100644 libs/nanofn/src/obj/invert.ts delete mode 100644 libs/nanofn/src/obj/invoke.ts delete mode 100644 libs/nanofn/src/obj/keys-in.ts delete mode 100644 libs/nanofn/src/obj/keys.ts delete mode 100644 libs/nanofn/src/obj/map-key.ts delete mode 100644 libs/nanofn/src/obj/map-object.ts delete mode 100644 libs/nanofn/src/obj/map-value.ts delete mode 100644 libs/nanofn/src/obj/merge-with.ts delete mode 100644 libs/nanofn/src/obj/merge.ts delete mode 100644 libs/nanofn/src/obj/pick-by.ts delete mode 100644 libs/nanofn/src/obj/pick.ts delete mode 100644 libs/nanofn/src/obj/result.ts delete mode 100644 libs/nanofn/src/obj/set-with.ts delete mode 100644 libs/nanofn/src/obj/setter.ts delete mode 100644 libs/nanofn/src/obj/transform.ts delete mode 100644 libs/nanofn/src/obj/unset.ts delete mode 100644 libs/nanofn/src/obj/update-with.ts delete mode 100644 libs/nanofn/src/obj/update.ts delete mode 100644 libs/nanofn/src/obj/values.ts delete mode 100644 libs/nanofn/src/str/deburr.ts delete mode 100644 libs/nanofn/src/str/ends-with.ts delete mode 100644 libs/nanofn/src/str/escape-reg-exp.ts delete mode 100644 libs/nanofn/src/str/escape.ts delete mode 100644 libs/nanofn/src/str/pad.ts delete mode 100644 libs/nanofn/src/str/parse-int.ts delete mode 100644 libs/nanofn/src/str/repeat.ts delete mode 100644 libs/nanofn/src/str/replace.ts delete mode 100644 libs/nanofn/src/str/split.ts delete mode 100644 libs/nanofn/src/str/starts-with.ts delete mode 100644 libs/nanofn/src/str/trim-end.ts delete mode 100644 libs/nanofn/src/str/trim-start.ts delete mode 100644 libs/nanofn/src/str/trim.ts delete mode 100644 libs/nanofn/src/str/truncate.ts delete mode 100644 libs/nanofn/src/str/unescape.ts delete mode 100644 libs/nanofn/src/util/attempt.ts delete mode 100644 libs/nanofn/src/util/cond.ts delete mode 100644 libs/nanofn/src/util/conforms.ts delete mode 100644 libs/nanofn/src/util/default-to-any.ts delete mode 100644 libs/nanofn/src/util/default-to.ts delete mode 100644 libs/nanofn/src/util/flow-right.ts delete mode 100644 libs/nanofn/src/util/flow.ts delete mode 100644 libs/nanofn/src/util/matches-property.ts delete mode 100644 libs/nanofn/src/util/matches.ts delete mode 100644 libs/nanofn/src/util/method-of.ts delete mode 100644 libs/nanofn/src/util/method.ts delete mode 100644 libs/nanofn/src/util/over-every.ts delete mode 100644 libs/nanofn/src/util/over-some.ts delete mode 100644 libs/nanofn/src/util/over.ts delete mode 100644 libs/nanofn/src/util/property-of.ts delete mode 100644 libs/nanofn/src/util/property.ts delete mode 100644 libs/nanofn/src/util/range-right.ts delete mode 100644 libs/nanofn/src/util/range.ts delete mode 100644 libs/nanofn/src/util/times.ts delete mode 100644 libs/nanofn/src/util/unique-id.ts delete mode 100644 libs/nanofn/test-setup.ts delete mode 100644 libs/nanofn/test/Arrays-category-methods.js delete mode 100644 libs/nanofn/test/Strings-category-methods.test.js delete mode 100644 libs/nanofn/test/__proto__-property-bugs.js delete mode 100644 libs/nanofn/test/add.test.js delete mode 100644 libs/nanofn/test/after.test.js delete mode 100644 libs/nanofn/test/ary.js delete mode 100644 libs/nanofn/test/assign-and-assignIn.js delete mode 100644 libs/nanofn/test/assignIn.js delete mode 100644 libs/nanofn/test/assignInWith.js delete mode 100644 libs/nanofn/test/assignWith-and-assignInWith.js delete mode 100644 libs/nanofn/test/at.test.js delete mode 100644 libs/nanofn/test/attempt.test.js delete mode 100644 libs/nanofn/test/basename.js delete mode 100644 libs/nanofn/test/before.js delete mode 100644 libs/nanofn/test/bind.js delete mode 100644 libs/nanofn/test/bindAll.js delete mode 100644 libs/nanofn/test/bindKey.js delete mode 100644 libs/nanofn/test/camelCase.test.js delete mode 100644 libs/nanofn/test/capitalize.test.js delete mode 100644 libs/nanofn/test/case-methods.test.js delete mode 100644 libs/nanofn/test/castArray.test.js delete mode 100644 libs/nanofn/test/chain.js delete mode 100644 libs/nanofn/test/chunk.test.js delete mode 100644 libs/nanofn/test/clamp.js delete mode 100644 libs/nanofn/test/clone-methods.js delete mode 100644 libs/nanofn/test/compact.js delete mode 100644 libs/nanofn/test/concat.js delete mode 100644 libs/nanofn/test/cond.js delete mode 100644 libs/nanofn/test/conforms-methods.js delete mode 100644 libs/nanofn/test/conforms.js delete mode 100644 libs/nanofn/test/constant.js delete mode 100644 libs/nanofn/test/countBy.js delete mode 100644 libs/nanofn/test/create.test.js delete mode 100644 libs/nanofn/test/curry-methods.js delete mode 100644 libs/nanofn/test/curry.js delete mode 100644 libs/nanofn/test/curryRight.js delete mode 100644 libs/nanofn/test/custom-_.iteratee-methods.js delete mode 100644 libs/nanofn/test/debounce-and-throttle.js delete mode 100644 libs/nanofn/test/debounce.test.js delete mode 100644 libs/nanofn/test/deburr.test.js delete mode 100644 libs/nanofn/test/defaultTo.test.js delete mode 100644 libs/nanofn/test/defaults.test.js delete mode 100644 libs/nanofn/test/defaultsDeep.js delete mode 100644 libs/nanofn/test/defer.test.js delete mode 100644 libs/nanofn/test/delay.js delete mode 100644 libs/nanofn/test/difference-methods.js delete mode 100644 libs/nanofn/test/differenceBy.js delete mode 100644 libs/nanofn/test/differenceWith.test.js delete mode 100644 libs/nanofn/test/divide.test.js delete mode 100644 libs/nanofn/test/drop.test.js delete mode 100644 libs/nanofn/test/dropRight.test.js delete mode 100644 libs/nanofn/test/dropRightWhile.js delete mode 100644 libs/nanofn/test/dropWhile.js delete mode 100644 libs/nanofn/test/endsWith.test.js delete mode 100644 libs/nanofn/test/eq.test.js delete mode 100644 libs/nanofn/test/escape.test.js delete mode 100644 libs/nanofn/test/escapeRegExp.test.js delete mode 100644 libs/nanofn/test/every.js delete mode 100644 libs/nanofn/test/exit-early.js delete mode 100644 libs/nanofn/test/extremum-methods.js delete mode 100644 libs/nanofn/test/fill.js delete mode 100644 libs/nanofn/test/filter-methods.js delete mode 100644 libs/nanofn/test/filter.test.js delete mode 100644 libs/nanofn/test/find-and-findLast.js delete mode 100644 libs/nanofn/test/find-and-includes.js delete mode 100644 libs/nanofn/test/find-methods.js delete mode 100644 libs/nanofn/test/findLast.test.js delete mode 100644 libs/nanofn/test/findLastIndex-and-lastIndexOf.test.js delete mode 100644 libs/nanofn/test/flatMap-methods.js delete mode 100644 libs/nanofn/test/flatMapDepth.js delete mode 100644 libs/nanofn/test/flatten-methods.js delete mode 100644 libs/nanofn/test/flattenDepth.js delete mode 100644 libs/nanofn/test/flip.test.js delete mode 100644 libs/nanofn/test/flow-methods.test.js delete mode 100644 libs/nanofn/test/forEach.test.js delete mode 100644 libs/nanofn/test/forEachRight.test.js delete mode 100644 libs/nanofn/test/forIn-methods.js delete mode 100644 libs/nanofn/test/forOwn-methods.js delete mode 100644 libs/nanofn/test/fromPairs.js delete mode 100644 libs/nanofn/test/functions.test.js delete mode 100644 libs/nanofn/test/get-and-result.js delete mode 100644 libs/nanofn/test/groupBy.js delete mode 100644 libs/nanofn/test/gt.test.js delete mode 100644 libs/nanofn/test/gte.test.js delete mode 100644 libs/nanofn/test/has-methods.js delete mode 100644 libs/nanofn/test/head.js delete mode 100644 libs/nanofn/test/identity.js delete mode 100644 libs/nanofn/test/inRange.js delete mode 100644 libs/nanofn/test/includes.js delete mode 100644 libs/nanofn/test/indexOf-methods.js delete mode 100644 libs/nanofn/test/indexOf.test.js delete mode 100644 libs/nanofn/test/initial.js delete mode 100644 libs/nanofn/test/intersection-methods.js delete mode 100644 libs/nanofn/test/intersectionBy.js delete mode 100644 libs/nanofn/test/intersectionWith.test.js delete mode 100644 libs/nanofn/test/invert.test.js delete mode 100644 libs/nanofn/test/invertBy.js delete mode 100644 libs/nanofn/test/invoke.js delete mode 100644 libs/nanofn/test/invokeMap.js delete mode 100644 libs/nanofn/test/isArguments.test.js delete mode 100644 libs/nanofn/test/isArray.js delete mode 100644 libs/nanofn/test/isArrayBuffer.test.js delete mode 100644 libs/nanofn/test/isArrayLike.test.js delete mode 100644 libs/nanofn/test/isBoolean.test.js delete mode 100644 libs/nanofn/test/isBuffer.test.js delete mode 100644 libs/nanofn/test/isDate.test.js delete mode 100644 libs/nanofn/test/isElement.test.js delete mode 100644 libs/nanofn/test/isEmpty.js delete mode 100644 libs/nanofn/test/isEqual.js delete mode 100644 libs/nanofn/test/isEqualWith.js delete mode 100644 libs/nanofn/test/isError.test.js delete mode 100644 libs/nanofn/test/isFinite.js delete mode 100644 libs/nanofn/test/isFunction.js delete mode 100644 libs/nanofn/test/isIndex.test.js delete mode 100644 libs/nanofn/test/isInteger-methods.js delete mode 100644 libs/nanofn/test/isIterateeCall.js delete mode 100644 libs/nanofn/test/isLength.test.js delete mode 100644 libs/nanofn/test/isMap.test.js delete mode 100644 libs/nanofn/test/isMatchWith.js delete mode 100644 libs/nanofn/test/isNaN.js delete mode 100644 libs/nanofn/test/isNative.js delete mode 100644 libs/nanofn/test/isNil.test.js delete mode 100644 libs/nanofn/test/isNull.test.js delete mode 100644 libs/nanofn/test/isNumber.test.js delete mode 100644 libs/nanofn/test/isObject.test.js delete mode 100644 libs/nanofn/test/isObjectLike.test.js delete mode 100644 libs/nanofn/test/isPlainObject.js delete mode 100644 libs/nanofn/test/isRegExp.test.js delete mode 100644 libs/nanofn/test/isSet.test.js delete mode 100644 libs/nanofn/test/isString.test.js delete mode 100644 libs/nanofn/test/isSymbol.test.js delete mode 100644 libs/nanofn/test/isType-checks.js delete mode 100644 libs/nanofn/test/isTypedArray.js delete mode 100644 libs/nanofn/test/isUndefined.test.js delete mode 100644 libs/nanofn/test/isWeakMap.test.js delete mode 100644 libs/nanofn/test/isWeakSet.test.js delete mode 100644 libs/nanofn/test/iteratee.js delete mode 100644 libs/nanofn/test/iteration-methods.js delete mode 100644 libs/nanofn/test/join.js delete mode 100644 libs/nanofn/test/keyBy.js delete mode 100644 libs/nanofn/test/keys-methods.js delete mode 100644 libs/nanofn/test/last.js delete mode 100644 libs/nanofn/test/lodash(...)-methods-that-return-new-wrapped-values.js delete mode 100644 libs/nanofn/test/lodash(...)-methods-that-return-the-wrapped-modified-array.js delete mode 100644 libs/nanofn/test/lodash(...)-methods-that-return-unwrapped-values.js delete mode 100644 libs/nanofn/test/lodash(...).commit.js delete mode 100644 libs/nanofn/test/lodash(...).next.js delete mode 100644 libs/nanofn/test/lodash(...).plant.js delete mode 100644 libs/nanofn/test/lodash(...).pop.js delete mode 100644 libs/nanofn/test/lodash(...).push.js delete mode 100644 libs/nanofn/test/lodash(...).shift.js delete mode 100644 libs/nanofn/test/lodash(...).sort.js delete mode 100644 libs/nanofn/test/lodash(...).splice.js delete mode 100644 libs/nanofn/test/lodash(...).unshift.js delete mode 100644 libs/nanofn/test/lodash(...).value.js delete mode 100644 libs/nanofn/test/lodash-constructor.js delete mode 100644 libs/nanofn/test/lodash-methods.js delete mode 100644 libs/nanofn/test/lodash.methodName.js delete mode 100644 libs/nanofn/test/lowerCase.test.js delete mode 100644 libs/nanofn/test/lowerFirst.test.js delete mode 100644 libs/nanofn/test/lt.test.js delete mode 100644 libs/nanofn/test/lte.test.js delete mode 100644 libs/nanofn/test/map-caches.js delete mode 100644 libs/nanofn/test/map.js delete mode 100644 libs/nanofn/test/mapKeys-and-mapValues.js delete mode 100644 libs/nanofn/test/mapKeys.js delete mode 100644 libs/nanofn/test/mapValues.js delete mode 100644 libs/nanofn/test/matches-methods.js delete mode 100644 libs/nanofn/test/matches.js delete mode 100644 libs/nanofn/test/matchesProperty.js delete mode 100644 libs/nanofn/test/math-operator-methods.js delete mode 100644 libs/nanofn/test/max.js delete mode 100644 libs/nanofn/test/mean.test.js delete mode 100644 libs/nanofn/test/meanBy.js delete mode 100644 libs/nanofn/test/memoize.test.js delete mode 100644 libs/nanofn/test/memoizeCapped.test.js delete mode 100644 libs/nanofn/test/merge.test.js delete mode 100644 libs/nanofn/test/mergeWith.js delete mode 100644 libs/nanofn/test/method.js delete mode 100644 libs/nanofn/test/methodOf.js delete mode 100644 libs/nanofn/test/methods-using-createWrapper.js delete mode 100644 libs/nanofn/test/min.js delete mode 100644 libs/nanofn/test/mixin.js delete mode 100644 libs/nanofn/test/multiply.test.js delete mode 100644 libs/nanofn/test/negate.js delete mode 100644 libs/nanofn/test/noConflict.js delete mode 100644 libs/nanofn/test/now.js delete mode 100644 libs/nanofn/test/nth.js delete mode 100644 libs/nanofn/test/nthArg.js delete mode 100644 libs/nanofn/test/number-coercion-methods.js delete mode 100644 libs/nanofn/test/object-assignments.js delete mode 100644 libs/nanofn/test/omit-methods.js delete mode 100644 libs/nanofn/test/omit.js delete mode 100644 libs/nanofn/test/omitBy.js delete mode 100644 libs/nanofn/test/once.test.js delete mode 100644 libs/nanofn/test/orderBy.js delete mode 100644 libs/nanofn/test/over.js delete mode 100644 libs/nanofn/test/overArgs.js delete mode 100644 libs/nanofn/test/overEvery.js delete mode 100644 libs/nanofn/test/overSome.js delete mode 100644 libs/nanofn/test/pad-methods.js delete mode 100644 libs/nanofn/test/pad.js delete mode 100644 libs/nanofn/test/padEnd.js delete mode 100644 libs/nanofn/test/padStart.js delete mode 100644 libs/nanofn/test/parseInt.js delete mode 100644 libs/nanofn/test/partial-methods.js delete mode 100644 libs/nanofn/test/partialRight.js delete mode 100644 libs/nanofn/test/partition.js delete mode 100644 libs/nanofn/test/pick-methods.js delete mode 100644 libs/nanofn/test/pick.js delete mode 100644 libs/nanofn/test/pickBy.test.js delete mode 100644 libs/nanofn/test/property.test.js delete mode 100644 libs/nanofn/test/propertyOf.test.js delete mode 100644 libs/nanofn/test/pull-methods.js delete mode 100644 libs/nanofn/test/pullAll.test.js delete mode 100644 libs/nanofn/test/pullAllBy.test.js delete mode 100644 libs/nanofn/test/pullAllWith.test.js delete mode 100644 libs/nanofn/test/pullAt.js delete mode 100644 libs/nanofn/test/random.js delete mode 100644 libs/nanofn/test/range-methods.js delete mode 100644 libs/nanofn/test/rearg.js delete mode 100644 libs/nanofn/test/reduce-methods.js delete mode 100644 libs/nanofn/test/reduce.js delete mode 100644 libs/nanofn/test/reduceRight.js delete mode 100644 libs/nanofn/test/reject.test.js delete mode 100644 libs/nanofn/test/remove.js delete mode 100644 libs/nanofn/test/repeat.js delete mode 100644 libs/nanofn/test/replace.test.js delete mode 100644 libs/nanofn/test/rest.js delete mode 100644 libs/nanofn/test/result.test.js delete mode 100644 libs/nanofn/test/reverse.js delete mode 100644 libs/nanofn/test/round-methods.js delete mode 100644 libs/nanofn/test/runInContext.js delete mode 100644 libs/nanofn/test/sample.js delete mode 100644 libs/nanofn/test/sampleSize.js delete mode 100644 libs/nanofn/test/set-methods.js delete mode 100644 libs/nanofn/test/setWith.js delete mode 100644 libs/nanofn/test/shuffle.js delete mode 100644 libs/nanofn/test/size.test.js delete mode 100644 libs/nanofn/test/slice-and-toArray.js delete mode 100644 libs/nanofn/test/slice.js delete mode 100644 libs/nanofn/test/some.js delete mode 100644 libs/nanofn/test/sortBy-methods.js delete mode 100644 libs/nanofn/test/sortBy.js delete mode 100644 libs/nanofn/test/sortedIndex-methods.js delete mode 100644 libs/nanofn/test/sortedIndexBy-methods.js delete mode 100644 libs/nanofn/test/sortedIndexOf-methods.js delete mode 100644 libs/nanofn/test/sortedUniq.test.js delete mode 100644 libs/nanofn/test/split.js delete mode 100644 libs/nanofn/test/spread.js delete mode 100644 libs/nanofn/test/startCase.test.js delete mode 100644 libs/nanofn/test/startsWith-and-endsWith.js delete mode 100644 libs/nanofn/test/startsWith.js delete mode 100644 libs/nanofn/test/strict-mode-checks.js delete mode 100644 libs/nanofn/test/stub-methods.js delete mode 100644 libs/nanofn/test/subtract.test.js delete mode 100644 libs/nanofn/test/sum-methods.js delete mode 100644 libs/nanofn/test/sumBy.js delete mode 100644 libs/nanofn/test/tail.js delete mode 100644 libs/nanofn/test/take.js delete mode 100644 libs/nanofn/test/takeRight.js delete mode 100644 libs/nanofn/test/takeRightWhile.js delete mode 100644 libs/nanofn/test/takeWhile.js delete mode 100644 libs/nanofn/test/tap.js delete mode 100644 libs/nanofn/test/template.js delete mode 100644 libs/nanofn/test/throttle.js delete mode 100644 libs/nanofn/test/times.js delete mode 100644 libs/nanofn/test/toArray.test.js delete mode 100644 libs/nanofn/test/toInteger-methods.js delete mode 100644 libs/nanofn/test/toLength.test.js delete mode 100644 libs/nanofn/test/toLower.js delete mode 100644 libs/nanofn/test/toPairs-methods.js delete mode 100644 libs/nanofn/test/toPairs.js delete mode 100644 libs/nanofn/test/toPairsIn.js delete mode 100644 libs/nanofn/test/toPath.js delete mode 100644 libs/nanofn/test/toPlainObject.js delete mode 100644 libs/nanofn/test/toString.test.js delete mode 100644 libs/nanofn/test/toUpper.js delete mode 100644 libs/nanofn/test/transform.js delete mode 100644 libs/nanofn/test/trim-methods.js delete mode 100644 libs/nanofn/test/truncate.js delete mode 100644 libs/nanofn/test/unary.js delete mode 100644 libs/nanofn/test/uncommon-symbols.js delete mode 100644 libs/nanofn/test/unescape.js delete mode 100644 libs/nanofn/test/union-methods.js delete mode 100644 libs/nanofn/test/unionBy.js delete mode 100644 libs/nanofn/test/unionWith.test.js delete mode 100644 libs/nanofn/test/uniq-methods.js delete mode 100644 libs/nanofn/test/uniq.js delete mode 100644 libs/nanofn/test/uniqBy-methods.js delete mode 100644 libs/nanofn/test/uniqWith.test.js delete mode 100644 libs/nanofn/test/uniqueId.test.js delete mode 100644 libs/nanofn/test/unset.js delete mode 100644 libs/nanofn/test/unzip-and-zip.js delete mode 100644 libs/nanofn/test/unzipWith.js delete mode 100644 libs/nanofn/test/update-methods.js delete mode 100644 libs/nanofn/test/updateWith.js delete mode 100644 libs/nanofn/test/upperCase.test.js delete mode 100644 libs/nanofn/test/upperFirst.test.js delete mode 100644 libs/nanofn/test/utils.js delete mode 100644 libs/nanofn/test/values-methods.js delete mode 100644 libs/nanofn/test/without.test.js delete mode 100644 libs/nanofn/test/words.test.js delete mode 100644 libs/nanofn/test/wrap.js delete mode 100644 libs/nanofn/test/xor-methods.js delete mode 100644 libs/nanofn/test/xorBy.js delete mode 100644 libs/nanofn/test/xorWith.test.js delete mode 100644 libs/nanofn/test/zipObject-methods.js delete mode 100644 libs/nanofn/test/zipWith.js delete mode 100644 libs/nanofn/tsconfig.json delete mode 100644 libs/nanofn/tsconfig.lib.json delete mode 100644 libs/nanofn/tsconfig.lib.prod.json delete mode 100644 libs/nanofn/tsconfig.spec.json delete mode 100644 libs/nanofn/tslint.json delete mode 100644 libs/triangle/slider/index.ts delete mode 100644 libs/triangle/slider/ng-package.json delete mode 100644 libs/triangle/slider/public-api.ts delete mode 100644 libs/triangle/slider/src/slider-handle.component.ts delete mode 100644 libs/triangle/slider/src/slider-marks.component.ts delete mode 100644 libs/triangle/slider/src/slider-step.component.ts delete mode 100644 libs/triangle/slider/src/slider-track.component.ts delete mode 100644 libs/triangle/slider/src/slider.component.ts delete mode 100644 libs/triangle/slider/src/slider.module.ts delete mode 100644 libs/triangle/slider/src/slider.service.ts delete mode 100644 libs/triangle/slider/src/slider.types.ts delete mode 100644 libs/triangle/slider/style/_slider-theme.scss delete mode 100644 libs/triangle/slider/style/slider.scss delete mode 100644 libs/triangle/tab-nav-bar/ng-package.json create mode 100644 libs/triangle/tab-nav-bar/ng-package.json.bak delete mode 100644 libs/triangle/tabs/ng-package.json create mode 100644 libs/triangle/tabs/ng-package.json.bak diff --git a/libs/nanofn/.babelrc b/libs/nanofn/.babelrc deleted file mode 100644 index cf7ddd99c..000000000 --- a/libs/nanofn/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] -} diff --git a/libs/nanofn/.eslintrc.json b/libs/nanofn/.eslintrc.json deleted file mode 100644 index 3994d68ea..000000000 --- a/libs/nanofn/.eslintrc.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts"], - "extends": [ - "plugin:@nrwl/nx/angular", - "plugin:@angular-eslint/template/process-inline-templates" - ], - "rules": { - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "applications", - "style": "camelCase" - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "applications", - "style": "kebab-case" - } - ] - } - }, - { - "files": ["*.html"], - "extends": ["plugin:@nrwl/nx/angular-template"], - "rules": {} - } - ] -} diff --git a/libs/nanofn/CHANGELOG.md b/libs/nanofn/CHANGELOG.md deleted file mode 100644 index 9e143712d..000000000 --- a/libs/nanofn/CHANGELOG.md +++ /dev/null @@ -1,23 +0,0 @@ -# Changelog - -This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). - -## [0.0.3](https://github.com/gradii/triangle/compare/nanofn-0.0.2...nanofn-0.0.3) (2022-05-22) - - - -## [0.0.2](https://github.com/gradii/triangle/compare/nanofn-0.0.1...nanofn-0.0.2) (2022-05-22) - - - -## 0.0.1 (2022-05-22) - - -### Bug Fixes - -* tree view ([5fad72f](https://github.com/gradii/triangle/commit/5fad72f2bcbb452457e1d374905ba2431621294f)) - - -### Features - -* nanofn progressing ([d74d5ed](https://github.com/gradii/triangle/commit/d74d5ed9fbdc2f561ec7201d9f501401d3006789)) diff --git a/libs/nanofn/README.md b/libs/nanofn/README.md deleted file mode 100644 index 797b89de8..000000000 --- a/libs/nanofn/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# nanofn - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test nanofn` to execute the unit tests. diff --git a/libs/nanofn/index.ts b/libs/nanofn/index.ts deleted file mode 100644 index 22a1313fd..000000000 --- a/libs/nanofn/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - - -export * from './public-api'; diff --git a/libs/nanofn/jest.config.js b/libs/nanofn/jest.config.js deleted file mode 100644 index 03d7cc944..000000000 --- a/libs/nanofn/jest.config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - displayName: "nanofn", - preset: "../../jest.preset.js", - setupFilesAfterEnv: ["/test-setup.ts"], - globals: { - "ts-jest": { - tsconfig: "/tsconfig.spec.json", - stringifyContentPathRegex: "\\.(html|svg)$", - }, - }, - coverageDirectory: "../../coverage/libs/nanofn", - transform: { - "^.+\\.(ts|js|html)$": "jest-preset-angular", - }, - snapshotSerializers: [ - "jest-preset-angular/build/serializers/no-ng-attributes", - "jest-preset-angular/build/serializers/ng-snapshot", - "jest-preset-angular/build/serializers/html-comment", - ], -}; diff --git a/libs/nanofn/ng-package.json b/libs/nanofn/ng-package.json deleted file mode 100644 index bc007bd5c..000000000 --- a/libs/nanofn/ng-package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", - "dest": "../../dist/libs/nanofn", - "lib": { - "entryFile": "index.ts" - } -} diff --git a/libs/nanofn/package.json b/libs/nanofn/package.json deleted file mode 100644 index c6c37c0ef..000000000 --- a/libs/nanofn/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@gradii/nanofn", - "version": "0.0.3", - "repository": { - "type": "git", - "url": "https://github.com/gradii/triangle.git" - }, - "license": "MIT", - "peerDependencies": { - "@angular/common": "^12.2.0", - "@angular/core": "^12.2.0" - }, - "dependencies": { - "tslib": "^2.3.0" - } -} diff --git a/libs/nanofn/project.json b/libs/nanofn/project.json deleted file mode 100644 index 51c20b233..000000000 --- a/libs/nanofn/project.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "nanofn", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "projectType": "library", - "sourceRoot": "libs/nanofn", - "prefix": "", - "targets": { - "version": { - "executor": "@jscutlery/semver:version", - "options": { - "baseBranch": "master", - "releaseAs": "patch", - "postTargets": ["nanofn:build"] - } - }, - "build": { - "executor": "@nrwl/angular:package", - "outputs": ["{workspaceRoot}/dist/libs/nanofn"], - "options": { - "project": "libs/nanofn/ng-package.json" - }, - "configurations": { - "production": { - "tsConfig": "libs/nanofn/tsconfig.lib.prod.json" - }, - "development": { - "tsConfig": "libs/nanofn/tsconfig.lib.json" - } - }, - "defaultConfiguration": "production" - }, - "test": { - "executor": "@nrwl/jest:jest", - "outputs": ["{workspaceRoot}/coverage/libs/nanofn"], - "options": { - "jestConfig": "libs/nanofn/jest.config.js", - "passWithNoTests": true - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [ - "libs/nanofn/src/**/*.ts", - "libs/nanofn/src/**/*.html" - ] - } - } - } -} diff --git a/libs/nanofn/public-api.ts b/libs/nanofn/public-api.ts deleted file mode 100644 index 5a894a634..000000000 --- a/libs/nanofn/public-api.ts +++ /dev/null @@ -1,330 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export { getter } from './src/obj/getter'; -export { setter } from './src/obj/setter'; - -// export * from './src/math/add'; -// export { default as after } from './src/after'; -// export { default as ary } from './src/ary'; -// export { default as assign } from './src/assign'; -// export { default as assignIn } from './src/assignIn'; -// export { default as assignInWith } from './src/assignInWith'; -// export { default as assignWith } from './src/assignWith'; -// export { default as at } from './src/at'; -// export { default as attempt } from './src/attempt'; -// export { default as before } from './src/before'; -// export { default as bind } from './src/bind'; -// export { default as bindAll } from './src/bindAll'; -// export { default as bindKey } from './src/bindKey'; -// export { default as camelCase } from './src/camelCase'; -// export { default as capitalize } from './src/capitalize'; -// export { default as castArray } from './src/castArray'; -// export { default as ceil } from './src/ceil'; -// export { default as chain } from './src/chain'; -// export { default as chunk } from './src/chunk'; -// export { default as clamp } from './src/clamp'; -// export { default as clone } from './src/clone'; -// export { default as cloneDeep } from './src/cloneDeep'; -// export { default as cloneDeepWith } from './src/cloneDeepWith'; -// export { default as cloneWith } from './src/cloneWith'; -// export { default as commit } from './src/commit'; -// export { default as compact } from './src/compact'; -// export { default as concat } from './src/concat'; -// export { default as cond } from './src/cond'; -// export { default as conforms } from './src/conforms'; -// export { default as conformsTo } from './src/conformsTo'; -// export { default as constant } from './src/constant'; -// export { default as countBy } from './src/countBy'; -// export { default as create } from './src/create'; -// export { default as curry } from './src/curry'; -// export { default as curryRight } from './src/curryRight'; -// export { default as debounce } from './src/debounce'; -// export { default as deburr } from './src/deburr'; -// export { default as defaultTo } from './src/defaultTo'; -// export { default as defaults } from './src/defaults'; -// export { default as defaultsDeep } from './src/defaultsDeep'; -// export { default as defer } from './src/defer'; -// export { default as delay } from './src/delay'; -// export { default as difference } from './src/difference'; -// export { default as differenceBy } from './src/differenceBy'; -// export { default as differenceWith } from './src/differenceWith'; -// export { default as divide } from './src/divide'; -// export { default as drop } from './src/drop'; -// export { default as dropRight } from './src/dropRight'; -// export { default as dropRightWhile } from './src/dropRightWhile'; -// export { default as dropWhile } from './src/dropWhile'; -// export { default as each } from './src/each'; -// export { default as eachRight } from './src/eachRight'; -// export { default as endsWith } from './src/endsWith'; -// export { default as entries } from './src/entries'; -// export { default as entriesIn } from './src/entriesIn'; -// export { default as eq } from './src/eq'; -// export { default as escape } from './src/escape'; -// export { default as escapeRegExp } from './src/escapeRegExp'; -// export { default as every } from './src/every'; -// export { default as extend } from './src/extend'; -// export { default as extendWith } from './src/extendWith'; -// export { default as fill } from './src/fill'; -// export { default as filter } from './src/filter'; -// export { default as find } from './src/find'; -// export { default as findIndex } from './src/findIndex'; -// export { default as findKey } from './src/findKey'; -// export { default as findLast } from './src/findLast'; -// export { default as findLastIndex } from './src/findLastIndex'; -// export { default as findLastKey } from './src/findLastKey'; -// export { default as first } from './src/first'; -// export { default as flatMap } from './src/flatMap'; -// export { default as flatMapDeep } from './src/flatMapDeep'; -// export { default as flatMapDepth } from './src/flatMapDepth'; -// export { default as flatten } from './src/flatten'; -// export { default as flattenDeep } from './src/flattenDeep'; -// export { default as flattenDepth } from './src/flattenDepth'; -// export { default as flip } from './src/flip'; -// export { default as floor } from './src/floor'; -// export { default as flow } from './src/flow'; -// export { default as flowRight } from './src/flowRight'; -// export { default as forEach } from './src/forEach'; -// export { default as forEachRight } from './src/forEachRight'; -// export { default as forIn } from './src/forIn'; -// export { default as forInRight } from './src/forInRight'; -// export { default as forOwn } from './src/forOwn'; -// export { default as forOwnRight } from './src/forOwnRight'; -// export { default as fromPairs } from './src/fromPairs'; -// export { default as functions } from './src/functions'; -// export { default as functionsIn } from './src/functionsIn'; -// export { default as get } from './src/get'; -// export { default as groupBy } from './src/groupBy'; -// export { default as gt } from './src/gt'; -// export { default as gte } from './src/gte'; -// export { default as has } from './src/has'; -// export { default as hasIn } from './src/hasIn'; -// export { default as head } from './src/head'; -// export { default as identity } from './src/identity'; -// export { default as inRange } from './src/inRange'; -// export { default as includes } from './src/includes'; -// export { default as indexOf } from './src/indexOf'; -// export { default as initial } from './src/initial'; -// export { default as intersection } from './src/intersection'; -// export { default as intersectionBy } from './src/intersectionBy'; -// export { default as intersectionWith } from './src/intersectionWith'; -// export { default as invert } from './src/invert'; -// export { default as invertBy } from './src/invertBy'; -// export { default as invoke } from './src/invoke'; -// export { default as invokeMap } from './src/invokeMap'; -// export { default as isArguments } from './src/isArguments'; -// export { default as isArray } from './src/isArray'; -// export { default as isArrayBuffer } from './src/isArrayBuffer'; -// export { default as isArrayLike } from './src/isArrayLike'; -// export { default as isArrayLikeObject } from './src/isArrayLikeObject'; -// export { default as isBoolean } from './src/isBoolean'; -// export { default as isBuffer } from './src/isBuffer'; -// export { default as isDate } from './src/isDate'; -// export { default as isElement } from './src/isElement'; -// export { default as isEmpty } from './src/isEmpty'; -// export { default as isEqual } from './src/isEqual'; -// export { default as isEqualWith } from './src/isEqualWith'; -// export { default as isError } from './src/isError'; -// export { default as isFinite } from './src/isFinite'; -// export { default as isFunction } from './src/isFunction'; -// export { default as isInteger } from './src/isInteger'; -// export { default as isLength } from './src/isLength'; -// export { default as isMap } from './src/isMap'; -// export { default as isMatch } from './src/isMatch'; -// export { default as isMatchWith } from './src/isMatchWith'; -// export { default as isNaN } from './src/isNaN'; -// export { default as isNative } from './src/isNative'; -// export { default as isNil } from './src/isNil'; -// export { default as isNull } from './src/isNull'; -// export { default as isNumber } from './src/isNumber'; -// export { default as isObject } from './src/isObject'; -// export { default as isObjectLike } from './src/isObjectLike'; -// export { default as isPlainObject } from './src/isPlainObject'; -// export { default as isRegExp } from './src/isRegExp'; -// export { default as isSafeInteger } from './src/isSafeInteger'; -// export { default as isSet } from './src/isSet'; -// export { default as isString } from './src/isString'; -// export { default as isSymbol } from './src/isSymbol'; -// export { default as isTypedArray } from './src/isTypedArray'; -// export { default as isUndefined } from './src/isUndefined'; -// export { default as isWeakMap } from './src/isWeakMap'; -// export { default as isWeakSet } from './src/isWeakSet'; -// export { default as iteratee } from './src/iteratee'; -// export { default as join } from './src/join'; -// export { default as kebabCase } from './src/kebabCase'; -// export { default as keyBy } from './src/keyBy'; -// export { default as keys } from './src/keys'; -// export { default as keysIn } from './src/keysIn'; -// export { default as last } from './src/last'; -// export { default as lastIndexOf } from './src/lastIndexOf'; -// export { default as lodash } from './src/wrapperLodash'; -// export { default as lowerCase } from './src/lowerCase'; -// export { default as lowerFirst } from './src/lowerFirst'; -// export { default as lt } from './src/lt'; -// export { default as lte } from './src/lte'; -// export { default as map } from './src/map'; -// export { default as mapKeys } from './src/mapKeys'; -// export { default as mapValues } from './src/mapValues'; -// export { default as matches } from './src/matches'; -// export { default as matchesProperty } from './src/matchesProperty'; -// export { default as max } from './src/max'; -// export { default as maxBy } from './src/maxBy'; -// export { default as mean } from './src/mean'; -// export { default as meanBy } from './src/meanBy'; -// export { default as memoize } from './src/memoize'; -// export { default as merge } from './src/merge'; -// export { default as mergeWith } from './src/mergeWith'; -// export { default as method } from './src/method'; -// export { default as methodOf } from './src/methodOf'; -// export { default as min } from './src/min'; -// export { default as minBy } from './src/minBy'; -// export { default as mixin } from './src/mixin'; -// export { default as multiply } from './src/multiply'; -// export { default as negate } from './src/negate'; -// export { default as next } from './src/next'; -// export { default as noop } from './src/noop'; -// export { default as now } from './src/now'; -// export { default as nth } from './src/nth'; -// export { default as nthArg } from './src/nthArg'; -// export { default as omit } from './src/omit'; -// export { default as omitBy } from './src/omitBy'; -// export { default as once } from './src/once'; -// export { default as orderBy } from './src/orderBy'; -// export { default as over } from './src/over'; -// export { default as overArgs } from './src/overArgs'; -// export { default as overEvery } from './src/overEvery'; -// export { default as overSome } from './src/overSome'; -// export { default as pad } from './src/pad'; -// export { default as padEnd } from './src/padEnd'; -// export { default as padStart } from './src/padStart'; -// export { default as parseInt } from './src/parseInt'; -// export { default as partial } from './src/partial'; -// export { default as partialRight } from './src/partialRight'; -// export { default as partition } from './src/partition'; -// export { default as pick } from './src/pick'; -// export { default as pickBy } from './src/pickBy'; -// export { default as plant } from './src/plant'; -// export { default as property } from './src/property'; -// export { default as propertyOf } from './src/propertyOf'; -// export { default as pull } from './src/pull'; -// export { default as pullAll } from './src/pullAll'; -// export { default as pullAllBy } from './src/pullAllBy'; -// export { default as pullAllWith } from './src/pullAllWith'; -// export { default as pullAt } from './src/pullAt'; -// export { default as random } from './src/random'; -// export { default as range } from './src/range'; -// export { default as rangeRight } from './src/rangeRight'; -// export { default as rearg } from './src/rearg'; -// export { default as reduce } from './src/reduce'; -// export { default as reduceRight } from './src/reduceRight'; -// export { default as reject } from './src/reject'; -// export { default as remove } from './src/remove'; -// export { default as repeat } from './src/repeat'; -// export { default as replace } from './src/replace'; -// export { default as rest } from './src/rest'; -// export { default as result } from './src/result'; -// export { default as reverse } from './src/reverse'; -// export { default as round } from './src/round'; -// export { default as sample } from './src/sample'; -// export { default as sampleSize } from './src/sampleSize'; -// export { default as set } from './src/set'; -// export { default as setWith } from './src/setWith'; -// export { default as shuffle } from './src/shuffle'; -// export { default as size } from './src/size'; -// export { default as slice } from './src/slice'; -// export { default as snakeCase } from './src/snakeCase'; -// export { default as some } from './src/some'; -// export { default as sortBy } from './src/sortBy'; -// export { default as sortedIndex } from './src/sortedIndex'; -// export { default as sortedIndexBy } from './src/sortedIndexBy'; -// export { default as sortedIndexOf } from './src/sortedIndexOf'; -// export { default as sortedLastIndex } from './src/sortedLastIndex'; -// export { default as sortedLastIndexBy } from './src/sortedLastIndexBy'; -// export { default as sortedLastIndexOf } from './src/sortedLastIndexOf'; -// export { default as sortedUniq } from './src/sortedUniq'; -// export { default as sortedUniqBy } from './src/sortedUniqBy'; -// export { default as split } from './src/split'; -// export { default as spread } from './src/spread'; -// export { default as startCase } from './src/startCase'; -// export { default as startsWith } from './src/startsWith'; -// export { default as stubArray } from './src/stubArray'; -// export { default as stubFalse } from './src/stubFalse'; -// export { default as stubObject } from './src/stubObject'; -// export { default as stubString } from './src/stubString'; -// export { default as stubTrue } from './src/stubTrue'; -// export { default as subtract } from './src/subtract'; -// export { default as sum } from './src/sum'; -// export { default as sumBy } from './src/sumBy'; -// export { default as tail } from './src/tail'; -// export { default as take } from './src/take'; -// export { default as takeRight } from './src/takeRight'; -// export { default as takeRightWhile } from './src/takeRightWhile'; -// export { default as takeWhile } from './src/takeWhile'; -// export { default as tap } from './src/tap'; -// export { default as template } from './src/template'; -// export { default as templateSettings } from './src/templateSettings'; -// export { default as throttle } from './src/throttle'; -// export { default as thru } from './src/thru'; -// export { default as times } from './src/times'; -// export { default as toArray } from './src/toArray'; -// export { default as toFinite } from './src/toFinite'; -// export { default as toInteger } from './src/toInteger'; -// export { default as toIterator } from './src/toIterator'; -// export { default as toJSON } from './src/toJSON'; -// export { default as toLength } from './src/toLength'; -// export { default as toLower } from './src/toLower'; -// export { default as toNumber } from './src/toNumber'; -// export { default as toPairs } from './src/toPairs'; -// export { default as toPairsIn } from './src/toPairsIn'; -// export { default as toPath } from './src/toPath'; -// export { default as toPlainObject } from './src/toPlainObject'; -// export { default as toSafeInteger } from './src/toSafeInteger'; -// export { default as toString } from './src/toString'; -// export { default as toUpper } from './src/toUpper'; -// export { default as transform } from './src/transform'; -// export { default as trim } from './src/trim'; -// export { default as trimEnd } from './src/trimEnd'; -// export { default as trimStart } from './src/trimStart'; -// export { default as truncate } from './src/truncate'; -// export { default as unary } from './src/unary'; -// export { default as unescape } from './src/unescape'; -// export { default as union } from './src/union'; -// export { default as unionBy } from './src/unionBy'; -// export { default as unionWith } from './src/unionWith'; -// export { default as uniq } from './src/uniq'; -// export { uniqBy } from './src/arr/uniq/uniq-by'; -// export { default as uniqWith } from './src/uniqWith'; -// export { default as uniqueId } from './src/uniqueId'; -// export { default as unset } from './src/unset'; -// export { default as unzip } from './src/unzip'; -// export { default as unzipWith } from './src/unzipWith'; -// export { default as update } from './src/update'; -// export { default as updateWith } from './src/updateWith'; -// export { default as upperCase } from './src/upperCase'; -// export { default as upperFirst } from './src/upperFirst'; -// export { default as value } from './src/value'; -// export { default as valueOf } from './src/valueOf'; -// export { default as values } from './src/values'; -// export { default as valuesIn } from './src/valuesIn'; -// export { default as without } from './src/without'; -// export { default as words } from './src/words'; -// export { default as wrap } from './src/wrap'; -// export { default as wrapperAt } from './src/wrapperAt'; -// export { default as wrapperChain } from './src/wrapperChain'; -// export { default as wrapperCommit } from './src/commit'; -// export { default as wrapperLodash } from './src/wrapperLodash'; -// export { default as wrapperNext } from './src/next'; -// export { default as wrapperPlant } from './src/plant'; -// export { default as wrapperReverse } from './src/wrapperReverse'; -// export { default as wrapperToIterator } from './src/toIterator'; -// export { default as wrapperValue } from './src/wrapperValue'; -// export { default as xor } from './src/xor'; -// export { default as xorBy } from './src/xorBy'; -// export { default as xorWith } from './src/xorWith'; -// export { default as zip } from './src/zip'; -// export { default as zipObject } from './src/zipObject'; -// export { default as zipObjectDeep } from './src/zipObjectDeep'; -// export { default as zipWith } from './src/zipWith'; diff --git a/libs/nanofn/src/_internal/add-map-entry.ts b/libs/nanofn/src/_internal/add-map-entry.ts deleted file mode 100644 index 0d483efdf..000000000 --- a/libs/nanofn/src/_internal/add-map-entry.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Adds the key-value `pair` to `map`. - * - * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. - */ -export function _addMapEntry(map: any, pair: any[]) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; -} diff --git a/libs/nanofn/src/_internal/add-set-entry.ts b/libs/nanofn/src/_internal/add-set-entry.ts deleted file mode 100644 index 2169c0eca..000000000 --- a/libs/nanofn/src/_internal/add-set-entry.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Adds `value` to `set`. - * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. - */ -export function _addSetEntry(set: Set, value: any) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; -} - - diff --git a/libs/nanofn/src/_internal/array-each-right.ts b/libs/nanofn/src/_internal/array-each-right.ts deleted file mode 100644 index 8bec29ee7..000000000 --- a/libs/nanofn/src/_internal/array-each-right.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `forEachRight` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ -export function _arrayEachRight(array: any[], - iteratee: (value: any, index: number, - array: any[]) => boolean | void) { - let length = array == null ? 0 : array.length; - - while (length--) { - if (iteratee(array[length], length, array) === false) { - break; - } - } - return array; -} - - diff --git a/libs/nanofn/src/_internal/array-each.ts b/libs/nanofn/src/_internal/array-each.ts deleted file mode 100644 index d0730e08c..000000000 --- a/libs/nanofn/src/_internal/array-each.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `forEach` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ -export function _arrayEach(array: any[], - iteratee: (value: any, index: number, array: any[]) => boolean | void -): any[] { - let index = -1; - const length = array.length; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; -} - - diff --git a/libs/nanofn/src/_internal/array-includes-with.ts b/libs/nanofn/src/_internal/array-includes-with.ts deleted file mode 100644 index 4d4ddc776..000000000 --- a/libs/nanofn/src/_internal/array-includes-with.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This function is like `arrayIncludes` except that it accepts a comparator. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -export function _arrayIncludesWith(array: any[], target: any, - comparator: (value: any, other: any) => boolean): boolean { - if (array == null) { - return false; - } - - for (const value of array) { - if (comparator(target, value)) { - return true; - } - } - return false; -} - - diff --git a/libs/nanofn/src/_internal/array-includes.ts b/libs/nanofn/src/_internal/array-includes.ts deleted file mode 100644 index afd9cfa82..000000000 --- a/libs/nanofn/src/_internal/array-includes.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIndexOf } from './base-index-of'; - -/** - * A specialized version of `includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -export function _arrayIncludes(array: any[], value: any): boolean { - const length = array == null ? 0 : array.length; - return !!length && _baseIndexOf(array, value, 0) > -1; -} - - diff --git a/libs/nanofn/src/_internal/array-like-keys.ts b/libs/nanofn/src/_internal/array-like-keys.ts deleted file mode 100644 index 54cded839..000000000 --- a/libs/nanofn/src/_internal/array-like-keys.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isArguments } from '../is/is-arguments'; -import { isBuffer } from '../is/is-buffer'; -import { isTypedArray } from '../is/is-typed-array'; -import { _isIndex } from './is-index'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -export function _arrayLikeKeys(value: any, inherited?: boolean): any[] { - const isArr = Array.isArray(value); - const isArg = !isArr && isArguments(value); - const isBuff = !isArr && !isArg && isBuffer(value); - const isType = !isArr && !isArg && !isBuff && isTypedArray(value); - const skipIndexes = isArr || isArg || isBuff || isType; - const length = value.length; - const result = new Array(skipIndexes ? length : 0); - let index = skipIndexes ? -1 : length; - while (++index < length) { - result[index] = `${index}`; - } - for (const key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - (key === 'length' || - // Skip index properties. - _isIndex(key, length)) - ))) { - result.push(key); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/array-reduce-right.ts b/libs/nanofn/src/_internal/array-reduce-right.ts deleted file mode 100644 index e971e4d46..000000000 --- a/libs/nanofn/src/_internal/array-reduce-right.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `reduceRight` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ -export function _arrayReduceRight(array, iteratee, accumulator, initAccum) { - let length = array == null ? 0 : array.length; - if (initAccum && length) { - accumulator = array[--length]; - } - while (length--) { - accumulator = iteratee(accumulator, array[length], length, array); - } - return accumulator; -} - - diff --git a/libs/nanofn/src/_internal/array-reduce.ts b/libs/nanofn/src/_internal/array-reduce.ts deleted file mode 100644 index 29e718791..000000000 --- a/libs/nanofn/src/_internal/array-reduce.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `reduce` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ -export function _arrayReduce(array, iteratee, accumulator, initAccum) { - let index = -1; - const length = array == null ? 0 : array.length; - - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; -} - - diff --git a/libs/nanofn/src/_internal/ascii-size.ts b/libs/nanofn/src/_internal/ascii-size.ts deleted file mode 100644 index 31661d2da..000000000 --- a/libs/nanofn/src/_internal/ascii-size.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets the size of an ASCII `string`. - * - * @private - * @param str The string inspect. - * @returns Returns the string size. - */ -export function _asciiSize(str: string): number { - return str.length; -} - - diff --git a/libs/nanofn/src/_internal/ascii-to-array.ts b/libs/nanofn/src/_internal/ascii-to-array.ts deleted file mode 100644 index 5bfa5c525..000000000 --- a/libs/nanofn/src/_internal/ascii-to-array.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -export function _asciiToArray(string) { - return string.split(''); -} - - diff --git a/libs/nanofn/src/_internal/assign-merge-value.ts b/libs/nanofn/src/_internal/assign-merge-value.ts deleted file mode 100644 index a1a541e3e..000000000 --- a/libs/nanofn/src/_internal/assign-merge-value.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from '../lang/eq'; -import { _baseAssignValue } from './base-assign-value'; - -/** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -export function _assignMergeValue(object, key, value) { - if ((value !== undefined && !eq(object[key], value)) || - (value === undefined && !(key in object))) { - _baseAssignValue(object, key, value); - } -} - - diff --git a/libs/nanofn/src/_internal/assign-value.ts b/libs/nanofn/src/_internal/assign-value.ts deleted file mode 100644 index 0afbca2c6..000000000 --- a/libs/nanofn/src/_internal/assign-value.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from '../lang/eq'; -import { _baseAssignValue } from './base-assign-value'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -export function _assignValue(object: any, key: string | symbol, value: any) { - const objValue = object[key]; - - if (!(hasOwnProperty.call(object, key) && eq(objValue, value))) { - if (value !== 0 || (1 / value) === (1 / objValue)) { - _baseAssignValue(object, key, value); - } - } else if (value === undefined && !(key in object)) { - _baseAssignValue(object, key, value); - } -} - - diff --git a/libs/nanofn/src/_internal/assoc-index-of.ts b/libs/nanofn/src/_internal/assoc-index-of.ts deleted file mode 100644 index 237b7549f..000000000 --- a/libs/nanofn/src/_internal/assoc-index-of.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from '../lang/eq'; - - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _assocIndexOf(array: any[], key: any): number { - let {length} = array; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/_internal/base-assign-value.ts b/libs/nanofn/src/_internal/base-assign-value.ts deleted file mode 100644 index 58975a1dc..000000000 --- a/libs/nanofn/src/_internal/base-assign-value.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -export function _baseAssignValue(object: any, - key: string | symbol, - value: any): any { - if (key == '__proto__') { - Object.defineProperty(object, key, { - 'configurable': true, - 'enumerable' : true, - 'value' : value, - 'writable' : true - }); - } else { - object[key] = value; - } -} - - diff --git a/libs/nanofn/src/_internal/base-at.ts b/libs/nanofn/src/_internal/base-at.ts deleted file mode 100644 index b151d539d..000000000 --- a/libs/nanofn/src/_internal/base-at.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { get } from '../get'; - -/** - * The base implementation of `at` without support for individual paths. - * - * @private - * @param {Object} object The object to iterate over. - * @param {string[]} paths The property paths to pick. - * @returns {Array} Returns the picked elements. - */ -export function _baseAt(object, paths) { - let index = -1; - const length = paths.length; - const result = new Array(length); - const skip = object == null; - - while (++index < length) { - result[index] = skip ? undefined : get(object, paths[index]); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-clone.ts b/libs/nanofn/src/_internal/base-clone.ts deleted file mode 100644 index c0fe05039..000000000 --- a/libs/nanofn/src/_internal/base-clone.ts +++ /dev/null @@ -1,253 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Stack } from './stack'; -import { _arrayEach } from './array-each'; -import { _assignValue } from './assign-value'; -import { _cloneBuffer } from './clone-buffer'; -import { _copyArray } from './copy-array'; -import { _copyObject } from './copy-object'; -import { _cloneArrayBuffer } from './clone-array-buffer'; -import { _cloneDataView } from './clone-data-view'; -import { _cloneRegExp } from './clone-reg-exp'; -import { _cloneSymbol } from './clone-symbol'; -import { _cloneTypedArray } from './clone-typed-array'; -import { _copySymbols } from './copy-symbols'; -import { _copySymbolsIn } from './copy-symbols-in'; -import { _getAllKeys } from './get-all-keys'; -import { _getAllKeysIn } from './get-all-keys-in'; -import { _getTag } from './get-tag'; -import { _initCloneObject } from './init-clone-object'; -import { isBuffer } from '../is/is-buffer'; -import { isObject } from '../is/is-object'; -import { isTypedArray } from '../is/is-typed-array'; -import { keys } from '../keys'; -import { keysIn } from '../keys-in'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; -const CLONE_FLAT_FLAG = 2; -const CLONE_SYMBOLS_FLAG = 4; - -/** `Object#toString` result references. */ -const argsTag = '[object Arguments]'; -const arrayTag = '[object Array]'; -const boolTag = '[object Boolean]'; -const dateTag = '[object Date]'; -const errorTag = '[object Error]'; -const mapTag = '[object Map]'; -const numberTag = '[object Number]'; -const objectTag = '[object Object]'; -const regexpTag = '[object RegExp]'; -const setTag = '[object Set]'; -const stringTag = '[object String]'; -const symbolTag = '[object Symbol]'; -const weakMapTag = '[object WeakMap]'; - -const arrayBufferTag = '[object ArrayBuffer]'; -const dataViewTag = '[object DataView]'; -const float32Tag = '[object Float32Array]'; -const float64Tag = '[object Float64Array]'; -const int8Tag = '[object Int8Array]'; -const int16Tag = '[object Int16Array]'; -const int32Tag = '[object Int32Array]'; -const uint8Tag = '[object Uint8Array]'; -const uint8ClampedTag = '[object Uint8ClampedArray]'; -const uint16Tag = '[object Uint16Array]'; -const uint32Tag = '[object Uint32Array]'; - -/** Used to identify `toStringTag` values supported by `clone`. */ -const cloneableTags: any = {}; -cloneableTags[argsTag] = cloneableTags[arrayTag] = -cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = -cloneableTags[boolTag] = cloneableTags[dateTag] = -cloneableTags[float32Tag] = cloneableTags[float64Tag] = -cloneableTags[int8Tag] = cloneableTags[int16Tag] = -cloneableTags[int32Tag] = cloneableTags[mapTag] = -cloneableTags[numberTag] = cloneableTags[objectTag] = -cloneableTags[regexpTag] = cloneableTags[setTag] = -cloneableTags[stringTag] = cloneableTags[symbolTag] = -cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = -cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; -cloneableTags[errorTag] = cloneableTags[weakMapTag] = false; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ -function _initCloneByTag(object, tag, isDeep) { - const Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return _cloneArrayBuffer(object); - - case boolTag: - case dateTag: - return new Ctor(+object); - - case dataViewTag: - return _cloneDataView(object, isDeep); - - case float32Tag: - case float64Tag: - case int8Tag: - case int16Tag: - case int32Tag: - case uint8Tag: - case uint8ClampedTag: - case uint16Tag: - case uint32Tag: - return _cloneTypedArray(object, isDeep); - - case mapTag: - return new Ctor; - - case numberTag: - case stringTag: - return new Ctor(object); - - case regexpTag: - return _cloneRegExp(object); - - case setTag: - return new Ctor; - - case symbolTag: - return _cloneSymbol(object); - } -} - -/** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ -function _initCloneArray(array) { - const {length} = array; - const result = new array.constructor(length); - - // Add properties assigned by `RegExp#exec`. - if (length && typeof array[0] === 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; -} - -/** - * The base implementation of `clone` and `cloneDeep` which tracks - * traversed objects. - * - * @private - * @param {*} value The value to clone. - * @param {number} bitmask The bitmask flags. - * 1 - Deep clone - * 2 - Flatten inherited properties - * 4 - Clone symbols - * @param {Function} [customizer] The function to customize cloning. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The parent object of `value`. - * @param {Object} [stack] Tracks traversed objects and their clone counterparts. - * @returns {*} Returns the cloned value. - */ -export function _baseClone(value: any, bitmask: number, customizer?, key?, object?, stack?): any { - let result: any; - const isDeep = bitmask & CLONE_DEEP_FLAG; - const isFlat = bitmask & CLONE_FLAT_FLAG; - const isFull = bitmask & CLONE_SYMBOLS_FLAG; - - if (customizer) { - result = object ? customizer(value, key, object, stack) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - const isArr = Array.isArray(value); - const tag = _getTag(value); - if (isArr) { - result = _initCloneArray(value); - if (!isDeep) { - return _copyArray(value, result); - } - } else { - const isFunc = typeof value === 'function'; - - if (isBuffer(value)) { - return _cloneBuffer(value, isDeep); - } - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = (isFlat || isFunc) ? {} : _initCloneObject(value); - if (!isDeep) { - return isFlat - ? _copySymbolsIn(value, _copyObject(value, keysIn(value), result)) - : _copySymbols(value, Object.assign(result, value)); - } - } else { - if (isFunc || !cloneableTags[tag]) { - return object ? value : {}; - } - result = _initCloneByTag(value, tag, isDeep); - } - } - // Check for circular references and return its corresponding clone. - stack || (stack = new Stack); - const stacked = stack.get(value); - if (stacked) { - return stacked; - } - stack.set(value, result); - - if (tag == mapTag) { - value.forEach((subValue, key) => { - result.set(key, _baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; - } - - if (tag == setTag) { - value.forEach((subValue) => { - result.add(_baseClone(subValue, bitmask, customizer, subValue, value, stack)); - }); - return result; - } - - if (isTypedArray(value)) { - return result; - } - - const keysFunc = isFull - ? (isFlat ? _getAllKeysIn : _getAllKeys) - : (isFlat ? keysIn : keys); - - const props = isArr ? undefined : keysFunc(value); - _arrayEach(props || value, (subValue, key) => { - if (props) { - key = subValue; - subValue = value[key]; - } - // Recursively populate clone (susceptible to call stack limits). - _assignValue(result, key, _baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-conforms-to.ts b/libs/nanofn/src/_internal/base-conforms-to.ts deleted file mode 100644 index 252351c27..000000000 --- a/libs/nanofn/src/_internal/base-conforms-to.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `conformsTo` which accepts `props` to check. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - */ -export function _baseConformsTo(object, source, props) { - let length = props.length; - if (object == null) { - return !length; - } - object = Object(object); - while (length--) { - const key = props[length]; - const predicate = source[key]; - const value = object[key]; - - if ((value === undefined && !(key in object)) || !predicate(value)) { - return false; - } - } - return true; -} - - diff --git a/libs/nanofn/src/_internal/base-conforms.ts b/libs/nanofn/src/_internal/base-conforms.ts deleted file mode 100644 index 8613a3598..000000000 --- a/libs/nanofn/src/_internal/base-conforms.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseConformsTo } from './base-conforms-to'; -import { keys } from '../keys'; - -/** - * The base implementation of `conforms` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. - */ -export function _baseConforms(source) { - const props = keys(source); - return (object) => _baseConformsTo(object, source, props); -} - - diff --git a/libs/nanofn/src/_internal/base-difference.ts b/libs/nanofn/src/_internal/base-difference.ts deleted file mode 100644 index de594627c..000000000 --- a/libs/nanofn/src/_internal/base-difference.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { SetCache } from './-set-cache'; -import { _arrayIncludes } from './array-includes'; -import { _arrayIncludesWith } from './array-includes-with'; -import { map } from '../map'; -import { _cacheHas } from './cache-has'; - -/** Used as the size to enable large array optimizations. */ -const LARGE_ARRAY_SIZE = 200; - -/** - * The base implementation of methods like `difference` without support - * for excluding multiple arrays. - * - * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - */ -export function _baseDifference(array, values, iteratee, comparator) { - let includes = _arrayIncludes; - let isCommon = true; - const result = []; - const valuesLength = values.length; - - if (!array.length) { - return result; - } - if (iteratee) { - values = map(values, (value) => iteratee(value)); - } - if (comparator) { - includes = _arrayIncludesWith; - isCommon = false; - } else if (values.length >= LARGE_ARRAY_SIZE) { - includes = _cacheHas; - isCommon = false; - values = new SetCache(values); - } - outer: - for (let value of array) { - const computed = iteratee == null ? value : iteratee(value); - - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - let valuesIndex = valuesLength; - while (valuesIndex--) { - if (values[valuesIndex] === computed) { - continue outer; - } - } - result.push(value); - } else if (!includes(values, computed, comparator)) { - result.push(value); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-each-right.ts b/libs/nanofn/src/_internal/base-each-right.ts deleted file mode 100644 index 14de983d0..000000000 --- a/libs/nanofn/src/_internal/base-each-right.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseForOwnRight } from './base-for-own-right'; -import { isArrayLike } from '../is-array-like'; - -/** - * The base implementation of `forEachRight`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ -export function _baseEachRight(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return _baseForOwnRight(collection, iteratee); - } - const iterable = Object(collection); - let length = collection.length; - - while (length--) { - if (iteratee(iterable[length], length, iterable) === false) { - break; - } - } - return collection; -} - - diff --git a/libs/nanofn/src/_internal/base-each.ts b/libs/nanofn/src/_internal/base-each.ts deleted file mode 100644 index 732b610cb..000000000 --- a/libs/nanofn/src/_internal/base-each.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseForOwn } from './base-for-own'; -import { isArrayLike } from '../is-array-like'; - -/** - * The base implementation of `forEach`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ -export function _baseEach(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return _baseForOwn(collection, iteratee); - } - const length = collection.length; - const iterable = Object(collection); - let index = -1; - - while (++index < length) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; -} - - diff --git a/libs/nanofn/src/_internal/base-find-index.ts b/libs/nanofn/src/_internal/base-find-index.ts deleted file mode 100644 index 65126f979..000000000 --- a/libs/nanofn/src/_internal/base-find-index.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `findIndex` and `findLastIndex`. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _baseFindIndex(array: any[], - predicate: (val: any, idx: number, target: any) => boolean, - fromIndex: number, - fromRight?: boolean): number { - const {length} = array; - let index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/_internal/base-find-key.ts b/libs/nanofn/src/_internal/base-find-key.ts deleted file mode 100644 index 6311906ca..000000000 --- a/libs/nanofn/src/_internal/base-find-key.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of methods like `findKey` and `findLastKey` - * which iterates over `collection` using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the found element or its key, else `undefined`. - */ -export function _baseFindKey(collection, predicate, eachFunc) { - let result; - eachFunc(collection, (value, key, collection) => { - if (predicate(value, key, collection)) { - result = key; - return false; - } - }); - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-flatten.ts b/libs/nanofn/src/_internal/base-flatten.ts deleted file mode 100644 index 7cb51df5c..000000000 --- a/libs/nanofn/src/_internal/base-flatten.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _isFlattenable } from './is-flattenable'; - -/** - * The base implementation of `flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ -export function _baseFlatten(array, depth, predicate, isStrict, result) { - predicate || (predicate = _isFlattenable); - result || (result = []); - - if (array == null) { - return result; - } - - for (const value of array) { - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - _baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - result.push(...value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-for-own-right.ts b/libs/nanofn/src/_internal/base-for-own-right.ts deleted file mode 100644 index 9f293cc24..000000000 --- a/libs/nanofn/src/_internal/base-for-own-right.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseForRight } from './base-for-right'; -import { keys } from '../keys'; - -/** - * The base implementation of `forOwnRight`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -export function _baseForOwnRight(object, iteratee) { - return object && _baseForRight(object, iteratee, keys); -} - - diff --git a/libs/nanofn/src/_internal/base-for-own.ts b/libs/nanofn/src/_internal/base-for-own.ts deleted file mode 100644 index a61075334..000000000 --- a/libs/nanofn/src/_internal/base-for-own.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFor } from './base-for'; -import { keys } from '../keys'; - -/** - * The base implementation of `forOwn`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -export function _baseForOwn(object, iteratee) { - return object && _baseFor(object, iteratee, keys); -} - - diff --git a/libs/nanofn/src/_internal/base-for-right.ts b/libs/nanofn/src/_internal/base-for-right.ts deleted file mode 100644 index e00e13a1d..000000000 --- a/libs/nanofn/src/_internal/base-for-right.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This function is like `baseFor` except that it iterates over properties - * in the opposite order. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -export function _baseForRight(object, iteratee, keysFunc) { - const iterable = Object(object); - const props = keysFunc(object); - let { length } = props; - - while (length--) { - const key = props[length]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; -} - - diff --git a/libs/nanofn/src/_internal/base-for.ts b/libs/nanofn/src/_internal/base-for.ts deleted file mode 100644 index 2b2b1d30b..000000000 --- a/libs/nanofn/src/_internal/base-for.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -export function _baseFor(object, iteratee, keysFunc) { - const iterable = Object(object); - const props = keysFunc(object); - let { length } = props; - let index = -1; - - while (length--) { - const key = props[++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; -} - - diff --git a/libs/nanofn/src/_internal/base-get.ts b/libs/nanofn/src/_internal/base-get.ts deleted file mode 100644 index db0108cd8..000000000 --- a/libs/nanofn/src/_internal/base-get.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from './cast-path'; -import { _toKey } from './to-key'; - -/** - * The base implementation of `get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -export function _baseGet(object: any, path: string | string[]) { - path = _castPath(path, object); - - let index = 0; - const length = path.length; - - while (object != null && index < length) { - object = object[_toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; -} - - diff --git a/libs/nanofn/src/_internal/base-in-range.ts b/libs/nanofn/src/_internal/base-in-range.ts deleted file mode 100644 index 8b7f52e67..000000000 --- a/libs/nanofn/src/_internal/base-in-range.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `inRange` which doesn't coerce arguments. - * - * @private - * @param {number} number The number to check. - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - */ -export function _baseInRange(number, start, end) { - return number >= Math.min(start, end) && number < Math.max(start, end); -} - - diff --git a/libs/nanofn/src/_internal/base-index-of-with.ts b/libs/nanofn/src/_internal/base-index-of-with.ts deleted file mode 100644 index db7c1569b..000000000 --- a/libs/nanofn/src/_internal/base-index-of-with.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This function is like `baseIndexOf` except that it accepts a comparator. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @param {Function} comparator The comparator invoked per element. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _baseIndexOfWith(array, value, fromIndex, comparator) { - let index = fromIndex - 1; - const { length } = array; - - while (++index < length) { - if (comparator(array[index], value)) { - return index; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/_internal/base-index-of.ts b/libs/nanofn/src/_internal/base-index-of.ts deleted file mode 100644 index 73da40c62..000000000 --- a/libs/nanofn/src/_internal/base-index-of.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFindIndex } from './base-find-index'; -import { _baseIsNaN } from './base-is-nan'; -import { _strictIndexOf } from './strict-index-of'; - -/** - * The base implementation of `indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _baseIndexOf(array: any[], value: any, fromIndex: number): number { - return value === value - ? _strictIndexOf(array, value, fromIndex) - : _baseFindIndex(array, _baseIsNaN, fromIndex); -} - - diff --git a/libs/nanofn/src/_internal/base-intersection.ts b/libs/nanofn/src/_internal/base-intersection.ts deleted file mode 100644 index f65097f9d..000000000 --- a/libs/nanofn/src/_internal/base-intersection.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { SetCache } from './-set-cache'; -import { _arrayIncludes } from './array-includes'; -import { _arrayIncludesWith } from './array-includes-with'; -import { map } from '../map'; -import { _cacheHas } from './cache-has'; - -/** - * The base implementation of methods like `intersection` that accepts an - * array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of shared values. - */ -export function _baseIntersection(arrays, iteratee, comparator) { - const includes = comparator ? _arrayIncludesWith : _arrayIncludes; - const length = arrays[0].length; - const othLength = arrays.length; - const caches = new Array(othLength); - const result = []; - - let array; - let maxLength = Infinity; - let othIndex = othLength; - - while (othIndex--) { - array = arrays[othIndex]; - if (othIndex && iteratee) { - array = map(array, (value) => iteratee(value)); - } - maxLength = Math.min(array.length, maxLength); - caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) - ? new SetCache(othIndex && array) - : undefined; - } - array = arrays[0]; - - let index = -1; - const seen = caches[0]; - - outer: - while (++index < length && result.length < maxLength) { - let value = array[index]; - const computed = iteratee ? iteratee(value) : value; - - value = (comparator || value !== 0) ? value : 0; - if (!(seen - ? _cacheHas(seen, computed) - : includes(result, computed, comparator) - )) { - othIndex = othLength; - while (--othIndex) { - const cache = caches[othIndex]; - if (!(cache - ? _cacheHas(cache, computed) - : includes(arrays[othIndex], computed, comparator)) - ) { - continue outer; - } - } - if (seen) { - seen.push(computed); - } - result.push(value); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-is-equal-deep.ts b/libs/nanofn/src/_internal/base-is-equal-deep.ts deleted file mode 100644 index 24ab296bf..000000000 --- a/libs/nanofn/src/_internal/base-is-equal-deep.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Stack } from './-stack'; -import { _equalArrays } from './equal-arrays'; -import { _equalByTag } from './equal-by-tag'; -import { _equalObjects } from './equal-objects'; -import { _getTag } from './get-tag'; -import { isBuffer } from '../is-buffer'; -import { isTypedArray } from '../is-typed-array'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; - -/** `Object#toString` result references. */ -const argsTag = '[object Arguments]'; -const arrayTag = '[object Array]'; -const objectTag = '[object Object]'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -export function _baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - let objIsArr = Array.isArray(object); - const othIsArr = Array.isArray(other); - let objTag = objIsArr ? arrayTag : _getTag(object); - let othTag = othIsArr ? arrayTag : _getTag(other); - - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - - let objIsObj = objTag == objectTag; - const othIsObj = othTag == objectTag; - const isSameTag = objTag == othTag; - - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) - : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'); - const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - const objUnwrapped = objIsWrapped ? object.value() : object; - const othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return _equalObjects(object, other, bitmask, customizer, equalFunc, stack); -} - - diff --git a/libs/nanofn/src/_internal/base-is-equal.ts b/libs/nanofn/src/_internal/base-is-equal.ts deleted file mode 100644 index 0948992cf..000000000 --- a/libs/nanofn/src/_internal/base-is-equal.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsEqualDeep } from './base-is-equal-deep'; -import { isObjectLike } from '../is-object-like'; - -/** - * The base implementation of `isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -export function _baseIsEqual(value: any, other: any, bitmask?: boolean, customizer?: Function, - stack?: any): boolean { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return _baseIsEqualDeep(value, other, bitmask, customizer, _baseIsEqual, stack); -} - - diff --git a/libs/nanofn/src/_internal/base-is-match.ts b/libs/nanofn/src/_internal/base-is-match.ts deleted file mode 100644 index e1b3cb6c4..000000000 --- a/libs/nanofn/src/_internal/base-is-match.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Stack } from './stack'; -import { _baseIsEqual } from './base-is-equal'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; -const COMPARE_UNORDERED_FLAG = 2; - -/** - * The base implementation of `isMatch`. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -export function _baseIsMatch(object, source, matchData, customizer) { - let index = matchData.length; - const length = index; - const noCustomizer = !customizer; - - if (object == null) { - return !length; - } - let data; - let result; - object = Object(object); - while (index--) { - data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - const key = data[0]; - const objValue = object[key]; - const srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - const stack = new Stack; - if (customizer) { - result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, - customizer, stack) - : result - )) { - return false; - } - } - } - return true; -} - - diff --git a/libs/nanofn/src/_internal/base-is-nan.ts b/libs/nanofn/src/_internal/base-is-nan.ts deleted file mode 100644 index 7ebeafbf2..000000000 --- a/libs/nanofn/src/_internal/base-is-nan.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ -export function _baseIsNaN(value: any) { - return value !== value; -} - - diff --git a/libs/nanofn/src/_internal/base-matches-property.ts b/libs/nanofn/src/_internal/base-matches-property.ts deleted file mode 100644 index 34708c113..000000000 --- a/libs/nanofn/src/_internal/base-matches-property.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsEqual } from './base-is-equal'; -import { get } from '../get'; -import { hasIn } from '../has-in'; -import { _isKey } from './is-key'; -import { _isStrictComparable } from './is-strict-comparable'; -import { _matchesStrictComparable } from './matches-strict-comparable'; -import { _toKey } from './to-key'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; -const COMPARE_UNORDERED_FLAG = 2; - -/** - * The base implementation of `matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -export function _baseMatchesProperty(path, srcValue) { - if (_isKey(path) && _isStrictComparable(srcValue)) { - return _matchesStrictComparable(_toKey(path), srcValue); - } - return (object) => { - const objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); - }; -} - - diff --git a/libs/nanofn/src/_internal/base-matches.ts b/libs/nanofn/src/_internal/base-matches.ts deleted file mode 100644 index ce9e4f0e3..000000000 --- a/libs/nanofn/src/_internal/base-matches.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsMatch } from './base-is-match'; -import { _getMatchData } from './get-match-data'; -import { _matchesStrictComparable } from './matches-strict-comparable'; - -/** - * The base implementation of `matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - */ -export function _baseMatches(source) { - const matchData = _getMatchData(source); - if (matchData.length === 1 && matchData[0][2]) { - return _matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return (object) => object === source || _baseIsMatch(object, source, matchData); -} - - diff --git a/libs/nanofn/src/_internal/base-merge-deep.ts b/libs/nanofn/src/_internal/base-merge-deep.ts deleted file mode 100644 index 54c18d9ed..000000000 --- a/libs/nanofn/src/_internal/base-merge-deep.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _assignMergeValue } from './assign-merge-value'; -import { _cloneBuffer } from './clone-buffer'; -import { _cloneTypedArray } from './clone-typed-array'; -import { _copyArray } from './copy-array'; -import { _initCloneObject } from './init-clone-object'; -import { isArguments } from '../is-arguments'; -import { isArrayLikeObject } from '../is-array-like-object'; -import { isBuffer } from '../is-buffer'; -import { isObject } from '../is-object'; -import { isPlainObject } from '../is-plain-object'; -import { isTypedArray } from '../is-typed-array'; -import { toPlainObject } from '../to-plain-object'; - -/** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {number} srcIndex The index of `source`. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ -export function _baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - const objValue = object[key]; - const srcValue = source[key]; - const stacked = stack.get(srcValue); - - if (stacked) { - _assignMergeValue(object, key, stacked); - return; - } - let newValue = customizer - ? customizer(objValue, srcValue, `${key}`, object, source, stack) - : undefined; - - let isCommon = newValue === undefined; - - if (isCommon) { - const isArr = Array.isArray(srcValue); - const isBuff = !isArr && isBuffer(srcValue); - const isTyped = !isArr && !isBuff && isTypedArray(srcValue); - - newValue = srcValue; - if (isArr || isBuff || isTyped) { - if (Array.isArray(objValue)) { - newValue = objValue; - } else if (isArrayLikeObject(objValue)) { - newValue = _copyArray(objValue); - } else if (isBuff) { - isCommon = false; - newValue = _cloneBuffer(srcValue, true); - } else if (isTyped) { - isCommon = false; - newValue = _cloneTypedArray(srcValue, true); - } else { - newValue = []; - } - } else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = objValue; - if (isArguments(objValue)) { - newValue = toPlainObject(objValue); - } else if (typeof objValue === 'function' || !isObject(objValue)) { - newValue = _initCloneObject(srcValue); - } - } else { - isCommon = false; - } - } - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, newValue); - mergeFunc(newValue, srcValue, srcIndex, customizer, stack); - stack['delete'](srcValue); - } - _assignMergeValue(object, key, newValue); -} - - diff --git a/libs/nanofn/src/_internal/base-merge.ts b/libs/nanofn/src/_internal/base-merge.ts deleted file mode 100644 index a673f2c99..000000000 --- a/libs/nanofn/src/_internal/base-merge.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Stack } from './-stack'; -import { _assignMergeValue } from './assign-merge-value'; -import { _baseFor } from './base-for'; -import { _baseMergeDeep } from './base-merge-deep'; -import { isObject } from '../is-object'; -import { keysIn } from '../keys-in'; - -/** - * The base implementation of `merge` without support for multiple sources. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {number} srcIndex The index of `source`. - * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ -export function _baseMerge(object, source, srcIndex, customizer, stack) { - if (object === source) { - return; - } - _baseFor(source, (srcValue, key) => { - if (isObject(srcValue)) { - stack || (stack = new Stack); - _baseMergeDeep(object, source, key, srcIndex, _baseMerge, customizer, stack); - } else { - let newValue = customizer - ? customizer(object[key], srcValue, `${key}`, object, source, stack) - : undefined; - - if (newValue === undefined) { - newValue = srcValue; - } - _assignMergeValue(object, key, newValue); - } - }, keysIn); -} - - diff --git a/libs/nanofn/src/_internal/base-order-by.ts b/libs/nanofn/src/_internal/base-order-by.ts deleted file mode 100644 index 5a522d522..000000000 --- a/libs/nanofn/src/_internal/base-order-by.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseEach } from './base-each'; -import { _baseSortBy } from './base-sort-by'; -import { _baseGet } from './base-get'; -import { _compareMultiple } from './compare-multiple'; -import { isArrayLike } from '../is-array-like'; - -const identity = (value) => value; - -/** - * The base implementation of `orderBy` without param guards. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ -export function _baseOrderBy(collection, iteratees, orders) { - if (iteratees.length) { - iteratees = iteratees.map((iteratee) => { - if (Array.isArray(iteratee)) { - return (value) => _baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); - } - - return iteratee; - }); - } else { - iteratees = [identity]; - } - - let criteriaIndex = -1; - let eachIndex = -1; - - const result = isArrayLike(collection) ? new Array(collection.length) : []; - - _baseEach(collection, (value) => { - const criteria = iteratees.map((iteratee) => iteratee(value)); - - result[++eachIndex] = { - criteria, - index: ++criteriaIndex, - value - }; - }); - - return _baseSortBy(result, (object, other) => _compareMultiple(object, other, orders)); -} - - diff --git a/libs/nanofn/src/_internal/base-pick-by.ts b/libs/nanofn/src/_internal/base-pick-by.ts deleted file mode 100644 index 7696fe1b8..000000000 --- a/libs/nanofn/src/_internal/base-pick-by.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from './base-get'; -import { _baseSet } from './base-set'; -import { _castPath } from './cast-path'; - -/** - * The base implementation of `pickBy`. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - */ -export function _basePickBy(object, paths, predicate) { - let index = -1; - const length = paths.length; - const result = {}; - - while (++index < length) { - const path = paths[index]; - const value = _baseGet(object, path); - if (predicate(value, path)) { - _baseSet(result, _castPath(path, object), value); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-pick.ts b/libs/nanofn/src/_internal/base-pick.ts deleted file mode 100644 index c567022f2..000000000 --- a/libs/nanofn/src/_internal/base-pick.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePickBy } from './base-pick-by'; -import { hasIn } from '../has-in'; - -/** - * The base implementation of `pick` without support for individual - * property identifiers. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @returns {Object} Returns the new object. - */ -export function _basePick(object, paths) { - return _basePickBy(object, paths, (value, path) => hasIn(object, path)); -} - - diff --git a/libs/nanofn/src/_internal/base-property-deep.ts b/libs/nanofn/src/_internal/base-property-deep.ts deleted file mode 100644 index d3cfc0167..000000000 --- a/libs/nanofn/src/_internal/base-property-deep.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from './base-get'; - -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ -export function _basePropertyDeep(path) { - return (object) => _baseGet(object, path); -} - - diff --git a/libs/nanofn/src/_internal/base-property-of.ts b/libs/nanofn/src/_internal/base-property-of.ts deleted file mode 100644 index 1a9008ee3..000000000 --- a/libs/nanofn/src/_internal/base-property-of.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `propertyOf` without support for deep paths. - * - * @private - * @param {Object} obj The object to query. - * @returns {Function} Returns the new accessor function. - */ -export function _basePropertyOf(obj: any): Function { - return (key) => obj == null ? undefined : obj[key]; -} - - diff --git a/libs/nanofn/src/_internal/base-property.ts b/libs/nanofn/src/_internal/base-property.ts deleted file mode 100644 index 11bae6539..000000000 --- a/libs/nanofn/src/_internal/base-property.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ -export function _baseProperty(key) { - return (object) => object == null ? undefined : object[key]; -} - - diff --git a/libs/nanofn/src/_internal/base-pull-all.ts b/libs/nanofn/src/_internal/base-pull-all.ts deleted file mode 100644 index 46a0fa106..000000000 --- a/libs/nanofn/src/_internal/base-pull-all.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../map'; -import { _baseIndexOf } from './base-index-of'; -import { _baseIndexOfWith } from './base-index-of-with'; -import { _copyArray } from './copy-array'; - -/** - * The base implementation of `pullAllBy`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - */ -export function _basePullAll(array, values, iteratee, comparator) { - const indexOf = comparator ? _baseIndexOfWith : _baseIndexOf; - const length = values.length; - - let index = -1; - let seen = array; - - if (array === values) { - values = _copyArray(values); - } - if (iteratee) { - seen = map(array, (value) => iteratee(value)); - } - while (++index < length) { - let fromIndex = 0; - const value = values[index]; - const computed = iteratee ? iteratee(value) : value; - - while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { - if (seen !== array) { - seen.splice(fromIndex, 1); - } - array.splice(fromIndex, 1); - } - } - return array; -} - - diff --git a/libs/nanofn/src/_internal/base-pull-at.ts b/libs/nanofn/src/_internal/base-pull-at.ts deleted file mode 100644 index ff480ffd0..000000000 --- a/libs/nanofn/src/_internal/base-pull-at.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUnset } from './base-unset'; -import { _isIndex } from './is-index'; - -/** - * The base implementation of `pullAt` without support for individual - * indexes or capturing the removed elements. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns `array`. - */ -export function _basePullAt(array, indexes) { - let length = array ? indexes.length : 0; - const lastIndex = length - 1; - - while (length--) { - let previous; - const index = indexes[length]; - if (length === lastIndex || index !== previous) { - previous = index; - if (_isIndex(index)) { - array.splice(index, 1); - } else { - _baseUnset(array, index); - } - } - } - return array; -} - - diff --git a/libs/nanofn/src/_internal/base-range.ts b/libs/nanofn/src/_internal/base-range.ts deleted file mode 100644 index 9a8f341f2..000000000 --- a/libs/nanofn/src/_internal/base-range.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `range` and `rangeRight` which doesn't - * coerce arguments. - * - * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. - */ -export function _baseRange(start, end, step, fromRight) { - let index = -1; - let length = Math.max(Math.ceil((end - start) / (step || 1)), 0); - const result = new Array(length); - - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-reduce.ts b/libs/nanofn/src/_internal/base-reduce.ts deleted file mode 100644 index c2a3a9f56..000000000 --- a/libs/nanofn/src/_internal/base-reduce.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `reduce` and `reduceRight` which iterates - * over `collection` using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of - * `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. - */ -export function _baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, (value, index, collection) => { - accumulator = initAccum - ? (initAccum = false, value) - : iteratee(accumulator, value, index, collection); - }); - return accumulator; -} - - diff --git a/libs/nanofn/src/_internal/base-set.ts b/libs/nanofn/src/_internal/base-set.ts deleted file mode 100644 index 79b300c9a..000000000 --- a/libs/nanofn/src/_internal/base-set.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _assignValue } from './assign-value'; -import { _castPath } from './cast-path'; -import { _isIndex } from './is-index'; -import { isObject } from '../is/is-object'; -import { _toKey } from './to-key'; - -/** - * The base implementation of `set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ -export function _baseSet(object: any, - path: string | string[], - value: any, - customizer?: Function) { - if (!isObject(object)) { - return object; - } - path = _castPath(path, object); - - const length = path.length; - const lastIndex = length - 1; - - let index = -1; - let nested: any = object; - - while (nested != null && ++index < length) { - const key = _toKey(path[index]); - let newValue = value; - - if (index != lastIndex) { - const objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - if (isObject(objValue)) { - newValue = objValue; - } else { - newValue = _isIndex(path[index + 1]) ? [] : {}; - } - } - } - _assignValue(nested, key, newValue); - nested = nested[key]; - } - return object; -} - - diff --git a/libs/nanofn/src/_internal/base-sort-by.ts b/libs/nanofn/src/_internal/base-sort-by.ts deleted file mode 100644 index 4f2764ac7..000000000 --- a/libs/nanofn/src/_internal/base-sort-by.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `sortBy` which uses `comparer` to define the - * sort order of `array` and replaces criteria objects with their corresponding - * values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ -export function _baseSortBy(array, comparer) { - let { length } = array; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; -} - - diff --git a/libs/nanofn/src/_internal/base-sorted-index-by.ts b/libs/nanofn/src/_internal/base-sorted-index-by.ts deleted file mode 100644 index 49b3faf2f..000000000 --- a/libs/nanofn/src/_internal/base-sorted-index-by.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is-symbol'; - -/** Used as references for the maximum length and index of an array. */ -const MAX_ARRAY_LENGTH = 4294967295; -const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - -/** - * The base implementation of `sortedIndexBy` and `sortedLastIndexBy` - * which invokes `iteratee` for `value` and each element of `array` to compute - * their sort ranking. The iteratee is invoked with one argument (value). - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ -export function _baseSortedIndexBy(array, value, iteratee, retHighest) { - let low = 0; - let high = array == null ? 0 : array.length; - if (high == 0) { - return 0; - } - - value = iteratee(value); - - const valIsNaN = value !== value; - const valIsNull = value === null; - const valIsSymbol = isSymbol(value); - const valIsUndefined = value === undefined; - - while (low < high) { - let setLow; - const mid = Math.floor((low + high) / 2); - const computed = iteratee(array[mid]); - const othIsDefined = computed !== undefined; - const othIsNull = computed === null; - const othIsReflexive = computed === computed; - const othIsSymbol = isSymbol(computed); - - if (valIsNaN) { - setLow = retHighest || othIsReflexive; - } else if (valIsUndefined) { - setLow = othIsReflexive && (retHighest || othIsDefined); - } else if (valIsNull) { - setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); - } else if (valIsSymbol) { - setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); - } else if (othIsNull || othIsSymbol) { - setLow = false; - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return Math.min(high, MAX_ARRAY_INDEX); -} - - diff --git a/libs/nanofn/src/_internal/base-sorted-index.ts b/libs/nanofn/src/_internal/base-sorted-index.ts deleted file mode 100644 index 3cf39a49c..000000000 --- a/libs/nanofn/src/_internal/base-sorted-index.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSortedIndexBy } from './base-sorted-index-by'; -import { isSymbol } from '../is-symbol'; - -/** Used as references for the maximum length and index of an array. */ -const MAX_ARRAY_LENGTH = 4294967295; -const HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - -/** - * The base implementation of `sortedIndex` and `sortedLastIndex` which - * performs a binary search of `array` to determine the index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ -export function _baseSortedIndex(array, value, retHighest) { - let low = 0; - let high = array == null ? low : array.length; - - if (typeof value === 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { - while (low < high) { - const mid = (low + high) >>> 1; - const computed = array[mid]; - if (computed !== null && !isSymbol(computed) && - (retHighest ? (computed <= value) : (computed < value))) { - low = mid + 1; - } else { - high = mid; - } - } - return high; - } - return _baseSortedIndexBy(array, value, (value) => value, retHighest); -} - - diff --git a/libs/nanofn/src/_internal/base-sorted-uniq.ts b/libs/nanofn/src/_internal/base-sorted-uniq.ts deleted file mode 100644 index d56361970..000000000 --- a/libs/nanofn/src/_internal/base-sorted-uniq.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from '../eq'; - -/** - * The base implementation of `sortedUniq` and `sortedUniqBy`. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ -export function _baseSortedUniq(array, iteratee) { - let seen; - let index = -1; - let resIndex = 0; - - const { length } = array; - const result = []; - - while (++index < length) { - const value = array[index], computed = iteratee ? iteratee(value) : value; - if (!index || !eq(computed, seen)) { - seen = computed; - result[resIndex++] = value === 0 ? 0 : value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-sum.ts b/libs/nanofn/src/_internal/base-sum.ts deleted file mode 100644 index f8bdbc1d8..000000000 --- a/libs/nanofn/src/_internal/base-sum.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `sum` and `sumBy`. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ -export function _baseSum(array, iteratee) { - let result; - - for (const value of array) { - const current = iteratee(value); - if (current !== undefined) { - result = result === undefined ? current : (result + current); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-to-number.ts b/libs/nanofn/src/_internal/base-to-number.ts deleted file mode 100644 index 3c1bb8939..000000000 --- a/libs/nanofn/src/_internal/base-to-number.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** Used as references for various `Number` constants. */ -const NAN = 0 / 0; - -/** - * The base implementation of `toNumber` which doesn't ensure correct - * conversions of binary, hexadecimal, or octal string values. - * - * @private - * @param {*} val The value to process. - * @returns {number} Returns the number. - */ -export function _baseToNumber(val: any): number { - if (typeof val === 'number') { - return val; - } - if (isSymbol(val)) { - return NAN; - } - return +val; -} - - diff --git a/libs/nanofn/src/_internal/base-to-string.ts b/libs/nanofn/src/_internal/base-to-string.ts deleted file mode 100644 index 1ed7898b2..000000000 --- a/libs/nanofn/src/_internal/base-to-string.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** Used to convert symbols to primitives and strings. */ -const symbolToString = Symbol.prototype.toString; - -/** - * The base implementation of `toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -export function _baseToString(value: any): string { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value === 'string') { - return value; - } - if (Array.isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return `${value.map(_baseToString)}`; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - const result = `${value}`; - return (result === '0' && (1 / value) === -INFINITY) ? '-0' : result; -} - - diff --git a/libs/nanofn/src/_internal/base-uniq.ts b/libs/nanofn/src/_internal/base-uniq.ts deleted file mode 100644 index 7b357ad6f..000000000 --- a/libs/nanofn/src/_internal/base-uniq.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { SetCache } from './set-cache'; -import { _arrayIncludes } from './array-includes'; -import { _arrayIncludesWith } from './array-includes-with'; -import { _cacheHas } from './cache-has'; -import { createSet } from './create-set'; -import { _setToArray } from './set-to-array'; - -/** Used as the size to enable large array optimizations. */ -const LARGE_ARRAY_SIZE = 200; - -/** - * The base implementation of `uniqBy`. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ -export function _baseUniq(array: any[], - iteratee: (value: any) => any, - comparator?: (value: any, other: any) => boolean): any[] { - let index = -1; - let includes: any = _arrayIncludes; - let isCommon = true; - - const {length} = array; - const result: any[] = []; - let seen: any[] | SetCache = result; - - if (comparator) { - isCommon = false; - includes = _arrayIncludesWith; - } else if (length >= LARGE_ARRAY_SIZE) { - const set = iteratee ? null : createSet(array); - if (set) { - return _setToArray(set); - } - isCommon = false; - includes = _cacheHas; - seen = new SetCache(); - } else { - seen = iteratee ? [] : result; - } - - outer: - while (++index < length) { - let value = array[index]; - const computed = iteratee ? iteratee(value) : value; - - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - let seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } else if (!includes(seen, computed, comparator)) { - if (seen !== result) { - seen.push(computed); - } - result.push(value); - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/base-unset.ts b/libs/nanofn/src/_internal/base-unset.ts deleted file mode 100644 index ba4288a47..000000000 --- a/libs/nanofn/src/_internal/base-unset.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from './cast-path'; -import { last } from '../last'; -import { _parent } from './parent'; -import { _toKey } from './to-key'; - -/** - * The base implementation of `unset`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The property path to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - */ -export function _baseUnset(object, path) { - path = _castPath(path, object); - object = _parent(object, path); - return object == null || delete object[_toKey(last(path))]; -} - - diff --git a/libs/nanofn/src/_internal/base-update.ts b/libs/nanofn/src/_internal/base-update.ts deleted file mode 100644 index 045098950..000000000 --- a/libs/nanofn/src/_internal/base-update.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from './base-get'; -import { _baseSet } from './base-set'; - -/** - * The base implementation of `update`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to update. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ -export function _baseUpdate(object, path, updater, customizer) { - return _baseSet(object, path, updater(_baseGet(object, path)), customizer); -} - - diff --git a/libs/nanofn/src/_internal/base-values.ts b/libs/nanofn/src/_internal/base-values.ts deleted file mode 100644 index 9030361a7..000000000 --- a/libs/nanofn/src/_internal/base-values.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The base implementation of `values` and `valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ -export function _baseValues(object, props) { - return props == null ? [] : props.map((key) => object[key]); -} - - diff --git a/libs/nanofn/src/_internal/base-while.ts b/libs/nanofn/src/_internal/base-while.ts deleted file mode 100644 index 2deb4dc0b..000000000 --- a/libs/nanofn/src/_internal/base-while.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from '../slice'; - -/** - * The base implementation of methods like `dropWhile` and `takeWhile`. - * - * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. - */ -export function _baseWhile(array, predicate, isDrop, fromRight) { - const { length } = array; - let index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length) && - predicate(array[index], index, array)) {} - - return isDrop - ? slice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) - : slice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); -} - - diff --git a/libs/nanofn/src/_internal/base-xor.ts b/libs/nanofn/src/_internal/base-xor.ts deleted file mode 100644 index d049b3f66..000000000 --- a/libs/nanofn/src/_internal/base-xor.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseDifference } from './base-difference'; -import { _baseFlatten } from './base-flatten'; -import { _baseUniq } from './base-uniq'; - -/** - * The base implementation of methods like `xor` which accepts an array of - * arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of values. - */ -export function _baseXor(arrays, iteratee, comparator) { - const length = arrays.length; - if (length < 2) { - return length ? _baseUniq(arrays[0]) : []; - } - let index = -1; - const result = new Array(length); - - while (++index < length) { - const array = arrays[index]; - let othIndex = -1; - - while (++othIndex < length) { - if (othIndex != index) { - result[index] = _baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); - } - } - } - return _baseUniq(_baseFlatten(result, 1), iteratee, comparator); -} - - diff --git a/libs/nanofn/src/_internal/base-zip-object.ts b/libs/nanofn/src/_internal/base-zip-object.ts deleted file mode 100644 index c54a75ae5..000000000 --- a/libs/nanofn/src/_internal/base-zip-object.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This base implementation of `zipObject` which assigns values using `assignFunc`. - * - * @private - * @param {Array} props The property identifiers. - * @param {Array} values The property values. - * @param {Function} assignFunc The function to assign values. - * @returns {Object} Returns the new object. - */ -export function _baseZipObject(props, values, assignFunc) { - let index = -1; - const length = props.length; - const valsLength = values.length; - const result = {}; - - while (++index < length) { - const value = index < valsLength ? values[index] : undefined; - assignFunc(result, props[index], value); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/cache-has.ts b/libs/nanofn/src/_internal/cache-has.ts deleted file mode 100644 index 1c58baee5..000000000 --- a/libs/nanofn/src/_internal/cache-has.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if a `cache` value for `key` exists. - * - * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -export function _cacheHas(cache: Record, key: string): boolean { - return cache.has(key); -} - - diff --git a/libs/nanofn/src/_internal/cast-array-like-object.ts b/libs/nanofn/src/_internal/cast-array-like-object.ts deleted file mode 100644 index d5cffa935..000000000 --- a/libs/nanofn/src/_internal/cast-array-like-object.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isArrayLikeObject } from '../is-array-like-object'; - -/** - * Casts `value` to an empty array if it's not an array like object. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array|Object} Returns the cast array-like object. - */ -export function _castArrayLikeObject(value) { - return isArrayLikeObject(value) ? value : []; -} - - diff --git a/libs/nanofn/src/_internal/cast-path.ts b/libs/nanofn/src/_internal/cast-path.ts deleted file mode 100644 index fcad4410d..000000000 --- a/libs/nanofn/src/_internal/cast-path.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _isKey } from './is-key'; -import { stringToPath } from './string-to-path'; - -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ -export function _castPath(value: any, object: any): any { - if (Array.isArray(value)) { - return value; - } - return _isKey(value, object) ? [value] : stringToPath(value); -} - - diff --git a/libs/nanofn/src/_internal/cast-slice.ts b/libs/nanofn/src/_internal/cast-slice.ts deleted file mode 100644 index cd6faa48e..000000000 --- a/libs/nanofn/src/_internal/cast-slice.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from '../arr/slice'; - -/** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ -export function _castSlice(array, start, end) { - const {length} = array; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : slice(array, start, end); -} - - diff --git a/libs/nanofn/src/_internal/chars-end-index.ts b/libs/nanofn/src/_internal/chars-end-index.ts deleted file mode 100644 index 714a1dc18..000000000 --- a/libs/nanofn/src/_internal/chars-end-index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIndexOf } from './base-index-of'; - -/** - * Used by `trim` and `trimEnd` to get the index of the last string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the last unmatched string symbol. - */ -export function _charsEndIndex(strSymbols, chrSymbols) { - let index = strSymbols.length; - - while (index-- && _baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; -} - - diff --git a/libs/nanofn/src/_internal/chars-start-index.ts b/libs/nanofn/src/_internal/chars-start-index.ts deleted file mode 100644 index 4d76eaf8d..000000000 --- a/libs/nanofn/src/_internal/chars-start-index.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIndexOf } from './base-index-of'; - -/** - * Used by `trim` and `trimStart` to get the index of the first string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the first unmatched string symbol. - */ -export function _charsStartIndex(strSymbols, chrSymbols) { - let index = -1; - const length = strSymbols.length; - - while (++index < length && _baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; -} - - diff --git a/libs/nanofn/src/_internal/clone-array-buffer.ts b/libs/nanofn/src/_internal/clone-array-buffer.ts deleted file mode 100644 index 7404db304..000000000 --- a/libs/nanofn/src/_internal/clone-array-buffer.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates a clone of `arrayBuffer`. - * - * @private - * @param {ArrayBuffer} arrayBuffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. - */ -export function _cloneArrayBuffer(arrayBuffer) { - const result = new arrayBuffer.constructor(arrayBuffer.byteLength); - new Uint8Array(result).set(new Uint8Array(arrayBuffer)); - return result; -} - - diff --git a/libs/nanofn/src/_internal/clone-buffer.ts b/libs/nanofn/src/_internal/clone-buffer.ts deleted file mode 100644 index def2dbba2..000000000 --- a/libs/nanofn/src/_internal/clone-buffer.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -declare const Buffer: any; -declare type Buffer = any; - -/** - * Creates a clone of `buffer`. - * - * @private - * @param {Buffer} buffer The buffer to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Buffer} Returns the cloned buffer. - */ -export function _cloneBuffer(buffer: Buffer, isDeep: boolean): Buffer { - if (isDeep) { - return buffer.slice(); - } - const length = buffer.length; - const result = Buffer.allocUnsafe(length); - - buffer.copy(result); - return result; -} - - diff --git a/libs/nanofn/src/_internal/clone-data-view.ts b/libs/nanofn/src/_internal/clone-data-view.ts deleted file mode 100644 index db16982a7..000000000 --- a/libs/nanofn/src/_internal/clone-data-view.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _cloneArrayBuffer } from './clone-array-buffer'; - -/** - * Creates a clone of `dataView`. - * - * @private - * @param {Object} dataView The data view to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned data view. - */ -export function _cloneDataView(dataView, isDeep) { - const buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer; - return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); -} - - diff --git a/libs/nanofn/src/_internal/clone-reg-exp.ts b/libs/nanofn/src/_internal/clone-reg-exp.ts deleted file mode 100644 index 9e4d29178..000000000 --- a/libs/nanofn/src/_internal/clone-reg-exp.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to match `RegExp` flags from their coerced string values. */ -const reFlags = /\w*$/; - -/** - * Creates a clone of `regexp`. - * - * @private - * @param {Object} regexp The regexp to clone. - * @returns {Object} Returns the cloned regexp. - */ -export function _cloneRegExp(regexp) { - const result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); - result.lastIndex = regexp.lastIndex; - return result; -} - - diff --git a/libs/nanofn/src/_internal/clone-symbol.ts b/libs/nanofn/src/_internal/clone-symbol.ts deleted file mode 100644 index bc2fe9088..000000000 --- a/libs/nanofn/src/_internal/clone-symbol.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to convert symbols to primitives and strings. */ -const symbolValueOf = Symbol.prototype.valueOf; - -/** - * Creates a clone of the `symbol` object. - * - * @private - * @param {Object} symbol The symbol object to clone. - * @returns {Object} Returns the cloned symbol object. - */ -export function _cloneSymbol(symbol) { - return Object(symbolValueOf.call(symbol)); -} - - diff --git a/libs/nanofn/src/_internal/clone-typed-array.ts b/libs/nanofn/src/_internal/clone-typed-array.ts deleted file mode 100644 index d1fd12514..000000000 --- a/libs/nanofn/src/_internal/clone-typed-array.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _cloneArrayBuffer } from './clone-array-buffer'; - -/** - * Creates a clone of `typedArray`. - * - * @private - * @param {Object} typedArray The typed array to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned typed array. - */ -export function _cloneTypedArray(typedArray, isDeep) { - const buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; - return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); -} - - diff --git a/libs/nanofn/src/_internal/compare-ascending.ts b/libs/nanofn/src/_internal/compare-ascending.ts deleted file mode 100644 index 1b7e10486..000000000 --- a/libs/nanofn/src/_internal/compare-ascending.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is-symbol'; - -/** - * Compares values to sort them in ascending order. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. - */ -export function _compareAscending(value, other) { - if (value !== other) { - const valIsDefined = value !== undefined; - const valIsNull = value === null; - const valIsReflexive = value === value; - const valIsSymbol = isSymbol(value); - - const othIsDefined = other !== undefined; - const othIsNull = other === null; - const othIsReflexive = other === other; - const othIsSymbol = isSymbol(other); - - const val = typeof value === 'string' - ? value.localeCompare(other) - : -other; - - if ((!othIsNull && !othIsSymbol && !valIsSymbol && val > 0) || - (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || - (valIsNull && othIsDefined && othIsReflexive) || - (!valIsDefined && othIsReflexive) || - !valIsReflexive) { - return 1; - } - if ((!valIsNull && !valIsSymbol && !othIsSymbol && val < 0) || - (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || - (othIsNull && valIsDefined && valIsReflexive) || - (!othIsDefined && valIsReflexive) || - !othIsReflexive) { - return -1; - } - } - return 0; -} - - diff --git a/libs/nanofn/src/_internal/compare-multiple.ts b/libs/nanofn/src/_internal/compare-multiple.ts deleted file mode 100644 index 47fe5181a..000000000 --- a/libs/nanofn/src/_internal/compare-multiple.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _compareAscending } from './compare-ascending'; - -/** - * Used by `orderBy` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, - * specify an order of "desc" for descending or "asc" for ascending sort order - * of corresponding values. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {(string|function)[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. - */ -export function _compareMultiple(object, other, orders) { - let index = -1; - const objCriteria = object.criteria; - const othCriteria = other.criteria; - const length = objCriteria.length; - const ordersLength = orders.length; - - while (++index < length) { - const order = index < ordersLength ? orders[index] : null; - const cmpFn = (order && typeof order === 'function') ? order : _compareAscending; - const result = cmpFn(objCriteria[index], othCriteria[index]); - if (result) { - if (order && typeof order !== 'function') { - return result * (order == 'desc' ? -1 : 1); - } - return result; - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; -} - - diff --git a/libs/nanofn/src/_internal/compose-args-right.ts b/libs/nanofn/src/_internal/compose-args-right.ts deleted file mode 100644 index 73130c460..000000000 --- a/libs/nanofn/src/_internal/compose-args-right.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This function is like `composeArgs` except that the arguments composition - * is tailored for `partialRight`. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to append to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ -export function _composeArgsRight(args, partials, holders, isCurried) { - let argsIndex = -1; - let holdersIndex = -1; - let rightIndex = -1; - - const argsLength = args.length; - const holdersLength = holders.length; - const rightLength = partials.length; - const rangeLength = Math.max(argsLength - holdersLength, 0); - const result = new Array(rangeLength + rightLength); - const isUncurried = !isCurried; - - while (++argsIndex < rangeLength) { - result[argsIndex] = args[argsIndex]; - } - const offset = argsIndex; - while (++rightIndex < rightLength) { - result[offset + rightIndex] = partials[rightIndex]; - } - while (++holdersIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; - } - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/compose-args.ts b/libs/nanofn/src/_internal/compose-args.ts deleted file mode 100644 index 4f80dd811..000000000 --- a/libs/nanofn/src/_internal/compose-args.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an array that is the composition of partially applied arguments, - * placeholders, and provided arguments into a single array of arguments. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to prepend to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ -export function _composeArgs(args, partials, holders, isCurried) { - const argsLength = args.length; - const holdersLength = holders.length; - const leftLength = partials.length; - - let argsIndex = -1; - let leftIndex = -1; - let rangeLength = Math.max(argsLength - holdersLength, 0); - - const result = new Array(leftLength + rangeLength); - const isUncurried = !isCurried; - - while (++leftIndex < leftLength) { - result[leftIndex] = partials[leftIndex]; - } - while (++argsIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[holders[argsIndex]] = args[argsIndex]; - } - } - while (rangeLength--) { - result[leftIndex++] = args[argsIndex++]; - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/copy-array.ts b/libs/nanofn/src/_internal/copy-array.ts deleted file mode 100644 index d15837767..000000000 --- a/libs/nanofn/src/_internal/copy-array.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [arr=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ -export function _copyArray(source: any[], arr?: any[]): any[] { - let index = -1; - const length = source.length; - - if (arr === undefined) { - arr = new Array(length); - } - - while (++index < length) { - arr[index] = source[index]; - } - return arr; -} - - diff --git a/libs/nanofn/src/_internal/copy-object.ts b/libs/nanofn/src/_internal/copy-object.ts deleted file mode 100644 index d7524a756..000000000 --- a/libs/nanofn/src/_internal/copy-object.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _assignValue } from './assign-value'; -import { _baseAssignValue } from './base-assign-value'; - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -export function _copyObject(source, props, object, customizer) { - const isNew = !object; - object || (object = {}); - - for (const key of props) { - let newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; - - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - _baseAssignValue(object, key, newValue); - } else { - _assignValue(object, key, newValue); - } - } - return object; -} - - diff --git a/libs/nanofn/src/_internal/copy-symbols-in.ts b/libs/nanofn/src/_internal/copy-symbols-in.ts deleted file mode 100644 index 5e9707704..000000000 --- a/libs/nanofn/src/_internal/copy-symbols-in.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _copyObject } from './copy-object'; -import { _getSymbolsIn } from './get-symbols-in'; - -/** - * Copies own and inherited symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ -export function _copySymbolsIn(source, object) { - return _copyObject(source, _getSymbolsIn(source), object); -} - - diff --git a/libs/nanofn/src/_internal/copy-symbols.ts b/libs/nanofn/src/_internal/copy-symbols.ts deleted file mode 100644 index c3755a4d0..000000000 --- a/libs/nanofn/src/_internal/copy-symbols.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _copyObject } from './copy-object'; -import { _getSymbols } from './get-symbols'; - -/** - * Copies own symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ -export function _copySymbols(source, object) { - return _copyObject(source, _getSymbols(source), object); -} - - diff --git a/libs/nanofn/src/_internal/create-assigner.ts b/libs/nanofn/src/_internal/create-assigner.ts deleted file mode 100644 index 271fb7ee7..000000000 --- a/libs/nanofn/src/_internal/create-assigner.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _isIterateeCall } from './is-iteratee-call'; - -/** - * Creates a function like `assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ -export function _createAssigner(assigner) { - return (object, ...sources) => { - let index = -1; - let length = sources.length; - let customizer = length > 1 ? sources[length - 1] : undefined; - const guard = length > 2 ? sources[2] : undefined; - - customizer = (assigner.length > 3 && typeof customizer === 'function') - ? (length--, customizer) - : undefined; - - if (guard && _isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - const source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }; -} - - diff --git a/libs/nanofn/src/_internal/create-math-operation.ts b/libs/nanofn/src/_internal/create-math-operation.ts deleted file mode 100644 index ecc0c14cd..000000000 --- a/libs/nanofn/src/_internal/create-math-operation.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseToNumber } from './base-to-number'; -import { _baseToString } from './base-to-string'; - -/** - * Creates a function that performs a mathematical operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @param {number} [defaultValue] The value used for `undefined` arguments. - * @returns {Function} Returns the new mathematical operation function. - */ -export function _createMathOperation(operator: (value: any, other: any) => number, - defaultValue: any): (value: any, other: any) => number { - return (value, other) => { - if (value === undefined && other === undefined) { - return defaultValue; - } - if (value !== undefined && other === undefined) { - return value; - } - if (other !== undefined && value === undefined) { - return other; - } - if (typeof value === 'string' || typeof other === 'string') { - value = _baseToString(value); - other = _baseToString(other); - } else { - value = _baseToNumber(value); - other = _baseToNumber(other); - } - return operator(value, other); - }; -} - - diff --git a/libs/nanofn/src/_internal/create-padding.ts b/libs/nanofn/src/_internal/create-padding.ts deleted file mode 100644 index 950513efe..000000000 --- a/libs/nanofn/src/_internal/create-padding.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { repeat } from '../repeat'; -import { _baseToString } from './base-to-string'; -import { _castSlice } from './cast-slice'; -import { _hasUnicode } from './has-unicode'; -import { _stringSize } from './string-size'; -import { _stringToArray } from './string-to-array'; - -/** - * Creates the padding for `string` based on `length`. The `chars` string - * is truncated if the number of characters exceeds `length`. - * - * @private - * @param {number} length The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padding for `string`. - */ -export function _createPadding(length, chars) { - chars = chars === undefined ? ' ' : _baseToString(chars); - - const charsLength = chars.length; - if (charsLength < 2) { - return charsLength ? repeat(chars, length) : chars; - } - const result = repeat(chars, Math.ceil(length / _stringSize(chars))); - return _hasUnicode(chars) - ? _castSlice(_stringToArray(result), 0, length).join('') - : result.slice(0, length); -} - - diff --git a/libs/nanofn/src/_internal/create-range.ts b/libs/nanofn/src/_internal/create-range.ts deleted file mode 100644 index a93791ea3..000000000 --- a/libs/nanofn/src/_internal/create-range.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseRange } from './base-range'; -import { toFinite } from '../to-finite'; - -/** - * Creates a `range` or `rangeRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new range function. - */ -export function _createRange(fromRight) { - return (start, end, step) => { - // Ensure the sign of `-0` is preserved. - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); - return _baseRange(start, end, step, fromRight); - }; -} - - diff --git a/libs/nanofn/src/_internal/create-round.ts b/libs/nanofn/src/_internal/create-round.ts deleted file mode 100644 index edb51a5e3..000000000 --- a/libs/nanofn/src/_internal/create-round.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates a function like `round`. - * - * @private - * @param {string} methodName The name of the `Math` method to use when rounding. - * @returns {Function} Returns the new round function. - */ -export function _createRound(methodName: string | keyof Math): - (num: number, precision?: number) => number { - // @ts-ignore - const func = Math[methodName]; - return (num, precision) => { - if (precision == null) { - precision = 0; - } else if (precision >= 0) { - precision = Math.min(precision, 292); - } else { - precision = Math.max( - precision, -292); - } - if (precision) { - // Shift with exponential notation to avoid floating-point issues. - // See [MDN](https://mdn.io/round#Examples) for more details. - let pair = `${num}e`.split('e'); - const value = func(`${pair[0]}e${+pair[1] + precision}`); - - pair = `${value}e`.split('e'); - return +`${pair[0]}e${+pair[1] - precision}`; - } - return func(num); - }; -} - - diff --git a/libs/nanofn/src/_internal/create-set.ts b/libs/nanofn/src/_internal/create-set.ts deleted file mode 100644 index 4064450a0..000000000 --- a/libs/nanofn/src/_internal/create-set.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _setToArray } from './set-to-array'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** - * Creates a set object of `values`. - * - * @private - * @param {Array} values The values to add to the set. - * @returns {Object} Returns the new set. - */ -export const createSet = (Set && (1 / _setToArray(new Set([, -0]))[1]) == INFINITY) - ? (values) => new Set(values) - : () => {}; diff --git a/libs/nanofn/src/_internal/custom-defaults-merge.ts b/libs/nanofn/src/_internal/custom-defaults-merge.ts deleted file mode 100644 index ae9cda8f3..000000000 --- a/libs/nanofn/src/_internal/custom-defaults-merge.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseMerge } from './base-merge'; -import { isObject } from '../is/is-object'; - -/** - * Used by `defaultsDeep` to customize its `merge` use to merge source - * objects into destination objects that are passed thru. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to merge. - * @param {Object} object The parent object of `objValue`. - * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - * @returns {*} Returns the value to assign. - */ -export function _customDefaultsMerge(objValue, srcValue, key, object, source, stack) { - if (isObject(objValue) && isObject(srcValue)) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, objValue); - _baseMerge(objValue, srcValue, undefined, _customDefaultsMerge, stack); - stack['delete'](srcValue); - } - return objValue; -} - - diff --git a/libs/nanofn/src/_internal/deburr-letter.ts b/libs/nanofn/src/_internal/deburr-letter.ts deleted file mode 100644 index 33d731a70..000000000 --- a/libs/nanofn/src/_internal/deburr-letter.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePropertyOf } from './base-property-of'; - -/** Used to map Latin Unicode letters to basic Latin letters. */ -const deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', - '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', - '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', - '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', - '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', - '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', - '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', - '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017f': 's' -}; - -/** - * Used by `deburr` to convert Latin-1 Supplement and Latin Extended-A - * letters to basic Latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ -export const deburrLetter = _basePropertyOf(deburredLetters); diff --git a/libs/nanofn/src/_internal/equal-arrays.ts b/libs/nanofn/src/_internal/equal-arrays.ts deleted file mode 100644 index 07f03f4f0..000000000 --- a/libs/nanofn/src/_internal/equal-arrays.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { SetCache } from './set-cache'; -import { some } from '../some'; -import { _cacheHas } from './cache-has'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; -const COMPARE_UNORDERED_FLAG = 2; - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -export function _equalArrays(array: any[], - other: any[], - bitmask: number, - customizer, - equalFunc, - stack) { - const isPartial = bitmask & COMPARE_PARTIAL_FLAG; - const arrLength = array.length; - const othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - const stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - let index = -1; - let result = true; - const seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache() : undefined; - - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - let compared; - const arrValue = array[index]; - const othValue = other[index]; - - if (customizer) { - compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!some(other, (othValue, othIndex) => { - if (!_cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; -} - - diff --git a/libs/nanofn/src/_internal/equal-by-tag.ts b/libs/nanofn/src/_internal/equal-by-tag.ts deleted file mode 100644 index ab2f56b0f..000000000 --- a/libs/nanofn/src/_internal/equal-by-tag.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from '../lang/eq'; -import { _equalArrays } from './equal-arrays'; -import { _mapToArray } from './map-to-array'; -import { _setToArray } from './set-to-array'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; -const COMPARE_UNORDERED_FLAG = 2; - -/** `Object#toString` result references. */ -const boolTag = '[object Boolean]'; -const dateTag = '[object Date]'; -const errorTag = '[object Error]'; -const mapTag = '[object Map]'; -const numberTag = '[object Number]'; -const regexpTag = '[object RegExp]'; -const setTag = '[object Set]'; -const stringTag = '[object String]'; -const symbolTag = '[object Symbol]'; - -const arrayBufferTag = '[object ArrayBuffer]'; -const dataViewTag = '[object DataView]'; - -/** Used to convert symbols to primitives and strings. */ -const symbolValueOf = Symbol.prototype.valueOf; - -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -export function _equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag: - return object.name == other.name && object.message == other.message; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == `${other}`; - - case mapTag: - let convert = _mapToArray; - - case setTag: - const isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert || (convert = _setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - const stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - const result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, - stack); - stack['delete'](object); - return result; - - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; -} - - diff --git a/libs/nanofn/src/_internal/equal-objects.ts b/libs/nanofn/src/_internal/equal-objects.ts deleted file mode 100644 index 22368f4fe..000000000 --- a/libs/nanofn/src/_internal/equal-objects.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getAllKeys } from './get-all-keys'; - -/** Used to compose bitmasks for value comparisons. */ -const COMPARE_PARTIAL_FLAG = 1; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -export function _equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - const isPartial = bitmask & COMPARE_PARTIAL_FLAG; - const objProps = _getAllKeys(object); - const objLength = objProps.length; - const othProps = _getAllKeys(other); - const othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - let key; - let index = objLength; - while (index--) { - key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - const stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - let result = true; - stack.set(object, other); - stack.set(other, object); - - let compared; - let skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - const objValue = object[key]; - const othValue = other[key]; - - if (customizer) { - compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - const objCtor = object.constructor; - const othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor === 'function' && objCtor instanceof objCtor && - typeof othCtor === 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - stack['delete'](other); - return result; -} - - diff --git a/libs/nanofn/src/_internal/free-global.ts b/libs/nanofn/src/_internal/free-global.ts deleted file mode 100644 index 57693d467..000000000 --- a/libs/nanofn/src/_internal/free-global.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Detect free variable `global` from Node.js. */ -export const freeGlobal = typeof global === 'object' && global !== null && global.Object === Object && global; diff --git a/libs/nanofn/src/_internal/get-all-keys-in.ts b/libs/nanofn/src/_internal/get-all-keys-in.ts deleted file mode 100644 index 459528478..000000000 --- a/libs/nanofn/src/_internal/get-all-keys-in.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getSymbolsIn } from './get-symbols-in'; - -/** - * Creates an array of own and inherited enumerable property names and symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ -export function _getAllKeysIn(object) { - const result = []; - for (const key in object) { - result.push(key); - } - if (!Array.isArray(object)) { - result.push(..._getSymbolsIn(object)); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/get-all-keys.ts b/libs/nanofn/src/_internal/get-all-keys.ts deleted file mode 100644 index 7233b3594..000000000 --- a/libs/nanofn/src/_internal/get-all-keys.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { keys } from '../obj/keys'; -import { _getSymbols } from './get-symbols'; - -/** - * Creates an array of own enumerable property names and symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ -export function _getAllKeys(object) { - const result = keys(object); - if (!Array.isArray(object)) { - result.push(..._getSymbols(object)); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/get-holder.ts b/libs/nanofn/src/_internal/get-holder.ts deleted file mode 100644 index 3f077a38c..000000000 --- a/libs/nanofn/src/_internal/get-holder.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets the argument placeholder value for `func`. - * - * @private - * @param {Function} func The function to inspect. - * @returns {*} Returns the placeholder value. - */ -export function _getHolder(func) { - const object = func; - return object.placeholder; -} - - diff --git a/libs/nanofn/src/_internal/get-match-data.ts b/libs/nanofn/src/_internal/get-match-data.ts deleted file mode 100644 index f1e038187..000000000 --- a/libs/nanofn/src/_internal/get-match-data.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { keys } from '../obj/keys'; -import { _isStrictComparable } from './is-strict-comparable'; - -/** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ -export function _getMatchData(object: any): any[] { - const result: any[] = keys(object); - let length = result.length; - - while (length--) { - const key = result[length]; - const value = object[key]; - result[length] = [key, value, _isStrictComparable(value)]; - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/get-symbols-in.ts b/libs/nanofn/src/_internal/get-symbols-in.ts deleted file mode 100644 index 39905e4f5..000000000 --- a/libs/nanofn/src/_internal/get-symbols-in.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getSymbols } from './get-symbols'; - -/** - * Creates an array of the own and inherited enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ -export function _getSymbolsIn(object) { - const result = []; - while (object) { - result.push(..._getSymbols(object)); - object = Object.getPrototypeOf(Object(object)); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/get-symbols.ts b/libs/nanofn/src/_internal/get-symbols.ts deleted file mode 100644 index d7a31bae9..000000000 --- a/libs/nanofn/src/_internal/get-symbols.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Built-in value references. */ -const propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeGetSymbols = Object.getOwnPropertySymbols; - -/** - * Creates an array of the own enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ -export function _getSymbols(object) { - if (object == null) { - return []; - } - object = Object(object); - return nativeGetSymbols(object).filter((symbol) => propertyIsEnumerable.call(object, symbol)); -} - - diff --git a/libs/nanofn/src/_internal/get-tag.ts b/libs/nanofn/src/_internal/get-tag.ts deleted file mode 100644 index c32aced13..000000000 --- a/libs/nanofn/src/_internal/get-tag.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -const toString = Object.prototype.toString; - -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -export function _getTag(value: any) { - if (value == null) { - return value === undefined ? '[object Undefined]' : '[object Null]'; - } - return toString.call(value); -} - - diff --git a/libs/nanofn/src/_internal/has-unicode.ts b/libs/nanofn/src/_internal/has-unicode.ts deleted file mode 100644 index b017e0e47..000000000 --- a/libs/nanofn/src/_internal/has-unicode.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to compose unicode character classes. */ -const rsAstralRange = '\\ud800-\\udfff'; -const rsComboMarksRange = '\\u0300-\\u036f'; -const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -const rsComboSymbolsRange = '\\u20d0-\\u20ff'; -const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'; -const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'; -const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + - rsComboSymbolsRange + rsComboMarksExtendedRange + - rsComboMarksSupplementRange; -const rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -const rsZWJ = '\\u200d'; - -/** - * 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/). - */ -const reHasUnicode = RegExp(`[${rsZWJ + rsAstralRange + rsComboRange + rsVarRange}]`); - -/** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ -export function _hasUnicode(string) { - return reHasUnicode.test(string); -} - - diff --git a/libs/nanofn/src/_internal/hash.ts b/libs/nanofn/src/_internal/hash.ts deleted file mode 100644 index 30277d39e..000000000 --- a/libs/nanofn/src/_internal/hash.ts +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to stand-in for `undefined` hash values. */ -const HASH_UNDEFINED = '__lodash_hash_undefined__'; - -export class Hash { - - /** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - constructor(entries?) { - let index = -1; - const length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - const entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the hash. - * - * @memberOf Hash - */ - clear() { - this.__data__ = Object.create(null); - this.size = 0; - } - - /** - * Removes `key` and its value from the hash. - * - * @memberOf Hash - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - delete(key) { - const result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; - } - - /** - * Gets the hash value for `key`. - * - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - get(key) { - const data = this.__data__; - const result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - - /** - * Checks if a hash value for `key` exists. - * - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - has(key) { - const data = this.__data__; - return data[key] !== undefined; - } - - /** - * Sets the hash `key` to `value`. - * - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ - set(key, value) { - const data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = value === undefined ? HASH_UNDEFINED : value; - return this; - } -} diff --git a/libs/nanofn/src/_internal/init-clone-object.ts b/libs/nanofn/src/_internal/init-clone-object.ts deleted file mode 100644 index c81b22169..000000000 --- a/libs/nanofn/src/_internal/init-clone-object.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _isPrototype } from './is-prototype'; - -/** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ -export function _initCloneObject(object) { - return (typeof object.constructor === 'function' && !_isPrototype(object)) - ? Object.create(Object.getPrototypeOf(object)) - : {}; -} - - diff --git a/libs/nanofn/src/_internal/is-flattenable.ts b/libs/nanofn/src/_internal/is-flattenable.ts deleted file mode 100644 index c9cbefadb..000000000 --- a/libs/nanofn/src/_internal/is-flattenable.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isArguments } from '../is-arguments'; - -/** Built-in value reference. */ -const spreadableSymbol = Symbol.isConcatSpreadable; - -/** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ -export function _isFlattenable(value) { - return Array.isArray(value) || isArguments(value) || - !!(value && value[spreadableSymbol]); -} - - diff --git a/libs/nanofn/src/_internal/is-index.ts b/libs/nanofn/src/_internal/is-index.ts deleted file mode 100644 index f4a3ceba2..000000000 --- a/libs/nanofn/src/_internal/is-index.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used as references for various `Number` constants. */ -const MAX_SAFE_INTEGER = 9007199254740991; - -/** Used to detect unsigned integer values. */ -const reIsUint = /^(?:0|[1-9]\d*)$/; - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -export function _isIndex(value: any, length: number = MAX_SAFE_INTEGER): boolean { - const type = typeof value; - - return !!length && - (type === 'number' || - (type !== 'symbol' && reIsUint.test(value))) && - (value > -1 && value % 1 == 0 && value < length); -} - - diff --git a/libs/nanofn/src/_internal/is-iteratee-call.ts b/libs/nanofn/src/_internal/is-iteratee-call.ts deleted file mode 100644 index dfc410893..000000000 --- a/libs/nanofn/src/_internal/is-iteratee-call.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isArrayLike } from '../is-array-like'; -import { _isIndex } from './is-index'; -import { isObject } from '../is-object'; -import { eq } from '../eq'; - -/** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ - -export function _isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - const type = typeof index; - if (type === 'number' - ? (isArrayLike(object) && _isIndex(index, object.length)) - : (type === 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; -} - - diff --git a/libs/nanofn/src/_internal/is-key.ts b/libs/nanofn/src/_internal/is-key.ts deleted file mode 100644 index 7bf0e1905..000000000 --- a/libs/nanofn/src/_internal/is-key.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - - -/** Used to match property names within property paths. */ -const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; -const reIsPlainProp = /^\w*$/; - -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -export function _isKey(value: any, object: any): boolean { - if (Array.isArray(value)) { - return false; - } - const type = typeof value; - if (type === 'number' || type === 'boolean' || value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); -} - - diff --git a/libs/nanofn/src/_internal/is-prototype.ts b/libs/nanofn/src/_internal/is-prototype.ts deleted file mode 100644 index d1ab9ba3e..000000000 --- a/libs/nanofn/src/_internal/is-prototype.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used for built-in method references. */ -const objectProto = Object.prototype; - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -export function _isPrototype(value) { - const Ctor = value && value.constructor; - const proto = (typeof Ctor === 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - - diff --git a/libs/nanofn/src/_internal/is-strict-comparable.ts b/libs/nanofn/src/_internal/is-strict-comparable.ts deleted file mode 100644 index 474288e5c..000000000 --- a/libs/nanofn/src/_internal/is-strict-comparable.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isObject } from '../is-object'; - -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -export function _isStrictComparable(value) { - return value === value && !isObject(value); -} - - diff --git a/libs/nanofn/src/_internal/iterator-to-array.ts b/libs/nanofn/src/_internal/iterator-to-array.ts deleted file mode 100644 index 6cb4a6624..000000000 --- a/libs/nanofn/src/_internal/iterator-to-array.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts `iterator` to an array. - * - * @private - * @param {Object} iterator The iterator to convert. - * @returns {Array} Returns the converted array. - */ -export function _iteratorToArray(iterator) { - let data; - const result = []; - - while (!(data = iterator.next()).done) { - result.push(data.value); - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/list-cache.ts b/libs/nanofn/src/_internal/list-cache.ts deleted file mode 100644 index abec3636e..000000000 --- a/libs/nanofn/src/_internal/list-cache.ts +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _assocIndexOf } from './assoc-index-of'; - -export class ListCache { - - /** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - constructor(entries) { - let index = -1; - const length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - const entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the list cache. - * - * @memberOf ListCache - */ - clear() { - this.__data__ = []; - this.size = 0; - } - - /** - * Removes `key` and its value from the list cache. - * - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - delete(key) { - const data = this.__data__; - const index = _assocIndexOf(data, key); - - if (index < 0) { - return false; - } - const lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - data.splice(index, 1); - } - --this.size; - return true; - } - - /** - * Gets the list cache value for `key`. - * - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - get(key) { - const data = this.__data__; - const index = _assocIndexOf(data, key); - return index < 0 ? undefined : data[index][1]; - } - - /** - * Checks if a list cache value for `key` exists. - * - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - has(key) { - return _assocIndexOf(this.__data__, key) > -1; - } - - /** - * Sets the list cache `key` to `value`. - * - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ - set(key, value) { - const data = this.__data__; - const index = _assocIndexOf(data, key); - - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; - } -} diff --git a/libs/nanofn/src/_internal/map-cache.ts b/libs/nanofn/src/_internal/map-cache.ts deleted file mode 100644 index d5486ad52..000000000 --- a/libs/nanofn/src/_internal/map-cache.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - - -import { Hash } from './hash'; - -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function _getMapData({__data__}, key) { - const data = __data__; - return _isKeyable(key) - ? data[typeof key === 'string' ? 'string' : 'hash'] - : data.map; -} - -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function _isKeyable(value) { - const type = typeof value; - return (type === 'string' || type === 'number' || type === 'symbol' || type === 'boolean') - ? (value !== '__proto__') - : (value === null); -} - -export class MapCache { - - size: number; - - __data__: { - 'hash': Hash, - 'map': Map, - 'string': Hash - }; - - /** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - constructor(entries?: any[]) { - let index = -1; - const length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - const entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the map. - * - * @memberOf MapCache - */ - clear() { - this.size = 0; - this.__data__ = { - 'hash' : new Hash(), - 'map' : new Map(), - 'string': new Hash() - }; - } - - /** - * Removes `key` and its value from the map. - * - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - delete(key) { - const result = _getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; - } - - /** - * Gets the map value for `key`. - * - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - get(key: string) { - return _getMapData(this, key).get(key); - } - - /** - * Checks if a map value for `key` exists. - * - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - has(key: string) { - return _getMapData(this, key).has(key); - } - - /** - * Sets the map `key` to `value`. - * - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ - set(key: string, value: any) { - const data = _getMapData(this, key); - const size = data.size; - - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; - } -} - diff --git a/libs/nanofn/src/_internal/map-to-array.ts b/libs/nanofn/src/_internal/map-to-array.ts deleted file mode 100644 index c071818aa..000000000 --- a/libs/nanofn/src/_internal/map-to-array.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ -export function _mapToArray(map) { - let index = -1; - const result = new Array(map.size); - - map.forEach((value, key) => { - result[++index] = [key, value]; - }); - return result; -} - - diff --git a/libs/nanofn/src/_internal/matches-strict-comparable.ts b/libs/nanofn/src/_internal/matches-strict-comparable.ts deleted file mode 100644 index 122587190..000000000 --- a/libs/nanofn/src/_internal/matches-strict-comparable.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -export function _matchesStrictComparable(key, srcValue) { - return (object) => { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; -} - - diff --git a/libs/nanofn/src/_internal/meta-map.ts b/libs/nanofn/src/_internal/meta-map.ts deleted file mode 100644 index 3aebf873e..000000000 --- a/libs/nanofn/src/_internal/meta-map.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export default new WeakMap; diff --git a/libs/nanofn/src/_internal/node-types.ts b/libs/nanofn/src/_internal/node-types.ts deleted file mode 100644 index be044bbcf..000000000 --- a/libs/nanofn/src/_internal/node-types.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { freeGlobal } from './free-global'; - -/** Detect free variable `exports`. */ -const freeExports = typeof exports === 'object' && exports !== null && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -const freeModule = freeExports && typeof module === 'object' && module !== null && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -const moduleExports = freeModule && freeModule.exports === freeExports; - -/** Detect free variable `process` from Node.js. */ -const freeProcess = moduleExports && freeGlobal.process; - -/** Used to access faster Node.js helpers. */ -export const nodeTypes = ((() => { - try { - /* Detect public `util.types` helpers for Node.js v10+. */ - /* Node.js deprecation code: DEP0103. */ - const typesHelper = freeModule && freeModule.require && freeModule.require('util').types; - return typesHelper - ? typesHelper - /* Legacy process.binding('util') for Node.js earlier than v10. */ - : freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} -})()); diff --git a/libs/nanofn/src/_internal/parent.ts b/libs/nanofn/src/_internal/parent.ts deleted file mode 100644 index f390a754e..000000000 --- a/libs/nanofn/src/_internal/parent.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from './base-get'; -import { slice } from '../arr/slice'; - -/** - * Gets the parent value at `path` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} path The path to get the parent value of. - * @returns {*} Returns the parent value. - */ -export function _parent(object, path) { - return path.length < 2 ? object : _baseGet(object, slice(path, 0, -1)); -} - - diff --git a/libs/nanofn/src/_internal/re-escape.ts b/libs/nanofn/src/_internal/re-escape.ts deleted file mode 100644 index 72925c155..000000000 --- a/libs/nanofn/src/_internal/re-escape.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to match template delimiters. */ -const reEscape = /<%-([\s\S]+?)%>/g; - -export default reEscape; diff --git a/libs/nanofn/src/_internal/re-evaluate.ts b/libs/nanofn/src/_internal/re-evaluate.ts deleted file mode 100644 index bf0f4f010..000000000 --- a/libs/nanofn/src/_internal/re-evaluate.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to match template delimiters. */ -const reEvaluate = /<%([\s\S]+?)%>/g; - -export default reEvaluate; diff --git a/libs/nanofn/src/_internal/re-interpolate.ts b/libs/nanofn/src/_internal/re-interpolate.ts deleted file mode 100644 index ab3d39f10..000000000 --- a/libs/nanofn/src/_internal/re-interpolate.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to match template delimiters. */ -const reInterpolate = /<%=([\s\S]+?)%>/g; - -export default reInterpolate; diff --git a/libs/nanofn/src/_internal/root.ts b/libs/nanofn/src/_internal/root.ts deleted file mode 100644 index 2d2092ffe..000000000 --- a/libs/nanofn/src/_internal/root.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/* global globalThis, self */ -import { freeGlobal } from './free-global'; - -/** Detect free variable `globalThis` */ -const freeGlobalThis = typeof globalThis === 'object' && globalThis !== null && globalThis.Object == Object && globalThis; - -/** Detect free variable `self`. */ -const freeSelf = typeof self === 'object' && self !== null && self.Object === Object && self; - -/** Used as a reference to the global object. */ -export const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')(); diff --git a/libs/nanofn/src/_internal/set-cache.ts b/libs/nanofn/src/_internal/set-cache.ts deleted file mode 100644 index ea645e6bf..000000000 --- a/libs/nanofn/src/_internal/set-cache.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { MapCache } from './map-cache'; - -/** Used to stand-in for `undefined` hash values. */ -const HASH_UNDEFINED = '__lodash_hash_undefined__'; - -export interface SetCache { - push(value: any): void; -} - -export class SetCache { - private _data: MapCache; - - /** - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ - constructor(values?: any[]) { - let index = -1; - const length = values == null ? 0 : values.length; - - this._data = new MapCache(); - while (++index < length) { - this.add(values[index]); - } - } - - /** - * Adds `value` to the array cache. - * - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ - add(value: any): SetCache { - this._data.set(value, HASH_UNDEFINED); - return this; - } - - /** - * Checks if `value` is in the array cache. - * - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {boolean} Returns `true` if `value` is found, else `false`. - */ - has(value: any): boolean { - return this._data.has(value); - } -} - -SetCache.prototype.push = SetCache.prototype.add; diff --git a/libs/nanofn/src/_internal/set-to-array.ts b/libs/nanofn/src/_internal/set-to-array.ts deleted file mode 100644 index 9e15cb2b4..000000000 --- a/libs/nanofn/src/_internal/set-to-array.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ -export function _setToArray(set: Set): any[] { - let index = -1; - const result = new Array(set.size); - - set.forEach((value) => { - result[++index] = value; - }); - return result; -} - - diff --git a/libs/nanofn/src/_internal/set-to-pairs.ts b/libs/nanofn/src/_internal/set-to-pairs.ts deleted file mode 100644 index ef3810cba..000000000 --- a/libs/nanofn/src/_internal/set-to-pairs.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts `set` to its value-value pairs. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the value-value pairs. - */ -export function _setToPairs(set) { - let index = -1; - const result = new Array(set.size); - - set.forEach((value) => { - result[++index] = [value, value]; - }); - return result; -} - - diff --git a/libs/nanofn/src/_internal/set-to-string.ts b/libs/nanofn/src/_internal/set-to-string.ts deleted file mode 100644 index 1615925ce..000000000 --- a/libs/nanofn/src/_internal/set-to-string.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Sets the `toString` method of `func` to return `string`. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ -export function _setToString(func, string) { - return Object.defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': () => string, - 'writable': true - }); -} - - diff --git a/libs/nanofn/src/_internal/stack.ts b/libs/nanofn/src/_internal/stack.ts deleted file mode 100644 index 9a9878e3d..000000000 --- a/libs/nanofn/src/_internal/stack.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { ListCache } from './list-cache'; -import { MapCache } from './map-cache'; - -/** Used as the size to enable large array optimizations. */ -const LARGE_ARRAY_SIZE = 200; - -export class Stack { - - /** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - constructor(entries) { - const data = this.__data__ = new ListCache(entries); - this.size = data.size; - } - - /** - * Removes all key-value entries from the stack. - * - * @memberOf Stack - */ - clear() { - this.__data__ = new ListCache; - this.size = 0; - } - - /** - * Removes `key` and its value from the stack. - * - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - delete(key) { - const data = this.__data__; - const result = data['delete'](key); - - this.size = data.size; - return result; - } - - /** - * Gets the stack value for `key`. - * - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - get(key) { - return this.__data__.get(key); - } - - /** - * Checks if a stack value for `key` exists. - * - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - has(key) { - return this.__data__.has(key); - } - - /** - * Sets the stack `key` to `value`. - * - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ - set(key, value) { - let data = this.__data__; - if (data instanceof ListCache) { - const pairs = data.__data__; - if (pairs.length < LARGE_ARRAY_SIZE - 1) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; - } -} diff --git a/libs/nanofn/src/_internal/strict-index-of.ts b/libs/nanofn/src/_internal/strict-index-of.ts deleted file mode 100644 index bd81925c3..000000000 --- a/libs/nanofn/src/_internal/strict-index-of.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _strictIndexOf(array: any[], value: any, fromIndex: number): number { - let index = fromIndex - 1; - const {length} = array; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/_internal/strict-last-index-of.ts b/libs/nanofn/src/_internal/strict-last-index-of.ts deleted file mode 100644 index ff79ba4d1..000000000 --- a/libs/nanofn/src/_internal/strict-last-index-of.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * A specialized version of `lastIndexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -export function _strictLastIndexOf(array: any[], value: any, fromIndex: number): number { - let index = fromIndex + 1; - while (index--) { - if (array[index] === value) { - return index; - } - } - return index; -} - - diff --git a/libs/nanofn/src/_internal/string-size.ts b/libs/nanofn/src/_internal/string-size.ts deleted file mode 100644 index 116df7998..000000000 --- a/libs/nanofn/src/_internal/string-size.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _asciiSize } from './ascii-size'; -import { _hasUnicode } from './has-unicode'; -import { _unicodeSize } from './unicode-size'; - -/** - * Gets the number of symbols in `string`. - * - * @private - * @param {string} str The string to inspect. - * @returns {number} Returns the string size. - */ -export function _stringSize(str: string): number { - return _hasUnicode(str) ? _unicodeSize(str) : _asciiSize(str); -} - - diff --git a/libs/nanofn/src/_internal/string-to-array.ts b/libs/nanofn/src/_internal/string-to-array.ts deleted file mode 100644 index 3a5f2884b..000000000 --- a/libs/nanofn/src/_internal/string-to-array.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _asciiToArray } from './ascii-to-array'; -import { _hasUnicode } from './has-unicode'; -import { _unicodeToArray } from './unicode-to-array'; - -/** - * Converts `string` to an array. - * - * @private - * @param {string} str The string to convert. - * @returns {Array} Returns the converted array. - */ -export function _stringToArray(str: string): number[] { - return _hasUnicode(str) - ? _unicodeToArray(str) - : _asciiToArray(str); -} - - diff --git a/libs/nanofn/src/_internal/string-to-path.ts b/libs/nanofn/src/_internal/string-to-path.ts deleted file mode 100644 index eba388139..000000000 --- a/libs/nanofn/src/_internal/string-to-path.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - - -const charCodeOfDot = '.'.charCodeAt(0); -const reEscapeChar = /\\(\\)?/g; -const rePropName = RegExp( - // Match anything that isn't a dot or bracket. - '[^.[\\]]+' + '|' + - // Or match property names within brackets. - '\\[(?:' + - // Match a non-string expression. - '([^"\'][^[]*)' + '|' + - // Or match strings (supports escaping characters). - '(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' + - ')\\]' + '|' + - // Or match "" as the space between consecutive dots or empty brackets. - '(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))' - , 'g'); - -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} str The string to convert. - * @returns {Array} Returns the property path array. - */ -export function stringToPath(str: string): string[] { - const result = []; - if (str.charCodeAt(0) === charCodeOfDot) { - result.push(''); - } - str.replace(rePropName, (match, expression, quote, subString) => { - let key = match; - if (quote) { - key = subString.replace(reEscapeChar, '$1'); - } else if (expression) { - key = expression.trim(); - } - result.push(key); - return ''; - }); - return result; -} diff --git a/libs/nanofn/src/_internal/to-key.ts b/libs/nanofn/src/_internal/to-key.ts deleted file mode 100644 index 99b8e338a..000000000 --- a/libs/nanofn/src/_internal/to-key.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ -export function _toKey(value: any): string | symbol { - if (typeof value === 'string' || isSymbol(value)) { - return value; - } - const result = `${value}`; - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - - diff --git a/libs/nanofn/src/_internal/unicode-size.ts b/libs/nanofn/src/_internal/unicode-size.ts deleted file mode 100644 index c8513a744..000000000 --- a/libs/nanofn/src/_internal/unicode-size.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to compose unicode character classes. */ -const rsAstralRange = '\\ud800-\\udfff'; -const rsComboMarksRange = '\\u0300-\\u036f'; -const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -const rsComboSymbolsRange = '\\u20d0-\\u20ff'; -const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'; -const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'; -const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + - rsComboSymbolsRange + rsComboMarksExtendedRange + - rsComboMarksSupplementRange; -const rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -const rsAstral = `[${rsAstralRange}]`; -const rsCombo = `[${rsComboRange}]`; -const rsFitz = '\\ud83c[\\udffb-\\udfff]'; -const rsModifier = `(?:${rsCombo}|${rsFitz})`; -const rsNonAstral = `[^${rsAstralRange}]`; -const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -const rsZWJ = '\\u200d'; - -/** Used to compose unicode regexes. */ -const reOptMod = `${rsModifier}?`; -const rsOptVar = `[${rsVarRange}]?`; -const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join( - '|')})${rsOptVar + reOptMod})*`; -const rsSeq = rsOptVar + reOptMod + rsOptJoin; -const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`; -const rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join( - '|')})`; - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g'); - -/** - * Gets the size of a Unicode `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ -export function _unicodeSize(string) { - let result = reUnicode.lastIndex = 0; - while (reUnicode.test(string)) { - ++result; - } - return result; -} - - diff --git a/libs/nanofn/src/_internal/unicode-to-array.ts b/libs/nanofn/src/_internal/unicode-to-array.ts deleted file mode 100644 index 4b76f473c..000000000 --- a/libs/nanofn/src/_internal/unicode-to-array.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to compose unicode character classes. */ -const rsAstralRange = '\\ud800-\\udfff'; -const rsComboMarksRange = '\\u0300-\\u036f'; -const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -const rsComboSymbolsRange = '\\u20d0-\\u20ff'; -const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'; -const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'; -const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + - rsComboSymbolsRange + rsComboMarksExtendedRange + - rsComboMarksSupplementRange; -const rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -const rsAstral = `[${rsAstralRange}]`; -const rsCombo = `[${rsComboRange}]`; -const rsFitz = '\\ud83c[\\udffb-\\udfff]'; -const rsModifier = `(?:${rsCombo}|${rsFitz})`; -const rsNonAstral = `[^${rsAstralRange}]`; -const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -const rsZWJ = '\\u200d'; - -/** Used to compose unicode regexes. */ -const reOptMod = `${rsModifier}?`; -const rsOptVar = `[${rsVarRange}]?`; -const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join( - '|')})${rsOptVar + reOptMod})*`; -const rsSeq = rsOptVar + reOptMod + rsOptJoin; -const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`; -const rsSymbol = `(?:${ - [rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') -})`; - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g'); - -/** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} str The string to convert. - * @returns {Array} Returns the converted array. - */ -export function _unicodeToArray(str: string): string[] { - return str.match(reUnicode) || []; -} - - diff --git a/libs/nanofn/src/_internal/unicode-words.ts b/libs/nanofn/src/_internal/unicode-words.ts deleted file mode 100644 index f4ca3caf8..000000000 --- a/libs/nanofn/src/_internal/unicode-words.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to compose unicode character classes. */ -const rsAstralRange = '\\ud800-\\udfff'; -const rsComboMarksRange = '\\u0300-\\u036f'; -const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -const rsComboSymbolsRange = '\\u20d0-\\u20ff'; -const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'; -const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'; -const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange; -const rsDingbatRange = '\\u2700-\\u27bf'; -const rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'; -const rsMathOpRange = '\\xac\\xb1\\xd7\\xf7'; -const rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'; -const rsPunctuationRange = '\\u2000-\\u206f'; -const rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000'; -const rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'; -const rsVarRange = '\\ufe0e\\ufe0f'; -const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; - -/** Used to compose unicode capture groups. */ -const rsApos = '[\'\u2019]'; -const rsBreak = `[${rsBreakRange}]`; -const rsCombo = `[${rsComboRange}]`; -const rsDigit = '\\d'; -const rsDingbat = `[${rsDingbatRange}]`; -const rsLower = `[${rsLowerRange}]`; -const rsMisc = `[^${rsAstralRange}${rsBreakRange + rsDigit + rsDingbatRange + rsLowerRange + rsUpperRange}]`; -const rsFitz = '\\ud83c[\\udffb-\\udfff]'; -const rsModifier = `(?:${rsCombo}|${rsFitz})`; -const rsNonAstral = `[^${rsAstralRange}]`; -const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -const rsUpper = `[${rsUpperRange}]`; -const rsZWJ = '\\u200d'; - -/** Used to compose unicode regexes. */ -const rsMiscLower = `(?:${rsLower}|${rsMisc})`; -const rsMiscUpper = `(?:${rsUpper}|${rsMisc})`; -const rsOptContrLower = `(?:${rsApos}(?:d|ll|m|re|s|t|ve))?`; -const rsOptContrUpper = `(?:${rsApos}(?:D|LL|M|RE|S|T|VE))?`; -const reOptMod = `${rsModifier}?`; -const rsOptVar = `[${rsVarRange}]?`; -const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join( - '|')})${rsOptVar + reOptMod})*`; -const rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])'; -const rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])'; -const rsSeq = rsOptVar + reOptMod + rsOptJoin; -const rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`; - -const reUnicodeWords = RegExp([ - `${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`, - `${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`, - `${rsUpper}?${rsMiscLower}+${rsOptContrLower}`, - `${rsUpper}+${rsOptContrUpper}`, - rsOrdUpper, - rsOrdLower, - `${rsDigit}+`, - rsEmoji -].join('|'), 'g'); - -/** - * Splits a Unicode `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ -export function _unicodeWords(str: string): string[] { - return str.match(reUnicodeWords); -} - - diff --git a/libs/nanofn/src/arr/chunk.ts b/libs/nanofn/src/arr/chunk.ts deleted file mode 100644 index f7e2601f7..000000000 --- a/libs/nanofn/src/arr/chunk.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from './slice'; -import { toInteger } from '../cast/to-integer'; - -/** - * Creates an array of elements split into groups the length of `size`. - * If `array` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk - * @returns {Array} Returns the new array of chunks. - * @example - * - * chunk(['a', 'b', 'c', 'd'], 2) - * // => [['a', 'b'], ['c', 'd']] - * - * chunk(['a', 'b', 'c', 'd'], 3) - * // => [['a', 'b', 'c'], ['d']] - */ -export function chunk(array: any[], size = 1) { - size = Math.max(toInteger(size), 0); - const length = array == null ? 0 : array.length; - if (!length || size < 1) { - return []; - } - let index = 0; - let resIndex = 0; - const result = new Array(Math.ceil(length / size)); - - while (index < length) { - result[resIndex++] = slice(array, index, (index += size)); - } - return result; -} - - diff --git a/libs/nanofn/src/arr/compact.ts b/libs/nanofn/src/arr/compact.ts deleted file mode 100644 index fa867f1cd..000000000 --- a/libs/nanofn/src/arr/compact.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * compact([0, 1, false, 2, '', 3]) - * // => [1, 2, 3] - */ -export function compact(array: any[]): any[] { - let resIndex = 0; - const result: any[] = []; - - if (array == null) { - return result; - } - - for (const value of array) { - if (value) { - result[resIndex++] = value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/arr/difference/difference.ts b/libs/nanofn/src/arr/difference/difference.ts deleted file mode 100644 index 1fd9e89e4..000000000 --- a/libs/nanofn/src/arr/difference/difference.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseDifference } from '../../_internal/base-difference'; -import { _baseFlatten } from '../../_internal/base-flatten'; -import { isArrayLikeObject } from '../../is/is-array-like-object'; -import { last } from '../last'; - -/** - * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * **Note:** Unlike `pullAll`, this method returns a new array. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see union, unionBy, unionWith, without, xor, xorBy, xorWith, - * @example - * - * difference([2, 1], [2, 3]) - * // => [1] - */ -export function difference(array, ...values) { - return isArrayLikeObject(array) - ? _baseDifference(array, _baseFlatten(values, 1, isArrayLikeObject, true)) - : []; -} - - -/** - * This method is like `difference` except that it accepts `iteratee` which - * is invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * **Note:** Unlike `pullAllBy`, this method returns a new array. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor) - * // => [1.2] - */ -export function differenceBy(array, ...values) { - let iteratee = last(values); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return isArrayLikeObject(array) - ? _baseDifference(array, _baseFlatten(values, 1, isArrayLikeObject, true), iteratee) - : []; -} - - -/** - * This method is like `difference` except that it accepts `comparator` - * which is invoked to compare elements of `array` to `values`. The order and - * references of result values are determined by the first array. The comparator - * is invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `pullAllWith`, this method returns a new array. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - * - * differenceWith(objects, [{ 'x': 1, 'y': 2 }], isEqual) - * // => [{ 'x': 2, 'y': 1 }] - */ -export function differenceWith(array, ...values) { - let comparator = last(values); - if (isArrayLikeObject(comparator)) { - comparator = undefined; - } - return isArrayLikeObject(array) - ? _baseDifference(array, _baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) - : []; -} - - diff --git a/libs/nanofn/src/arr/drop.ts b/libs/nanofn/src/arr/drop.ts deleted file mode 100644 index 4c45efd9f..000000000 --- a/libs/nanofn/src/arr/drop.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseWhile } from '../_internal/base-while'; -import { toInteger } from '../cast/to-integer'; -import { slice } from './slice'; - -/** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @category Array - * @param {Array} arr The array to query. - * @param {number} [n=1] The number of elements to drop. - * @returns {Array} Returns the slice of `array`. - * @example - * - * drop([1, 2, 3]) - * // => [2, 3] - * - * drop([1, 2, 3], 2) - * // => [3] - * - * drop([1, 2, 3], 5) - * // => [] - * - * drop([1, 2, 3], 0) - * // => [1, 2, 3] - */ -export function drop(arr: any[], n = 1): any[] { - const length = arr == null ? 0 : arr.length; - return length - ? slice(arr, n < 0 ? 0 : toInteger(n), length) - : []; -} - - -/** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @category Array - * @param {Array} arr The array to query. - * @param {number} [n=1] The number of elements to drop. - * @returns {Array} Returns the slice of `array`. - * @example - * - * dropRight([1, 2, 3]) - * // => [1, 2] - * - * dropRight([1, 2, 3], 2) - * // => [1] - * - * dropRight([1, 2, 3], 5) - * // => [] - * - * dropRight([1, 2, 3], 0) - * // => [1, 2, 3] - */ -export function dropRight(arr: any[], n = 1): any[] { - const length = arr == null ? 0 : arr.length; - n = length - toInteger(n); - return length ? slice(arr, 0, n < 0 ? 0 : n) : []; -} - - -/** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * const users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': true }, - * { 'user': 'pebbles', 'active': true } - * ] - * - * dropRightWhile(users, ({ active }) => active) - * // => objects for ['barney'] - */ -export function dropRightWhile(array, predicate) { - return (array != null && array.length) - ? _baseWhile(array, predicate, true, true) - : []; -} - - -/** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': true }, - * { 'user': 'pebbles', 'active': false } - * ] - * - * dropWhile(users, ({ active }) => active) - * // => objects for ['pebbles'] - */ -export function dropWhile(array, predicate) { - return (array != null && array.length) - ? _baseWhile(array, predicate, true) - : []; -} - diff --git a/libs/nanofn/src/arr/each.ts b/libs/nanofn/src/arr/each.ts deleted file mode 100644 index df912fd20..000000000 --- a/libs/nanofn/src/arr/each.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export { forEach as each } from './forEach'; - -export { forEachRight } from './for-each-right'; \ No newline at end of file diff --git a/libs/nanofn/src/arr/every.ts b/libs/nanofn/src/arr/every.ts deleted file mode 100644 index 4db14b045..000000000 --- a/libs/nanofn/src/arr/every.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `predicate` returns truthy for **all** elements of `array`. - * Iteration is stopped once `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * **Note:** This method returns `true` for - * [empty arrays](https://en.wikipedia.org/wiki/Empty_set) because - * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of - * elements of empty arrays. - * - * @category Array - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * every([true, 1, null, 'yes'], Boolean) - * // => false - */ -export function every(array, predicate) { - let index = -1; - const length = array == null ? 0 : array.length; - - while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } - } - return true; -} - - diff --git a/libs/nanofn/src/arr/filter.ts b/libs/nanofn/src/arr/filter.ts deleted file mode 100644 index f9cc05d33..000000000 --- a/libs/nanofn/src/arr/filter.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Iterates over elements of `array`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index, array). - * - * **Note:** Unlike `remove`, this method returns a new array. - * - * @category Array - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, reject - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ] - * - * filter(users, ({ active }) => active) - * // => objects for ['barney'] - */ -export function filter(array, predicate) { - let index = -1; - let resIndex = 0; - const length = array == null ? 0 : array.length; - const result = []; - - while (++index < length) { - const value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/arr/find-last-index.ts b/libs/nanofn/src/arr/find-last-index.ts deleted file mode 100644 index 0416b38e1..000000000 --- a/libs/nanofn/src/arr/find-last-index.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFindIndex } from '../_internal/base-find-index'; -import { toInteger } from '../cast/to-integer'; - -/** - * This method is like `findIndex` except that it iterates over elements - * of `collection` from right to left. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @see find, findIndex, findKey, findLast, findLastKey - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ] - * - * findLastIndex(users, ({ user }) => user == 'pebbles') - * // => 2 - */ -export function findLastIndex(array, predicate, fromIndex) { - const length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - let index = length - 1; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = fromIndex < 0 - ? Math.max(length + index, 0) - : Math.min(index, length - 1); - } - return _baseFindIndex(array, predicate, index, true); -} - - diff --git a/libs/nanofn/src/arr/first.ts b/libs/nanofn/src/arr/first.ts deleted file mode 100644 index cf5d70225..000000000 --- a/libs/nanofn/src/arr/first.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export { head as first } from './head'; diff --git a/libs/nanofn/src/arr/flat/flat-map-deep.ts b/libs/nanofn/src/arr/flat/flat-map-deep.ts deleted file mode 100644 index eabbf6775..000000000 --- a/libs/nanofn/src/arr/flat/flat-map-deep.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; -import { map } from '../map'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** - * This method is like `flatMap` except that it recursively flattens the - * mapped results. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @see flatMap, flatMapDepth, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues - * @example - * - * function duplicate(n) { - * return [[[n, n]]] - * } - * - * flatMapDeep([1, 2], duplicate) - * // => [1, 1, 2, 2] - */ -export function flatMapDeep(collection, iteratee) { - return _baseFlatten(map(collection, iteratee), INFINITY); -} - - diff --git a/libs/nanofn/src/arr/flat/flat-map-depth.ts b/libs/nanofn/src/arr/flat/flat-map-depth.ts deleted file mode 100644 index d5221c929..000000000 --- a/libs/nanofn/src/arr/flat/flat-map-depth.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; -import { map } from '../map'; - -/** - * This method is like `flatMap` except that it recursively flattens the - * mapped results up to `depth` times. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @see flatMap, flatMapDeep, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues - * @example - * - * function duplicate(n) { - * return [[[n, n]]] - * } - * - * flatMapDepth([1, 2], duplicate, 2) - * // => [[1, 1], [2, 2]] - */ -export function flatMapDepth(collection, iteratee, depth) { - depth = depth === undefined ? 1 : +depth; - return _baseFlatten(map(collection, iteratee), depth); -} - - diff --git a/libs/nanofn/src/arr/flat/flat-map.ts b/libs/nanofn/src/arr/flat/flat-map.ts deleted file mode 100644 index 5db196dd6..000000000 --- a/libs/nanofn/src/arr/flat/flat-map.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; -import { map } from '../map'; - -/** - * Creates a flattened array of values by running each element in `collection` - * thru `iteratee` and flattening the mapped results. The iteratee is invoked - * with three arguments: (value, index|key, collection). - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @see flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues - * @example - * - * function duplicate(n) { - * return [n, n] - * } - * - * flatMap([1, 2], duplicate) - * // => [1, 1, 2, 2] - */ -export function flatMap(collection, iteratee) { - return _baseFlatten(map(collection, iteratee), 1); -} - - diff --git a/libs/nanofn/src/arr/flat/flatten-deep.ts b/libs/nanofn/src/arr/flat/flatten-deep.ts deleted file mode 100644 index 4748e621e..000000000 --- a/libs/nanofn/src/arr/flat/flatten-deep.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** - * Recursively flattens `array`. - * - * @category Array - * @param {Array} arr The array to flatten. - * @returns {Array} Returns the new flattened array. - * @see flatMap, flatMapDeep, flatMapDepth, flatten, flattenDepth - * @example - * - * flattenDeep([1, [2, [3, [4]], 5]]) - * // => [1, 2, 3, 4, 5] - */ -export function flattenDeep(arr: any[]): any[] { - const length = arr == null ? 0 : arr.length; - return length ? _baseFlatten(arr, INFINITY) : []; -} - - diff --git a/libs/nanofn/src/arr/flat/flatten-depth.ts b/libs/nanofn/src/arr/flat/flatten-depth.ts deleted file mode 100644 index b36429361..000000000 --- a/libs/nanofn/src/arr/flat/flatten-depth.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; - -/** - * Recursively flatten `array` up to `depth` times. - * - * @category Array - * @param {Array} array The array to flatten. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @see flatMap, flatMapDeep, flatMapDepth, flattenDeep - * @example - * - * const array = [1, [2, [3, [4]], 5]] - * - * flattenDepth(array, 1) - * // => [1, 2, [3, [4]], 5] - * - * flattenDepth(array, 2) - * // => [1, 2, 3, [4], 5] - */ -export function flattenDepth(array, depth) { - const length = array == null ? 0 : array.length; - if (!length) { - return []; - } - depth = depth === undefined ? 1 : +depth; - return _baseFlatten(array, depth); -} - - diff --git a/libs/nanofn/src/arr/flat/flatten.ts b/libs/nanofn/src/arr/flat/flatten.ts deleted file mode 100644 index 64cf90f26..000000000 --- a/libs/nanofn/src/arr/flat/flatten.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFlatten } from '../../_internal/base-flatten'; - -/** - * Flattens `array` a single level deep. - * - * @category Array - * @param {Array} arr The array to flatten. - * @returns {Array} Returns the new flattened array. - * @see flatMap, flatMapDeep, flatMapDepth, flattenDeep, flattenDepth - * @example - * - * flatten([1, [2, [3, [4]], 5]]) - * // => [1, 2, [3, [4]], 5] - */ -export function flatten(arr: any[]): any[] { - const length = arr == null ? 0 : arr.length; - return length ? _baseFlatten(arr, 1) : []; -} - - diff --git a/libs/nanofn/src/arr/from-entries.ts b/libs/nanofn/src/arr/from-entries.ts deleted file mode 100644 index a2956a6e4..000000000 --- a/libs/nanofn/src/arr/from-entries.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The inverse of `entries`is method returns an object composed - * from key-value `pairs`. - * - * @category Array - * @param {Array} pairs The key-value pairs. - * @returns {Object} Returns the new object. - * @example - * - * fromEntries([['a', 1], ['b', 2]]) - * // => { 'a': 1, 'b': 2 } - */ -export function fromEntries(pairs) { - const result = {}; - if (pairs == null) { - return result; - } - for (const pair of pairs) { - result[pair[0]] = pair[1]; - } - return result; -} - - diff --git a/libs/nanofn/src/arr/head.ts b/libs/nanofn/src/arr/head.ts deleted file mode 100644 index cd60c4e52..000000000 --- a/libs/nanofn/src/arr/head.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets the first element of `array`. - * - * @alias first - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @see last - * @example - * - * head([1, 2, 3]) - * // => 1 - * - * head([]) - * // => undefined - */ -export function head(array) { - return (array != null && array.length) - ? array[0] - : undefined; -} - - diff --git a/libs/nanofn/src/arr/index-of.ts b/libs/nanofn/src/arr/index-of.ts deleted file mode 100644 index ea0aa4a1c..000000000 --- a/libs/nanofn/src/arr/index-of.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIndexOf } from '../_internal/base-index-of'; -import { toInteger } from '../cast/to-integer'; - -/** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the - * offset from the end of `array`. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * indexOf([1, 2, 1, 2], 2) - * // => 1 - * - * // Search from the `fromIndex`. - * indexOf([1, 2, 1, 2], 2, 2) - * // => 3 - */ -export function indexOf(array, value, fromIndex) { - const length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - let index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = Math.max(length + index, 0); - } - return _baseIndexOf(array, value, index); -} - - diff --git a/libs/nanofn/src/arr/initial.ts b/libs/nanofn/src/arr/initial.ts deleted file mode 100644 index c56d70b47..000000000 --- a/libs/nanofn/src/arr/initial.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from './slice'; - -/** - * Gets all but the last element of `array`. - * - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * initial([1, 2, 3]) - * // => [1, 2] - */ -export function initial(array) { - const length = array == null ? 0 : array.length; - return length ? slice(array, 0, -1) : []; -} - - diff --git a/libs/nanofn/src/arr/intersection-by.ts b/libs/nanofn/src/arr/intersection-by.ts deleted file mode 100644 index 1c6ae54ef..000000000 --- a/libs/nanofn/src/arr/intersection-by.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from './map'; -import { _baseIntersection } from '../_internal/base-intersection'; -import { _castArrayLikeObject } from '../_internal/cast-array-like-object'; -import { last } from './last'; - -/** - * This method is like `intersection` except that it accepts `iteratee` - * which is invoked for each element of each `arrays` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor) - * // => [2.1] - */ -export function intersectionBy(...arrays) { - let iteratee = last(arrays); - const mapped = map(arrays, _castArrayLikeObject); - - if (iteratee === last(mapped)) { - iteratee = undefined; - } else { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? _baseIntersection(mapped, iteratee) - : []; -} - - diff --git a/libs/nanofn/src/arr/intersection-with.ts b/libs/nanofn/src/arr/intersection-with.ts deleted file mode 100644 index 75ffc7c21..000000000 --- a/libs/nanofn/src/arr/intersection-with.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIntersection } from '../_internal/base-intersection'; -import { _castArrayLikeObject } from '../_internal/cast-array-like-object'; -import { last } from './last'; -import { map } from './map'; - -/** - * This method is like `intersection` except that it accepts `comparator` - * which is invoked to compare elements of `arrays`. The order and references - * of result values are determined by the first array. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }] - * - * intersectionWith(objects, others, isEqual) - * // => [{ 'x': 1, 'y': 2 }] - */ -export function intersectionWith(...arrays) { - let comparator = last(arrays); - const mapped = map(arrays, _castArrayLikeObject); - - comparator = typeof comparator === 'function' ? comparator : undefined; - if (comparator) { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? _baseIntersection(mapped, undefined, comparator) - : []; -} - - diff --git a/libs/nanofn/src/arr/intersection.ts b/libs/nanofn/src/arr/intersection.ts deleted file mode 100644 index ef58d18c8..000000000 --- a/libs/nanofn/src/arr/intersection.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from './map'; -import { _baseIntersection } from '../_internal/base-intersection'; -import { _castArrayLikeObject } from '../_internal/cast-array-like-object'; - -/** - * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * intersection([2, 1], [2, 3]) - * // => [2] - */ -export function intersection(...arrays) { - const mapped = map(arrays, _castArrayLikeObject); - return (mapped.length && mapped[0] === arrays[0]) - ? _baseIntersection(mapped) - : []; -} diff --git a/libs/nanofn/src/arr/last-index-of.ts b/libs/nanofn/src/arr/last-index-of.ts deleted file mode 100644 index efb8c9212..000000000 --- a/libs/nanofn/src/arr/last-index-of.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFindIndex } from '../_internal/base-find-index'; -import { _baseIsNaN } from '../_internal/base-is-nan'; -import { _strictLastIndexOf } from '../_internal/strict-last-index-of'; -import { toInteger } from '../cast/to-integer'; - -/** - * This method is like `indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * lastIndexOf([1, 2, 1, 2], 2) - * // => 3 - * - * // Search from the `fromIndex`. - * lastIndexOf([1, 2, 1, 2], 2, 2) - * // => 1 - */ -export function lastIndexOf(array: any[], value: any, fromIndex: number): number { - const length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - let index = length; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = index < 0 ? Math.max(length + index, 0) : Math.min(index, length - 1); - } - return value === value - ? _strictLastIndexOf(array, value, index) - : _baseFindIndex(array, _baseIsNaN, index, true); -} - - diff --git a/libs/nanofn/src/arr/last.ts b/libs/nanofn/src/arr/last.ts deleted file mode 100644 index e1006675c..000000000 --- a/libs/nanofn/src/arr/last.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets the last element of `array`. - * - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * last([1, 2, 3]) - * // => 3 - */ -export function last(array: any[]): any { - const length = array == null ? 0 : array.length; - return length ? array[length - 1] : undefined; -} - - diff --git a/libs/nanofn/src/arr/map.ts b/libs/nanofn/src/arr/map.ts deleted file mode 100644 index 91b5f6849..000000000 --- a/libs/nanofn/src/arr/map.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an array of values by running each element of `array` thru `iteratee`. - * The iteratee is invoked with three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n - * } - * - * map([4, 8], square) - * // => [16, 64] - */ -export function map(array, iteratee) { - let index = -1; - const length = array == null ? 0 : array.length; - const result = new Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - - diff --git a/libs/nanofn/src/arr/nth.ts b/libs/nanofn/src/arr/nth.ts deleted file mode 100644 index 8519076f3..000000000 --- a/libs/nanofn/src/arr/nth.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isIndex } from './_internal/is-index'; - -/** - * Gets the element at index `n` of `array`. If `n` is negative, the nth - * element from the end is returned. - * - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=0] The index of the element to return. - * @returns {*} Returns the nth element of `array`. - * @example - * - * const array = ['a', 'b', 'c', 'd'] - * - * nth(array, 1) - * // => 'b' - * - * nth(array, -2) - * // => 'c' - */ -export function nth(array, n) { - const length = array == null ? 0 : array.length; - if (!length) { - return; - } - n += n < 0 ? length : 0; - return isIndex(n, length) ? array[n] : undefined; -} - - diff --git a/libs/nanofn/src/arr/pull/pull-all-by.ts b/libs/nanofn/src/arr/pull/pull-all-by.ts deleted file mode 100644 index 785d0395d..000000000 --- a/libs/nanofn/src/arr/pull/pull-all-by.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePullAll } from '../../_internal/base-pull-all'; - -/** - * This method is like `pullAll` except that it accepts `iteratee` which is - * invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The iteratee is invoked with one argument: (value). - * - * **Note:** Unlike `differenceBy`, this method mutates `array`. - * - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns `array`. - * @see pull, pullAll, pullAllWith, pullAt, remove, reject - * @example - * - * const array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }] - * - * pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x') - * console.log(array) - * // => [{ 'x': 2 }] - */ -export function pullAllBy(array, values, iteratee) { - return (array != null && array.length && values != null && values.length) - ? _basePullAll(array, values, iteratee) - : array; -} - - diff --git a/libs/nanofn/src/arr/pull/pull-all-with.ts b/libs/nanofn/src/arr/pull/pull-all-with.ts deleted file mode 100644 index 6fd3272aa..000000000 --- a/libs/nanofn/src/arr/pull/pull-all-with.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePullAll } from '../../_internal/base-pull-all'; - -/** - * This method is like `pullAll` except that it accepts `comparator` which - * is invoked to compare elements of `array` to `values`. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `differenceWith`, this method mutates `array`. - * - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - * @see pull, pullAll, pullAllBy, pullAt, remove, reject - * @example - * - * const array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }] - * - * pullAllWith(array, [{ 'x': 3, 'y': 4 }], isEqual) - * console.log(array) - * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] - */ -export function pullAllWith(array, values, comparator) { - return (array != null && array.length && values != null && values.length) - ? _basePullAll(array, values, undefined, comparator) - : array; -} - - diff --git a/libs/nanofn/src/arr/pull/pull-all.ts b/libs/nanofn/src/arr/pull/pull-all.ts deleted file mode 100644 index 4333adff4..000000000 --- a/libs/nanofn/src/arr/pull/pull-all.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePullAll } from '../../_internal/base-pull-all'; - -/** - * This method is like `pull` except that it accepts an array of values to remove. - * - * **Note:** Unlike `difference`, this method mutates `array`. - * - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @returns {Array} Returns `array`. - * @see pull, pullAllBy, pullAllWith, pullAt, remove, reject - * @example - * - * const array = ['a', 'b', 'c', 'a', 'b', 'c'] - * - * pullAll(array, ['a', 'c']) - * console.log(array) - * // => ['b', 'b'] - */ -export function pullAll(array, values) { - return (array != null && array.length && values != null && values.length) - ? _basePullAll(array, values) - : array; -} - - diff --git a/libs/nanofn/src/arr/pull/pull-at.ts b/libs/nanofn/src/arr/pull/pull-at.ts deleted file mode 100644 index 335541945..000000000 --- a/libs/nanofn/src/arr/pull/pull-at.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../map'; -import { _baseAt } from '../../_internal/base-at'; -import { _basePullAt } from '../../_internal/base-pull-at'; -import { _compareAscending } from '../../_internal/compare-ascending'; -import { _isIndex } from '../../_internal/is-index'; - -/** - * Removes elements from `array` corresponding to `indexes` and returns an - * array of removed elements. - * - * **Note:** Unlike `at`, this method mutates `array`. - * - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. - * @see pull, pullAll, pullAllBy, pullAllWith, remove, reject - * @example - * - * const array = ['a', 'b', 'c', 'd'] - * const pulled = pullAt(array, [1, 3]) - * - * console.log(array) - * // => ['a', 'c'] - * - * console.log(pulled) - * // => ['b', 'd'] - */ -export function pullAt(array, ...indexes) { - const length = array == null ? 0 : array.length; - const result = _baseAt(array, indexes); - - _basePullAt(array, map(indexes, (index) => _isIndex(index, length) ? +index : index).sort(_compareAscending)); - return result; -} - - diff --git a/libs/nanofn/src/arr/pull/pull.ts b/libs/nanofn/src/arr/pull/pull.ts deleted file mode 100644 index 8bdbc1154..000000000 --- a/libs/nanofn/src/arr/pull/pull.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { pullAll } from './pull-all'; - -/** - * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `without`, this method mutates `array`. Use `remove` - * to remove elements from an array by predicate. - * - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @see pullAll, pullAllBy, pullAllWith, pullAt, remove, reject - * @example - * - * const array = ['a', 'b', 'c', 'a', 'b', 'c'] - * - * pull(array, 'a', 'c') - * console.log(array) - * // => ['b', 'b'] - */ -export function pull(array, ...values) { - return pullAll(array, values); -} - - diff --git a/libs/nanofn/src/arr/remove.ts b/libs/nanofn/src/arr/remove.ts deleted file mode 100644 index 507327434..000000000 --- a/libs/nanofn/src/arr/remove.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { basePullAt } from './_internal/base-pull-at'; - -/** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is invoked - * with three arguments: (value, index, array). - * - * **Note:** Unlike `filter`, this method mutates `array`. Use `pull` - * to pull elements from an array by value. - * - * @category Array - * @param {Array} array The array to modify. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new array of removed elements. - * @see pull, pullAll, pullAllBy, pullAllWith, pullAt, reject, filter - * @example - * - * const array = [1, 2, 3, 4] - * const evens = remove(array, n => n % 2 == 0) - * - * console.log(array) - * // => [1, 3] - * - * console.log(evens) - * // => [2, 4] - */ -export function remove(array, predicate) { - const result = []; - if (!(array != null && array.length)) { - return result; - } - let index = -1; - const indexes = []; - const { length } = array; - - while (++index < length) { - const value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } - } - basePullAt(array, indexes); - return result; -} - - diff --git a/libs/nanofn/src/arr/sample-size.ts b/libs/nanofn/src/arr/sample-size.ts deleted file mode 100644 index 61669dfdd..000000000 --- a/libs/nanofn/src/arr/sample-size.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { copyArray } from './_internal/copy-array'; -import { slice } from './slice'; - -/** - * Gets `n` random elements at unique keys from `array` up to the - * size of `array`. - * - * @category Array - * @param {Array} array The array to sample. - * @param {number} [n=1] The number of elements to sample. - * @returns {Array} Returns the random elements. - * @example - * - * sampleSize([1, 2, 3], 2) - * // => [3, 1] - * - * sampleSize([1, 2, 3], 4) - * // => [2, 3, 1] - */ -export function sampleSize(array, n) { - n = n == null ? 1 : n; - const length = array == null ? 0 : array.length; - if (!length || n < 1) { - return []; - } - n = n > length ? length : n; - let index = -1; - const lastIndex = length - 1; - const result = copyArray(array); - while (++index < n) { - const rand = index + Math.floor(Math.random() * (lastIndex - index + 1)); - const value = result[rand]; - result[rand] = result[index]; - result[index] = value; - } - return slice(result, 0, n); -} - - diff --git a/libs/nanofn/src/arr/sample.ts b/libs/nanofn/src/arr/sample.ts deleted file mode 100644 index c8901520e..000000000 --- a/libs/nanofn/src/arr/sample.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets a random element from `array`. - * - * @category Array - * @param {Array} array The array to sample. - * @returns {*} Returns the random element. - * @example - * - * sample([1, 2, 3, 4]) - * // => 2 - */ -export function sample(array) { - const length = array == null ? 0 : array.length; - return length ? array[Math.floor(Math.random() * length)] : undefined; -} - - diff --git a/libs/nanofn/src/arr/shuffle.ts b/libs/nanofn/src/arr/shuffle.ts deleted file mode 100644 index 90b596f2b..000000000 --- a/libs/nanofn/src/arr/shuffle.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { copyArray } from './_internal/copy-array'; - -/** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). - * - * @category Array - * @param {Array} array The array to shuffle. - * @returns {Array} Returns the new shuffled array. - * @example - * - * shuffle([1, 2, 3, 4]) - * // => [4, 1, 3, 2] - */ -export function shuffle(array) { - const length = array == null ? 0 : array.length; - if (!length) { - return []; - } - let index = -1; - const lastIndex = length - 1; - const result = copyArray(array); - while (++index < length) { - const rand = index + Math.floor(Math.random() * (lastIndex - index + 1)); - const value = result[rand]; - result[rand] = result[index]; - result[index] = value; - } - return result; -} - - diff --git a/libs/nanofn/src/arr/slice.ts b/libs/nanofn/src/arr/slice.ts deleted file mode 100644 index 3acb18822..000000000 --- a/libs/nanofn/src/arr/slice.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates a slice of `array` from `start` up to, but not including, `end`. - * - * **Note:** This method is used instead of - * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are - * returned. - * - * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. A negative index will be treated as an offset from the end. - * @param {number} [end=array.length] The end position. A negative index will be treated as an offset from the end. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var array = [1, 2, 3, 4] - * - * _.slice(array, 2) - * // => [3, 4] - */ -export function slice(array, start, end) { - let length = array == null ? 0 : array.length; - if (!length) { - return []; - } - start = start == null ? 0 : start; - end = end === undefined ? length : end; - - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - let index = -1; - const result = new Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; -} - - diff --git a/libs/nanofn/src/arr/some.ts b/libs/nanofn/src/arr/some.ts deleted file mode 100644 index be7e134e7..000000000 --- a/libs/nanofn/src/arr/some.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `predicate` returns truthy for **any** element of `array`. - * Iteration is stopped once `predicate` returns truthy. The predicate is - * invoked with three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * some([null, 0, 'yes', false], Boolean) - * // => true - */ -export function some(array, predicate) { - let index = -1; - const length = array == null ? 0 : array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - - diff --git a/libs/nanofn/src/arr/sort/some-value.ts b/libs/nanofn/src/arr/sort/some-value.ts deleted file mode 100644 index 3cb184a4f..000000000 --- a/libs/nanofn/src/arr/sort/some-value.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `predicate` returns truthy for **any** element of `object`. - * Iteration is stopped once `predicate` returns truthy. The predicate is - * invoked with three arguments: (value, key, object). - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * someValues({ 'a': 0, 'b': 'yes', 'c': false }, Boolean) - * // => true - */ -export function someValues(object, predicate) { - object = Object(object); - const props = Object.keys(object); - - for (const key of props) { - if (predicate(object[key], key, object)) { - return true; - } - } - return false; -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-index-by.ts b/libs/nanofn/src/arr/sort/sorted-index-by.ts deleted file mode 100644 index 2ae332de6..000000000 --- a/libs/nanofn/src/arr/sort/sorted-index-by.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndexBy } from './_internal/base-sorted-index-by'; - -/** - * This method is like `sortedIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * const objects = [{ 'n': 4 }, { 'n': 5 }] - * - * sortedIndexBy(objects, { 'n': 4 }, ({ n }) => n) - * // => 0 - */ -export function sortedIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, iteratee); -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-index-of.ts b/libs/nanofn/src/arr/sort/sorted-index-of.ts deleted file mode 100644 index 19f320b06..000000000 --- a/libs/nanofn/src/arr/sort/sorted-index-of.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndex } from './_internal/base-sorted-index'; -import { eq } from './eq'; - -/** - * This method is like `indexOf` except that it performs a binary - * search on a sorted `array`. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * sortedIndexOf([4, 5, 5, 5, 6], 5) - * // => 1 - */ -export function sortedIndexOf(array, value) { - const length = array == null ? 0 : array.length; - if (length) { - const index = baseSortedIndex(array, value); - if (index < length && eq(array[index], value)) { - return index; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-index.ts b/libs/nanofn/src/arr/sort/sorted-index.ts deleted file mode 100644 index f90bb5318..000000000 --- a/libs/nanofn/src/arr/sort/sorted-index.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndex } from './_internal/base-sorted-index'; - -/** - * Uses a binary search to determine the lowest index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * sortedIndex([30, 50], 40) - * // => 1 - */ -export function sortedIndex(array, value) { - return baseSortedIndex(array, value); -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-last-index-by.ts b/libs/nanofn/src/arr/sort/sorted-last-index-by.ts deleted file mode 100644 index 0bfd84999..000000000 --- a/libs/nanofn/src/arr/sort/sorted-last-index-by.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndexBy } from './_internal/base-sorted-index-by'; - -/** - * This method is like `sortedLastIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * const objects = [{ 'n': 4 }, { 'n': 5 }] - * - * sortedLastIndexBy(objects, { 'n': 4 }, ({ n }) => n) - * // => 1 - */ -export function sortedLastIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, iteratee, true); -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-last-index-of.ts b/libs/nanofn/src/arr/sort/sorted-last-index-of.ts deleted file mode 100644 index 0c62e728a..000000000 --- a/libs/nanofn/src/arr/sort/sorted-last-index-of.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndex } from './_internal/base-sorted-index'; -import { eq } from './eq'; - -/** - * This method is like `lastIndexOf` except that it performs a binary - * search on a sorted `array`. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * sortedLastIndexOf([4, 5, 5, 5, 6], 5) - * // => 3 - */ -export function sortedLastIndexOf(array, value) { - const length = array == null ? 0 : array.length; - if (length) { - const index = baseSortedIndex(array, value, true) - 1; - if (eq(array[index], value)) { - return index; - } - } - return -1; -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-last-index.ts b/libs/nanofn/src/arr/sort/sorted-last-index.ts deleted file mode 100644 index e3d201f67..000000000 --- a/libs/nanofn/src/arr/sort/sorted-last-index.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedIndex } from './_internal/base-sorted-index'; - -/** - * This method is like `sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * sortedLastIndex([4, 5, 5, 5, 6], 5) - * // => 4 - */ -export function sortedLastIndex(array, value) { - return baseSortedIndex(array, value, true); -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-uniq-by.ts b/libs/nanofn/src/arr/sort/sorted-uniq-by.ts deleted file mode 100644 index 49038d140..000000000 --- a/libs/nanofn/src/arr/sort/sorted-uniq-by.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedUniq } from './_internal/base-sorted-uniq'; - -/** - * This method is like `uniqBy` except that it's designed and optimized - * for sorted arrays. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor) - * // => [1.1, 2.3] - */ -export function sortedUniqBy(array, iteratee) { - return (array != null && array.length) - ? baseSortedUniq(array, iteratee) - : []; -} - - diff --git a/libs/nanofn/src/arr/sort/sorted-uniq.ts b/libs/nanofn/src/arr/sort/sorted-uniq.ts deleted file mode 100644 index dfc4fd0ab..000000000 --- a/libs/nanofn/src/arr/sort/sorted-uniq.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSortedUniq } from './_internal/base-sorted-uniq'; - -/** - * This method is like `uniq` except that it only works - * for sorted arrays. - * If the input array is known to be sorted `sortedUniq` is - * faster than `uniq`. - * - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * sortedUniq([1, 1, 2]) - * // => [1, 2] - */ -export function sortedUniq(array) { - return (array != null && array.length) - ? baseSortedUniq(array) - : []; -} - - diff --git a/libs/nanofn/src/arr/tail.ts b/libs/nanofn/src/arr/tail.ts deleted file mode 100644 index 02eb001b0..000000000 --- a/libs/nanofn/src/arr/tail.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Gets all but the first element of `array`. - * - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * tail([1, 2, 3]) - * // => [2, 3] - */ -export function tail(array) { - const length = array == null ? 0 : array.length; - if (!length) { - return []; - } - const [, ...result] = array; - return result; -} - - diff --git a/libs/nanofn/src/arr/take/take-right-while.ts b/libs/nanofn/src/arr/take/take-right-while.ts deleted file mode 100644 index 20d67842e..000000000 --- a/libs/nanofn/src/arr/take/take-right-while.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseWhile } from './_internal/base-while'; - -/** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * const users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': true }, - * { 'user': 'pebbles', 'active': true } - * ] - * - * takeRightWhile(users, ({ active }) => active) - * // => objects for ['fred', 'pebbles'] - */ -export function takeRightWhile(array, predicate) { - return (array != null && array.length) - ? baseWhile(array, predicate, false, true) - : []; -} - - diff --git a/libs/nanofn/src/arr/take/take-right.ts b/libs/nanofn/src/arr/take/take-right.ts deleted file mode 100644 index 5b7a5e317..000000000 --- a/libs/nanofn/src/arr/take/take-right.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from './slice'; - -/** - * Creates a slice of `array` with `n` elements taken from the end. - * - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @returns {Array} Returns the slice of `array`. - * @example - * - * takeRight([1, 2, 3]) - * // => [3] - * - * takeRight([1, 2, 3], 2) - * // => [2, 3] - * - * takeRight([1, 2, 3], 5) - * // => [1, 2, 3] - * - * takeRight([1, 2, 3], 0) - * // => [] - */ -export function takeRight(array, n= 1) { - const length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = length - n; - return slice(array, n < 0 ? 0 : n, length); -} - - diff --git a/libs/nanofn/src/arr/take/take-while.ts b/libs/nanofn/src/arr/take/take-while.ts deleted file mode 100644 index 471ba5c56..000000000 --- a/libs/nanofn/src/arr/take/take-while.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseWhile } from './_internal/base-while'; - -/** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @category Array - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': true }, - * { 'user': 'pebbles', 'active': false } - * ] - * - * takeWhile(users, ({ active }) => active) - * // => objects for ['barney', 'fred'] - */ -export function takeWhile(array, predicate) { - return (array != null && array.length) - ? baseWhile(array, predicate) - : []; -} - - diff --git a/libs/nanofn/src/arr/take/take.ts b/libs/nanofn/src/arr/take/take.ts deleted file mode 100644 index 10ed78549..000000000 --- a/libs/nanofn/src/arr/take/take.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { slice } from './slice'; - -/** - * Creates a slice of `array` with `n` elements taken from the beginning. - * - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @returns {Array} Returns the slice of `array`. - * @example - * - * take([1, 2, 3]) - * // => [1] - * - * take([1, 2, 3], 2) - * // => [1, 2] - * - * take([1, 2, 3], 5) - * // => [1, 2, 3] - * - * take([1, 2, 3], 0) - * // => [] - */ -export function take(array, n= 1) { - if (!(array != null && array.length)) { - return []; - } - return slice(array, 0, n < 0 ? 0 : n); -} - - diff --git a/libs/nanofn/src/arr/union/union-by.ts b/libs/nanofn/src/arr/union/union-by.ts deleted file mode 100644 index b79139207..000000000 --- a/libs/nanofn/src/arr/union/union-by.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseFlatten } from './_internal/base-flatten'; -import { baseUniq } from './_internal/base-uniq'; -import { isArrayLikeObject } from './is-array-like-object'; -import { last } from './last'; - -/** - * This method is like `union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which uniqueness is computed. Result values are chosen from the first - * array in which the value occurs. The iteratee is invoked with one argument: - * (value). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new array of combined values. - * @see difference, union, unionWith, without, xor, xorBy - * @example - * - * unionBy([2.1], [1.2, 2.3], Math.floor) - * // => [2.1, 1.2] - */ -export function unionBy(...arrays) { - let iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), iteratee); -} - - diff --git a/libs/nanofn/src/arr/union/union-with.ts b/libs/nanofn/src/arr/union/union-with.ts deleted file mode 100644 index ef36fb644..000000000 --- a/libs/nanofn/src/arr/union/union-with.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseFlatten } from './_internal/base-flatten'; -import { baseUniq } from './_internal/base-uniq'; -import { isArrayLikeObject } from './is-array-like-object'; -import { last } from './last'; - -/** - * This method is like `union` except that it accepts `comparator` which - * is invoked to compare elements of `arrays`. Result values are chosen from - * the first array in which the value occurs. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of combined values. - * @see difference, union, unionBy, without, xor, xorBy - * @example - * - * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }] - * - * unionWith(objects, others, isEqual) - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ -export function unionWith(...arrays) { - let comparator = last(arrays); - comparator = typeof comparator === 'function' ? comparator : undefined; - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); -} - - diff --git a/libs/nanofn/src/arr/union/union.ts b/libs/nanofn/src/arr/union/union.ts deleted file mode 100644 index 901dbeb87..000000000 --- a/libs/nanofn/src/arr/union/union.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseFlatten } from './_internal/base-flatten'; -import { baseUniq } from './_internal/base-uniq'; -import { isArrayLikeObject } from './is-array-like-object'; - -/** - * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @see difference, unionBy, unionWith, without, xor, xorBy - * @example - * - * union([2, 3], [1, 2]) - * // => [2, 3, 1] - */ -export function union(...arrays) { - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); -} - - diff --git a/libs/nanofn/src/arr/uniq/uniq-by.ts b/libs/nanofn/src/arr/uniq/uniq-by.ts deleted file mode 100644 index 8dce282a9..000000000 --- a/libs/nanofn/src/arr/uniq/uniq-by.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUniq } from '../../_internal/base-uniq'; - -/** - * This method is like `uniq` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * uniqueness is computed. The order of result values is determined by the - * order they occur in the array. The iteratee is invoked with one argument: - * (value). - * - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @see uniq, uniqWith - * @example - * - * uniqBy([2.1, 1.2, 2.3], Math.floor) - * // => [2.1, 1.2] - */ -export function uniqBy(array: any[], iteratee: (value: any) => any): any[] { - return (array != null && array.length) - ? _baseUniq(array, iteratee) - : []; -} - - diff --git a/libs/nanofn/src/arr/uniq/uniq-with.ts b/libs/nanofn/src/arr/uniq/uniq-with.ts deleted file mode 100644 index fc8448d3f..000000000 --- a/libs/nanofn/src/arr/uniq/uniq-with.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUniq } from '../../_internal/base-uniq'; - -/** - * This method is like `uniq` except that it accepts `comparator` which - * is invoked to compare elements of `array`. The order of result values is - * determined by the order they occur in the array. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @see uniq, uniqBy - * @example - * - * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }] - * - * uniqWith(objects, isEqual) - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - */ -export function uniqWith(array, comparator) { - comparator = typeof comparator === 'function' ? comparator : undefined; - return (array != null && array.length) - ? _baseUniq(array, undefined, comparator) - : []; -} - - diff --git a/libs/nanofn/src/arr/uniq/uniq.ts b/libs/nanofn/src/arr/uniq/uniq.ts deleted file mode 100644 index 0345bb337..000000000 --- a/libs/nanofn/src/arr/uniq/uniq.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUniq } from '../../_internal/base-uniq'; - -/** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. The order of result values is determined by the order they occur - * in the array. - * - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @see uniqBy, uniqWith - * @example - * - * uniq([2, 1, 2]) - * // => [2, 1] - */ -export function uniq(array) { - return (array != null && array.length) - ? _baseUniq(array) - : []; -} - - diff --git a/libs/nanofn/src/arr/without.ts b/libs/nanofn/src/arr/without.ts deleted file mode 100644 index 2b5b4d313..000000000 --- a/libs/nanofn/src/arr/without.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseDifference } from '../_internal/base-difference'; -import { isArrayLikeObject } from '../is/is-array-like-object'; - -/** - * Creates an array excluding all given values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `pull`, this method returns a new array. - * - * @category Array - * @param {Array} array The array to inspect. - * @param {...*} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see difference, union, unionBy, unionWith, xor, xorBy, xorWith - * @example - * - * without([2, 1, 2, 3], 1, 2) - * // => [3] - */ -export function without(array, ...values) { - return isArrayLikeObject(array) ? _baseDifference(array, values) : []; -} - - diff --git a/libs/nanofn/src/arr/xor/xor-by.ts b/libs/nanofn/src/arr/xor/xor-by.ts deleted file mode 100644 index e9ca00b8b..000000000 --- a/libs/nanofn/src/arr/xor/xor-by.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseXor } from './_internal/base-xor'; -import { isArrayLikeObject } from './is-array-like-object'; -import { last } from './last'; - -/** - * This method is like `xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which they're compared. The order of result values is determined - * by the order they occur in the arrays. The iteratee is invoked with one - * argument: (value). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @see difference, union, unionBy, unionWith, without, xor, xorWith - * @example - * - * xorBy([2.1, 1.2], [2.3, 3.4], Math.floor) - * // => [1.2, 3.4] - */ -export function xorBy(...arrays) { - let iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return baseXor(arrays.filter(isArrayLikeObject), iteratee); -} - - diff --git a/libs/nanofn/src/arr/xor/xor-with.ts b/libs/nanofn/src/arr/xor/xor-with.ts deleted file mode 100644 index 011159037..000000000 --- a/libs/nanofn/src/arr/xor/xor-with.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseXor } from './_internal/base-xor'; -import { isArrayLikeObject } from './is-array-like-object'; -import { last } from './last'; - -/** - * This method is like `xor` except that it accepts `comparator` which is - * invoked to compare elements of `arrays`. The order of result values is - * determined by the order they occur in the arrays. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @see difference, union, unionBy, unionWith, without, xor, xorBy - * @example - * - * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }] - * - * xorWith(objects, others, isEqual) - * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ -export function xorWith(...arrays) { - let comparator = last(arrays); - comparator = typeof comparator === 'function' ? comparator : undefined; - return baseXor(arrays.filter(isArrayLikeObject), undefined, comparator); -} - - diff --git a/libs/nanofn/src/arr/xor/xor.ts b/libs/nanofn/src/arr/xor/xor.ts deleted file mode 100644 index 3280f6aa6..000000000 --- a/libs/nanofn/src/arr/xor/xor.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseXor } from '../../_internal/base-xor'; -import { isArrayLikeObject } from '../../is/is-array-like-object'; - -/** - * Creates an array of unique values that is the - * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) - * of the given arrays. The order of result values is determined by the order - * they occur in the arrays. - * - * @category Array - * @param {...Array} [arrList] The arrays to inspect. - * @returns {Array} Returns the new array of filtered values. - * @see difference, union, unionBy, unionWith, without, xorBy, xorWith - * @example - * - * xor([2, 1], [2, 3]) - * // => [1, 3] - */ -export function xor(...arrList: Array>): Array { - return _baseXor(arrList.filter(isArrayLikeObject)); -} - - diff --git a/libs/nanofn/src/arr/zip/unzip-with.ts b/libs/nanofn/src/arr/zip/unzip-with.ts deleted file mode 100644 index 5d9562e43..000000000 --- a/libs/nanofn/src/arr/zip/unzip-with.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../map'; -import { unzip } from './unzip'; - -/** - * This method is like `unzip` except that it accepts `iteratee` to specify - * how regrouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @category Array - * @param {Array} array The array of grouped elements to process. - * @param {Function} iteratee The function to combine - * regrouped values. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * const zipped = zip([1, 2], [10, 20], [100, 200]) - * // => [[1, 10, 100], [2, 20, 200]] - * - * unzipWith(zipped, add) - * // => [3, 30, 300] - */ -export function unzipWith(array, iteratee) { - if (!(array != null && array.length)) { - return []; - } - const result = unzip(array); - return map(result, (group) => iteratee.apply(undefined, group)); -} - - diff --git a/libs/nanofn/src/arr/zip/unzip.ts b/libs/nanofn/src/arr/zip/unzip.ts deleted file mode 100644 index 7b70df70c..000000000 --- a/libs/nanofn/src/arr/zip/unzip.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { filter } from './filter'; -import { map } from './map'; -import { baseProperty } from './_internal/base-property'; -import { isArrayLikeObject } from './is-array-like-object'; - -/** - * This method is like `zip` except that it accepts an array of grouped - * elements and creates an array regrouping the elements to their pre-zip - * configuration. - * - * @category Array - * @param {Array} array The array of grouped elements to process. - * @returns {Array} Returns the new array of regrouped elements. - * @see unzipWith, zip, zipObject, zipObjectDeep, zipWith - * @example - * - * const zipped = zip(['a', 'b'], [1, 2], [true, false]) - * // => [['a', 1, true], ['b', 2, false]] - * - * unzip(zipped) - * // => [['a', 'b'], [1, 2], [true, false]] - */ -export function unzip(array) { - if (!(array != null && array.length)) { - return []; - } - let length = 0; - array = filter(array, (group) => { - if (isArrayLikeObject(group)) { - length = Math.max(group.length, length); - return true; - } - }); - let index = -1; - const result = new Array(length); - while (++index < length) { - result[index] = map(array, baseProperty(index)); - } - return result; -} - - diff --git a/libs/nanofn/src/arr/zip/zip-object-deep.ts b/libs/nanofn/src/arr/zip/zip-object-deep.ts deleted file mode 100644 index 2f09ab29b..000000000 --- a/libs/nanofn/src/arr/zip/zip-object-deep.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseSet } from './_internal/base-set'; -import { baseZipObject } from './_internal/base-zip-object'; - -/** - * This method is like `zipObject` except that it supports property paths. - * - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @see unzip, unzipWith, zip, zipObject, zipWith - * @example - * - * zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]) - * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } - */ -export function zipObjectDeep(props, values) { - return baseZipObject(props || [], values || [], baseSet); -} - - diff --git a/libs/nanofn/src/arr/zip/zip-object.ts b/libs/nanofn/src/arr/zip/zip-object.ts deleted file mode 100644 index 23a8688a0..000000000 --- a/libs/nanofn/src/arr/zip/zip-object.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { assignValue } from './_internal/assign-value'; -import { baseZipObject } from './_internal/base-zip-object'; - -/** - * This method is like `fromPairs` except that it accepts two arrays, - * one of property identifiers and one of corresponding values. - * - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @see unzip, unzipWith, zip, zipObjectDeep, zipWith - * @example - * - * zipObject(['a', 'b'], [1, 2]) - * // => { 'a': 1, 'b': 2 } - */ -export function zipObject(props, values) { - return baseZipObject(props || [], values || [], assignValue); -} - - diff --git a/libs/nanofn/src/arr/zip/zip-with.ts b/libs/nanofn/src/arr/zip/zip-with.ts deleted file mode 100644 index bcb5c3bf8..000000000 --- a/libs/nanofn/src/arr/zip/zip-with.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { unzipWith } from './unzip-with'; - -/** - * This method is like `zip` except that it accepts `iteratee` to specify - * how grouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @param {Function} iteratee The function to combine - * grouped values. - * @returns {Array} Returns the new array of grouped elements. - * @see unzip, unzipWith, zip, zipObject, zipObjectDeep, zipWith - * @example - * - * zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c) - * // => [111, 222] - */ -export function zipWith(...arrays) { - const length = arrays.length; - let iteratee = length > 1 ? arrays[length - 1] : undefined; - iteratee = typeof iteratee === 'function' ? (arrays.pop(), iteratee) : undefined; - return unzipWith(arrays, iteratee); -} - - diff --git a/libs/nanofn/src/arr/zip/zip.ts b/libs/nanofn/src/arr/zip/zip.ts deleted file mode 100644 index b1c00c668..000000000 --- a/libs/nanofn/src/arr/zip/zip.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { unzip } from './unzip'; - -/** - * Creates an array of grouped elements, the first of which contains the - * first elements of the given arrays, the second of which contains the - * second elements of the given arrays, and so on. - * - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @returns {Array} Returns the new array of grouped elements. - * @see unzip, unzipWith, zipObject, zipObjectDeep, zipWith - * @example - * - * zip(['a', 'b'], [1, 2], [true, false]) - * // => [['a', 1, true], ['b', 2, false]] - */ -export function zip(...arrays) { - return unzip(arrays); -} - - diff --git a/libs/nanofn/src/case/camel-case.ts b/libs/nanofn/src/case/camel-case.ts deleted file mode 100644 index 8184af78a..000000000 --- a/libs/nanofn/src/case/camel-case.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { upperFirst } from './upper-first'; -import { words } from './words'; - -/** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the camel cased string. - * @see lowerCase, kebabCase, snakeCase, startCase, upperCase, upperFirst - * @example - * - * camelCase('Foo Bar') - * // => 'fooBar' - * - * camelCase('--foo-bar--') - * // => 'fooBar' - * - * camelCase('__FOO_BAR__') - * // => 'fooBar' - */ -export function camelCase(str: string) { - words(str.replace(/['\u2019]/g, '')) - .reduce((result, word, index) => { - word = word.toLowerCase(); - return result + (index ? upperFirst(word) : word); - }, ''); -} diff --git a/libs/nanofn/src/case/capitalize.ts b/libs/nanofn/src/case/capitalize.ts deleted file mode 100644 index 93ed27b0b..000000000 --- a/libs/nanofn/src/case/capitalize.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { upperFirst } from './upper-first'; - -/** - * Converts the first character of `string` to upper case and the remaining - * to lower case. - * - * @category String - * @param {string} [str=''] The string to capitalize. - * @returns {string} Returns the capitalized string. - * @example - * - * capitalize('FRED') - * // => 'Fred' - */ -export function capitalize(str: string) { - return upperFirst(str.toLowerCase()); -} diff --git a/libs/nanofn/src/case/kebab-case.ts b/libs/nanofn/src/case/kebab-case.ts deleted file mode 100644 index 5ef95a59f..000000000 --- a/libs/nanofn/src/case/kebab-case.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { words } from './words'; -import { toString } from '../cast/to-string'; - -/** - * Converts `string` to - * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the kebab cased string. - * @see camelCase, lowerCase, snakeCase, startCase, upperCase, upperFirst - * @example - * - * kebabCase('Foo Bar') - * // => 'foo-bar' - * - * kebabCase('fooBar') - * // => 'foo-bar' - * - * kebabCase('__FOO_BAR__') - * // => 'foo-bar' - */ -export function kebabCase(str: string) { - return words(toString(str).replace(/['\u2019]/g, '')) - .reduce((result, word, index) => ( - result + (index ? '-' : '') + word.toLowerCase() - ), ''); -} diff --git a/libs/nanofn/src/case/lower-case.ts b/libs/nanofn/src/case/lower-case.ts deleted file mode 100644 index 14548dbdf..000000000 --- a/libs/nanofn/src/case/lower-case.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { words } from './words'; -import { toString } from '../cast/to-string'; - -const reQuotes = /['\u2019]/g; - - -/** - * Converts `string`, as space separated words, to lower case. - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the lower cased string. - * @see camelCase, kebabCase, snakeCase, startCase, upperCase, upperFirst - * @example - * - * lowerCase('--Foo-Bar--') - * // => 'foo bar' - * - * lowerCase('fooBar') - * // => 'foo bar' - * - * lowerCase('__FOO_BAR__') - * // => 'foo bar' - */ -export function lowerCase(str: string): string { - return words(str.replace(reQuotes, '')) - .reduce((result, word, index) => ( - result + (index ? ' ' : '') + word.toLowerCase() - ), ''); -} diff --git a/libs/nanofn/src/case/lower-first.ts b/libs/nanofn/src/case/lower-first.ts deleted file mode 100644 index a4abbc1cf..000000000 --- a/libs/nanofn/src/case/lower-first.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts the first character of `string` to lower case. - * - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * lowerFirst('Fred') - * // => 'fred' - * - * lowerFirst('FRED') - * // => 'fRED' - */ - -export function lowerFirst(str: string) { - if (str.length > 1) { - return str[0].toLowerCase() + str.slice(1); - } else { - return str.toLowerCase(); - } -} diff --git a/libs/nanofn/src/case/snake-case.ts b/libs/nanofn/src/case/snake-case.ts deleted file mode 100644 index a761c89f4..000000000 --- a/libs/nanofn/src/case/snake-case.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { words } from './words'; - - -/** - * Converts `string` to - * [snake case](https://en.wikipedia.org/wiki/Snake_case). - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the snake cased string. - * @see camelCase, lowerCase, kebabCase, startCase, upperCase, upperFirst - * @example - * - * snakeCase('Foo Bar') - * // => 'foo_bar' - * - * snakeCase('fooBar') - * // => 'foo_bar' - * - * snakeCase('--FOO-BAR--') - * // => 'foo_bar' - * - * snakeCase('foo2bar') - * // => 'foo_2_bar' - */ -export function snakeCase(str: string): string { - return words(str.replace(/['\u2019]/g, '')) - .reduce((result, word, index) => ( - result + (index ? '_' : '') + word.toLowerCase() - ), ''); -} diff --git a/libs/nanofn/src/case/start-case.ts b/libs/nanofn/src/case/start-case.ts deleted file mode 100644 index f5f8a8aa5..000000000 --- a/libs/nanofn/src/case/start-case.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { upperFirst } from './upper-first'; -import { words } from './words'; - - -/** - * Converts `string` to - * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the start cased string. - * @see camelCase, lowerCase, kebabCase, snakeCase, upperCase, upperFirst - * @example - * - * startCase('--foo-bar--') - * // => 'Foo Bar' - * - * startCase('fooBar') - * // => 'Foo Bar' - * - * startCase('__FOO_BAR__') - * // => 'FOO BAR' - */ -export function startCase(str: string): string { - return words(`${str}`.replace(/['\u2019]/g, '')) - .reduce((result, word, index) => ( - result + (index ? ' ' : '') + upperFirst(word) - ), ''); -} - diff --git a/libs/nanofn/src/case/str-case.ts b/libs/nanofn/src/case/str-case.ts deleted file mode 100644 index 0e08eecb6..000000000 --- a/libs/nanofn/src/case/str-case.ts +++ /dev/null @@ -1,362 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * @license (c) -2020 blakeembrey - * @license (c) 2020-2021 gradii - */ - -export interface Options { - splitRegexp?: RegExp | RegExp[]; - stripRegexp?: RegExp | RegExp[]; - delimiter?: string; - transform?: (part: string, index: number, parts: string[]) => string; -} - -interface Locale { - regexp: RegExp; - map: Record; -} - - -const SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i; -const TOKENS = /[^\s:–—-]+|./g; -const WHITESPACE = /\s/; -const IS_MANUAL_CASE = /.(?=[A-Z]|\..)/; -const ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/; - - -const UPPERCASE_SUPPORTED_LOCALE: Record = { - tr: { - regexp: /[\u0069]/g, - map : { - i: '\u0130', - }, - }, - az: { - regexp: /[\u0069]/g, - map : { - i: '\u0130', - }, - }, - lt: { - regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g, - map : { - i̇ : '\u0049', - j̇ : '\u004A', - į̇ : '\u012E', - i̇̀: '\u00CC', - i̇́: '\u00CD', - i̇̃: '\u0128', - }, - }, -}; - - -/** - * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt - */ -const LOWERCASE_SUPPORTED_LOCALE: Record = { - tr: { - regexp: /\u0130|\u0049|\u0049\u0307/g, - map : { - İ : '\u0069', - I : '\u0131', - İ: '\u0069' - } - }, - az: { - regexp: /\u0130/g, - map : { - İ : '\u0069', - I : '\u0131', - İ: '\u0069' - } - }, - lt: { - regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, - map : { - I: '\u0069\u0307', - J: '\u006A\u0307', - Į: '\u012F\u0307', - Ì: '\u0069\u0307\u0300', - Í: '\u0069\u0307\u0301', - Ĩ: '\u0069\u0307\u0303' - } - } -}; - -/** - * Replace `re` in the input string with the replacement value. - */ -function _replace(input: string, re: RegExp | RegExp[], value: string) { - if (re instanceof RegExp) { - return input.replace(re, value); - } - // @ts-ignore - return (re as RegExp[]).reduce((target, it) => target.replace(it, value), input); -} - -export function _camelCaseTransform(input: string, index: number) { - if (index === 0) { - return input.toLowerCase(); - } - return _pascalCaseTransform(input, index); -} - -export function _camelCaseTransformMerge(input: string, index: number) { - if (index === 0) { - return input.toLowerCase(); - } - return _pascalCaseTransformMerge(input); -} - -export function camelCase(input: string, options: Options = {}) { - return pascalCase(input, { - transform: _camelCaseTransform, - ...options - }); -} - -export function capitalCaseTransform(input: string) { - return upperCaseFirst(input.toLowerCase()); -} - -export function capitalCase(input: string, options: Options = {}) { - return noCase(input, { - delimiter: ' ', - transform: capitalCaseTransform, - ...options - }); -} - -export function constantCase(input: string, options: Options = {}) { - return noCase(input, { - delimiter: '_', - transform: upperCase, - ...options - }); -} - -export function dotCase(input: string, options: Options = {}) { - return noCase(input, { - delimiter: '.', - ...options - }); -} - -export function headerCase(input: string, options: Options = {}) { - return capitalCase(input, { - delimiter: '-', - ...options - }); -} - -export function slugCase(input: string, options: Options = {}) { - return dotCase(input, { - delimiter: '-', - ...options - }); -} - -export function isLowerCase(input: string) { - return input.toLowerCase() === input && input.toUpperCase() !== input; -} - -export function isUpperCase(input: string) { - return input.toUpperCase() === input && input.toLowerCase() !== input; -} - -/** - * Localized lower case. - */ -export function localeLowerCase(str: string, locale: string) { - const lang = LOWERCASE_SUPPORTED_LOCALE[locale.toLowerCase()]; - if (lang) { - return lowerCase(str.replace(lang.regexp, (m) => lang.map[m])); - } - return lowerCase(str); -} - -/** - * Lower case as a function. - */ -export function lowerCase(str: string) { - return str.toLowerCase(); -} - -export function lowerCaseFirst(input: string) { - return input.charAt(0).toLowerCase() + input.substr(1); -} - -// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). -const DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; - -// Remove all non-word characters. -const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; - -/** - * Normalize the string into something other libraries can manipulate easier. - */ -export function noCase(input: string, options: Options = {}) { - const { - splitRegexp = DEFAULT_SPLIT_REGEXP, - stripRegexp = DEFAULT_STRIP_REGEXP, - transform = lowerCase, - delimiter = ' ' - } = options; - - const result = _replace( - _replace(input, splitRegexp, '$1\0$2'), - stripRegexp, - '\0' - ); - let start = 0; - let end = result.length; - - // Trim the delimiter from around the output string. - while (result.charAt(start) === '\0') { - start++; - } - while (result.charAt(end - 1) === '\0') { - end--; - } - - // Transform each token independently. - return result.slice(start, end).split('\0').map(transform).join(delimiter); -} - - -export function paramCase(input: string, options: Options = {}) { - return dotCase(input, { - delimiter: '-', - ...options - }); -} - -export function _pascalCaseTransform(input: string, index: number) { - const firstChar = input.charAt(0); - const lowerChars = input.substr(1).toLowerCase(); - if (index > 0 && firstChar >= '0' && firstChar <= '9') { - return `_${firstChar}${lowerChars}`; - } - return `${firstChar.toUpperCase()}${lowerChars}`; -} - -export function _pascalCaseTransformMerge(input: string) { - return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); -} - -export function pascalCase(input: string, options: Options = {}) { - return noCase(input, { - delimiter: '', - transform: _pascalCaseTransform, - ...options - }); -} - -export function pathCase(input: string, options: Options = {}) { - return dotCase(input, { - delimiter: '/', - ...options - }); -} - -export function _sentenceCaseTransform(input: string, index: number) { - const result = input.toLowerCase(); - if (index === 0) { - return upperCaseFirst(result); - } - return result; -} - -export function sentenceCase(input: string, options: Options = {}) { - return noCase(input, { - delimiter: ' ', - transform: _sentenceCaseTransform, - ...options - }); -} - -export function snakeCase(input: string, options: Options = {}) { - return dotCase(input, { - delimiter: '_', - ...options - }); -} - -export function spongeCase(input: string): string { - let result = ''; - for (let i = 0; i < input.length; i++) { - result += - Math.random() > 0.5 ? input[i].toUpperCase() : input[i].toLowerCase(); - } - return result; -} - -export function swapCase(input: string) { - let result = ''; - for (let i = 0; i < input.length; i++) { - const lower = input[i].toLowerCase(); - result += input[i] === lower ? input[i].toUpperCase() : lower; - } - return result; -} - -export function titleCase(input: string) { - let result = ''; - let m: RegExpExecArray | null; - - // tslint:disable-next-line - while ((m = TOKENS.exec(input)) !== null) { - const {0: token, index} = m; - - if ( - // Ignore already capitalized words. - !IS_MANUAL_CASE.test(token) && - // Ignore small words except at beginning or end. - (!SMALL_WORDS.test(token) || - index === 0 || - index + token.length === input.length) && - // Ignore URLs. - (input.charAt(index + token.length) !== ':' || - WHITESPACE.test(input.charAt(index + token.length + 1))) - ) { - // Find and uppercase first word character, skips over *modifiers*. - result += token.replace(ALPHANUMERIC_PATTERN, (_m) => _m.toUpperCase()); - continue; - } - - result += token; - } - - return result; -} - -/** - * Localized upper case. - */ -export function localeUpperCase(str: string, locale: string) { - const lang = UPPERCASE_SUPPORTED_LOCALE[locale.toLowerCase()]; - if (lang) { - return upperCase(str.replace(lang.regexp, (m) => lang.map[m])); - } - return upperCase(str); -} - -/** - * Upper case as a function. - */ -export function upperCase(str: string) { - return str.toUpperCase(); -} - -/** - * Upper case the first character of an input string. - */ -export function upperCaseFirst(input: string) { - return input.charAt(0).toUpperCase() + input.slice(1); -} diff --git a/libs/nanofn/src/case/upper-case.ts b/libs/nanofn/src/case/upper-case.ts deleted file mode 100644 index 3e40e9c78..000000000 --- a/libs/nanofn/src/case/upper-case.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { words } from './words'; -import { toString } from '../cast/to-string'; - - -/** - * Converts `string`, as space separated words, to upper case. - * - * @category String - * @param {string} [str=''] The string to convert. - * @returns {string} Returns the upper cased string. - * @see camelCase, kebabCase, lowerCase, snakeCase, startCase, upperFirst - * @example - * - * upperCase('--foo-bar') - * // => 'FOO BAR' - * - * upperCase('fooBar') - * // => 'FOO BAR' - * - * upperCase('__foo_bar__') - * // => 'FOO BAR' - */ -export function upperCase(str: string) { - return words(toString(str).replace(/['\u2019]/g, '')).reduce((result, word, index) => ( - result + (index ? ' ' : '') + word.toUpperCase() - ), ''); -} diff --git a/libs/nanofn/src/case/upper-first.ts b/libs/nanofn/src/case/upper-first.ts deleted file mode 100644 index 3d9638715..000000000 --- a/libs/nanofn/src/case/upper-first.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts the first character of `string` to upper case. - * - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @see camelCase, kebabCase, lowerCase, snakeCase, startCase, upperCase - * @example - * - * upperFirst('fred') - * // => 'Fred' - * - * upperFirst('FRED') - * // => 'FRED' - */ -export function upperFirst(input: string) { - return input.charAt(0).toUpperCase() + input.slice(1); -} diff --git a/libs/nanofn/src/case/words.ts b/libs/nanofn/src/case/words.ts deleted file mode 100644 index a71929a3f..000000000 --- a/libs/nanofn/src/case/words.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { unicodeWords } from './_internal/unicode-words'; - -const hasUnicodeWord = RegExp.prototype.test.bind( - /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/ -); - -/** Used to match words composed of alphanumeric characters. */ -const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; - -function asciiWords(string) { - return string.match(reAsciiWord); -} - -/** - * Splits `string` into an array of its words. - * - * @category String - * @param {string} [str=''] The string to inspect. - * @param {RegExp|string} [pattern] The pattern to match words. - * @returns {Array} Returns the words of `string`. - * @example - * - * words('fred, barney, & pebbles') - * // => ['fred', 'barney', 'pebbles'] - * - * words('fred, barney, & pebbles', /[^, ]+/g) - * // => ['fred', 'barney', '&', 'pebbles'] - */ -export function words(str: string, pattern?: RegExp | string): string[] { - if (pattern === undefined) { - const result = hasUnicodeWord(str) ? unicodeWords(str) : asciiWords(str); - return result || []; - } - return str.match(pattern) || []; -} - - diff --git a/libs/nanofn/src/cast/cast-array.ts b/libs/nanofn/src/cast/cast-array.ts deleted file mode 100644 index 6a7fe17cc..000000000 --- a/libs/nanofn/src/cast/cast-array.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - - -/** - * Casts `value` as an array if it's not one. - * - * @category Lang - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast array. - * @example - * - * castArray(1) - * // => [1] - * - * castArray({ 'a': 1 }) - * // => [{ 'a': 1 }] - * - * castArray('abc') - * // => ['abc'] - * - * castArray(null) - * // => [null] - * - * castArray(undefined) - * // => [undefined] - * - * castArray() - * // => [] - * - * const array = [1, 2, 3] - * console.log(castArray(array) === array) - * // => true - */ -export function castArray(...args: any[]): any[] { - if (!args.length) { - return []; - } - const value = args[0]; - return Array.isArray(value) ? value : [value]; -} - - diff --git a/libs/nanofn/src/cast/to-array.ts b/libs/nanofn/src/cast/to-array.ts deleted file mode 100644 index eac89af86..000000000 --- a/libs/nanofn/src/cast/to-array.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _copyArray } from '../_internal/copy-array'; -import { _getTag } from '../_internal/get-tag'; -import { isArrayLike } from '../is/is-array-like'; -import { isString } from '../is/is-string'; -import { _iteratorToArray } from '../_internal/iterator-to-array'; -import { _mapToArray } from '../_internal/map-to-array'; -import { _setToArray } from '../_internal/set-to-array'; -import { _stringToArray } from '../_internal/string-to-array'; -import { values } from '../obj/values'; - -/** `Object#toString` result references. */ -const mapTag = '[object Map]'; -const setTag = '[object Set]'; - -/** Built-in value references. */ -const symIterator = Symbol.iterator; - -/** - * Converts `value` to an array. - * - * @category Lang - * @param {*} value The value to convert. - * @returns {Array} Returns the converted array. - * @example - * - * toArray({ 'a': 1, 'b': 2 }) - * // => [1, 2] - * - * toArray('abc') - * // => ['a', 'b', 'c'] - * - * toArray(1) - * // => [] - * - * toArray(null) - * // => [] - */ -export function toArray(value: any): any[] { - if (!value) { - return []; - } - if (isArrayLike(value)) { - return isString(value) ? _stringToArray(value) : _copyArray(value); - } - if (symIterator && value[symIterator]) { - return _iteratorToArray(value[symIterator]()); - } - const tag = _getTag(value); - const func = tag == mapTag ? _mapToArray : (tag == setTag ? _setToArray : values); - - return func(value); -} - - diff --git a/libs/nanofn/src/cast/to-finite.ts b/libs/nanofn/src/cast/to-finite.ts deleted file mode 100644 index 89842f418..000000000 --- a/libs/nanofn/src/cast/to-finite.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { toNumber } from './to-number'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; -const MAX_INTEGER = 1.7976931348623157e+308; - -/** - * Converts `value` to a finite number. - * - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted number. - * @example - * - * toFinite(3.2) - * // => 3.2 - * - * toFinite(Number.MIN_VALUE) - * // => 5e-324 - * - * toFinite(Infinity) - * // => 1.7976931348623157e+308 - * - * toFinite('3.2') - * // => 3.2 - */ -export function toFinite(value: any): number { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - const sign = (value < 0 ? -1 : 1); - return sign * MAX_INTEGER; - } - return value === value ? value : 0; -} - - diff --git a/libs/nanofn/src/cast/to-integer.ts b/libs/nanofn/src/cast/to-integer.ts deleted file mode 100644 index f4ef66362..000000000 --- a/libs/nanofn/src/cast/to-integer.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { toFinite } from './to-finite'; - -/** - * Converts `value` to an integer. - * - * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). - * - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @see isInteger, isNumber, toNumber - * @example - * - * toInteger(3.2) - * // => 3 - * - * toInteger(Number.MIN_VALUE) - * // => 0 - * - * toInteger(Infinity) - * // => 1.7976931348623157e+308 - * - * toInteger('3.2') - * // => 3 - */ -export function toInteger(value: any): number { - const result = toFinite(value); - const remainder = result % 1; - - return remainder ? result - remainder : result; -} - - diff --git a/libs/nanofn/src/cast/to-length.ts b/libs/nanofn/src/cast/to-length.ts deleted file mode 100644 index 98e688659..000000000 --- a/libs/nanofn/src/cast/to-length.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { toInteger } from './to-integer'; - -/** Used as references for the maximum length and index of an array. */ -const MAX_ARRAY_LENGTH = 4294967295; - -/** - * Converts `value` to an integer suitable for use as the length of an - * array-like object. - * - * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * toLength(3.2) - * // => 3 - * - * toLength(Number.MIN_VALUE) - * // => 0 - * - * toLength(Infinity) - * // => 4294967295 - * - * toLength('3.2') - * // => 3 - */ -export function toLength(value: any): number { - if (!value) { - return 0; - } - value = toInteger(value); - if (value < 0) { - return 0; - } - if (value > MAX_ARRAY_LENGTH) { - return MAX_ARRAY_LENGTH; - } - return value; -} - - diff --git a/libs/nanofn/src/cast/to-number.ts b/libs/nanofn/src/cast/to-number.ts deleted file mode 100644 index 2e230ed7a..000000000 --- a/libs/nanofn/src/cast/to-number.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isObject } from '../is/is-object'; -import { isSymbol } from '../is/is-symbol'; - -/** Used as references for various `Number` constants. */ -const NAN = 0 / 0; - -/** Used to match leading and trailing whitespace. */ -const reTrim = /^\s+|\s+$/g; - -/** Used to detect bad signed hexadecimal string values. */ -const reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - -/** Used to detect binary string values. */ -const reIsBinary = /^0b[01]+$/i; - -/** Used to detect octal string values. */ -const reIsOctal = /^0o[0-7]+$/i; - -/** Built-in method references without a dependency on `root`. */ -const freeParseInt = parseInt; - -/** - * Converts `value` to a number. - * - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @see isInteger, toInteger, isNumber - * @example - * - * toNumber(3.2) - * // => 3.2 - * - * toNumber(Number.MIN_VALUE) - * // => 5e-324 - * - * toNumber(Infinity) - * // => Infinity - * - * toNumber('3.2') - * // => 3.2 - */ -export function toNumber(value: any): number { - if (typeof value === 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - const other = typeof value.valueOf === 'function' ? - value.valueOf() : - value; - value = isObject(other) ? `${other}` : other; - } - if (typeof value !== 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - const isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); -} - - diff --git a/libs/nanofn/src/cast/to-path.ts b/libs/nanofn/src/cast/to-path.ts deleted file mode 100644 index 5abc2babf..000000000 --- a/libs/nanofn/src/cast/to-path.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../arr/map'; -import { _copyArray } from '../_internal/copy-array'; -import { isSymbol } from '../is/is-symbol'; -import { stringToPath } from '../_internal/string-to-path'; -import { _toKey } from '../_internal/to-key'; - -/** - * Converts `value` to a property path array. - * - * @category Util - * @param {*} value The value to convert. - * @returns {Array} Returns the new property path array. - * @example - * - * toPath('a.b.c') - * // => ['a', 'b', 'c'] - * - * toPath('a[0].b.c') - * // => ['a', '0', 'b', 'c'] - */ -export function toPath(value: any): string[] { - if (Array.isArray(value)) { - return map(value, _toKey); - } - return isSymbol(value) ? [value] : _copyArray(stringToPath(value)); -} - - diff --git a/libs/nanofn/src/cast/to-plain-object.ts b/libs/nanofn/src/cast/to-plain-object.ts deleted file mode 100644 index 2979b45a5..000000000 --- a/libs/nanofn/src/cast/to-plain-object.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Converts `value` to a plain object flattening inherited enumerable string - * keyed properties of `value` to own properties of the plain object. - * - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2 - * } - * - * Foo.prototype.c = 3 - * - * assign({ 'a': 1 }, new Foo) - * // => { 'a': 1, 'b': 2 } - * - * assign({ 'a': 1 }, toPlainObject(new Foo)) - * // => { 'a': 1, 'b': 2, 'c': 3 } - */ -export function toPlainObject(value: any): Record { - value = Object(value); - const result: Record = {}; - for (const key in value) { - result[key] = value[key]; - } - return result; -} - - diff --git a/libs/nanofn/src/cast/to-safe-integer.ts b/libs/nanofn/src/cast/to-safe-integer.ts deleted file mode 100644 index 83f806c3d..000000000 --- a/libs/nanofn/src/cast/to-safe-integer.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { toInteger } from './to-integer'; - -/** Used as references for various `Number` constants. */ -const MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Converts `value` to a safe integer. A safe integer can be compared and - * represented correctly. - * - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * toSafeInteger(3.2) - * // => 3 - * - * toSafeInteger(Number.MIN_VALUE) - * // => 0 - * - * toSafeInteger(Infinity) - * // => 9007199254740991 - * - * toSafeInteger('3.2') - * // => 3 - */ -export function toSafeInteger(value: any): number { - if (!value) { - return value === 0 ? value : 0; - } - value = toInteger(value); - if (value < -MAX_SAFE_INTEGER) { - return -MAX_SAFE_INTEGER; - } - if (value > MAX_SAFE_INTEGER) { - return MAX_SAFE_INTEGER; - } - return value; -} - - diff --git a/libs/nanofn/src/cast/to-string.ts b/libs/nanofn/src/cast/to-string.ts deleted file mode 100644 index 2886426db..000000000 --- a/libs/nanofn/src/cast/to-string.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** Used as references for various `Number` constants. */ -const INFINITY = 1 / 0; - -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * toString(null) - * // => '' - * - * toString(-0) - * // => '-0' - * - * toString([1, 2, 3]) - * // => '1,2,3' - */ -export function toString(value: any): string { - if (value == null) { - return ''; - } - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value === 'string') { - return value; - } - if (Array.isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return `${value.map((other) => other == null ? other : toString(other))}`; - } - if (isSymbol(value)) { - return value.toString(); - } - const result = `${value}`; - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - - diff --git a/libs/nanofn/src/clone/clone-deep-with.ts b/libs/nanofn/src/clone/clone-deep-with.ts deleted file mode 100644 index 34647b839..000000000 --- a/libs/nanofn/src/clone/clone-deep-with.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; -const CLONE_SYMBOLS_FLAG = 4; - -/** - * This method is like `cloneWith` except that it recursively clones `value`. - * The customizer is invoked with up to four arguments - * (value [, index|key, object, stack]). - * - * @category Lang - * @param {*} value The value to recursively clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the deep cloned value. - * @see cloneWith - * @example - * - * export function customizer(value) { - * if (isElement(value)) { - * return value.cloneNode(true) - * } - * } - * - * const el = cloneDeepWith(document.body, customizer) - * - * console.log(el === document.body) - * // => false - * console.log(el.nodeName) - * // => 'BODY' - * console.log(el.childNodes.length) - * // => 20 - */ -export function cloneDeepWith(value, customizer) { - customizer = typeof customizer === 'function' ? customizer : undefined; - return _baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); -} - diff --git a/libs/nanofn/src/clone/clone-deep.ts b/libs/nanofn/src/clone/clone-deep.ts deleted file mode 100644 index 504ae350a..000000000 --- a/libs/nanofn/src/clone/clone-deep.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; -const CLONE_SYMBOLS_FLAG = 4; - -/** - * This method is like `clone` except that it recursively clones `value`. - * Object inheritance is preserved. - * - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @see clone - * @example - * - * const objects = [{ 'a': 1 }, { 'b': 2 }] - * - * const deep = cloneDeep(objects) - * console.log(deep[0] === objects[0]) - * // => false - */ -export function cloneDeep(value) { - return _baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); -} - - diff --git a/libs/nanofn/src/clone/clone-with.ts b/libs/nanofn/src/clone/clone-with.ts deleted file mode 100644 index 4867aa1a8..000000000 --- a/libs/nanofn/src/clone/clone-with.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_SYMBOLS_FLAG = 4; - -/** - * This method is like `clone` except that it accepts `customizer` which - * is invoked to produce the cloned value. If `customizer` returns `undefined`, - * cloning is handled by the method instead. The `customizer` is invoked with - * one argument (value). - * - * @category Lang - * @param {*} value The value to clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the cloned value. - * @see cloneDeepWith - * @example - * - * export function customizer(value) { - * if (isElement(value)) { - * return value.cloneNode(false) - * } - * } - * - * const el = cloneWith(document.body, customizer) - * - * console.log(el === document.body) - * // => false - * console.log(el.nodeName) - * // => 'BODY' - * console.log(el.childNodes.length) - * // => 0 - */ -export function cloneWith(value, customizer) { - customizer = typeof customizer === 'function' ? customizer : undefined; - return _baseClone(value, CLONE_SYMBOLS_FLAG, customizer); -} - diff --git a/libs/nanofn/src/clone/clone.ts b/libs/nanofn/src/clone/clone.ts deleted file mode 100644 index 34a2c0e64..000000000 --- a/libs/nanofn/src/clone/clone.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_SYMBOLS_FLAG = 4; - -/** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. Object inheritance is preserved. An empty object is - * returned for uncloneable values such as error objects, functions, DOM nodes, - * and WeakMaps. - * - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @see cloneDeep - * @example - * - * const objects = [{ 'a': 1 }, { 'b': 2 }] - * - * const shallow = clone(objects) - * console.log(shallow[0] === objects[0]) - * // => true - */ -export function clone(value: any): any { - return _baseClone(value, CLONE_SYMBOLS_FLAG); -} - - diff --git a/libs/nanofn/src/collection/count-by.ts b/libs/nanofn/src/collection/count-by.ts deleted file mode 100644 index aa66241c6..000000000 --- a/libs/nanofn/src/collection/count-by.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseAssignValue } from '../_internal/base-assign-value'; -import { reduce } from './reduce'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the number of times the key was returned by `iteratee`. The - * iteratee is invoked with one argument: (value). - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'betty', 'active': true }, - * { 'user': 'fred', 'active': false } - * ] - * - * countBy(users, value => value.active); - * // => { 'true': 2, 'false': 1 } - */ -export function countBy(collection: any[] | Record, - iteratee: (value: any) => any): any { - return reduce(collection, (result, value, key) => { - key = iteratee(value); - if (hasOwnProperty.call(result, key)) { - ++result[key]; - } else { - _baseAssignValue(result, key, 1); - } - return result; - }, {}); -} - - diff --git a/libs/nanofn/src/collection/find-last.ts b/libs/nanofn/src/collection/find-last.ts deleted file mode 100644 index e022b9de0..000000000 --- a/libs/nanofn/src/collection/find-last.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { findLastIndex } from '../arr/find-last-index'; -import { isArrayLike } from '../is/is-array-like'; - -/** - * This method is like `find` except that it iterates over elements of - * `collection` from right to left. - * - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} [fromIndex=collection.length-1] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @see find, findIndex, findKey, findLastIndex, findLastKey - * @example - * - * findLast([1, 2, 3, 4], n => n % 2 == 1) - * // => 3 - */ -export function findLast(collection, predicate, fromIndex) { - let iteratee; - const iterable = Object(collection); - if (!isArrayLike(collection)) { - collection = Object.keys(collection); - iteratee = predicate; - predicate = (key) => iteratee(iterable[key], key, iterable); - } - const index = findLastIndex(collection, predicate, fromIndex); - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; -} - - diff --git a/libs/nanofn/src/collection/for-each-right.ts b/libs/nanofn/src/collection/for-each-right.ts deleted file mode 100644 index 4879c9f65..000000000 --- a/libs/nanofn/src/collection/for-each-right.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { arrayEachRight } from './_internal/array-each-right'; -import { baseEachRight } from './_internal/base-each-right'; - -/** - * This method is like `forEach` except that it iterates over elements of - * `collection` from right to left. - * - * @alias eachRight - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see forEach, forIn, forInRight, forOwn, forOwnRight - * @example - * - * forEachRight([1, 2], value => console.log(value)) - * // => Logs `2` then `1`. - */ -export function forEachRight(collection, iteratee) { - const func = Array.isArray(collection) ? arrayEachRight : baseEachRight; - return func(collection, iteratee); -} - - diff --git a/libs/nanofn/src/collection/for-each.ts b/libs/nanofn/src/collection/for-each.ts deleted file mode 100644 index e6112db6c..000000000 --- a/libs/nanofn/src/collection/for-each.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { arrayEach } from './_internal/array-each'; -import { baseEach } from './_internal/base-each'; - -/** - * Iterates over elements of `collection` and invokes `iteratee` for each element. - * The iteratee is invoked with three arguments: (value, index|key, collection). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" - * property are iterated like arrays. To avoid this behavior use `forIn` - * or `forOwn` for object iteration. - * - * @alias each - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see forEachRight, forIn, forInRight, forOwn, forOwnRight - * @example - * - * forEach([1, 2], value => console.log(value)) - * // => Logs `1` then `2`. - * - * forEach({ 'a': 1, 'b': 2 }, (value, key) => console.log(key)) - * // => Logs 'a' then 'b' (iteration order is not guaranteed). - */ -export function forEach(collection, iteratee) { - const func = Array.isArray(collection) ? arrayEach : baseEach; - return func(collection, iteratee); -} - - diff --git a/libs/nanofn/src/collection/group-by.ts b/libs/nanofn/src/collection/group-by.ts deleted file mode 100644 index 4a78d1387..000000000 --- a/libs/nanofn/src/collection/group-by.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseAssignValue } from './_internal/base-assign-value'; -import { reduce } from './reduce'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The order of grouped values - * is determined by the order they occur in `collection`. The corresponding - * value of each key is an array of elements responsible for generating the - * key. The iteratee is invoked with one argument: (value). - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * groupBy([6.1, 4.2, 6.3], Math.floor) - * // => { '4': [4.2], '6': [6.1, 6.3] } - */ -export function groupBy(collection, iteratee) { - return reduce(collection, (result, value, key) => { - key = iteratee(value); - if (hasOwnProperty.call(result, key)) { - result[key].push(value); - } else { - baseAssignValue(result, key, [value]); - } - return result; - }, {}); -} - - diff --git a/libs/nanofn/src/collection/invoke-map.ts b/libs/nanofn/src/collection/invoke-map.ts deleted file mode 100644 index 36855a906..000000000 --- a/libs/nanofn/src/collection/invoke-map.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseEach } from './_internal/base-each'; -import { invoke } from './invoke'; -import { isArrayLike } from './is-array-like'; - -/** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `path` is a function, it's invoked - * for, and `this` bound to, each element in `collection`. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the export function invoked per iteration. - * @param {Array} [args] The arguments to invoke each method with. - * @returns {Array} Returns the array of results. - * @example - * - * invokeMap([[5, 1, 7], [3, 2, 1]], 'sort') - * // => [[1, 5, 7], [1, 2, 3]] - * - * invokeMap([123, 456], String.prototype.split, ['']) - * // => [['1', '2', '3'], ['4', '5', '6']] - */ -export function invokeMap(collection, path, args) { - let index = -1; - const isFunc = typeof path === 'function'; - const result = isArrayLike(collection) ? new Array(collection.length) : []; - - _baseEach(collection, (value) => { - result[++index] = isFunc ? path.apply(value, args) : invoke(value, path, args); - }); - return result; -} diff --git a/libs/nanofn/src/collection/key-by.ts b/libs/nanofn/src/collection/key-by.ts deleted file mode 100644 index 158dc2ff4..000000000 --- a/libs/nanofn/src/collection/key-by.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseAssignValue } from '../_internal/base-assign-value'; -import { reduce } from './reduce'; - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the last element responsible for generating the key. The - * iteratee is invoked with one argument: (value). - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @see groupBy, partition - * @example - * - * const array = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ] - * - * keyBy(array, ({ code }) => String.fromCharCode(code)) - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - */ -export function keyBy(collection, iteratee) { - return reduce(collection, (result, value, key) => ( - _baseAssignValue(result, iteratee(value), value), result - ), {}); -} - - diff --git a/libs/nanofn/src/collection/order-by.ts b/libs/nanofn/src/collection/order-by.ts deleted file mode 100644 index dbe75992f..000000000 --- a/libs/nanofn/src/collection/order-by.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseOrderBy } from '../_internal/base-order-by'; - -/** - * This method is like `sortBy` except that it allows specifying the sort - * orders of the iteratees to sort by. If `orders` is unspecified, all values - * are sorted in ascending order. Otherwise, specify an order of "desc" for - * descending or "asc" for ascending sort order of corresponding values. - * You may also specify a compare function for an order. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[identity]] - * The iteratees to sort by. - * @param {(string|function)[]} [orders] The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - * @see reverse - * @example - * - * const users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } - * ] - * - * // Sort by `user` in ascending order and by `age` in descending order. - * orderBy(users, ['user', 'age'], ['asc', 'desc']) - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - * - * // Sort by `user` then by `age` using custom compare functions for each - * orderBy(users, ['user', 'age'], [ - * (a, b) => a.localeCompare(b, 'de', { sensitivity: 'base' }), - * (a, b) => a - b, - * ]) - * - */ -export function orderBy(collection: any[], iteratees: any[], orders: any[]) { - if (collection == null) { - return []; - } - if (!Array.isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - if (!Array.isArray(orders)) { - orders = orders == null ? [] : [orders]; - } - return _baseOrderBy(collection, iteratees, orders); -} - - diff --git a/libs/nanofn/src/collection/partition.ts b/libs/nanofn/src/collection/partition.ts deleted file mode 100644 index 17bfb34eb..000000000 --- a/libs/nanofn/src/collection/partition.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { reduce } from './reduce'; - -/** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, the second of which - * contains elements `predicate` returns falsey for. The predicate is - * invoked with one argument: (value). - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the array of grouped elements. - * @see groupBy, keyBy - * @example - * - * const users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } - * ] - * - * partition(users, ({ active }) => active) - * // => objects for [['fred'], ['barney', 'pebbles']] - */ -export function partition(collection, predicate) { - return reduce(collection, (result, value, key) => ( - result[predicate(value) ? 0 : 1].push(value), result - ), [[], []]); -} - - diff --git a/libs/nanofn/src/collection/reduce-right.ts b/libs/nanofn/src/collection/reduce-right.ts deleted file mode 100644 index b33eb886a..000000000 --- a/libs/nanofn/src/collection/reduce-right.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _arrayReduceRight } from '../_internal/array-reduce-right'; -import { _baseEachRight } from '../_internal/base-each-right'; -import { _baseReduce } from '../_internal/base-reduce'; - -/** - * This method is like `reduce` except that it iterates over elements of - * `collection` from right to left. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see reduce - * @example - * - * const array = [[0, 1], [2, 3], [4, 5]] - * - * reduceRight(array, (flattened, other) => flattened.concat(other), []) - * // => [4, 5, 2, 3, 0, 1] - */ -export function reduceRight(collection, iteratee, accumulator) { - const func = Array.isArray(collection) ? _arrayReduceRight : _baseReduce; - const initAccum = arguments.length < 3; - return func(collection, iteratee, accumulator, initAccum, _baseEachRight); -} - - diff --git a/libs/nanofn/src/collection/reduce.ts b/libs/nanofn/src/collection/reduce.ts deleted file mode 100644 index db72d02f8..000000000 --- a/libs/nanofn/src/collection/reduce.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _arrayReduce } from '../_internal/array-reduce'; -import { _baseEach } from '../_internal/base-each'; -import { _baseReduce } from '../_internal/base-reduce'; - -/** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` thru `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not given, the first element of `collection` is used as the initial - * value. The iteratee is invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `reduce`, `reduceRight`, and `transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, - * and `sortBy` - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see reduceRight, transform - * @example - * - * reduce([1, 2], (sum, n) => sum + n, 0) - * // => 3 - * - * reduce({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => { - * (result[value] || (result[value] = [])).push(key) - * return result - * }, {}) - * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) - */ -export function reduce(collection, iteratee, accumulator) { - const func = Array.isArray(collection) ? _arrayReduce : _baseReduce; - const initAccum = arguments.length < 3; - return func(collection, iteratee, accumulator, initAccum, _baseEach); -} - - diff --git a/libs/nanofn/src/collection/reject.ts b/libs/nanofn/src/collection/reject.ts deleted file mode 100644 index 06290e8b8..000000000 --- a/libs/nanofn/src/collection/reject.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { filter } from '../arr/filter'; -import { negate } from '../fun/negate'; -import { filterObject } from '../obj/filter-object'; - -/** - * The opposite of `filter` this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. - * - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, filter - * @example - * - * const users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ] - * - * reject(users, ({ active }) => active) - * // => objects for ['fred'] - */ -export function reject(collection, predicate) { - const func = Array.isArray(collection) ? filter : filterObject; - return func(collection, negate(predicate)); -} - - diff --git a/libs/nanofn/src/collection/size.ts b/libs/nanofn/src/collection/size.ts deleted file mode 100644 index 2395975ba..000000000 --- a/libs/nanofn/src/collection/size.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { getTag } from './_internal/get-tag'; -import { isArrayLike } from './is-array-like'; -import { isString } from './is-string'; -import { stringSize } from './_internal/string-size'; - -/** `Object#toString` result references. */ -const mapTag = '[object Map]'; -const setTag = '[object Set]'; - -/** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable string keyed properties for objects. - * - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the collection size. - * @example - * - * size([1, 2, 3]) - * // => 3 - * - * size({ 'a': 1, 'b': 2 }) - * // => 2 - * - * size('pebbles') - * // => 7 - */ -export function size(collection) { - if (collection == null) { - return 0; - } - if (isArrayLike(collection)) { - return isString(collection) ? stringSize(collection) : collection.length; - } - const tag = getTag(collection); - if (tag == mapTag || tag == setTag) { - return collection.size; - } - return Object.keys(collection).length; -} - - diff --git a/libs/nanofn/src/is/is-arguments.ts b/libs/nanofn/src/is/is-arguments.ts deleted file mode 100644 index d9e88af0b..000000000 --- a/libs/nanofn/src/is/is-arguments.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is likely an `arguments` object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, else `false`. - * @example - * - * isArguments(function() { return arguments }()) - * // => true - * - * isArguments([1, 2, 3]) - * // => false - */ -export function isArguments(val: any): val is IArguments { - return isObjectLike(val) && _getTag(val) == '[object Arguments]'; -} - - diff --git a/libs/nanofn/src/is/is-array-buffer.ts b/libs/nanofn/src/is/is-array-buffer.ts deleted file mode 100644 index 8f5404447..000000000 --- a/libs/nanofn/src/is/is-array-buffer.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; -import { nodeTypes } from '../_internal/node-types'; - -/* Node.js helper references. */ -const nodeIsArrayBuffer = nodeTypes && nodeTypes.isArrayBuffer; - -/** - * Checks if `value` is classified as an `ArrayBuffer` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - * @example - * - * isArrayBuffer(new ArrayBuffer(2)) - * // => true - * - * isArrayBuffer(new Array(2)) - * // => false - */ -export const isArrayBuffer = nodeIsArrayBuffer - ? (value) => nodeIsArrayBuffer(value) - : (value) => isObjectLike(value) && _getTag(value) == '[object ArrayBuffer]'; diff --git a/libs/nanofn/src/is/is-array-like-object.ts b/libs/nanofn/src/is/is-array-like-object.ts deleted file mode 100644 index 5effaf863..000000000 --- a/libs/nanofn/src/is/is-array-like-object.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isArrayLike } from './is-array-like'; -import { isObjectLike } from './is-object-like'; - -/** - * This method is like `isArrayLike` except that it also checks if `value` - * is an object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * isArrayLikeObject([1, 2, 3]) - * // => true - * - * isArrayLikeObject(document.body.children) - * // => true - * - * isArrayLikeObject('abc') - * // => false - * - * isArrayLikeObject(Function) - * // => false - */ -export function isArrayLikeObject(value: any): value is ArrayLike { - return isObjectLike(value) && isArrayLike(value); -} - - diff --git a/libs/nanofn/src/is/is-array-like.ts b/libs/nanofn/src/is/is-array-like.ts deleted file mode 100644 index 6100bdbe2..000000000 --- a/libs/nanofn/src/is/is-array-like.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isLength } from './is-length'; - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * isArrayLike([1, 2, 3]) - * // => true - * - * isArrayLike(document.body.children) - * // => true - * - * isArrayLike('abc') - * // => true - * - * isArrayLike(Function) - * // => false - */ -export function isArrayLike(value: any) { - return value != null && typeof value !== 'function' && isLength(value.length); -} - - diff --git a/libs/nanofn/src/is/is-boolean.ts b/libs/nanofn/src/is/is-boolean.ts deleted file mode 100644 index 2b57427d8..000000000 --- a/libs/nanofn/src/is/is-boolean.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is classified as a boolean primitive or object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. - * @example - * - * isBoolean(false) - * // => true - * - * isBoolean(null) - * // => false - */ -export function isBoolean(value: any): value is boolean { - return value === true || value === false || - (isObjectLike(value) && _getTag(value) == '[object Boolean]'); -} - - diff --git a/libs/nanofn/src/is/is-buffer.ts b/libs/nanofn/src/is/is-buffer.ts deleted file mode 100644 index 7b7e60ee4..000000000 --- a/libs/nanofn/src/is/is-buffer.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { root } from '../_internal/root'; - -/** Detect free variable `exports`. */ -const freeExports = typeof exports === 'object' && exports !== null && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -const freeModule = freeExports && typeof module === 'object' && module !== null && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -const moduleExports = freeModule && freeModule.exports === freeExports; - -/** Built-in value references. */ -const Buffer = moduleExports ? root.Buffer : undefined; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - -/** - * Checks if `value` is a buffer. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * isBuffer(new Buffer(2)) - * // => true - * - * isBuffer(new Uint8Array(2)) - * // => false - */ -export const isBuffer = nativeIsBuffer || (() => false); diff --git a/libs/nanofn/src/is/is-date.ts b/libs/nanofn/src/is/is-date.ts deleted file mode 100644 index 5cb5b9b51..000000000 --- a/libs/nanofn/src/is/is-date.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { nodeTypes } from '../_internal/node-types'; -import { isObjectLike } from './is-object-like'; - -/* Node.js helper references. */ -const nodeIsDate = nodeTypes && nodeTypes.isDate; - -/** - * Checks if `value` is classified as a `Date` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - * @example - * - * isDate(new Date) - * // => true - * - * isDate('Mon April 23 2012') - * // => false - */ -export const isDate = nodeIsDate - ? (value) => nodeIsDate(value) - : (value) => isObjectLike(value) && _getTag(value) == '[object Date]'; diff --git a/libs/nanofn/src/is/is-element.ts b/libs/nanofn/src/is/is-element.ts deleted file mode 100644 index 8a49db3cb..000000000 --- a/libs/nanofn/src/is/is-element.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isObjectLike } from './is-object-like'; -import { isPlainObject } from './is-plain-object'; - -/** - * Checks if `value` is likely a DOM element. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. - * @example - * - * isElement(document.body) - * // => true - * - * isElement('') - * // => false - */ -export function isElement(val: any): val is Element { - return isObjectLike(val) && (val as Element).nodeType === 1 && !isPlainObject(val); -} - - diff --git a/libs/nanofn/src/is/is-empty.ts b/libs/nanofn/src/is/is-empty.ts deleted file mode 100644 index 8a7b8c13e..000000000 --- a/libs/nanofn/src/is/is-empty.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isArguments } from './is-arguments'; -import { isArrayLike } from './is-array-like'; -import { isBuffer } from './is-buffer'; -import { _isPrototype } from '../_internal/is-prototype'; -import { isTypedArray } from './is-typed-array'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Checks if `value` is an empty object, collection, map, or set. - * - * Objects are considered empty if they have no own enumerable string keyed - * properties. - * - * Array-like values such as `arguments` objects, arrays, buffers, strings, or - * jQuery-like collections are considered empty if they have a `length` of `0`. - * Similarly, maps and sets are considered empty if they have a `size` of `0`. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * isEmpty(null) - * // => true - * - * isEmpty(true) - * // => true - * - * isEmpty(1) - * // => true - * - * isEmpty([1, 2, 3]) - * // => false - * - * isEmpty('abc') - * // => false - * - * isEmpty({ 'a': 1 }) - * // => false - */ -export function isEmpty(value: any): boolean { - if (value == null) { - return true; - } - if (isArrayLike(value) && - (Array.isArray(value) || typeof value === 'string' || typeof value.splice === 'function' || - isBuffer(value) || isTypedArray(value) || isArguments(value))) { - return !value.length; - } - const tag = _getTag(value); - if (tag == '[object Map]' || tag == '[object Set]') { - return !value.size; - } - if (_isPrototype(value)) { - return !Object.keys(value).length; - } - for (const key in value) { - if (hasOwnProperty.call(value, key)) { - return false; - } - } - return true; -} - - diff --git a/libs/nanofn/src/is/is-equal-with.ts b/libs/nanofn/src/is/is-equal-with.ts deleted file mode 100644 index aa3629209..000000000 --- a/libs/nanofn/src/is/is-equal-with.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsEqual } from '../_internal/base-is-equal'; - -/** - * This method is like `isEqual` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with up to - * six arguments: (objValue, othValue [, index|key, object, other, stack]). - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * export function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value) - * } - * - * function customizer(objValue, othValue) { - * if (isGreeting(objValue) && isGreeting(othValue)) { - * return true - * } - * } - * - * const array = ['hello', 'goodbye'] - * const other = ['hi', 'goodbye'] - * - * isEqualWith(array, other, customizer) - * // => true - */ -export function isEqualWith(value: any, other: any, - customizer?: (value: any, other: any) => boolean | void): boolean { - customizer = typeof customizer === 'function' ? customizer : undefined; - const result = customizer ? customizer(value, other) : undefined; - return result === undefined ? _baseIsEqual(value, other, undefined, customizer) : !!result; -} diff --git a/libs/nanofn/src/is/is-error.ts b/libs/nanofn/src/is/is-error.ts deleted file mode 100644 index ccaef061e..000000000 --- a/libs/nanofn/src/is/is-error.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; -import { isPlainObject } from './is-plain-object'; - -/** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * isError(new Error) - * // => true - * - * isError(Error) - * // => false - */ -export function isError(value) { - if (!isObjectLike(value)) { - return false; - } - const tag = _getTag(value); - return tag == '[object Error]' || tag == '[object DOMException]' || - (typeof value.message === 'string' && typeof value.name === 'string' && !isPlainObject(value)); -} - - diff --git a/libs/nanofn/src/is/is-function.ts b/libs/nanofn/src/is/is-function.ts deleted file mode 100644 index 82507361a..000000000 --- a/libs/nanofn/src/is/is-function.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is classified as a `Function` object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * isFunction(class Any{}) - * // => true - * - * isFunction(() => {}) - * // => true - * - * isFunction(async () => {}) - * // => true - * - * isFunction(function * Any() {}) - * // => true - * - * isFunction(Math.round) - * // => true - * - * isFunction(/abc/) - * // => false - */ -export function isFunction(val: any): val is Function { - return typeof val === 'function'; -} - - diff --git a/libs/nanofn/src/is/is-length.ts b/libs/nanofn/src/is/is-length.ts deleted file mode 100644 index 296fbc70f..000000000 --- a/libs/nanofn/src/is/is-length.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used as references for various `Number` constants. */ -const MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * isLength(3) - * // => true - * - * isLength(Number.MIN_VALUE) - * // => false - * - * isLength(Infinity) - * // => false - * - * isLength('3') - * // => false - */ -export function isLength(value: any): boolean { - return typeof value === 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - - diff --git a/libs/nanofn/src/is/is-map.ts b/libs/nanofn/src/is/is-map.ts deleted file mode 100644 index 3b26a2bfa..000000000 --- a/libs/nanofn/src/is/is-map.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; -import { nodeTypes } from '../_internal/node-types'; - -/* Node.js helper references. */ -const nodeIsMap = nodeTypes && nodeTypes.isMap; - -/** - * Checks if `value` is classified as a `Map` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - * @example - * - * isMap(new Map) - * // => true - * - * isMap(new WeakMap) - * // => false - */ -export const isMap = nodeIsMap - ? (value) => nodeIsMap(value) - : (value) => isObjectLike(value) && _getTag(value) == '[object Map]'; diff --git a/libs/nanofn/src/is/is-match-with.ts b/libs/nanofn/src/is/is-match-with.ts deleted file mode 100644 index 69a78fd77..000000000 --- a/libs/nanofn/src/is/is-match-with.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsMatch } from '../_internal/base-is-match'; -import { _getMatchData } from '../_internal/get-match-data'; - -/** - * This method is like `isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with five - * arguments: (objValue, srcValue, index|key, object, source). - * - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * export function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value) - * } - * - * function customizer(objValue, srcValue) { - * if (isGreeting(objValue) && isGreeting(srcValue)) { - * return true - * } - * } - * - * const object = { 'greeting': 'hello' } - * const source = { 'greeting': 'hi' } - * - * isMatchWith(object, source, customizer) - * // => true - */ -function isMatchWith(object, source, customizer) { - customizer = typeof customizer === 'function' ? customizer : undefined; - return _baseIsMatch(object, source, _getMatchData(source), customizer); -} - -MatchWith; diff --git a/libs/nanofn/src/is/is-match.ts b/libs/nanofn/src/is/is-match.ts deleted file mode 100644 index 892eb439f..000000000 --- a/libs/nanofn/src/is/is-match.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseIsMatch } from '../_internal/base-is-match'; -import { _getMatchData } from '../_internal/get-match-data'; - -/** - * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. - * - * **Note:** This method is equivalent to `matches` when `source` is - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `isEqual` - * for a list of supported value comparisons. - * - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * const object = { 'a': 1, 'b': 2 } - * - * isMatch(object, { 'b': 2 }) - * // => true - * - * isMatch(object, { 'b': 1 }) - * // => false - */ -export function isMatch(object, source) { - return object === source || _baseIsMatch(object, source, _getMatchData(source)); -} - - diff --git a/libs/nanofn/src/is/is-native.ts b/libs/nanofn/src/is/is-native.ts deleted file mode 100644 index 198be007e..000000000 --- a/libs/nanofn/src/is/is-native.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isObject } from './is-object'; - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to detect if a method is native. */ -const reIsNative = RegExp(`^${ - Function.prototype.toString.call(Object.prototype.hasOwnProperty) - .replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') -}$`); - -/** - * Checks if `value` is a pristine native function. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * isNative(Array.prototype.push) - * // => true - * - * isNative(isDate) - * // => false - */ -export function isNative(value) { - return isObject(value) && reIsNative.test(value); -} - - diff --git a/libs/nanofn/src/is/is-nil.ts b/libs/nanofn/src/is/is-nil.ts deleted file mode 100644 index 61c076392..000000000 --- a/libs/nanofn/src/is/is-nil.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is `null` or `undefined`. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * isNil(null) - * // => true - * - * isNil(void 0) - * // => true - * - * isNil(NaN) - * // => false - */ -export function isNil(value: any): boolean { - return value == null; -} - - diff --git a/libs/nanofn/src/is/is-null.ts b/libs/nanofn/src/is/is-null.ts deleted file mode 100644 index 3e4b71589..000000000 --- a/libs/nanofn/src/is/is-null.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is `null`. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is `null`, else `false`. - * @example - * - * isNull(null) - * // => true - * - * isNull(void 0) - * // => false - */ -export function isNull(val: any): val is null { - return val === null; -} - - diff --git a/libs/nanofn/src/is/is-number.ts b/libs/nanofn/src/is/is-number.ts deleted file mode 100644 index 29ade0dd6..000000000 --- a/libs/nanofn/src/is/is-number.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is classified as a `Number` primitive or object. - * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are - * classified as numbers, use the `Number.isFinite` method. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a number, else `false`. - * @see isInteger, toInteger, toNumber - * @example - * - * isNumber(3) - * // => true - * - * isNumber(Number.MIN_VALUE) - * // => true - * - * isNumber(Infinity) - * // => true - * - * isNumber('3') - * // => false - */ -export function isNumber(val: any): val is number { - return typeof val === 'number' || - (isObjectLike(val) && _getTag(val) == '[object Number]'); -} - - diff --git a/libs/nanofn/src/is/is-object-like.ts b/libs/nanofn/src/is/is-object-like.ts deleted file mode 100644 index abc4dffc3..000000000 --- a/libs/nanofn/src/is/is-object-like.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * isObjectLike({}) - * // => true - * - * isObjectLike([1, 2, 3]) - * // => true - * - * isObjectLike(Function) - * // => false - * - * isObjectLike(null) - * // => false - */ -export function isObjectLike(val: any): val is object { - return typeof val === 'object' && val !== null; -} - - diff --git a/libs/nanofn/src/is/is-object.ts b/libs/nanofn/src/is/is-object.ts deleted file mode 100644 index 6f005e116..000000000 --- a/libs/nanofn/src/is/is-object.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * isObject({}) - * // => true - * - * isObject([1, 2, 3]) - * // => true - * - * isObject(Function) - * // => true - * - * isObject(null) - * // => false - */ -export function isObject(val: any): val is object { - const type = typeof val; - return val != null && (type === 'object' || type === 'function'); -} - - diff --git a/libs/nanofn/src/is/is-plain-object.ts b/libs/nanofn/src/is/is-plain-object.ts deleted file mode 100644 index bf1ee4e71..000000000 --- a/libs/nanofn/src/is/is-plain-object.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1 - * } - * - * isPlainObject(new Foo) - * // => false - * - * isPlainObject([1, 2, 3]) - * // => false - * - * isPlainObject({ 'x': 0, 'y': 0 }) - * // => true - * - * isPlainObject(Object.create(null)) - * // => true - */ -export function isPlainObject(value: any): boolean { - if (!isObjectLike(value) || _getTag(value) != '[object Object]') { - return false; - } - if (Object.getPrototypeOf(value) === null) { - return true; - } - let proto = value; - while (Object.getPrototypeOf(proto) !== null) { - proto = Object.getPrototypeOf(proto); - } - return Object.getPrototypeOf(value) === proto; -} - - diff --git a/libs/nanofn/src/is/is-reg-exp.ts b/libs/nanofn/src/is/is-reg-exp.ts deleted file mode 100644 index cb8a5bdde..000000000 --- a/libs/nanofn/src/is/is-reg-exp.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { nodeTypes } from '../_internal/node-types'; -import { isObjectLike } from './is-object-like'; - -/* Node.js helper references. */ -const nodeIsRegExp = nodeTypes && nodeTypes.isRegExp; - -/** - * Checks if `value` is classified as a `RegExp` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - * @example - * - * isRegExp(/abc/) - * // => true - * - * isRegExp('/abc/') - * // => false - */ -export const isRegExp = nodeIsRegExp - ? (value) => nodeIsRegExp(value) - : (value) => isObjectLike(value) && _getTag(value) == '[object RegExp]'; - diff --git a/libs/nanofn/src/is/is-set.ts b/libs/nanofn/src/is/is-set.ts deleted file mode 100644 index 4a03da199..000000000 --- a/libs/nanofn/src/is/is-set.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { nodeTypes } from '../_internal/node-types'; -import { isObjectLike } from './is-object-like'; - -/* Node.js helper references. */ -const nodeIsSet = nodeTypes && nodeTypes.isSet; - -/** - * Checks if `value` is classified as a `Set` object. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - * @example - * - * isSet(new Set) - * // => true - * - * isSet(new WeakSet) - * // => false - */ -export const isSet = nodeIsSet - ? (value) => nodeIsSet(value) - : (value) => isObjectLike(value) && _getTag(value) == '[object Set]'; diff --git a/libs/nanofn/src/is/is-string.ts b/libs/nanofn/src/is/is-string.ts deleted file mode 100644 index 08756c0b1..000000000 --- a/libs/nanofn/src/is/is-string.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; - -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * isString('abc') - * // => true - * - * isString(1) - * // => false - */ -export function isString(val: any): val is string { - const type = typeof val; - return type === 'string' || - ( - type === 'object' && - val != null && - !Array.isArray(val) && _getTag(val) == '[object String]' - ); -} - - diff --git a/libs/nanofn/src/is/is-symbol.ts b/libs/nanofn/src/is/is-symbol.ts deleted file mode 100644 index c81a3f23e..000000000 --- a/libs/nanofn/src/is/is-symbol.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * isSymbol(Symbol.iterator) - * // => true - * - * isSymbol('abc') - * // => false - */ -export function isSymbol(val: any): val is symbol { - const type = typeof val; - return type == 'symbol' || (type === 'object' && val != null && _getTag( - val) == '[object Symbol]'); -} - - diff --git a/libs/nanofn/src/is/is-typed-array.ts b/libs/nanofn/src/is/is-typed-array.ts deleted file mode 100644 index d8c61044f..000000000 --- a/libs/nanofn/src/is/is-typed-array.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { nodeTypes } from '../_internal/node-types'; -import { isObjectLike } from './is-object-like'; - -/** Used to match `toStringTag` values of typed arrays. */ -const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/; - -/* Node.js helper references. */ -const nodeIsTypedArray = nodeTypes && nodeTypes.isTypedArray; - -/** - * Checks if `value` is classified as a typed array. - * - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * isTypedArray(new Uint8Array) - * // => true - * - * isTypedArray([]) - * // => false - */ -export const isTypedArray = nodeIsTypedArray - ? (value) => nodeIsTypedArray(value) - : (value) => isObjectLike(value) && reTypedTag.test(_getTag(value)); diff --git a/libs/nanofn/src/is/is-undefined.ts b/libs/nanofn/src/is/is-undefined.ts deleted file mode 100644 index bc2eabbbb..000000000 --- a/libs/nanofn/src/is/is-undefined.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is `undefined`. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * isUndefined(void 0) - * // => true - * - * isUndefined(null) - * // => false - */ -export function isUndefined(val: any): val is undefined { - return val === undefined; -} - - diff --git a/libs/nanofn/src/is/is-weak-map.ts b/libs/nanofn/src/is/is-weak-map.ts deleted file mode 100644 index 04b69c232..000000000 --- a/libs/nanofn/src/is/is-weak-map.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is classified as a `WeakMap` object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. - * @example - * - * isWeakMap(new WeakMap) - * // => true - * - * isWeakMap(new Map) - * // => false - */ -export function isWeakMap(val: any): val is WeakMap { - return isObjectLike(val) && _getTag(val) == '[object WeakMap]'; -} - - diff --git a/libs/nanofn/src/is/is-weak-set.ts b/libs/nanofn/src/is/is-weak-set.ts deleted file mode 100644 index a7568c79c..000000000 --- a/libs/nanofn/src/is/is-weak-set.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _getTag } from '../_internal/get-tag'; -import { isObjectLike } from './is-object-like'; - -/** - * Checks if `value` is classified as a `WeakSet` object. - * - * @category Lang - * @param {*} val The value to check. - * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. - * @example - * - * isWeakSet(new WeakSet) - * // => true - * - * isWeakSet(new Set) - * // => false - */ -export function isWeakSet(val: unknown): val is WeakSet { - return isObjectLike(val) && _getTag(val) == '[object WeakSet]'; -} - - diff --git a/libs/nanofn/src/lang/conforms-to.ts b/libs/nanofn/src/lang/conforms-to.ts deleted file mode 100644 index 7aa690bf3..000000000 --- a/libs/nanofn/src/lang/conforms-to.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseConformsTo } from '../_internal/base-conforms-to'; -import { keys } from './keys'; - -/** - * Checks if `object` conforms to `source` by invoking the predicate - * properties of `source` with the corresponding property values of `object`. - * - * **Note:** This method is equivalent to `conforms` when `source` is - * partially applied. - * - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - * @example - * - * const object = { 'a': 1, 'b': 2 } - * - * conformsTo(object, { 'b': function(n) { return n > 1 } }) - * // => true - * - * conformsTo(object, { 'b': function(n) { return n > 2 } }) - * // => false - */ -export function conformsTo(object, source) { - return source == null || _baseConformsTo(object, source, keys(source)); -} - - diff --git a/libs/nanofn/src/lang/eq-deep.ts b/libs/nanofn/src/lang/eq-deep.ts deleted file mode 100644 index 6b343464a..000000000 --- a/libs/nanofn/src/lang/eq-deep.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseIsEqual } from './_internal/base-is-equal'; - -/** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are compared by strict equality, i.e. `===`. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * const object = { 'a': 1 } - * const other = { 'a': 1 } - * - * isEqual(object, other) - * // => true - * - * object === other - * // => false - */ -export function isEqual(value: any, other: any): boolean { - return baseIsEqual(value, other); -} - - diff --git a/libs/nanofn/src/lang/eq.ts b/libs/nanofn/src/lang/eq.ts deleted file mode 100644 index 311280fbe..000000000 --- a/libs/nanofn/src/lang/eq.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * const object = { 'a': 1 } - * const other = { 'a': 1 } - * - * eq(object, object) - * // => true - * - * eq(object, other) - * // => false - * - * eq('a', 'a') - * // => true - * - * eq('a', Object('a')) - * // => false - * - * eq(NaN, NaN) - * // => true - */ -export function eq(value: any, other: any): boolean { - return value === other || (value !== value && other !== other); -} - - diff --git a/libs/nanofn/src/lang/gt.ts b/libs/nanofn/src/lang/gt.ts deleted file mode 100644 index c20655735..000000000 --- a/libs/nanofn/src/lang/gt.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is greater than `other`. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - * @see gte, lt, lte - * @example - * - * gt(3, 1) - * // => true - * - * gt(3, 3) - * // => false - * - * gt(1, 3) - * // => false - */ -export function gt(value, other) { - if (!(typeof value === 'string' && typeof other === 'string')) { - value = +value; - other = +other; - } - return value > other; -} - - diff --git a/libs/nanofn/src/lang/gte.ts b/libs/nanofn/src/lang/gte.ts deleted file mode 100644 index 649faf9d0..000000000 --- a/libs/nanofn/src/lang/gte.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is greater than or equal to `other`. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to - * `other`, else `false`. - * @see gt, lt, lte - * @example - * - * gte(3, 1) - * // => true - * - * gte(3, 3) - * // => true - * - * gte(1, 3) - * // => false - */ -export function gte(value, other) { - if (!(typeof value === 'string' && typeof other === 'string')) { - value = +value; - other = +other; - } - return value >= other; -} - - diff --git a/libs/nanofn/src/lang/lt.ts b/libs/nanofn/src/lang/lt.ts deleted file mode 100644 index 750fb8aa7..000000000 --- a/libs/nanofn/src/lang/lt.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is less than `other`. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - * @see gt, gte, lte - * @example - * - * lt(1, 3) - * // => true - * - * lt(3, 3) - * // => false - * - * lt(3, 1) - * // => false - */ -export function lt(value, other) { - if (!(typeof value === 'string' && typeof other === 'string')) { - value = +value; - other = +other; - } - return value < other; -} - - diff --git a/libs/nanofn/src/lang/lte.ts b/libs/nanofn/src/lang/lte.ts deleted file mode 100644 index dd3418078..000000000 --- a/libs/nanofn/src/lang/lte.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `value` is less than or equal to `other`. - * - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to - * `other`, else `false`. - * @see gt, gte, lt - * @example - * - * lte(1, 3) - * // => true - * - * lte(3, 3) - * // => true - * - * lte(3, 1) - * // => false - */ -export function lte(value, other) { - if (!(typeof value === 'string' && typeof other === 'string')) { - value = +value; - other = +other; - } - return value <= other; -} - - diff --git a/libs/nanofn/src/math/add.ts b/libs/nanofn/src/math/add.ts deleted file mode 100644 index 8adcd6329..000000000 --- a/libs/nanofn/src/math/add.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createMathOperation } from '../_internal/create-math-operation'; - -/** - * Adds two numbers. - * - * @category Math - * @param {number} augend The first number in an addition. - * @param {number} addend The second number in an addition. - * @returns {number} Returns the total. - * @example - * - * add(6, 4) - * // => 10 - */ -export type add = (augend: number, addend: number) => number; -export const add = _createMathOperation((augend: number, addend: number) => augend + addend, 0); diff --git a/libs/nanofn/src/math/ceil.ts b/libs/nanofn/src/math/ceil.ts deleted file mode 100644 index 02a4903fe..000000000 --- a/libs/nanofn/src/math/ceil.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createRound } from '../_internal/create-round'; - -/** - * Computes `number` rounded up to `precision`. (Round up: the smallest integer greater than or equal to a given number.) - * - * @category Math - * @param {number} number The number to round up. - * @param {number} [precision=0] The precision to round up to. - * @returns {number} Returns the rounded up number. - * @example - * - * ceil(4.006) - * // => 5 - * - * ceil(6.004, 2) - * // => 6.01 - * - * ceil(6040, -2) - * // => 6100 - */ -export type ceil = (num: number, precision?: number) => number; -export const ceil = _createRound('ceil'); diff --git a/libs/nanofn/src/math/divide.ts b/libs/nanofn/src/math/divide.ts deleted file mode 100644 index 5ff34c436..000000000 --- a/libs/nanofn/src/math/divide.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createMathOperation } from '../_internal/create-math-operation'; - -/** - * Divide two numbers. - * - * @category Math - * @param {number} dividend The first number in a division. - * @param {number} divisor The second number in a division. - * @returns {number} Returns the quotient. - * @example - * - * divide(6, 4) - * // => 1.5 - */ -export type divide = (num: number, precision?: number) => number; -export const divide = _createMathOperation( - (dividend: number, divisor: number) => dividend / divisor, 1); diff --git a/libs/nanofn/src/math/floor.ts b/libs/nanofn/src/math/floor.ts deleted file mode 100644 index 0eea37f4c..000000000 --- a/libs/nanofn/src/math/floor.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createRound } from '../_internal/create-round'; - -/** - * Computes `number` rounded down to `precision`. - * - * @category Math - * @param {number} number The number to round down. - * @param {number} [precision=0] The precision to round down to. - * @returns {number} Returns the rounded down number. - * @example - * - * floor(4.006) - * // => 4 - * - * floor(0.046, 2) - * // => 0.04 - * - * floor(4060, -2) - * // => 4000 - */ -export type floor = (num: number, precision?: number) => number; -export const floor = _createRound('floor'); diff --git a/libs/nanofn/src/math/max-by.ts b/libs/nanofn/src/math/max-by.ts deleted file mode 100644 index d5d66aa8b..000000000 --- a/libs/nanofn/src/math/max-by.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** - * This method is like `max` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). - * - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {*} Returns the maximum value. - * @example - * - * const objects = [{ 'n': 1 }, { 'n': 2 }] - * - * maxBy(objects, ({ n }) => n) - * // => { 'n': 2 } - */ -export function maxBy(array: any[], iteratee: (value: any) => number): any { - let result; - if (array == null) { - return result; - } - let computed; - for (const value of array) { - const current = iteratee(value); - - if (current != null && (computed === undefined - ? (current === current && !isSymbol(current)) - : (current > computed) - )) { - computed = current; - result = value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/math/mean-by.ts b/libs/nanofn/src/math/mean-by.ts deleted file mode 100644 index 2d35c8b14..000000000 --- a/libs/nanofn/src/math/mean-by.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSum } from '../_internal/base-sum'; - -/** Used as references for various `Number` constants. */ -const NAN = 0 / 0; - -/** - * This method is like `mean` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be averaged. - * The iteratee is invoked with one argument: (value). - * - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {number} Returns the mean. - * @example - * - * const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }] - * - * meanBy(objects, ({ n }) => n) - * // => 5 - */ -export function meanBy(array: any[], iteratee: (value: any) => number): number { - const length = array == null ? 0 : array.length; - return length ? (_baseSum(array, iteratee) / length) : NAN; -} - - diff --git a/libs/nanofn/src/math/mean.ts b/libs/nanofn/src/math/mean.ts deleted file mode 100644 index c2c601b67..000000000 --- a/libs/nanofn/src/math/mean.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { meanBy as baseMean } from './mean-by'; - -/** - * Computes the mean of the values in `array`. - * - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the mean. - * @example - * - * mean([4, 2, 8, 6]) - * // => 5 - */ -export function mean(array) { - return baseMean(array, (value) => value); -} - - diff --git a/libs/nanofn/src/math/min-by.ts b/libs/nanofn/src/math/min-by.ts deleted file mode 100644 index 238dae3c0..000000000 --- a/libs/nanofn/src/math/min-by.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isSymbol } from '../is/is-symbol'; - -/** - * This method is like `min` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). - * - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {*} Returns the minimum value. - * @example - * - * const objects = [{ 'n': 1 }, { 'n': 2 }] - * - * minBy(objects, ({ n }) => n) - * // => { 'n': 1 } - */ -export function minBy(array: any[], iteratee: (value: any) => number): any { - let result; - if (array == null) { - return result; - } - let computed; - for (const value of array) { - const current = iteratee(value); - - if (current != null && (computed === undefined - ? (current === current && !isSymbol(current)) - : (current < computed) - )) { - computed = current; - result = value; - } - } - return result; -} - - diff --git a/libs/nanofn/src/math/multiply.ts b/libs/nanofn/src/math/multiply.ts deleted file mode 100644 index 0693bfca4..000000000 --- a/libs/nanofn/src/math/multiply.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createMathOperation } from '../_internal/create-math-operation'; - -/** - * Multiply two numbers. - * - * @category Math - * @param {number} multiplier The first number in a multiplication. - * @param {number} multiplicand The second number in a multiplication. - * @returns {number} Returns the product. - * @example - * - * multiply(6, 4) - * // => 24 - */ -const multiply = _createMathOperation((multiplier, multiplicand) => multiplier * multiplicand, 1); - -export default multiply; diff --git a/libs/nanofn/src/math/round.ts b/libs/nanofn/src/math/round.ts deleted file mode 100644 index c8a8bf560..000000000 --- a/libs/nanofn/src/math/round.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createRound } from '../_internal/create-round'; - -/** - * Computes `number` rounded to `precision`. - * - * @category Math - * @param {number} number The number to round. - * @param {number} [precision=0] The precision to round to. - * @returns {number} Returns the rounded number. - * @example - * - * round(4.006) - * // => 4 - * - * round(4.006, 2) - * // => 4.01 - * - * round(4060, -2) - * // => 4100 - */ -const round = _createRound('round'); - -export default round; diff --git a/libs/nanofn/src/math/subtract.ts b/libs/nanofn/src/math/subtract.ts deleted file mode 100644 index 060b16cc5..000000000 --- a/libs/nanofn/src/math/subtract.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createMathOperation } from '../_internal/create-math-operation'; - -/** - * Subtract two numbers. - * - * @category Math - * @param {number} minuend The first number in a subtraction. - * @param {number} subtrahend The second number in a subtraction. - * @returns {number} Returns the difference. - * @example - * - * subtract(6, 4) - * // => 2 - */ -export const subtract = _createMathOperation((minuend, subtrahend) => minuend - subtrahend, 0); diff --git a/libs/nanofn/src/math/sum-by.ts b/libs/nanofn/src/math/sum-by.ts deleted file mode 100644 index 9f11b4038..000000000 --- a/libs/nanofn/src/math/sum-by.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSum } from '../_internal/base-sum'; - -/** - * This method is like `sum` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be summed. - * The iteratee is invoked with one argument: (value). - * - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {number} Returns the sum. - * @example - * - * const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }] - * - * sumBy(objects, ({ n }) => n) - * // => 20 - */ -export function sumBy(array, iteratee) { - return (array != null && array.length) - ? _baseSum(array, iteratee) - : 0; -} - - diff --git a/libs/nanofn/src/math/sum.ts b/libs/nanofn/src/math/sum.ts deleted file mode 100644 index 757dea156..000000000 --- a/libs/nanofn/src/math/sum.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSum } from '../_internal/base-sum'; - -/** - * Computes the sum of the values in `array`. - * - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the sum. - * @example - * - * sum([4, 2, 8, 6]) - * // => 20 - */ -export function sum(array) { - return (array != null && array.length) - ? _baseSum(array, (value) => value) - : 0; -} - - diff --git a/libs/nanofn/src/num/clamp.ts b/libs/nanofn/src/num/clamp.ts deleted file mode 100644 index 3d43ca613..000000000 --- a/libs/nanofn/src/num/clamp.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Clamps `number` within the inclusive `lower` and `upper` bounds. - * - * @category Number - * @param {number} num The number to clamp. - * @param {number} lower The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. - * @example - * - * clamp(-10, -5, 5) - * // => -5 - * - * clamp(10, -5, 5) - * // => 5 - */ -export function clamp(num: number, lower: number, upper: number): number { - num = +num; - lower = +lower; - upper = +upper; - lower = lower === lower ? lower : 0; - upper = upper === upper ? upper : 0; - if (num === num) { - num = num <= upper ? num : upper; - num = num >= lower ? num : lower; - } - return num; -} - - diff --git a/libs/nanofn/src/num/in-range.ts b/libs/nanofn/src/num/in-range.ts deleted file mode 100644 index 2222a8cdf..000000000 --- a/libs/nanofn/src/num/in-range.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseInRange } from '../_internal/base-in-range'; - -/** - * Checks if `number` is between `start` and up to, but not including, `end`. If - * `end` is not specified, it's set to `start` with `start` then set to `0`. - * If `start` is greater than `end` the params are swapped to support - * negative ranges. - * - * @category Number - * @param {number} number The number to check. - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - * @see range, rangeRight - * @example - * - * inRange(3, 2, 4) - * // => true - * - * inRange(4, 8) - * // => true - * - * inRange(4, 2) - * // => false - * - * inRange(2, 2) - * // => false - * - * inRange(1.2, 2) - * // => true - * - * inRange(5.2, 4) - * // => false - * - * inRange(-3, -2, -6) - * // => true - */ -export function inRange(num: number, end: number): boolean; -export function inRange(num: number, start: number, end?: number): boolean { - if (end === undefined) { - end = start; - start = 0; - } - return _baseInRange(+num, +start, +end); -} - - diff --git a/libs/nanofn/src/num/random.ts b/libs/nanofn/src/num/random.ts deleted file mode 100644 index de621098b..000000000 --- a/libs/nanofn/src/num/random.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { toFinite } from '../cast/to-finite'; - -/** Built-in method references without a dependency on `root`. */ -const freeParseFloat = parseFloat; - -/** - * Produces a random number between the inclusive `lower` and `upper` bounds. - * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are - * floats, a floating-point number is returned instead of an integer. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. - * - * @category Number - * @param {number} [lower=0] The lower bound. - * @param {number} [upper=1] The upper bound. - * @param {boolean} [floating] Specify returning a floating-point number. - * @returns {number} Returns the random number. - * @see uniqueId - * @example - * - * random(0, 5) - * // => an integer between 0 and 5 - * - * random(5) - * // => also an integer between 0 and 5 - * - * random(5, true) - * // => a floating-point number between 0 and 5 - * - * random(1.2, 5.2) - * // => a floating-point number between 1.2 and 5.2 - */ -export function random(floating: boolean): number; -export function random(lower: number, floating?: boolean): number; -export function random(lower?: number | boolean, upper?: number | boolean, - floating?: boolean): number { - if (floating === undefined) { - if (typeof upper === 'boolean') { - floating = upper; - upper = undefined; - } else if (typeof lower === 'boolean') { - floating = lower; - lower = undefined; - } - } - if (lower === undefined && upper === undefined) { - lower = 0; - upper = 1; - } else { - lower = toFinite(lower); - if (upper === undefined) { - upper = lower; - lower = 0; - } else { - upper = toFinite(upper); - } - } - if (lower > upper) { - const temp = lower; - lower = upper; - upper = temp; - } - if (floating || (lower as number) % 1 || (upper as number) % 1) { - const rand = Math.random(); - const randLength = `${rand}`.length - 1; - return Math.min( - (lower as number) + (rand * ((upper as number) - (lower as number) + - freeParseFloat(`1e-${randLength}`))), (upper as number) - ); - } - return (lower as number) + Math.floor( - Math.random() * ((upper as number) - (lower as number) + 1)); -} - - diff --git a/libs/nanofn/src/obj/at.ts b/libs/nanofn/src/obj/at.ts deleted file mode 100644 index af379a058..000000000 --- a/libs/nanofn/src/obj/at.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseAt } from '../_internal/base-at'; -import { _baseFlatten } from '../_internal/base-flatten'; - -/** - * Creates an array of values corresponding to `paths` of `object`. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Array} Returns the picked values. - * @example - * - * const object = { 'a': [{ 'b': { 'c': 3 } }, 4] } - * - * at(object, ['a[0].b.c', 'a[1]']) - * // => [3, 4] - */ -export const at = (object, ...paths) => _baseAt(object, _baseFlatten(paths, 1)); diff --git a/libs/nanofn/src/obj/create.ts b/libs/nanofn/src/obj/create.ts deleted file mode 100644 index 18d6eee81..000000000 --- a/libs/nanofn/src/obj/create.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given, its own enumerable string keyed properties - * are assigned to the created object. - * - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0 - * this.y = 0 - * } - * - * export function Circle() { - * Shape.call(this) - * } - * - * Circle.prototype = create(Shape.prototype, { - * 'constructor': Circle - * }) - * - * const circle = new Circle - * circle instanceof Circle - * // => true - * - * circle instanceof Shape - * // => true - */ -function create(prototype, properties) { - prototype = prototype === null ? null : Object(prototype); - const result = Object.create(prototype); - return properties == null ? result : Object.assign(result, properties); -} diff --git a/libs/nanofn/src/obj/defaults-deep.ts b/libs/nanofn/src/obj/defaults-deep.ts deleted file mode 100644 index 62cec51f0..000000000 --- a/libs/nanofn/src/obj/defaults-deep.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _customDefaultsMerge } from '../_internal/custom-defaults-merge'; -import { mergeWith } from './merge-with'; - -/** - * This method is like `defaults` except that it recursively assigns - * default properties. - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see defaults - * @example - * - * defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }) - * // => { 'a': { 'b': 2, 'c': 3 } } - */ -export function defaultsDeep(...args) { - args.push(undefined, _customDefaultsMerge); - return mergeWith.apply(undefined, args); -} - - diff --git a/libs/nanofn/src/obj/defaults.ts b/libs/nanofn/src/obj/defaults.ts deleted file mode 100644 index c95921800..000000000 --- a/libs/nanofn/src/obj/defaults.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { eq } from './eq'; - -/** Used for built-in method references. */ -const objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -const hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Assigns own and inherited enumerable string keyed properties of source - * objects to the destination object for all destination properties that - * resolve to `undefined`. Source objects are applied from left to right. - * Once a property is set, additional values of the same property are ignored. - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see defaultsDeep - * @example - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }) - * // => { 'a': 1, 'b': 2 } - */ -export function defaults(object, ...sources) { - object = Object(object); - sources.forEach((source) => { - if (source != null) { - source = Object(source); - for (const key in source) { - const value = object[key]; - if (value === undefined || - (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { - object[key] = source[key]; - } - } - } - }); - return object; -} - - diff --git a/libs/nanofn/src/obj/every-value.ts b/libs/nanofn/src/obj/every-value.ts deleted file mode 100644 index a37201eaa..000000000 --- a/libs/nanofn/src/obj/every-value.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `predicate` returns truthy for **all** properties of `object`. - * Iteration is stopped once `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, key, object). - * - * **Note:** This method returns `true` for - * [empty objects](https://en.wikipedia.org/wiki/Empty_set) because - * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of - * elements of empty objects. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all properties pass the predicate check, - * else `false`. - * @example - * - * everyValue({ 'a': 0, 'b': 'yes', 'c': false }, Boolean) - * // => false - */ -export function everyValue(object, predicate) { - object = Object(object); - const props = Object.keys(object); - - for (const key of props) { - if (!predicate(object[key], key, object)) { - return false; - } - } - return true; -} - - diff --git a/libs/nanofn/src/obj/filter-object.ts b/libs/nanofn/src/obj/filter-object.ts deleted file mode 100644 index 80560ce05..000000000 --- a/libs/nanofn/src/obj/filter-object.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Iterates over properties of `object`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, key, object). - * - * If you want an object in return, consider `pickBy`. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see pickBy, pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, reject - * @example - * - * const object = { 'a': 5, 'b': 8, 'c': 10 } - * - * filterObject(object, (n) => !(n % 5)) - * // => [5, 10] - */ -export function filterObject(object, predicate) { - object = Object(object); - const result = []; - - Object.keys(object).forEach((key) => { - const value = object[key]; - if (predicate(value, key, object)) { - result.push(value); - } - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/find-key.ts b/libs/nanofn/src/obj/find-key.ts deleted file mode 100644 index 664af5e7e..000000000 --- a/libs/nanofn/src/obj/find-key.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This method is like `find` except that it returns the key of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} predicate The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @see find, findIndex, findLast, findLastIndex, findLastKey - * @example - * - * const users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * } - * - * findKey(users, ({ age }) => age < 40) - * // => 'barney' (iteration order is not guaranteed) - */ -export function findKey(object, predicate) { - let result; - if (object == null) { - return result; - } - Object.keys(object).some((key) => { - const value = object[key]; - if (predicate(value, key, object)) { - result = key; - return true; - } - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/find-last-key.ts b/libs/nanofn/src/obj/find-last-key.ts deleted file mode 100644 index a42a65932..000000000 --- a/libs/nanofn/src/obj/find-last-key.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseFindKey } from '../_internal/base-find-key'; -import { _baseForOwnRight } from '../_internal/base-for-own-right'; - -/** - * This method is like `findKey` except that it iterates over elements of - * a collection in the opposite order. - * - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} predicate The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @see find, findIndex, findKey, findLast, findLastIndex - * @example - * - * const users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * } - * - * findLastKey(users, ({ age }) => age < 40) - * // => returns 'pebbles' assuming `findKey` returns 'barney' - */ -export function findLastKey(object, predicate) { - return _baseFindKey(object, predicate, _baseForOwnRight); -} diff --git a/libs/nanofn/src/obj/for-own-right.ts b/libs/nanofn/src/obj/for-own-right.ts deleted file mode 100644 index 90ec3e88e..000000000 --- a/libs/nanofn/src/obj/for-own-right.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * This method is like `forOwn` except that it iterates over properties of - * `object` in the opposite order. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see forEach, forEachRight, forIn, forInRight, forOwn - * @example - * - * export function Foo() { - * this.a = 1 - * this.b = 2 - * } - * - * Foo.prototype.c = 3 - * - * forOwnRight(new Foo, function(value, key) { - * console.log(key) - * }) - * // => Logs 'b' then 'a' assuming `forOwn` logs 'a' then 'b'. - */ -export function forOwnRight(object, iteratee) { - if (object == null) { - return; - } - const props = Object.keys(object); - let length = props.length; - while (length--) { - iteratee(object[props[length]], iteratee, object); - } -} diff --git a/libs/nanofn/src/obj/for-own.ts b/libs/nanofn/src/obj/for-own.ts deleted file mode 100644 index 2b01c9958..000000000 --- a/libs/nanofn/src/obj/for-own.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Iterates over own enumerable string keyed properties of an object and - * invokes `iteratee` for each property. The iteratee is invoked with three - * arguments: (value, key, object). Iteratee functions may exit iteration - * early by explicitly returning `false`. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @see forEach, forEachRight, forIn, forInRight, forOwnRight - * @example - * - * export function Foo() { - * this.a = 1 - * this.b = 2 - * } - * - * Foo.prototype.c = 3 - * - * forOwn(new Foo, function(value, key) { - * console.log(key) - * }) - * // => Logs 'a' then 'b' (iteration order is not guaranteed). - */ -export function forOwn(object, iteratee) { - object = Object(object); - Object.keys(object).forEach((key) => iteratee(object[key], key, object)); -} diff --git a/libs/nanofn/src/obj/getter.ts b/libs/nanofn/src/obj/getter.ts deleted file mode 100644 index e276e4866..000000000 --- a/libs/nanofn/src/obj/getter.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from '../_internal/base-get'; - -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @see has, hasIn, set, unset - * @example - * - * const object = { 'a': [{ 'b': { 'c': 3 } }] } - * - * get(object, 'a[0].b.c') - * // => 3 - * - * get(object, ['a', '0', 'b', 'c']) - * // => 3 - * - * get(object, 'a.b.c', 'default') - * // => 'default' - */ -export function getter(object: Record, path: string, defaultValue?: any): any { - const result = object == null ? undefined : _baseGet(object, path); - return result === undefined ? defaultValue : result; -} - - diff --git a/libs/nanofn/src/obj/has-in.ts b/libs/nanofn/src/obj/has-in.ts deleted file mode 100644 index eae21222c..000000000 --- a/libs/nanofn/src/obj/has-in.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `path` is a direct or inherited property of `object`. - * - * @category Object - * @param {Object} object The object to query. - * @param {string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - * @see has, hasPath, hasPathIn - * @example - * - * const object = create({ 'a': create({ 'b': 2 }) }) - * - * hasIn(object, 'a') - * // => true - * - * hasIn(object, 'b') - * // => false - */ -export function hasIn(object: Record, key: string): boolean { - return object != null && key in Object(object); -} - - diff --git a/libs/nanofn/src/obj/has-path-in.ts b/libs/nanofn/src/obj/has-path-in.ts deleted file mode 100644 index fdf34fdb6..000000000 --- a/libs/nanofn/src/obj/has-path-in.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from '../_internal/cast-path'; -import { _isIndex } from '../_internal/is-index'; -import { _toKey } from '../_internal/to-key'; -import { isArguments } from '../is/is-arguments'; -import { isLength } from '../is/is-length'; - -/** - * Checks if `path` is a direct property of `object`. - * - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @see has, hasIn hasPath - * @example - * - * const object = { 'a': { 'b': 2 } } - * const other = create({ 'a': create({ 'b': 2 }) }) - * - * hasPathIn(object, 'a.b') - * // => true - * - * hasPathIn(object, ['a', 'b']) - * // => true - */ -export function hasPathIn(object, path) { - path = _castPath(path, object); - - let index = -1; - let { length } = path; - let result = false; - let key; - - while (++index < length) { - key = _toKey(path[index]); - if (!(result = object != null && key in Object(object))) { - break; - } - object = object[key]; - } - if (result || ++index != length) { - return result; - } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && _isIndex(key, length) && - (Array.isArray(object) || isArguments(object)); -} - - diff --git a/libs/nanofn/src/obj/has-path.ts b/libs/nanofn/src/obj/has-path.ts deleted file mode 100644 index 8d0190ee1..000000000 --- a/libs/nanofn/src/obj/has-path.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from '../_internal/cast-path'; -import { isArguments } from '../is/is-arguments'; -import { _isIndex } from '../_internal/is-index'; -import { isLength } from '../is/is-length'; -import { _toKey } from '../_internal/to-key'; - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Checks if `path` is a direct property of `object`. - * - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @see has, hasIn, hasPathIn - * @example - * - * const object = { 'a': { 'b': 2 } } - * const other = create({ 'a': create({ 'b': 2 }) }) - * - * hasPath(object, 'a.b') - * // => true - * - * hasPath(object, ['a', 'b']) - * // => true - */ -export function hasPath(object: any, path: string): boolean { - path = _castPath(path, object); - - let index = -1; - let {length} = path; - let result = false; - let key; - - while (++index < length) { - key = _toKey(path[index]); - if (!(result = object != null && hasOwnProperty.call(object, key))) { - break; - } - object = object[key]; - } - if (result || ++index != length) { - return result; - } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && _isIndex(key, length) && - (Array.isArray(object) || isArguments(object)); -} - - diff --git a/libs/nanofn/src/obj/has.ts b/libs/nanofn/src/obj/has.ts deleted file mode 100644 index a8e39f6fe..000000000 --- a/libs/nanofn/src/obj/has.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Checks if `key` is a direct property of `object`. - * - * @category Object - * @param {Object} object The object to query. - * @param {string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - * @see hasIn, hasPath, hasPathIn - * @example - * - * const object = { 'a': { 'b': 2 } } - * const other = create({ 'a': create({ 'b': 2 }) }) - * - * has(object, 'a') - * // => true - * - * has(other, 'a') - * // => false - */ -export function has(object: Record, key: string): boolean { - return object != null && hasOwnProperty.call(object, key); -} - - diff --git a/libs/nanofn/src/obj/invert-by.ts b/libs/nanofn/src/obj/invert-by.ts deleted file mode 100644 index e4c90832a..000000000 --- a/libs/nanofn/src/obj/invert-by.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * This method is like `invert` except that the inverted object is generated - * from the results of running each element of `object` thru `iteratee`. The - * corresponding inverted value of each inverted key is an array of keys - * responsible for generating the inverted value. The iteratee is invoked - * with one argument: (value). - * - * @category Object - * @param {Object} object The object to invert. - * @param {Function} iteratee The iteratee invoked per element. - * @returns {Object} Returns the new inverted object. - * @example - * - * const object = { 'a': 1, 'b': 2, 'c': 1 } - * - * invertBy(object, value => `group${value}`) - * // => { 'group1': ['a', 'c'], 'group2': ['b'] } - */ -export function invertBy(object, iteratee) { - const result = {}; - Object.keys(object).forEach((key) => { - const value = iteratee(object[key]); - if (hasOwnProperty.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; - } - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/invert.ts b/libs/nanofn/src/obj/invert.ts deleted file mode 100644 index 344423420..000000000 --- a/libs/nanofn/src/obj/invert.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -const toString = Object.prototype.toString; - -/** - * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite - * property assignments of previous values. - * - * @category Object - * @param {Object} object The object to invert. - * @returns {Object} Returns the new inverted object. - * @example - * - * const object = { 'a': 1, 'b': 2, 'c': 1 } - * - * invert(object) - * // => { '1': 'c', '2': 'b' } - */ -export function invert(object) { - const result = {}; - Object.keys(object).forEach((key) => { - let value = object[key]; - if (value != null && typeof value.toString !== 'function') { - value = toString.call(value); - } - result[value] = key; - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/invoke.ts b/libs/nanofn/src/obj/invoke.ts deleted file mode 100644 index 32fa4bcc6..000000000 --- a/libs/nanofn/src/obj/invoke.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from '../_internal/cast-path'; -import { _parent } from '../_internal/parent'; -import { _toKey } from '../_internal/to-key'; -import { last } from '../arr/last'; - -/** - * Invokes the method at `path` of `object`. - * - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} [args] The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - * @example - * - * const object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] } - * - * invoke(object, 'a[0].b.c.slice', [1, 3]) - * // => [2, 3] - */ -export function invoke(object, path, args) { - path = _castPath(path, object); - object = _parent(object, path); - const func = object == null ? object : object[_toKey(last(path))]; - return func == null ? undefined : func.apply(object, args); -} - - diff --git a/libs/nanofn/src/obj/keys-in.ts b/libs/nanofn/src/obj/keys-in.ts deleted file mode 100644 index acb7cb457..000000000 --- a/libs/nanofn/src/obj/keys-in.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -export function keysIn(object) { - const result = []; - for (const key in object) { - result.push(key); - } - return result; -} - - - diff --git a/libs/nanofn/src/obj/keys.ts b/libs/nanofn/src/obj/keys.ts deleted file mode 100644 index cc798b4ba..000000000 --- a/libs/nanofn/src/obj/keys.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _arrayLikeKeys } from '../_internal/array-like-keys'; -import { isArrayLike } from '../is/is-array-like'; - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @category Object - * @param {Object} obj The object to query. - * @returns {Array} Returns the array of property names. - * @see values, valuesIn - * @example - * - * function Foo() { - * this.a = 1 - * this.b = 2 - * } - * - * Foo.prototype.c = 3 - * - * keys(new Foo) - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * keys('hi') - * // => ['0', '1'] - */ -export function keys(obj: any): string[] { - return isArrayLike(obj) - ? _arrayLikeKeys(obj) - : Object.keys(Object(obj)); -} - - diff --git a/libs/nanofn/src/obj/map-key.ts b/libs/nanofn/src/obj/map-key.ts deleted file mode 100644 index e416ec3c0..000000000 --- a/libs/nanofn/src/obj/map-key.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * The opposite of `mapValue` this method creates an object with the - * same values as `object` and keys generated by running each own enumerable - * string keyed property of `object` thru `iteratee`. The iteratee is invoked - * with three arguments: (value, key, object). - * - * @category Object - * @param {Object} obj The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see mapValue - * @example - * - * mapKey({ 'a': 1, 'b': 2 }, function(value, key) { - * return key + value - * }) - * // => { 'a1': 1, 'b2': 2 } - */ -export function mapKey( - obj: any, - iteratee: (value: any, key: string, object: any) => any -): any { - obj = Object(obj); - const result: any = {}; - - Object.keys(obj).forEach((key) => { - const value = obj[key]; - result[iteratee(value, key, obj)] = value; - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/map-object.ts b/libs/nanofn/src/obj/map-object.ts deleted file mode 100644 index 71b4aa167..000000000 --- a/libs/nanofn/src/obj/map-object.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an array of values by running each property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: (value, key, object). - * - * @category Object - * @param {Object} obj The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n - * } - * - * map({ 'a': 4, 'b': 8 }, square) - * // => [16, 64] (iteration order is not guaranteed) - */ -export function mapObject( - obj: any, - iteratee: (value: any, key: string, object: any) => any -): any { - const props = Object.keys(obj); - const result = new Array(props.length); - - props.forEach((key, index) => { - result[index] = iteratee(obj[key], key, obj); - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/map-value.ts b/libs/nanofn/src/obj/map-value.ts deleted file mode 100644 index b32b88774..000000000 --- a/libs/nanofn/src/obj/map-value.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Creates an object with the same keys as `object` and values generated - * by running each own enumerable string keyed property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, key, object). - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see mapKeys - * @example - * - * const users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * } - * - * mapValue(users, ({ age }) => age) - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - */ -export function mapValue(object: any, iteratee) { - object = Object(object); - const result = {}; - - Object.keys(object).forEach((key) => { - result[key] = iteratee(object[key], key, object); - }); - return result; -} - - diff --git a/libs/nanofn/src/obj/merge-with.ts b/libs/nanofn/src/obj/merge-with.ts deleted file mode 100644 index 119428306..000000000 --- a/libs/nanofn/src/obj/merge-with.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseMerge } from '../_internal/base-merge'; -import { _createAssigner } from '../_internal/create-assigner'; - -/** - * This method is like `merge` except that it accepts `customizer` which - * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined`, merging is handled by the - * method instead. The `customizer` is invoked with six arguments: - * (objValue, srcValue, key, object, source, stack). - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * if (Array.isArray(objValue)) { - * return objValue.concat(srcValue) - * } - * } - * - * const object = { 'a': [1], 'b': [2] } - * const other = { 'a': [3], 'b': [4] } - * - * mergeWith(object, other, customizer) - * // => { 'a': [1, 3], 'b': [2, 4] } - */ -export const mergeWith = _createAssigner((object, source, srcIndex, customizer) => { - _baseMerge(object, source, srcIndex, customizer); -}); diff --git a/libs/nanofn/src/obj/merge.ts b/libs/nanofn/src/obj/merge.ts deleted file mode 100644 index aadbea555..000000000 --- a/libs/nanofn/src/obj/merge.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseMerge } from '../_internal/base-merge'; -import { _createAssigner } from '../_internal/create-assigner'; - -/** - * This method is like `assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * const object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * } - * - * const other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * } - * - * merge(object, other) - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } - */ -const merge = _createAssigner((object, source, srcIndex) => { - _baseMerge(object, source, srcIndex); -}); - -export default merge; diff --git a/libs/nanofn/src/obj/pick-by.ts b/libs/nanofn/src/obj/pick-by.ts deleted file mode 100644 index 22f5d7582..000000000 --- a/libs/nanofn/src/obj/pick-by.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../arr/map'; -import { _basePickBy } from '../_internal/base-pick-by'; -import { _getAllKeysIn } from '../_internal/get-all-keys-in'; - -/** - * Creates an object composed of the `object` properties `predicate` returns - * truthy for. The predicate is invoked with two arguments: (value, key). - * - * @category Object - * @param {Object} object The source object. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * const object = { 'a': 1, 'b': '2', 'c': 3 } - * - * pickBy(object, isNumber) - * // => { 'a': 1, 'c': 3 } - */ -export function pickBy(object, predicate) { - if (object == null) { - return {}; - } - const props = map(_getAllKeysIn(object), (prop) => [prop]); - return _basePickBy(object, props, (value, path) => predicate(value, path[0])); -} - - diff --git a/libs/nanofn/src/obj/pick.ts b/libs/nanofn/src/obj/pick.ts deleted file mode 100644 index 786293db8..000000000 --- a/libs/nanofn/src/obj/pick.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _basePick } from '../_internal/base-pick'; - -/** - * Creates an object composed of the picked `object` properties. - * - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. - * @example - * - * const object = { 'a': 1, 'b': '2', 'c': 3 } - * - * pick(object, ['a', 'c']) - * // => { 'a': 1, 'c': 3 } - */ -export function pick(object, ...paths) { - return object == null ? {} : _basePick(object, paths); -} - - diff --git a/libs/nanofn/src/obj/result.ts b/libs/nanofn/src/obj/result.ts deleted file mode 100644 index 3432ce18c..000000000 --- a/libs/nanofn/src/obj/result.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castPath } from '../_internal/cast-path'; -import { _toKey } from '../_internal/to-key'; - -/** - * This method is like `get` except that if the resolved value is a - * function it's invoked with the `this` binding of its parent object and - * its result is returned. - * - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * const object = { 'a': [{ 'b': { 'c1': 3, 'c2': () => 4 } }] } - * - * result(object, 'a[0].b.c1') - * // => 3 - * - * result(object, 'a[0].b.c2') - * // => 4 - * - * result(object, 'a[0].b.c3', 'default') - * // => 'default' - * - * result(object, 'a[0].b.c3', () => 'default') - * // => 'default' - */ -export function result(object, path, defaultValue) { - path = _castPath(path, object); - - let index = -1; - let length = path.length; - - // Ensure the loop is entered when path is empty. - if (!length) { - length = 1; - object = undefined; - } - while (++index < length) { - let value = object == null ? undefined : object[_toKey(path[index])]; - if (value === undefined) { - index = length; - value = defaultValue; - } - object = typeof value === 'function' ? value.call(object) : value; - } - return object; -} - - diff --git a/libs/nanofn/src/obj/set-with.ts b/libs/nanofn/src/obj/set-with.ts deleted file mode 100644 index 7bdf1079f..000000000 --- a/libs/nanofn/src/obj/set-with.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSet } from '../_internal/base-set'; - -/** - * This method is like `set` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * const object = {} - * - * setWith(object, '[0][1]', 'a', Object) - * // => { '0': { '1': 'a' } } - */ -export function setWith(object, path, value, customizer) { - customizer = typeof customizer === 'function' ? customizer : undefined; - return object == null ? object : _baseSet(object, path, value, customizer); -} - - diff --git a/libs/nanofn/src/obj/setter.ts b/libs/nanofn/src/obj/setter.ts deleted file mode 100644 index 394c1e2a3..000000000 --- a/libs/nanofn/src/obj/setter.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseSet } from '../_internal/base-set'; - -/** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, - * it's created. Arrays are created for missing index properties while objects - * are created for all other missing properties. Use `setWith` to customize - * `path` creation. - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. - * @see has, hasIn, get, unset - * @example - * - * const object = { 'a': [{ 'b': { 'c': 3 } }] } - * - * set(object, 'a[0].b.c', 4) - * console.log(object.a[0].b.c) - * // => 4 - * - * set(object, ['x', '0', 'y', 'z'], 5) - * console.log(object.x[0].y.z) - * // => 5 - */ -export function setter(object: any, path: string, value: any): any { - return object == null ? object : _baseSet(object, path, value); -} - - diff --git a/libs/nanofn/src/obj/transform.ts b/libs/nanofn/src/obj/transform.ts deleted file mode 100644 index 3dc0be059..000000000 --- a/libs/nanofn/src/obj/transform.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _arrayEach } from '../_internal/array-each'; -import { _baseForOwn } from '../_internal/base-for-own'; -import { isBuffer } from '../is/is-buffer'; -import { isObject } from '../is/is-object'; -import { isTypedArray } from '../is/is-typed-array'; - -/** - * An alternative to `reduce` this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable string keyed properties thru `iteratee`, with each invocation - * potentially mutating the `accumulator` object. If `accumulator` is not - * provided, a new object with the same `[[Prototype]]` will be used. The - * iteratee is invoked with four arguments: (accumulator, value, key, object). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @returns {*} Returns the accumulated value. - * @see reduce, reduceRight - * @example - * - * transform([2, 3, 4], (result, n) => { - * result.push(n *= n) - * return n % 2 == 0 - * }, []) - * // => [4, 9] - * - * transform({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => { - * (result[value] || (result[value] = [])).push(key) - * }, {}) - * // => { '1': ['a', 'c'], '2': ['b'] } - */ -export function transform(object, iteratee, accumulator) { - const isArr = Array.isArray(object); - const isArrLike = isArr || isBuffer(object) || isTypedArray(object); - - if (accumulator == null) { - const Ctor = object && object.constructor; - if (isArrLike) { - accumulator = isArr ? new Ctor : []; - } else if (isObject(object)) { - accumulator = typeof Ctor === 'function' - ? Object.create(Object.getPrototypeOf(object)) - : {}; - } else { - accumulator = {}; - } - } - (isArrLike ? _arrayEach : _baseForOwn)(object, (value, index, object) => - iteratee(accumulator, value, index, object)); - return accumulator; -} - - diff --git a/libs/nanofn/src/obj/unset.ts b/libs/nanofn/src/obj/unset.ts deleted file mode 100644 index 355ec238a..000000000 --- a/libs/nanofn/src/obj/unset.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUnset } from '../_internal/base-unset'; - -/** - * Removes the property at `path` of `object`. - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - * @see get, has, set - * @example - * - * const object = { 'a': [{ 'b': { 'c': 7 } }] } - * unset(object, 'a[0].b.c') - * // => true - * - * console.log(object) - * // => { 'a': [{ 'b': {} }] } - * - * unset(object, ['a', '0', 'b', 'c']) - * // => true - * - * console.log(object) - * // => { 'a': [{ 'b': {} }] } - */ -export function unset(object: any, path: string): boolean { - return object == null ? true : _baseUnset(object, path); -} - - diff --git a/libs/nanofn/src/obj/update-with.ts b/libs/nanofn/src/obj/update-with.ts deleted file mode 100644 index 29f6615a7..000000000 --- a/libs/nanofn/src/obj/update-with.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUpdate } from '../_internal/base-update'; - -/** - * This method is like `update` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * const object = {} - * - * updateWith(object, '[0][1]', () => 'a', Object) - * // => { '0': { '1': 'a' } } - */ -export function updateWith(object, path, updater, customizer) { - customizer = typeof customizer === 'function' ? customizer : undefined; - return object == null ? object : _baseUpdate(object, path, updater, customizer); -} - - diff --git a/libs/nanofn/src/obj/update.ts b/libs/nanofn/src/obj/update.ts deleted file mode 100644 index e5440666d..000000000 --- a/libs/nanofn/src/obj/update.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseUpdate } from '../_internal/base-update'; - -/** - * This method is like `set` except that it accepts `updater` to produce the - * value to set. Use `updateWith` to customize `path` creation. The `updater` - * is invoked with one argument: (value). - * - * **Note:** This method mutates `object`. - * - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @returns {Object} Returns `object`. - * @example - * - * const object = { 'a': [{ 'b': { 'c': 3 } }] } - * - * update(object, 'a[0].b.c', n => n * n) - * console.log(object.a[0].b.c) - * // => 9 - * - * update(object, 'x[0].y.z', n => n ? n + 1 : 0) - * console.log(object.x[0].y.z) - * // => 0 - */ -export function update(object, path, updater) { - return object == null ? object : _baseUpdate(object, path, updater); -} diff --git a/libs/nanofn/src/obj/values.ts b/libs/nanofn/src/obj/values.ts deleted file mode 100644 index 3e3d01502..000000000 --- a/libs/nanofn/src/obj/values.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseValues } from '../_internal/base-values'; -import { keys } from './keys'; - -/** - * Creates an array of the own enumerable string keyed property values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @see keys, valuesIn - * @example - * - * function Foo() { - * this.a = 1 - * this.b = 2 - * } - * - * Foo.prototype.c = 3 - * - * values(new Foo) - * // => [1, 2] (iteration order is not guaranteed) - * - * values('hi') - * // => ['h', 'i'] - */ -export function values(object: any) { - return object == null ? [] : _baseValues(object, keys(object)); -} - - diff --git a/libs/nanofn/src/str/deburr.ts b/libs/nanofn/src/str/deburr.ts deleted file mode 100644 index 47d2bb459..000000000 --- a/libs/nanofn/src/str/deburr.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { deburrLetter } from '../_internal/deburr-letter'; - -/** Used to match Latin Unicode letters (excluding mathematical operators). */ -const reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - -/** Used to compose unicode character classes. */ -const rsComboMarksRange = '\\u0300-\\u036f'; -const reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -const rsComboSymbolsRange = '\\u20d0-\\u20ff'; -const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'; -const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'; -const rsComboRange = - rsComboMarksRange + - reComboHalfMarksRange + - rsComboSymbolsRange + - rsComboMarksExtendedRange + - rsComboMarksSupplementRange; - -/** Used to compose unicode capture groups. */ -const rsCombo = `[${rsComboRange}]`; - -/** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ -const reComboMark = RegExp(rsCombo, 'g'); - -/** - * Deburrs `string` by converting - * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) - * letters to basic Latin letters and removing - * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). - * - * @category String - * @param {string} [str=''] The string to deburr. - * @returns {string} Returns the deburred string. - * @example - * - * deburr('déjà vu') - * // => 'deja vu' - */ -export function deburr(str: string): string { - return str && str.replace(reLatin, deburrLetter).replace(reComboMark, ''); -} diff --git a/libs/nanofn/src/str/ends-with.ts b/libs/nanofn/src/str/ends-with.ts deleted file mode 100644 index 92564cac3..000000000 --- a/libs/nanofn/src/str/ends-with.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `string` ends with the given target string. - * - * @category String - * @param {string} [str=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=string.length] The position to search up to. - * @returns {boolean} Returns `true` if `string` ends with `target`, - * else `false`. - * @see includes, startsWith - * @example - * - * endsWith('abc', 'c') - * // => true - * - * endsWith('abc', 'b') - * // => false - * - * endsWith('abc', 'b', 2) - * // => true - */ -export function endsWith(str: string, target, position) { - const {length} = str; - position = position === undefined ? length : +position; - if (position < 0 || position != position) { - position = 0; - } else if (position > length) { - position = length; - } - const end = position; - position -= target.length; - return position >= 0 && str.slice(position, end) == target; -} - - diff --git a/libs/nanofn/src/str/escape-reg-exp.ts b/libs/nanofn/src/str/escape-reg-exp.ts deleted file mode 100644 index a37c50ae1..000000000 --- a/libs/nanofn/src/str/escape-reg-exp.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; -const reHasRegExpChar = RegExp(reRegExpChar.source); - -/** - * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", - * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. - * - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @see escape, escapeRegExp, unescape - * @example - * - * escapeRegExp('[lodash](https://lodash.com/)') - * // => '\[lodash\]\(https://lodash\.com/\)' - */ -export function escapeRegExp(string) { - return (string && reHasRegExpChar.test(string)) - ? string.replace(reRegExpChar, '\\$&') - : (string || ''); -} - - diff --git a/libs/nanofn/src/str/escape.ts b/libs/nanofn/src/str/escape.ts deleted file mode 100644 index 8f16f69f7..000000000 --- a/libs/nanofn/src/str/escape.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to map characters to HTML entities. */ -const htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' -}; - -/** Used to match HTML entities and HTML characters. */ -const reUnescapedHtml = /[&<>"']/g; -const reHasUnescapedHtml = RegExp(reUnescapedHtml.source); - -/** - * Converts the characters "&", "<", ">", '"', and "'" in `string` to their - * corresponding HTML entities. - * - * **Note:** No other characters are escaped. To escape additional - * characters use a third-party library like [_he_](https://mths.be/he). - * - * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. See - * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * When working with HTML you should always - * [quote attribute values](http://wonko.com/post/html-escaping) to reduce - * XSS vectors. - * - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @see escapeRegExp, unescape - * @example - * - * escape('fred, barney, & pebbles') - * // => 'fred, barney, & pebbles' - */ -export function escape(string) { - return (string && reHasUnescapedHtml.test(string)) - ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) - : (string || ''); -} - - diff --git a/libs/nanofn/src/str/pad.ts b/libs/nanofn/src/str/pad.ts deleted file mode 100644 index f32a8da99..000000000 --- a/libs/nanofn/src/str/pad.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createPadding } from '../_internal/create-padding'; -import { _stringSize } from '../_internal/string-size'; - -/** - * Pads `string` on the left and right sides if it's shorter than `length`. - * Padding characters are truncated if they can't be evenly divided by `length`. - * - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * pad('abc', 8) - * // => ' abc ' - * - * pad('abc', 8, '_-') - * // => '_-abc_-_' - * - * pad('abc', 2) - * // => 'abc' - */ -export function pad(string, length, chars) { - const strLength = length ? _stringSize(string) : 0; - if (!length || strLength >= length) { - return (string || ''); - } - const mid = (length - strLength) / 2; - return ( - _createPadding(Math.floor(mid), chars) + - string + - _createPadding(Math.ceil(mid), chars) - ); -} - -/** - * Pads `string` on the right side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * padEnd('abc', 6) - * // => 'abc ' - * - * padEnd('abc', 6, '_-') - * // => 'abc_-_' - * - * padEnd('abc', 2) - * // => 'abc' - */ -export function padEnd(string, length, chars) { - const strLength = length ? _stringSize(string) : 0; - return (length && strLength < length) - ? (string + _createPadding(length - strLength, chars)) - : (string || ''); -} - - -/** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * padStart('abc', 6) - * // => ' abc' - * - * padStart('abc', 6, '_-') - * // => '_-_abc' - * - * padStart('abc', 2) - * // => 'abc' - */ -export function padStart(string, length, chars) { - const strLength = length ? _stringSize(string) : 0; - return (length && strLength < length) - ? (_createPadding(length - strLength, chars) + string) - : (string || ''); -} - - - - diff --git a/libs/nanofn/src/str/parse-int.ts b/libs/nanofn/src/str/parse-int.ts deleted file mode 100644 index f31e2e910..000000000 --- a/libs/nanofn/src/str/parse-int.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { root } from './_internal/root'; - -/** Used to match leading and trailing whitespace. */ -const reTrimStart = /^\s+/; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeParseInt = root.parseInt; - -/** - * Converts `string` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `string` is a - * hexadecimal, in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the - * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. - * - * @category String - * @param {string} string The string to convert. - * @param {number} [radix=10] The radix to interpret `string` by. - * @returns {number} Returns the converted integer. - * @example - * - * parseInt('08') - * // => 8 - */ -export function parseInt(string, radix) { - if (radix == null) { - radix = 0; - } else if (radix) { - radix = +radix; - } - return nativeParseInt(`${string}`.replace(reTrimStart, ''), radix || 0); -} - - diff --git a/libs/nanofn/src/str/repeat.ts b/libs/nanofn/src/str/repeat.ts deleted file mode 100644 index afe204546..000000000 --- a/libs/nanofn/src/str/repeat.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Repeats the given string `n` times. - * - * @category String - * @param {string} [string=''] The string to repeat. - * @param {number} [n=1] The number of times to repeat the string. - * @returns {string} Returns the repeated string. - * @example - * - * repeat('*', 3) - * // => '***' - * - * repeat('abc', 2) - * // => 'abcabc' - * - * repeat('abc', 0) - * // => '' - */ -export function repeat(string, n) { - let result = ''; - if (!string || n < 1 || n > Number.MAX_SAFE_INTEGER) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = Math.floor(n / 2); - if (n) { - string += string; - } - } while (n); - - return result; -} - - diff --git a/libs/nanofn/src/str/replace.ts b/libs/nanofn/src/str/replace.ts deleted file mode 100644 index 15458543a..000000000 --- a/libs/nanofn/src/str/replace.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Replaces matches for `pattern` in `string` with `replacement`. - * - * **Note:** This method is based on - * [`String#replace`](https://mdn.io/String/replace). - * - * @category String - * @param {string} [string=''] The string to modify. - * @param {RegExp|string} pattern The pattern to replace. - * @param {Function|string} replacement The match replacement. - * @returns {string} Returns the modified string. - * @see truncate, trim - * @example - * - * replace('Hi Fred', 'Fred', 'Barney') - * // => 'Hi Barney' - */ -export function replace(...args) { - const string = `${args[0]}`; - return args.length < 3 ? string : string.replace(args[1], args[2]); -} - - diff --git a/libs/nanofn/src/str/split.ts b/libs/nanofn/src/str/split.ts deleted file mode 100644 index 283a14b53..000000000 --- a/libs/nanofn/src/str/split.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _castSlice } from '../_internal/cast-slice'; -import { _hasUnicode } from '../_internal/has-unicode'; -import { isRegExp } from '../is/is-reg-exp'; -import { _stringToArray } from '../_internal/string-to-array'; - -/** Used as references for the maximum length and index of an array. */ -const MAX_ARRAY_LENGTH = 4294967295; - -/** - * Splits `string` by `separator`. - * - * **Note:** This method is based on - * [`String#split`](https://mdn.io/String/split). - * - * @category String - * @param {string} [string=''] The string to split. - * @param {RegExp|string} separator The separator pattern to split by. - * @param {number} [limit] The length to truncate results to. - * @returns {Array} Returns the string segments. - * @example - * - * split('a-b-c', '-', 2) - * // => ['a', 'b'] - */ -export function split(string, separator, limit) { - limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; - if (!limit) { - return []; - } - if (string && ( - typeof separator === 'string' || - (separator != null && !isRegExp(separator)) - )) { - if (!separator && _hasUnicode(string)) { - return _castSlice(_stringToArray(string), 0, limit); - } - } - return string.split(separator, limit); -} - - diff --git a/libs/nanofn/src/str/starts-with.ts b/libs/nanofn/src/str/starts-with.ts deleted file mode 100644 index 96752931b..000000000 --- a/libs/nanofn/src/str/starts-with.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks if `string` starts with the given target string. - * - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, - * else `false`. - * @see endsWith, includes - * @example - * - * startsWith('abc', 'a') - * // => true - * - * startsWith('abc', 'b') - * // => false - * - * startsWith('abc', 'b', 1) - * // => true - */ -export function startsWith(string, target, position) { - const { length } = string; - position = position == null ? 0 : position; - if (position < 0) { - position = 0; - } else if (position > length) { - position = length; - } - target = `${target}`; - return string.slice(position, position + target.length) == target; -} - - diff --git a/libs/nanofn/src/str/trim-end.ts b/libs/nanofn/src/str/trim-end.ts deleted file mode 100644 index 575a1e5e6..000000000 --- a/libs/nanofn/src/str/trim-end.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { castSlice } from './_internal/cast-slice'; -import { charsEndIndex } from './_internal/chars-end-index'; -import { stringToArray } from './_internal/string-to-array'; - -const methodName = ''.trimRight ? 'trimRight' : 'trimEnd'; - -/** - * Removes trailing whitespace or specified characters from `string`. - * - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @returns {string} Returns the trimmed string. - * @see trim, trimStart - * @example - * - * trimEnd(' abc ') - * // => ' abc' - * - * trimEnd('-_-abc-_-', '_-') - * // => '-_-abc' - */ -export function trimEnd(string, chars) { - if (string && chars === undefined) { - return string[methodName](); - } - if (!string || !chars) { - return (string || ''); - } - const strSymbols = stringToArray(string); - const end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; - return castSlice(strSymbols, 0, end).join(''); -} - - diff --git a/libs/nanofn/src/str/trim-start.ts b/libs/nanofn/src/str/trim-start.ts deleted file mode 100644 index c4ea87646..000000000 --- a/libs/nanofn/src/str/trim-start.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { castSlice } from './_internal/cast-slice'; -import { charsStartIndex } from './_internal/chars-start-index'; -import { stringToArray } from './_internal/string-to-array'; - -const methodName = ''.trimLeft ? 'trimLeft' : 'trimStart'; - -/** - * Removes leading whitespace or specified characters from `string`. - * - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @returns {string} Returns the trimmed string. - * @see trim, trimEnd - * @example - * - * trimStart(' abc ') - * // => 'abc ' - * - * trimStart('-_-abc-_-', '_-') - * // => 'abc-_-' - */ -export function trimStart(string, chars) { - if (string && chars === undefined) { - return string[methodName](); - } - if (!string || !chars) { - return (string || ''); - } - const strSymbols = stringToArray(string); - const start = charsStartIndex(strSymbols, stringToArray(chars)); - return castSlice(strSymbols, start).join(''); -} - - diff --git a/libs/nanofn/src/str/trim.ts b/libs/nanofn/src/str/trim.ts deleted file mode 100644 index ab579c9b1..000000000 --- a/libs/nanofn/src/str/trim.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { castSlice } from './_internal/cast-slice'; -import { charsEndIndex } from './_internal/chars-end-index'; -import { charsStartIndex } from './_internal/chars-start-index'; -import { stringToArray } from './_internal/string-to-array'; - -/** - * Removes leading and trailing whitespace or specified characters from `string`. - * - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @returns {string} Returns the trimmed string. - * @see trimEnd, trimStart - * @example - * - * trim(' abc ') - * // => 'abc' - * - * trim('-_-abc-_-', '_-') - * // => 'abc' - */ -export function trim(string, chars) { - if (string && chars === undefined) { - return string.trim(); - } - if (!string || !chars) { - return (string || ''); - } - const strSymbols = stringToArray(string); - const chrSymbols = stringToArray(chars); - const start = charsStartIndex(strSymbols, chrSymbols); - const end = charsEndIndex(strSymbols, chrSymbols) + 1; - - return castSlice(strSymbols, start, end).join(''); -} - - diff --git a/libs/nanofn/src/str/truncate.ts b/libs/nanofn/src/str/truncate.ts deleted file mode 100644 index 083fbd1c6..000000000 --- a/libs/nanofn/src/str/truncate.ts +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseToString } from './_internal/base-to-string'; -import { castSlice } from './_internal/cast-slice'; -import { hasUnicode } from './_internal/has-unicode'; -import { isObject } from './is-object'; -import { isRegExp } from './is-reg-exp'; -import { stringSize } from './_internal/string-size'; -import { stringToArray } from './_internal/string-to-array'; -import { toString } from './to-string'; - -/** Used as default options for `truncate`. */ -const DEFAULT_TRUNC_LENGTH = 30; -const DEFAULT_TRUNC_OMISSION = '...'; - -/** Used to match `RegExp` flags from their coerced string values. */ -const reFlags = /\w*$/; - -/** - * Truncates `string` if it's longer than the given maximum string length. - * The last characters of the truncated string are replaced with the omission - * string which defaults to "...". - * - * @category String - * @param {string} [string=''] The string to truncate. - * @param {Object} [options={}] The options object. - * @param {number} [options.length=30] The maximum string length. - * @param {string} [options.omission='...'] The string to indicate text is omitted. - * @param {RegExp|string} [options.separator] The separator pattern to truncate to. - * @returns {string} Returns the truncated string. - * @see replace - * @example - * - * truncate('hi-diddly-ho there, neighborino') - * // => 'hi-diddly-ho there, neighbo...' - * - * truncate('hi-diddly-ho there, neighborino', { - * 'length': 24, - * 'separator': ' ' - * }) - * // => 'hi-diddly-ho there,...' - * - * truncate('hi-diddly-ho there, neighborino', { - * 'length': 24, - * 'separator': /,? +/ - * }) - * // => 'hi-diddly-ho there...' - * - * truncate('hi-diddly-ho there, neighborino', { - * 'omission': ' [...]' - * }) - * // => 'hi-diddly-ho there, neig [...]' - */ -export function truncate(string, options) { - let separator; - let length = DEFAULT_TRUNC_LENGTH; - let omission = DEFAULT_TRUNC_OMISSION; - - if (isObject(options)) { - separator = 'separator' in options ? options.separator : separator; - length = 'length' in options ? options.length : length; - omission = 'omission' in options ? baseToString(options.omission) : omission; - } - - string = toString(string); - - let strSymbols; - let strLength = string.length; - if (hasUnicode(string)) { - strSymbols = stringToArray(string); - strLength = strSymbols.length; - } - if (length >= strLength) { - return string; - } - let end = length - stringSize(omission); - if (end < 1) { - return omission; - } - let result = strSymbols - ? castSlice(strSymbols, 0, end).join('') - : string.slice(0, end); - - if (separator === undefined) { - return result + omission; - } - if (strSymbols) { - end += (result.length - end); - } - if (isRegExp(separator)) { - if (string.slice(end).search(separator)) { - let match; - let newEnd; - const substring = result; - - if (!separator.global) { - separator = RegExp(separator.source, `${reFlags.exec(separator) || ''}g`); - } - separator.lastIndex = 0; - while ((match = separator.exec(substring))) { - newEnd = match.index; - } - result = result.slice(0, newEnd === undefined ? end : newEnd); - } - } else if (string.indexOf(baseToString(separator), end) != end) { - const index = result.lastIndexOf(separator); - if (index > -1) { - result = result.slice(0, index); - } - } - return result + omission; -} - - diff --git a/libs/nanofn/src/str/unescape.ts b/libs/nanofn/src/str/unescape.ts deleted file mode 100644 index 9d2afdf56..000000000 --- a/libs/nanofn/src/str/unescape.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to map HTML entities to characters. */ -const htmlUnescapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - ''': "'" -}; - -/** Used to match HTML entities and HTML characters. */ -const reEscapedHtml = /&(?:amp|lt|gt|quot|#(0+)?39);/g; -const reHasEscapedHtml = RegExp(reEscapedHtml.source); - -/** - * The inverse of `escape`this method converts the HTML entities - * `&`, `<`, `>`, `"` and `'` in `string` to - * their corresponding characters. - * - * **Note:** No other HTML entities are unescaped. To unescape additional - * HTML entities use a third-party library like [_he_](https://mths.be/he). - * - * @category String - * @param {string} [string=''] The string to unescape. - * @returns {string} Returns the unescaped string. - * @see escape, escapeRegExp - * @example - * - * unescape('fred, barney, & pebbles') - * // => 'fred, barney, & pebbles' - */ -export function unescape(string) { - return (string && reHasEscapedHtml.test(string)) - ? string.replace(reEscapedHtml, (entity) => (htmlUnescapes[entity] || "'")) - : (string || ''); -} - - diff --git a/libs/nanofn/src/util/attempt.ts b/libs/nanofn/src/util/attempt.ts deleted file mode 100644 index 26936dc23..000000000 --- a/libs/nanofn/src/util/attempt.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { isError } from '../is/is-error'; - -/** - * Attempts to invoke `func`, returning either the result or the caught error - * object. Any additional arguments are provided to `func` when it's invoked. - * - * @category Util - * @param {Function} func The function to attempt. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {*} Returns the `func` result or error object. - * @example - * - * // Avoid throwing errors for invalid selectors. - * const elements = attempt(selector => - * document.querySelectorAll(selector), '>_>') - * - * if (isError(elements)) { - * elements = [] - * } - */ -export function attempt(func, ...args) { - try { - return func(...args); - } catch (e) { - return isError(e) ? e : new Error(e); - } -} - - diff --git a/libs/nanofn/src/util/cond.ts b/libs/nanofn/src/util/cond.ts deleted file mode 100644 index 88a1886b3..000000000 --- a/libs/nanofn/src/util/cond.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../arr/map'; - -/** - * Creates a function that iterates over `pairs` and invokes the corresponding - * function of the first predicate to return truthy. The predicate-function - * pairs are invoked with the `this` binding and arguments of the created - * function. - * - * @category Util - * @param {Array} pairs The predicate-function pairs. - * @returns {Function} Returns the new composite function. - * @example - * - * const func = cond([ - * [matches({ 'a': 1 }), () => 'matches A'], - * [conforms({ 'b': isNumber }), () => 'matches B'], - * [() => true, () => 'no match'] - * ]) - * - * func({ 'a': 1, 'b': 2 }) - * // => 'matches A' - * - * func({ 'a': 0, 'b': 1 }) - * // => 'matches B' - * - * func({ 'a': '1', 'b': '2' }) - * // => 'no match' - */ -export function cond(pairs) { - const length = pairs == null ? 0 : pairs.length; - - pairs = !length ? [] : map(pairs, (pair) => { - if (typeof pair[1] !== 'function') { - throw new TypeError('Expected a function'); - } - return [pair[0], pair[1]]; - }); - - return (...args) => { - for (const pair of pairs) { - if (pair[0].apply(this, args)) { - return pair[1].apply(this, args); - } - } - }; -} - - diff --git a/libs/nanofn/src/util/conforms.ts b/libs/nanofn/src/util/conforms.ts deleted file mode 100644 index 0c5c056e3..000000000 --- a/libs/nanofn/src/util/conforms.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; -import { _baseConforms } from '../_internal/base-conforms'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; - -/** - * Creates a function that invokes the predicate properties of `source` with - * the corresponding property values of a given object, returning `true` if - * all predicates return truthy, else `false`. - * - * **Note:** The created function is equivalent to `conformsTo` with - * `source` partially applied. - * - * @category Util - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. - * @example - * - * const objects = [ - * { 'a': 2, 'b': 1 }, - * { 'a': 1, 'b': 2 } - * ] - * - * filter(objects, conforms({ 'b': function(n) { return n > 1 } })) - * // => [{ 'a': 1, 'b': 2 }] - */ -export function conforms(source) { - return _baseConforms(_baseClone(source, CLONE_DEEP_FLAG)); -} - - diff --git a/libs/nanofn/src/util/default-to-any.ts b/libs/nanofn/src/util/default-to-any.ts deleted file mode 100644 index 012161e67..000000000 --- a/libs/nanofn/src/util/default-to-any.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _arrayReduce } from '../_internal/array-reduce'; -import { defaultTo } from './default-to'; - -/** - * This method is like `defaultTo` except that it accepts multiple default values and returns the first one that is not - * `NaN`, `null`, or `undefined`. - * - * @category Util - * @param {*} value The value to check. - * @param {...*} defaultValues The default values. - * @returns {*} Returns the resolved value. - * @see _.defaultTo - * @example - * - * defaultToAny(1, 10, 20) - * // => 1 - * - * defaultToAny(undefined, 10, 20) - * // => 10 - * - * defaultToAny(undefined, null, 20) - * // => 20 - * - * defaultToAny(undefined, null, NaN) - * // => NaN - */ -export function defaultToAny(value, ...defaultValues) { - return _arrayReduce(defaultValues, defaultTo, value); -} - - diff --git a/libs/nanofn/src/util/default-to.ts b/libs/nanofn/src/util/default-to.ts deleted file mode 100644 index dac95773a..000000000 --- a/libs/nanofn/src/util/default-to.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Checks `value` to determine whether a default value should be returned in - * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, - * or `undefined`. - * - * @category Util - * @param {*} value The value to check. - * @param {*} defaultValue The default value. - * @returns {*} Returns the resolved value. - * @example - * - * defaultTo(1, 10) - * // => 1 - * - * defaultTo(undefined, 10) - * // => 10 - */ -export function defaultTo(value: any, defaultValue: any) { - return (value == null || value !== value) ? defaultValue : value; -} - - diff --git a/libs/nanofn/src/util/flow-right.ts b/libs/nanofn/src/util/flow-right.ts deleted file mode 100644 index 6e0c16557..000000000 --- a/libs/nanofn/src/util/flow-right.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { flow } from './flow'; - -/** - * This method is like `flow` except that it composes a function that - * invokes the given functions from right to left. - * - * @category Util - * @param {Function[]} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see flow - * @example - * - * import { add } from 'lodash/add' - * - * function square(n) { - * return n * n - * } - * - * const addSquare = flowRight(square, add) - * addSquare(1, 2) - * // => 9 - */ -export function flowRight(...funcs) { - return flow(...funcs.reverse()); -} - - diff --git a/libs/nanofn/src/util/flow.ts b/libs/nanofn/src/util/flow.ts deleted file mode 100644 index b1962109e..000000000 --- a/libs/nanofn/src/util/flow.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** - * Composes a function that returns the result of invoking the given functions - * with the `this` binding of the created function, where each successive - * invocation is supplied the return value of the previous. - * - * @category Util - * @param {Function[]} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see flowRight - * @example - * - * import { add } from 'lodash/add' - * - * function square(n) { - * return n * n - * } - * - * const addSquare = flow(add, square) - * addSquare(1, 2) - * // => 9 - */ -export function flow(...funcs) { - const length = funcs.length; - let index = length; - while (index--) { - if (typeof funcs[index] !== 'function') { - throw new TypeError('Expected a function'); - } - } - return function(...args) { - let index = 0; - let result = length ? funcs[index].apply(this, args) : args[0]; - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; -} - - diff --git a/libs/nanofn/src/util/matches-property.ts b/libs/nanofn/src/util/matches-property.ts deleted file mode 100644 index 663c0bee7..000000000 --- a/libs/nanofn/src/util/matches-property.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseClone } from '../_internal/base-clone'; -import { _baseMatchesProperty } from '../_internal/base-matches-property'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; - -/** - * Creates a function that performs a partial deep comparison between the - * value at `path` of a given object to `srcValue`, returning `true` if the - * object value is equivalent, else `false`. - * - * **Note:** Partial comparisons will match empty array and empty object - * `srcValue` values against any array or object value, respectively. See - * `isEqual` for a list of supported value comparisons. - * - * @category Util - * @param {Array|string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - * @example - * - * const objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ] - * - * find(objects, matchesProperty('a', 4)) - * // => { 'a': 4, 'b': 5, 'c': 6 } - */ -export function matchesProperty(path, srcValue) { - return _baseMatchesProperty(path, _baseClone(srcValue, CLONE_DEEP_FLAG)); -} - - diff --git a/libs/nanofn/src/util/matches.ts b/libs/nanofn/src/util/matches.ts deleted file mode 100644 index 1de723165..000000000 --- a/libs/nanofn/src/util/matches.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { baseClone } from './_internal/base-clone'; -import { baseMatches } from './_internal/base-matches'; - -/** Used to compose bitmasks for cloning. */ -const CLONE_DEEP_FLAG = 1; - -/** - * Creates a function that performs a partial deep comparison between a given - * object and `source`, returning `true` if the given object has equivalent - * property values, else `false`. - * - * **Note:** The created function is equivalent to `isMatch` with `source` - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `isEqual` - * for a list of supported value comparisons. - * - * @category Util - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - * @example - * - * const objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ] - * - * filter(objects, matches({ 'a': 4, 'c': 6 })) - * // => [{ 'a': 4, 'b': 5, 'c': 6 }] - */ -export function matches(source) { - return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); -} - - diff --git a/libs/nanofn/src/util/method-of.ts b/libs/nanofn/src/util/method-of.ts deleted file mode 100644 index 7aa5cc514..000000000 --- a/libs/nanofn/src/util/method-of.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { invoke } from './invoke'; - -/** - * The opposite of `method` this method creates a function that invokes - * the method at a given path of `object`. Any additional arguments are - * provided to the invoked method. - * - * @category Util - * @param {Object} object The object to query. - * @param {Array} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. - * @example - * - * const array = times(3, i => () => i) - * const object = { 'a': array, 'b': array, 'c': array } - * - * map(['a[2]', 'c[0]'], methodOf(object)) - * // => [2, 0] - * - * map([['a', '2'], ['c', '0']], methodOf(object)) - * // => [2, 0]f - */ -export function methodOf(object, args) { - return (path) => invoke(object, path, args); -} - - diff --git a/libs/nanofn/src/util/method.ts b/libs/nanofn/src/util/method.ts deleted file mode 100644 index 43a6cf1b7..000000000 --- a/libs/nanofn/src/util/method.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { invoke } from './invoke'; - -/** - * Creates a function that invokes the method at `path` of a given object. - * Any additional arguments are provided to the invoked method. - * - * @category Util - * @param {Array|string} path The path of the method to invoke. - * @param {Array} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. - * @example - * - * const objects = [ - * { 'a': { 'b': () => 2 } }, - * { 'a': { 'b': () => 1 } } - * ] - * - * map(objects, method('a.b')) - * // => [2, 1] - * - * map(objects, method(['a', 'b'])) - * // => [2, 1] - */ -export function method(path, args) { - return (object) => invoke(object, path, args); -} - - diff --git a/libs/nanofn/src/util/over-every.ts b/libs/nanofn/src/util/over-every.ts deleted file mode 100644 index 00a191183..000000000 --- a/libs/nanofn/src/util/over-every.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { every } from '../arr/every'; - -/** - * Creates a function that checks if **all** of the `predicates` return - * truthy when invoked with the arguments it receives. - * - * @category Util - * @param {Function[]} [predicates=[identity]] - * The predicates to check. - * @returns {Function} Returns the new function. - * @example - * - * const func = overEvery([Boolean, isFinite]) - * - * func('1') - * // => true - * - * func(null) - * // => false - * - * func(NaN) - * // => false - */ -export function overEvery(iteratees) { - return function (...args) { - return every(iteratees, (iteratee) => iteratee.apply(this, args)); - }; -} - - diff --git a/libs/nanofn/src/util/over-some.ts b/libs/nanofn/src/util/over-some.ts deleted file mode 100644 index 91ad44f17..000000000 --- a/libs/nanofn/src/util/over-some.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { some } from '../arr/some'; - -/** - * Creates a function that checks if **any** of the `predicates` return - * truthy when invoked with the arguments it receives. - * - * @category Util - * @param {Function[]} [predicates=[identity]] - * The predicates to check. - * @returns {Function} Returns the new function. - * @example - * - * const func = overSome([Boolean, isFinite]) - * - * func('1') - * // => true - * - * func(null) - * // => true - * - * func(NaN) - * // => false - */ -export function overSome(iteratees) { - return function (...args) { - return some(iteratees, (iteratee) => iteratee.apply(this, args)); - }; -} - - diff --git a/libs/nanofn/src/util/over.ts b/libs/nanofn/src/util/over.ts deleted file mode 100644 index 4bfa3a737..000000000 --- a/libs/nanofn/src/util/over.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { map } from '../arr/map'; - -/** - * Creates a function that invokes `iteratees` with the arguments it receives - * and returns their results. - * - * @category Util - * @param {Function[]} [iteratees=[identity]] - * The iteratees to invoke. - * @returns {Function} Returns the new function. - * @example - * - * const func = over([Math.max, Math.min]) - * - * func(1, 2, 3, 4) - * // => [4, 1] - */ -export function over(iteratees) { - return function(...args) { - return map(iteratees, (iteratee) => iteratee.apply(this, args)); - }; -} - - diff --git a/libs/nanofn/src/util/property-of.ts b/libs/nanofn/src/util/property-of.ts deleted file mode 100644 index 4fae5e372..000000000 --- a/libs/nanofn/src/util/property-of.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseGet } from '../_internal/base-get'; - -/** - * The opposite of `property`s method creates a function that returns - * the value at a given path of `object`. - * - * @category Util - * @param {Object} obj The object to query. - * @returns {Function} Returns the new accessor function. - * @example - * - * const array = [0, 1, 2] - * const object = { 'a': array, 'b': array, 'c': array } - * - * map(['a[2]', 'c[0]'], propertyOf(object)) - * // => [2, 0] - * - * map([['a', '2'], ['c', '0']], propertyOf(object)) - * // => [2, 0] - */ -export function propertyOf(obj) { - return (path) => obj == null ? undefined : _baseGet(obj, path); -} - - diff --git a/libs/nanofn/src/util/property.ts b/libs/nanofn/src/util/property.ts deleted file mode 100644 index b772375d9..000000000 --- a/libs/nanofn/src/util/property.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _baseProperty } from '../_internal/base-property'; -import { _basePropertyDeep } from '../_internal/base-property-deep'; -import { _isKey } from '../_internal/is-key'; -import { _toKey } from '../_internal/to-key'; - -/** - * Creates a function that returns the value at `path` of a given object. - * - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - * @example - * - * const objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ] - * - * map(objects, property('a.b')) - * // => [2, 1] - * - * map(sortBy(objects, property(['a', 'b'])), 'a.b') - * // => [1, 2] - */ -export function property(path) { - return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path); -} - - diff --git a/libs/nanofn/src/util/range-right.ts b/libs/nanofn/src/util/range-right.ts deleted file mode 100644 index f7f620e2c..000000000 --- a/libs/nanofn/src/util/range-right.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createRange } from '../_internal/create-range'; - -/** - * This method is like `range` except that it populates values in - * descending order. - * - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see inRange, range - * @example - * - * rangeRight(4) - * // => [3, 2, 1, 0] - * - * rangeRight(-4) - * // => [-3, -2, -1, 0] - * - * rangeRight(1, 5) - * // => [4, 3, 2, 1] - * - * rangeRight(0, 20, 5) - * // => [15, 10, 5, 0] - * - * rangeRight(0, -4, -1) - * // => [-3, -2, -1, 0] - * - * rangeRight(1, 4, 0) - * // => [1, 1, 1] - * - * rangeRight(0) - * // => [] - */ -export const rangeRight = _createRange(true); diff --git a/libs/nanofn/src/util/range.ts b/libs/nanofn/src/util/range.ts deleted file mode 100644 index 2d8f33e6d..000000000 --- a/libs/nanofn/src/util/range.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { _createRange } from '../_internal/create-range'; - -/** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. A step of `-1` is used if a negative - * `start` is specified without an `end` or `step`. If `end` is not specified, - * it's set to `start`, and `start` is then set to `0`. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. - * - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see inRange, rangeRight - * @example - * - * range(4) - * // => [0, 1, 2, 3] - * - * range(-4) - * // => [0, -1, -2, -3] - * - * range(1, 5) - * // => [1, 2, 3, 4] - * - * range(0, 20, 5) - * // => [0, 5, 10, 15] - * - * range(0, -4, -1) - * // => [0, -1, -2, -3] - * - * range(1, 4, 0) - * // => [1, 1, 1] - * - * range(0) - * // => [] - */ -export const range = _createRange(); diff --git a/libs/nanofn/src/util/times.ts b/libs/nanofn/src/util/times.ts deleted file mode 100644 index 530787a4d..000000000 --- a/libs/nanofn/src/util/times.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used as references for various `Number` constants. */ -const MAX_SAFE_INTEGER = 9007199254740991; - -/** Used as references for the maximum length and index of an array. */ -const MAX_ARRAY_LENGTH = 4294967295; - -/** - * Invokes the iteratee `n` times, returning an array of the results of - * each invocation. The iteratee is invoked with one argument: (index). - * - * @category Util - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - * @example - * - * times(3, String) - * // => ['0', '1', '2'] - * - * times(4, () => 0) - * // => [0, 0, 0, 0] - */ -export function times(n: number, iteratee: (...args: any[]) => any): any[] { - if (n < 1 || n > MAX_SAFE_INTEGER) { - return []; - } - let index = -1; - const length = Math.min(n, MAX_ARRAY_LENGTH); - const result = new Array(length); - while (++index < length) { - result[index] = iteratee(index); - } - index = MAX_ARRAY_LENGTH; - n -= MAX_ARRAY_LENGTH; - while (++index < n) { - iteratee(index); - } - return result; -} - - diff --git a/libs/nanofn/src/util/unique-id.ts b/libs/nanofn/src/util/unique-id.ts deleted file mode 100644 index 79198e2f2..000000000 --- a/libs/nanofn/src/util/unique-id.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -/** Used to generate unique IDs. */ -const idCounter: Record = {}; - -/** - * Generates a unique ID. If `prefix` is given, the ID is appended to it. - * - * @category Util - * @param {string} [prefix=''] The value to prefix the ID with. - * @returns {string} Returns the unique ID. - * @see random - * @example - * - * uniqueId('contact_') - * // => 'contact_104' - * - * uniqueId() - * // => '105' - */ -export function uniqueId(prefix = '$$narafun$$') { - if (!idCounter[prefix]) { - idCounter[prefix] = 0; - } - - const id = ++idCounter[prefix]; - if (prefix === '$$narafun$$') { - return `${id}`; - } - - return `${prefix}${id}`; -} - - diff --git a/libs/nanofn/test-setup.ts b/libs/nanofn/test-setup.ts deleted file mode 100644 index a702c6339..000000000 --- a/libs/nanofn/test-setup.ts +++ /dev/null @@ -1 +0,0 @@ -import "jest-preset-angular/setup-jest"; diff --git a/libs/nanofn/test/Arrays-category-methods.js b/libs/nanofn/test/Arrays-category-methods.js deleted file mode 100644 index 79cd15954..000000000 --- a/libs/nanofn/test/Arrays-category-methods.js +++ /dev/null @@ -1,97 +0,0 @@ -import assert from 'assert'; -import { args, toArgs, identity } from './utils.js'; -import difference from '../difference.js'; -import union from '../union.js'; -import compact from '../compact.js'; -import drop from '../drop.js'; -import dropRight from '../dropRight.js'; -import dropRightWhile from '../dropRightWhile.js'; -import dropWhile from '../dropWhile.js'; -import findIndex from '../findIndex.js'; -import findLastIndex from '../findLastIndex.js'; -import flatten from '../flatten.js'; -import head from '../head.js'; -import indexOf from '../indexOf.js'; -import initial from '../initial.js'; -import intersection from '../intersection.js'; -import last from '../last.js'; -import lastIndexOf from '../lastIndexOf.js'; -import sortedIndex from '../sortedIndex.js'; -import sortedIndexOf from '../sortedIndexOf.js'; -import sortedLastIndex from '../sortedLastIndex.js'; -import sortedLastIndexOf from '../sortedLastIndexOf.js'; -import tail from '../tail.js'; -import take from '../take.js'; -import takeRight from '../takeRight.js'; -import takeRightWhile from '../takeRightWhile.js'; -import takeWhile from '../takeWhile.js'; -import uniq from '../uniq.js'; -import without from '../without.js'; -import zip from '../zip.js'; -import xor from '../xor.js'; - -describe('"Arrays" category methods', function() { - var args = toArgs([1, null, [3], null, 5]), - sortedArgs = toArgs([1, [3], 5, null, null]), - array = [1, 2, 3, 4, 5, 6]; - - it('should work with `arguments` objects', function() { - function message(methodName) { - return '`_.' + methodName + '` should work with `arguments` objects'; - } - - assert.deepStrictEqual(difference(args, [null]), [1, [3], 5], message('difference')); - assert.deepStrictEqual(difference(array, args), [2, 3, 4, 6], '_.difference should work with `arguments` objects as secondary arguments'); - - assert.deepStrictEqual(union(args, [null, 6]), [1, null, [3], 5, 6], message('union')); - assert.deepStrictEqual(union(array, args), array.concat([null, [3]]), '_.union should work with `arguments` objects as secondary arguments'); - - assert.deepStrictEqual(compact(args), [1, [3], 5], message('compact')); - assert.deepStrictEqual(drop(args, 3), [null, 5], message('drop')); - assert.deepStrictEqual(dropRight(args, 3), [1, null], message('dropRight')); - assert.deepStrictEqual(dropRightWhile(args,identity), [1, null, [3], null], message('dropRightWhile')); - assert.deepStrictEqual(dropWhile(args,identity), [null, [3], null, 5], message('dropWhile')); - assert.deepStrictEqual(findIndex(args, identity), 0, message('findIndex')); - assert.deepStrictEqual(findLastIndex(args, identity), 4, message('findLastIndex')); - assert.deepStrictEqual(flatten(args), [1, null, 3, null, 5], message('flatten')); - assert.deepStrictEqual(head(args), 1, message('head')); - assert.deepStrictEqual(indexOf(args, 5), 4, message('indexOf')); - assert.deepStrictEqual(initial(args), [1, null, [3], null], message('initial')); - assert.deepStrictEqual(intersection(args, [1]), [1], message('intersection')); - assert.deepStrictEqual(last(args), 5, message('last')); - assert.deepStrictEqual(lastIndexOf(args, 1), 0, message('lastIndexOf')); - assert.deepStrictEqual(sortedIndex(sortedArgs, 6), 3, message('sortedIndex')); - assert.deepStrictEqual(sortedIndexOf(sortedArgs, 5), 2, message('sortedIndexOf')); - assert.deepStrictEqual(sortedLastIndex(sortedArgs, 5), 3, message('sortedLastIndex')); - assert.deepStrictEqual(sortedLastIndexOf(sortedArgs, 1), 0, message('sortedLastIndexOf')); - assert.deepStrictEqual(tail(args, 4), [null, [3], null, 5], message('tail')); - assert.deepStrictEqual(take(args, 2), [1, null], message('take')); - assert.deepStrictEqual(takeRight(args, 1), [5], message('takeRight')); - assert.deepStrictEqual(takeRightWhile(args, identity), [5], message('takeRightWhile')); - assert.deepStrictEqual(takeWhile(args, identity), [1], message('takeWhile')); - assert.deepStrictEqual(uniq(args), [1, null, [3], 5], message('uniq')); - assert.deepStrictEqual(without(args, null), [1, [3], 5], message('without')); - assert.deepStrictEqual(zip(args, args), [[1, 1], [null, null], [[3], [3]], [null, null], [5, 5]], message('zip')); - }); - - it('should accept falsey primary arguments', function() { - function message(methodName) { - return '`_.' + methodName + '` should accept falsey primary arguments'; - } - - assert.deepStrictEqual(difference(null, array), [], message('difference')); - assert.deepStrictEqual(intersection(null, array), [], message('intersection')); - assert.deepStrictEqual(union(null, array), array, message('union')); - assert.deepStrictEqual(xor(null, array), array, message('xor')); - }); - - it('should accept falsey secondary arguments', function() { - function message(methodName) { - return '`_.' + methodName + '` should accept falsey secondary arguments'; - } - - assert.deepStrictEqual(difference(array, null), array, message('difference')); - assert.deepStrictEqual(intersection(array, null), [], message('intersection')); - assert.deepStrictEqual(union(array, null), array, message('union')); - }); -}); diff --git a/libs/nanofn/test/Strings-category-methods.test.js b/libs/nanofn/test/Strings-category-methods.test.js deleted file mode 100644 index 781a050ef..000000000 --- a/libs/nanofn/test/Strings-category-methods.test.js +++ /dev/null @@ -1,83 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubString } from './utils.js'; - -import camelCase from '../camelCase.js'; -import capitalize from '../capitalize.js'; -import escape from '../escape.js'; -import kebabCase from '../kebabCase.js'; -import lowerCase from '../lowerCase.js'; -import lowerFirst from '../lowerFirst.js'; -import pad from '../pad.js'; -import padEnd from '../padEnd.js'; -import padStart from '../padStart.js'; -import repeat from '../repeat.js'; -import snakeCase from '../snakeCase.js'; -import trim from '../trim.js'; -import trimStart from '../trimStart.js'; -import trimEnd from '../trimEnd.js'; -import truncate from '../truncate.js'; -import unescape from '../unescape.js'; -import upperCase from '../upperCase.js'; -import upperFirst from '../upperFirst'; - - -const methods = { - camelCase, - capitalize, - escape, - kebabCase, - lowerCase, - lowerFirst, - pad, - padEnd, - padStart, - repeat, - snakeCase, - trim, - trimStart, - trimEnd, - truncate, - unescape, - upperCase, - upperFirst -} - - -describe('"Strings" category methods', function() { - var stringMethods = [ - 'camelCase', - 'capitalize', - 'escape', - 'kebabCase', - 'lowerCase', - 'lowerFirst', - 'pad', - 'padEnd', - 'padStart', - 'repeat', - 'snakeCase', - 'trim', - 'trimEnd', - 'trimStart', - 'truncate', - 'unescape', - 'upperCase', - 'upperFirst' - ]; - - lodashStable.each(stringMethods, function(methodName) { - var func = methods[methodName]; - - it('`_.' + methodName + '` should return an empty string for empty values', function() { - var values = [, null, undefined, ''], - expected = lodashStable.map(values, stubString); - - var actual = lodashStable.map(values, function(value, index) { - return index ? func(value) : func(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/__proto__-property-bugs.js b/libs/nanofn/test/__proto__-property-bugs.js deleted file mode 100644 index 4814e441d..000000000 --- a/libs/nanofn/test/__proto__-property-bugs.js +++ /dev/null @@ -1,87 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, isEven, _, create, stubFalse, objectProto, funcProto } from './utils.js'; -import difference from '../difference.js'; -import intersection from '../intersection.js'; -import uniq from '../uniq.js'; -import without from '../without.js'; -import groupBy from '../groupBy.js'; -import merge from '../merge.js'; - -describe('`__proto__` property bugs', function() { - it('should work with the "__proto__" key in internal data objects', function() { - var stringLiteral = '__proto__', - stringObject = Object(stringLiteral), - expected = [stringLiteral, stringObject]; - - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, function(count) { - return isEven(count) ? stringLiteral : stringObject; - }); - - assert.deepStrictEqual(difference(largeArray, largeArray), []); - assert.deepStrictEqual(intersection(largeArray, largeArray), expected); - assert.deepStrictEqual(uniq(largeArray), expected); - assert.deepStrictEqual(without.apply(_, [largeArray].concat(largeArray)), []); - }); - - it('should treat "__proto__" as a regular key in assignments', function() { - var methods = [ - 'assign', - 'assignIn', - 'defaults', - 'defaultsDeep', - 'merge' - ]; - - var source = create(null); - source.__proto__ = []; - - var expected = lodashStable.map(methods, stubFalse); - - var actual = lodashStable.map(methods, function(methodName) { - var result = _[methodName]({}, source); - return result instanceof Array; - }); - - assert.deepStrictEqual(actual, expected); - - actual = groupBy([{ 'a': '__proto__' }], 'a'); - assert.ok(!(actual instanceof Array)); - }); - - it('should not merge "__proto__" properties', function() { - if (JSON) { - merge({}, JSON.parse('{"__proto__":{"a":1}}')); - - var actual = 'a' in objectProto; - delete objectProto.a; - - assert.ok(!actual); - } - }); - - it('should not indirectly merge builtin prototype properties', function() { - merge({}, { 'toString': { 'constructor': { 'prototype': { 'a': 1 } } } }); - - var actual = 'a' in funcProto; - delete funcProto.a; - - assert.ok(!actual); - - merge({}, { 'constructor': { 'prototype': { 'a': 1 } } }); - - actual = 'a' in objectProto; - delete objectProto.a; - - assert.ok(!actual); - }); - - it('should not indirectly merge `Object` properties', function() { - merge({}, { 'constructor': { 'a': 1 } }); - - var actual = 'a' in Object; - delete Object.a; - - assert.ok(!actual); - }); -}); diff --git a/libs/nanofn/test/add.test.js b/libs/nanofn/test/add.test.js deleted file mode 100644 index cbc12a0bc..000000000 --- a/libs/nanofn/test/add.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import add from '../add.js'; - -describe('add', function() { - it('should add two numbers', function() { - assert.strictEqual(add(6, 4), 10); - assert.strictEqual(add(-6, 4), -2); - assert.strictEqual(add(-6, -4), -10); - }); - - it('should not coerce arguments to numbers', function() { - assert.strictEqual(add('6', '4'), '64'); - assert.strictEqual(add('x', 'y'), 'xy'); - }); -}); diff --git a/libs/nanofn/test/after.test.js b/libs/nanofn/test/after.test.js deleted file mode 100644 index ab509ecd1..000000000 --- a/libs/nanofn/test/after.test.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import after from '../after.js'; - -describe('after', function() { - function testAfter(n, times) { - var count = 0; - lodashStable.times(times, after(n, function() { count++; })); - return count; - } - - it('should create a function that invokes `func` after `n` calls', function() { - assert.strictEqual(testAfter(5, 5), 1, 'after(n) should invoke `func` after being called `n` times'); - assert.strictEqual(testAfter(5, 4), 0, 'after(n) should not invoke `func` before being called `n` times'); - assert.strictEqual(testAfter(0, 0), 0, 'after(0) should not invoke `func` immediately'); - assert.strictEqual(testAfter(0, 1), 1, 'after(0) should invoke `func` when called once'); - }); - - it('should coerce `n` values of `NaN` to `0`', function() { - assert.strictEqual(testAfter(NaN, 1), 1); - }); - - it('should use `this` binding of function', function() { - var afterFn = after(1, function() { return ++this.count; }), - object = { 'after': afterFn, 'count': 0 }; - - object.after(); - assert.strictEqual(object.after(), 2); - assert.strictEqual(object.count, 2); - }); -}); diff --git a/libs/nanofn/test/ary.js b/libs/nanofn/test/ary.js deleted file mode 100644 index 80e5fb286..000000000 --- a/libs/nanofn/test/ary.js +++ /dev/null @@ -1,91 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, _ } from './utils.js'; -import ary from '../ary.js'; -import curry from '../curry.js'; -import rearg from '../rearg.js'; - -describe('ary', function() { - function fn(a, b, c) { - return slice.call(arguments); - } - - it('should cap the number of arguments provided to `func`', function() { - var actual = lodashStable.map(['6', '8', '10'], ary(parseInt, 1)); - assert.deepStrictEqual(actual, [6, 8, 10]); - - var capped = ary(fn, 2); - assert.deepStrictEqual(capped('a', 'b', 'c', 'd'), ['a', 'b']); - }); - - it('should use `func.length` if `n` is not given', function() { - var capped = ary(fn); - assert.deepStrictEqual(capped('a', 'b', 'c', 'd'), ['a', 'b', 'c']); - }); - - it('should treat a negative `n` as `0`', function() { - var capped = ary(fn, -1); - - try { - var actual = capped('a'); - } catch (e) {} - - assert.deepStrictEqual(actual, []); - }); - - it('should coerce `n` to an integer', function() { - var values = ['1', 1.6, 'xyz'], - expected = [['a'], ['a'], []]; - - var actual = lodashStable.map(values, function(n) { - var capped = ary(fn, n); - return capped('a', 'b'); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not force a minimum argument count', function() { - var args = ['a', 'b', 'c'], - capped = ary(fn, 3); - - var expected = lodashStable.map(args, function(arg, index) { - return args.slice(0, index); - }); - - var actual = lodashStable.map(expected, function(array) { - return capped.apply(undefined, array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should use `this` binding of function', function() { - var capped = ary(function(a, b) { return this; }, 1), - object = { 'capped': capped }; - - assert.strictEqual(object.capped(), object); - }); - - it('should use the existing `ary` if smaller', function() { - var capped = ary(ary(fn, 1), 2); - assert.deepStrictEqual(capped('a', 'b', 'c'), ['a']); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var funcs = lodashStable.map([fn], ary), - actual = funcs[0]('a', 'b', 'c'); - - assert.deepStrictEqual(actual, ['a', 'b', 'c']); - }); - - it('should work when combined with other methods that use metadata', function() { - var array = ['a', 'b', 'c'], - includes = curry(rearg(ary(_.includes, 2), 1, 0), 2); - - assert.strictEqual(includes('b')(array, 2), true); - - includes = _(_.includes).ary(2).rearg(1, 0).curry(2).value(); - assert.strictEqual(includes('b')(array, 2), true); - }); -}); diff --git a/libs/nanofn/test/assign-and-assignIn.js b/libs/nanofn/test/assign-and-assignIn.js deleted file mode 100644 index 251d199ce..000000000 --- a/libs/nanofn/test/assign-and-assignIn.js +++ /dev/null @@ -1,88 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, defineProperty, stubOne, noop, stubNaN } from './utils.js'; - -describe('assign and assignIn', function() { - lodashStable.each(['assign', 'assignIn'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should assign source properties to `object`', function() { - assert.deepStrictEqual(func({ 'a': 1 }, { 'b': 2 }), { 'a': 1, 'b': 2 }); - }); - - it('`_.' + methodName + '` should accept multiple sources', function() { - var expected = { 'a': 1, 'b': 2, 'c': 3 }; - assert.deepStrictEqual(func({ 'a': 1 }, { 'b': 2 }, { 'c': 3 }), expected); - assert.deepStrictEqual(func({ 'a': 1 }, { 'b': 2, 'c': 2 }, { 'c': 3 }), expected); - }); - - it('`_.' + methodName + '` should overwrite destination properties', function() { - var expected = { 'a': 3, 'b': 2, 'c': 1 }; - assert.deepStrictEqual(func({ 'a': 1, 'b': 2 }, expected), expected); - }); - - it('`_.' + methodName + '` should assign source properties with nullish values', function() { - var expected = { 'a': null, 'b': undefined, 'c': null }; - assert.deepStrictEqual(func({ 'a': 1, 'b': 2 }, expected), expected); - }); - - it('`_.' + methodName + '` should skip assignments if values are the same', function() { - var object = {}; - - var descriptor = { - 'configurable': true, - 'enumerable': true, - 'set': function() { throw new Error; } - }; - - var source = { - 'a': 1, - 'b': undefined, - 'c': NaN, - 'd': undefined, - 'constructor': Object, - 'toString': lodashStable.constant('source') - }; - - defineProperty(object, 'a', lodashStable.assign({}, descriptor, { - 'get': stubOne - })); - - defineProperty(object, 'b', lodashStable.assign({}, descriptor, { - 'get': noop - })); - - defineProperty(object, 'c', lodashStable.assign({}, descriptor, { - 'get': stubNaN - })); - - defineProperty(object, 'constructor', lodashStable.assign({}, descriptor, { - 'get': lodashStable.constant(Object) - })); - - try { - var actual = func(object, source); - } catch (e) {} - - assert.deepStrictEqual(actual, source); - }); - - it('`_.' + methodName + '` should treat sparse array sources as dense', function() { - var array = [1]; - array[2] = 3; - - assert.deepStrictEqual(func({}, array), { '0': 1, '1': undefined, '2': 3 }); - }); - - it('`_.' + methodName + '` should assign values of prototype objects', function() { - function Foo() {} - Foo.prototype.a = 1; - - assert.deepStrictEqual(func({}, Foo.prototype), { 'a': 1 }); - }); - - it('`_.' + methodName + '` should coerce string sources to objects', function() { - assert.deepStrictEqual(func({}, 'a'), { '0': 'a' }); - }); - }); -}); diff --git a/libs/nanofn/test/assignIn.js b/libs/nanofn/test/assignIn.js deleted file mode 100644 index 03a93beab..000000000 --- a/libs/nanofn/test/assignIn.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import extend from '../extend.js'; -import assignIn from '../assignIn.js'; - -describe('assignIn', function() { - it('should be aliased', function() { - assert.strictEqual(extend, assignIn); - }); -}); diff --git a/libs/nanofn/test/assignInWith.js b/libs/nanofn/test/assignInWith.js deleted file mode 100644 index e253b3f1e..000000000 --- a/libs/nanofn/test/assignInWith.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import extendWith from '../extendWith.js'; -import assignInWith from '../assignInWith.js'; - -describe('assignInWith', function() { - it('should be aliased', function() { - assert.strictEqual(extendWith, assignInWith); - }); -}); diff --git a/libs/nanofn/test/assignWith-and-assignInWith.js b/libs/nanofn/test/assignWith-and-assignInWith.js deleted file mode 100644 index 70ec24a6b..000000000 --- a/libs/nanofn/test/assignWith-and-assignInWith.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, noop } from './utils.js'; - -describe('assignWith and assignInWith', function() { - lodashStable.each(['assignWith', 'assignInWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should work with a `customizer` callback', function() { - var actual = func({ 'a': 1, 'b': 2 }, { 'a': 3, 'c': 3 }, function(a, b) { - return a === undefined ? b : a; - }); - - assert.deepStrictEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); - }); - - it('`_.' + methodName + '` should work with a `customizer` that returns `undefined`', function() { - var expected = { 'a': 1 }; - assert.deepStrictEqual(func({}, expected, noop), expected); - }); - }); -}); diff --git a/libs/nanofn/test/at.test.js b/libs/nanofn/test/at.test.js deleted file mode 100644 index c466829f2..000000000 --- a/libs/nanofn/test/at.test.js +++ /dev/null @@ -1,124 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, stubOne, falsey, args, LARGE_ARRAY_SIZE, square, identity } from './utils.js'; -import at from '../at.js'; - -describe('at', function() { - var array = ['a', 'b', 'c'], - object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; - - it('should return the elements corresponding to the specified keys', function() { - var actual = at(array, [0, 2]); - assert.deepStrictEqual(actual, ['a', 'c']); - }); - - it('should return `undefined` for nonexistent keys', function() { - var actual = at(array, [2, 4, 0]); - assert.deepStrictEqual(actual, ['c', undefined, 'a']); - }); - - it('should work with non-index keys on array values', function() { - var values = lodashStable.reject(empties, function(value) { - return (value === 0) || lodashStable.isArray(value); - }).concat(-1, 1.1); - - var array = lodashStable.transform(values, function(result, value) { - result[value] = 1; - }, []); - - var expected = lodashStable.map(values, stubOne), - actual = at(array, values); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an empty array when no keys are given', function() { - assert.deepStrictEqual(at(array), []); - assert.deepStrictEqual(at(array, [], []), []); - }); - - it('should accept multiple key arguments', function() { - var actual = at(['a', 'b', 'c', 'd'], 3, 0, 2); - assert.deepStrictEqual(actual, ['d', 'a', 'c']); - }); - - it('should work with a falsey `object` when keys are given', function() { - var expected = lodashStable.map(falsey, lodashStable.constant(Array(4).fill(undefined))); - - var actual = lodashStable.map(falsey, function(object) { - try { - return at(object, 0, 1, 'pop', 'push'); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with an `arguments` object for `object`', function() { - var actual = at(args, [2, 0]); - assert.deepStrictEqual(actual, [3, 1]); - }); - - it('should work with `arguments` object as secondary arguments', function() { - var actual = at([1, 2, 3, 4, 5], args); - assert.deepStrictEqual(actual, [2, 3, 4]); - }); - - it('should work with an object for `object`', function() { - var actual = at(object, ['a[0].b.c', 'a[1]']); - assert.deepStrictEqual(actual, [3, 4]); - }); - - it('should pluck inherited property values', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var actual = at(new Foo, 'b'); - assert.deepStrictEqual(actual, [2]); - }); - - it('should work in a lazy sequence', function() { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE), - smallArray = array; - - lodashStable.each([[2], ['2'], [2, 1]], function(paths) { - lodashStable.times(2, function(index) { - var array = index ? largeArray : smallArray, - wrapped = _(array).map(identity).at(paths); - - assert.deepEqual(wrapped.value(), at(_.map(array, identity), paths)); - }); - }); - }); - - it('should support shortcut fusion', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - count = 0, - iteratee = function(value) { count++; return square(value); }, - lastIndex = LARGE_ARRAY_SIZE - 1; - - lodashStable.each([lastIndex, lastIndex + '', LARGE_ARRAY_SIZE, []], function(n, index) { - count = 0; - var actual = _(array).map(iteratee).at(n).value(), - expected = index < 2 ? 1 : 0; - - assert.strictEqual(count, expected); - - expected = index == 3 ? [] : [index == 2 ? undefined : square(lastIndex)]; - assert.deepEqual(actual, expected); - }); - }); - - it('work with an object for `object` when chaining', function() { - var paths = ['a[0].b.c', 'a[1]'], - actual = _(object).map(identity).at(paths).value(); - - assert.deepEqual(actual, at(_.map(object, identity), paths)); - - var indexObject = { '0': 1 }; - actual = _(indexObject).at(0).value(); - assert.deepEqual(actual, at(indexObject, 0)); - }); -}); diff --git a/libs/nanofn/test/attempt.test.js b/libs/nanofn/test/attempt.test.js deleted file mode 100644 index d453ce0ac..000000000 --- a/libs/nanofn/test/attempt.test.js +++ /dev/null @@ -1,55 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, errors, stubTrue, CustomError, realm } from './utils.js'; -import attempt from '../attempt.js'; - -describe('attempt', function() { - it('should return the result of `func`', function() { - assert.strictEqual(attempt(lodashStable.constant('x')), 'x'); - }); - - it('should provide additional arguments to `func`', function() { - var actual = attempt(function() { return slice.call(arguments); }, 1, 2); - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('should return the caught error', function() { - var expected = lodashStable.map(errors, stubTrue); - - var actual = lodashStable.map(errors, function(error) { - return attempt(function() { throw error; }) === error; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should coerce errors to error objects', function() { - var actual = attempt(function() { throw 'x'; }); - assert.ok(lodashStable.isEqual(actual, Error('x'))); - }); - - it('should preserve custom errors', function() { - var actual = attempt(function() { throw new CustomError('x'); }); - assert.ok(actual instanceof CustomError); - }); - - it('should work with an error object from another realm', function() { - if (realm.errors) { - var expected = lodashStable.map(realm.errors, stubTrue); - - var actual = lodashStable.map(realm.errors, function(error) { - return attempt(function() { throw error; }) === error; - }); - - assert.deepStrictEqual(actual, expected); - } - }); - - it('should return an unwrapped value when implicitly chaining', function() { - assert.strictEqual(_(lodashStable.constant('x')).attempt(), 'x'); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_(lodashStable.constant('x')).chain().attempt() instanceof _); - }); -}); diff --git a/libs/nanofn/test/basename.js b/libs/nanofn/test/basename.js deleted file mode 100644 index e60f93796..000000000 --- a/libs/nanofn/test/basename.js +++ /dev/null @@ -1,151 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - basename, - amd, - ui, - Worker, - QUnit, - lodashBizarro, - LARGE_ARRAY_SIZE, - symbol, - setProperty, -} from './utils.js'; - -import _VERSION from '../.internal/VERSION.js'; -import VERSION from '../VERSION.js'; - -describe(basename, function() { - it('should support loading ' + basename + ' as the "lodash" module', function() { - if (amd) { - assert.strictEqual((lodashModule || {}).moduleName, 'lodash'); - } - }); - - it('should support loading ' + basename + ' with the Require.js "shim" configuration option', function() { - if (amd && lodashStable.includes(ui.loaderPath, 'requirejs')) { - assert.strictEqual((shimmedModule || {}).moduleName, 'shimmed'); - } - }); - - it('should support loading ' + basename + ' as the "underscore" module', function() { - if (amd) { - assert.strictEqual((underscoreModule || {}).moduleName, 'underscore'); - } - }); - - it('should support loading ' + basename + ' in a web worker', function(done) { - if (Worker) { - var limit = 30000 / QUnit.config.asyncRetries, - start = +new Date; - - var attempt = function() { - var actual = _VERSION; - if ((new Date - start) < limit && typeof actual !== 'string') { - setTimeout(attempt, 16); - return; - } - assert.strictEqual(actual, VERSION); - done(); - }; - - attempt(); - } - else { - done(); - } - }); - - it('should not add `Function.prototype` extensions to lodash', function() { - if (lodashBizarro) { - assert.ok(!('_method' in lodashBizarro)); - } - }); - - it('should avoid non-native built-ins', function() { - function message(lodashMethod, nativeMethod) { - return '`' + lodashMethod + '` should avoid overwritten native `' + nativeMethod + '`'; - } - - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var object = { 'a': 1 }, - otherObject = { 'b': 2 }, - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(object)); - - if (lodashBizarro) { - try { - var actual = lodashBizarro.create(Foo.prototype); - } catch (e) { - actual = null; - } - var label = message('_.create', 'Object.create'); - assert.ok(actual instanceof Foo, label); - - try { - actual = [ - lodashBizarro.difference([object, otherObject], largeArray), - lodashBizarro.intersection(largeArray, [object]), - lodashBizarro.uniq(largeArray) - ]; - } catch (e) { - actual = null; - } - label = message('_.difference`, `_.intersection`, and `_.uniq', 'Map'); - assert.deepStrictEqual(actual, [[otherObject], [object], [object]], label); - - try { - if (Symbol) { - object[symbol] = {}; - } - actual = [ - lodashBizarro.clone(object), - lodashBizarro.cloneDeep(object) - ]; - } catch (e) { - actual = null; - } - label = message('_.clone` and `_.cloneDeep', 'Object.getOwnPropertySymbols'); - assert.deepStrictEqual(actual, [object, object], label); - - try { - // Avoid buggy symbol detection in Babel's `_typeof` helper. - var symObject = setProperty(Object(symbol), 'constructor', Object); - actual = [ - Symbol ? lodashBizarro.clone(symObject) : {}, - Symbol ? lodashBizarro.isEqual(symObject, Object(symbol)) : false, - Symbol ? lodashBizarro.toString(symObject) : '' - ]; - } catch (e) { - actual = null; - } - label = message('_.clone`, `_.isEqual`, and `_.toString', 'Symbol'); - assert.deepStrictEqual(actual, [{}, false, ''], label); - - try { - var map = new lodashBizarro.memoize.Cache; - actual = map.set('a', 1).get('a'); - } catch (e) { - actual = null; - } - label = message('_.memoize.Cache', 'Map'); - assert.deepStrictEqual(actual, 1, label); - - try { - map = new (Map || Object); - if (Symbol && Symbol.iterator) { - map[Symbol.iterator] = null; - } - actual = lodashBizarro.toArray(map); - } catch (e) { - actual = null; - } - label = message('_.toArray', 'Map'); - assert.deepStrictEqual(actual, [], label); - } - }); -}); diff --git a/libs/nanofn/test/before.js b/libs/nanofn/test/before.js deleted file mode 100644 index d1a678b1e..000000000 --- a/libs/nanofn/test/before.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('before', function() { - function before(n, times) { - var count = 0; - lodashStable.times(times, _.before(n, function() { count++; })); - return count; - } - - it('should create a function that invokes `func` after `n` calls', function() { - assert.strictEqual(before(5, 4), 4, 'before(n) should invoke `func` before being called `n` times'); - assert.strictEqual(before(5, 6), 4, 'before(n) should not invoke `func` after being called `n - 1` times'); - assert.strictEqual(before(0, 0), 0, 'before(0) should not invoke `func` immediately'); - assert.strictEqual(before(0, 1), 0, 'before(0) should not invoke `func` when called'); - }); - - it('should coerce `n` values of `NaN` to `0`', function() { - assert.strictEqual(before(NaN, 1), 0); - }); - - it('should use `this` binding of function', function() { - var before = _.before(2, function() { return ++this.count; }), - object = { 'before': before, 'count': 0 }; - - object.before(); - assert.strictEqual(object.before(), 1); - assert.strictEqual(object.count, 1); - }); -}); diff --git a/libs/nanofn/test/bind.js b/libs/nanofn/test/bind.js deleted file mode 100644 index 384ddd9b3..000000000 --- a/libs/nanofn/test/bind.js +++ /dev/null @@ -1,231 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { push, falsey, stubTrue } from './utils.js'; -import bind from '../bind.js'; -import placeholder from '../placeholder.js'; - -describe('bind', function() { - function fn() { - var result = [this]; - push.apply(result, arguments); - return result; - } - - it('should bind a function to an object', function() { - var object = {}, - bound = bind(fn, object); - - assert.deepStrictEqual(bound('a'), [object, 'a']); - }); - - it('should accept a falsey `thisArg`', function() { - var values = lodashStable.reject(falsey.slice(1), function(value) { return value == null; }), - expected = lodashStable.map(values, function(value) { return [value]; }); - - var actual = lodashStable.map(values, function(value) { - try { - var bound = bind(fn, value); - return bound(); - } catch (e) {} - }); - - assert.ok(lodashStable.every(actual, function(value, index) { - return lodashStable.isEqual(value, expected[index]); - })); - }); - - it('should bind a function to nullish values', function() { - var bound = bind(fn, null), - actual = bound('a'); - - assert.ok((actual[0] === null) || (actual[0] && actual[0].Array)); - assert.strictEqual(actual[1], 'a'); - - lodashStable.times(2, function(index) { - bound = index ? bind(fn, undefined) : bind(fn); - actual = bound('b'); - - assert.ok((actual[0] === undefined) || (actual[0] && actual[0].Array)); - assert.strictEqual(actual[1], 'b'); - }); - }); - - it('should partially apply arguments ', function() { - var object = {}, - bound = bind(fn, object, 'a'); - - assert.deepStrictEqual(bound(), [object, 'a']); - - bound = bind(fn, object, 'a'); - assert.deepStrictEqual(bound('b'), [object, 'a', 'b']); - - bound = bind(fn, object, 'a', 'b'); - assert.deepStrictEqual(bound(), [object, 'a', 'b']); - assert.deepStrictEqual(bound('c', 'd'), [object, 'a', 'b', 'c', 'd']); - }); - - it('should support placeholders', function() { - var object = {}, - ph = bind.placeholder, - bound = bind(fn, object, ph, 'b', ph); - - assert.deepStrictEqual(bound('a', 'c'), [object, 'a', 'b', 'c']); - assert.deepStrictEqual(bound('a'), [object, 'a', 'b', undefined]); - assert.deepStrictEqual(bound('a', 'c', 'd'), [object, 'a', 'b', 'c', 'd']); - assert.deepStrictEqual(bound(), [object, undefined, 'b', undefined]); - }); - - it('should use `_.placeholder` when set', function() { - var _ph = placeholder = {}, - ph = bind.placeholder, - object = {}, - bound = bind(fn, object, _ph, 'b', ph); - - assert.deepEqual(bound('a', 'c'), [object, 'a', 'b', ph, 'c']); - delete placeholder; - }); - - it('should create a function with a `length` of `0`', function() { - var fn = function(a, b, c) {}, - bound = bind(fn, {}); - - assert.strictEqual(bound.length, 0); - - bound = bind(fn, {}, 1); - assert.strictEqual(bound.length, 0); - }); - - it('should ignore binding when called with the `new` operator', function() { - function Foo() { - return this; - } - - var bound = bind(Foo, { 'a': 1 }), - newBound = new bound; - - assert.strictEqual(bound().a, 1); - assert.strictEqual(newBound.a, undefined); - assert.ok(newBound instanceof Foo); - }); - - it('should handle a number of arguments when called with the `new` operator', function() { - function Foo() { - return this; - } - - function Bar() {} - - var thisArg = { 'a': 1 }, - boundFoo = bind(Foo, thisArg), - boundBar = bind(Bar, thisArg), - count = 9, - expected = lodashStable.times(count, lodashStable.constant([undefined, undefined])); - - var actual = lodashStable.times(count, function(index) { - try { - switch (index) { - case 0: return [new boundFoo().a, new boundBar().a]; - case 1: return [new boundFoo(1).a, new boundBar(1).a]; - case 2: return [new boundFoo(1, 2).a, new boundBar(1, 2).a]; - case 3: return [new boundFoo(1, 2, 3).a, new boundBar(1, 2, 3).a]; - case 4: return [new boundFoo(1, 2, 3, 4).a, new boundBar(1, 2, 3, 4).a]; - case 5: return [new boundFoo(1, 2, 3, 4, 5).a, new boundBar(1, 2, 3, 4, 5).a]; - case 6: return [new boundFoo(1, 2, 3, 4, 5, 6).a, new boundBar(1, 2, 3, 4, 5, 6).a]; - case 7: return [new boundFoo(1, 2, 3, 4, 5, 6, 7).a, new boundBar(1, 2, 3, 4, 5, 6, 7).a]; - case 8: return [new boundFoo(1, 2, 3, 4, 5, 6, 7, 8).a, new boundBar(1, 2, 3, 4, 5, 6, 7, 8).a]; - } - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should ensure `new bound` is an instance of `func`', function() { - function Foo(value) { - return value && object; - } - - var bound = bind(Foo), - object = {}; - - assert.ok(new bound instanceof Foo); - assert.strictEqual(new bound(true), object); - }); - - it('should append array arguments to partially applied arguments', function() { - var object = {}, - bound = bind(fn, object, 'a'); - - assert.deepStrictEqual(bound(['b'], 'c'), [object, 'a', ['b'], 'c']); - }); - - it('should not rebind functions', function() { - var object1 = {}, - object2 = {}, - object3 = {}; - - var bound1 = bind(fn, object1), - bound2 = bind(bound1, object2, 'a'), - bound3 = bind(bound1, object3, 'b'); - - assert.deepStrictEqual(bound1(), [object1]); - assert.deepStrictEqual(bound2(), [object1, 'a']); - assert.deepStrictEqual(bound3(), [object1, 'b']); - }); - - it('should not error when instantiating bound built-ins', function() { - var Ctor = bind(Date, null), - expected = new Date(2012, 4, 23, 0, 0, 0, 0); - - try { - var actual = new Ctor(2012, 4, 23, 0, 0, 0, 0); - } catch (e) {} - - assert.deepStrictEqual(actual, expected); - - Ctor = bind(Date, null, 2012, 4, 23); - - try { - actual = new Ctor(0, 0, 0, 0); - } catch (e) {} - - assert.deepStrictEqual(actual, expected); - }); - - it('should not error when calling bound class constructors with the `new` operator', function() { - var createCtor = lodashStable.attempt(Function, '"use strict";return class A{}'); - - if (typeof createCtor === 'function') { - var bound = bind(createCtor()), - count = 8, - expected = lodashStable.times(count, stubTrue); - - var actual = lodashStable.times(count, function(index) { - try { - switch (index) { - case 0: return !!(new bound); - case 1: return !!(new bound(1)); - case 2: return !!(new bound(1, 2)); - case 3: return !!(new bound(1, 2, 3)); - case 4: return !!(new bound(1, 2, 3, 4)); - case 5: return !!(new bound(1, 2, 3, 4, 5)); - case 6: return !!(new bound(1, 2, 3, 4, 5, 6)); - case 7: return !!(new bound(1, 2, 3, 4, 5, 6, 7)); - } - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - } - }); - - it('should return a wrapped value when chaining', function() { - var object = {}, - bound = _(fn).bind({}, 'a', 'b'); - - assert.ok(bound instanceof _); - - var actual = bound.value()('c'); - assert.deepEqual(actual, [object, 'a', 'b', 'c']); - }); -}); diff --git a/libs/nanofn/test/bindAll.js b/libs/nanofn/test/bindAll.js deleted file mode 100644 index a085bd97b..000000000 --- a/libs/nanofn/test/bindAll.js +++ /dev/null @@ -1,74 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, toArgs, arrayProto } from './utils.js'; -import bindAll from '../bindAll.js'; - -describe('bindAll', function() { - var args = toArgs(['a']); - - var source = { - '_n0': -2, - '_p0': -1, - '_a': 1, - '_b': 2, - '_c': 3, - '_d': 4, - '-0': function() { return this._n0; }, - '0': function() { return this._p0; }, - 'a': function() { return this._a; }, - 'b': function() { return this._b; }, - 'c': function() { return this._c; }, - 'd': function() { return this._d; } - }; - - it('should accept individual method names', function() { - var object = lodashStable.cloneDeep(source); - bindAll(object, 'a', 'b'); - - var actual = lodashStable.map(['a', 'b', 'c'], function(key) { - return object[key].call({}); - }); - - assert.deepStrictEqual(actual, [1, 2, undefined]); - }); - - it('should accept arrays of method names', function() { - var object = lodashStable.cloneDeep(source); - bindAll(object, ['a', 'b'], ['c']); - - var actual = lodashStable.map(['a', 'b', 'c', 'd'], function(key) { - return object[key].call({}); - }); - - assert.deepStrictEqual(actual, [1, 2, 3, undefined]); - }); - - it('should preserve the sign of `0`', function() { - var props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - var object = lodashStable.cloneDeep(source); - bindAll(object, key); - return object[lodashStable.toString(key)].call({}); - }); - - assert.deepStrictEqual(actual, [-2, -2, -1, -1]); - }); - - it('should work with an array `object`', function() { - var array = ['push', 'pop']; - bindAll(array); - assert.strictEqual(array.pop, arrayProto.pop); - }); - - it('should work with `arguments` objects as secondary arguments', function() { - var object = lodashStable.cloneDeep(source); - bindAll(object, args); - - var actual = lodashStable.map(args, function(key) { - return object[key].call({}); - }); - - assert.deepStrictEqual(actual, [1]); - }); -}); diff --git a/libs/nanofn/test/bindKey.js b/libs/nanofn/test/bindKey.js deleted file mode 100644 index 1489f30d3..000000000 --- a/libs/nanofn/test/bindKey.js +++ /dev/null @@ -1,66 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import bindKey from '../bindKey.js'; - -describe('bindKey', function() { - it('should work when the target function is overwritten', function() { - var object = { - 'user': 'fred', - 'greet': function(greeting) { - return this.user + ' says: ' + greeting; - } - }; - - var bound = bindKey(object, 'greet', 'hi'); - assert.strictEqual(bound(), 'fred says: hi'); - - object.greet = function(greeting) { - return this.user + ' says: ' + greeting + '!'; - }; - - assert.strictEqual(bound(), 'fred says: hi!'); - }); - - it('should support placeholders', function() { - var object = { - 'fn': function() { - return slice.call(arguments); - } - }; - - var ph = bindKey.placeholder, - bound = bindKey(object, 'fn', ph, 'b', ph); - - assert.deepStrictEqual(bound('a', 'c'), ['a', 'b', 'c']); - assert.deepStrictEqual(bound('a'), ['a', 'b', undefined]); - assert.deepStrictEqual(bound('a', 'c', 'd'), ['a', 'b', 'c', 'd']); - assert.deepStrictEqual(bound(), [undefined, 'b', undefined]); - }); - - it('should use `_.placeholder` when set', function() { - var object = { - 'fn': function() { - return slice.call(arguments); - } - }; - - var _ph = _.placeholder = {}, - ph = bindKey.placeholder, - bound = bindKey(object, 'fn', _ph, 'b', ph); - - assert.deepEqual(bound('a', 'c'), ['a', 'b', ph, 'c']); - delete _.placeholder; - }); - - it('should ensure `new bound` is an instance of `object[key]`', function() { - function Foo(value) { - return value && object; - } - - var object = { 'Foo': Foo }, - bound = bindKey(object, 'Foo'); - - assert.ok(new bound instanceof Foo); - assert.strictEqual(new bound(true), object); - }); -}); diff --git a/libs/nanofn/test/camelCase.test.js b/libs/nanofn/test/camelCase.test.js deleted file mode 100644 index 89a36b02c..000000000 --- a/libs/nanofn/test/camelCase.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import camelCase from '../camelCase.js'; - -describe('camelCase', function() { - it('should work with numbers', function() { - assert.strictEqual(camelCase('12 feet'), '12Feet'); - assert.strictEqual(camelCase('enable 6h format'), 'enable6HFormat'); - assert.strictEqual(camelCase('enable 24H format'), 'enable24HFormat'); - assert.strictEqual(camelCase('too legit 2 quit'), 'tooLegit2Quit'); - assert.strictEqual(camelCase('walk 500 miles'), 'walk500Miles'); - assert.strictEqual(camelCase('xhr2 request'), 'xhr2Request'); - }); - - it('should handle acronyms', function() { - lodashStable.each(['safe HTML', 'safeHTML'], function(string) { - assert.strictEqual(camelCase(string), 'safeHtml'); - }); - - lodashStable.each(['escape HTML entities', 'escapeHTMLEntities'], function(string) { - assert.strictEqual(camelCase(string), 'escapeHtmlEntities'); - }); - - lodashStable.each(['XMLHttpRequest', 'XmlHTTPRequest'], function(string) { - assert.strictEqual(camelCase(string), 'xmlHttpRequest'); - }); - }); -}); diff --git a/libs/nanofn/test/capitalize.test.js b/libs/nanofn/test/capitalize.test.js deleted file mode 100644 index 0aeb2be92..000000000 --- a/libs/nanofn/test/capitalize.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import capitalize from '../capitalize.js'; - -describe('capitalize', function() { - it('should capitalize the first character of a string', function() { - assert.strictEqual(capitalize('fred'), 'Fred'); - assert.strictEqual(capitalize('Fred'), 'Fred'); - assert.strictEqual(capitalize(' fred'), ' fred'); - }); -}); diff --git a/libs/nanofn/test/case-methods.test.js b/libs/nanofn/test/case-methods.test.js deleted file mode 100644 index 0fb6a5d87..000000000 --- a/libs/nanofn/test/case-methods.test.js +++ /dev/null @@ -1,105 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue, burredLetters, deburredLetters } from './utils.js'; -import camelCase from '../camelCase.js'; -import kebabCase from '../kebabCase.js'; -import lowerCase from '../lowerCase.js'; -import snakeCase from '../snakeCase.js'; -import startCase from '../startCase.js'; -import upperCase from '../upperCase.js'; - -const caseMethods = { - camelCase, - kebabCase, - lowerCase, - snakeCase, - startCase, - upperCase -}; - -describe('case methods', function() { - lodashStable.each(['camel', 'kebab', 'lower', 'snake', 'start', 'upper'], function(caseName) { - var methodName = caseName + 'Case', - func = caseMethods[methodName]; - - var strings = [ - 'foo bar', 'Foo bar', 'foo Bar', 'Foo Bar', - 'FOO BAR', 'fooBar', '--foo-bar--', '__foo_bar__' - ]; - - var converted = (function() { - switch (caseName) { - case 'camel': return 'fooBar'; - case 'kebab': return 'foo-bar'; - case 'lower': return 'foo bar'; - case 'snake': return 'foo_bar'; - case 'start': return 'Foo Bar'; - case 'upper': return 'FOO BAR'; - } - }()); - - it('`_.' + methodName + '` should convert `string` to ' + caseName + ' case', function() { - var actual = lodashStable.map(strings, function(string) { - var expected = (caseName == 'start' && string == 'FOO BAR') ? string : converted; - return func(string) === expected; - }); - - assert.deepStrictEqual(actual, lodashStable.map(strings, stubTrue)); - }); - - it('`_.' + methodName + '` should handle double-converting strings', function() { - var actual = lodashStable.map(strings, function(string) { - var expected = (caseName == 'start' && string == 'FOO BAR') ? string : converted; - return func(func(string)) === expected; - }); - - assert.deepStrictEqual(actual, lodashStable.map(strings, stubTrue)); - }); - - it('`_.' + methodName + '` should remove contraction apostrophes', function() { - var postfixes = ['d', 'll', 'm', 're', 's', 't', 've']; - - lodashStable.each(["'", '\u2019'], function(apos) { - var actual = lodashStable.map(postfixes, function(postfix) { - return func('a b' + apos + postfix + ' c'); - }); - - var expected = lodashStable.map(postfixes, function(postfix) { - switch (caseName) { - case 'camel': return 'aB' + postfix + 'C'; - case 'kebab': return 'a-b' + postfix + '-c'; - case 'lower': return 'a b' + postfix + ' c'; - case 'snake': return 'a_b' + postfix + '_c'; - case 'start': return 'A B' + postfix + ' C'; - case 'upper': return 'A B' + postfix.toUpperCase() + ' C'; - } - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should remove Latin mathematical operators', function() { - var actual = lodashStable.map(['\xd7', '\xf7'], func); - assert.deepStrictEqual(actual, ['', '']); - }); - - it('`_.' + methodName + '` should coerce `string` to a string', function() { - var string = 'foo bar'; - assert.strictEqual(func(Object(string)), converted); - assert.strictEqual(func({ 'toString': lodashStable.constant(string) }), converted); - }); - }); - - (function() { - it('should get the original value after cycling through all case methods', function() { - var funcs = [camelCase, kebabCase, lowerCase, snakeCase, startCase, lowerCase, camelCase]; - - var actual = lodashStable.reduce(funcs, function(result, func) { - return func(result); - }, 'enable 6h format'); - - assert.strictEqual(actual, 'enable6HFormat'); - }); - })(); -}); diff --git a/libs/nanofn/test/castArray.test.js b/libs/nanofn/test/castArray.test.js deleted file mode 100644 index be874b5e0..000000000 --- a/libs/nanofn/test/castArray.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey } from './utils.js'; -import castArray from '../castArray.js'; - -describe('castArray', function() { - it('should wrap non-array items in an array', function() { - var values = falsey.concat(true, 1, 'a', { 'a': 1 }), - expected = lodashStable.map(values, function(value) { return [value]; }), - actual = lodashStable.map(values, castArray); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return array values by reference', function() { - var array = [1]; - assert.strictEqual(castArray(array), array); - }); - - it('should return an empty array when no arguments are given', function() { - assert.deepStrictEqual(castArray(), []); - }); -}); diff --git a/libs/nanofn/test/chain.js b/libs/nanofn/test/chain.js deleted file mode 100644 index d02142071..000000000 --- a/libs/nanofn/test/chain.js +++ /dev/null @@ -1,74 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { square } from './utils.js'; -import chain from '../chain.js'; - -describe('chain', function() { - it('should return a wrapped value', function() { - var actual = chain({ 'a': 0 }); - assert.ok(actual instanceof _); - }); - - it('should return existing wrapped values', function() { - var wrapped = _({ 'a': 0 }); - assert.strictEqual(chain(wrapped), wrapped); - assert.strictEqual(wrapped.chain(), wrapped); - }); - - it('should enable chaining for methods that return unwrapped values', function() { - var array = ['c', 'b', 'a']; - - assert.ok(chain(array).head() instanceof _); - assert.ok(_(array).chain().head() instanceof _); - - assert.ok(chain(array).isArray() instanceof _); - assert.ok(_(array).chain().isArray() instanceof _); - - assert.ok(chain(array).sortBy().head() instanceof _); - assert.ok(_(array).chain().sortBy().head() instanceof _); - }); - - it('should chain multiple methods', function() { - lodashStable.times(2, function(index) { - var array = ['one two three four', 'five six seven eight', 'nine ten eleven twelve'], - expected = { ' ': 9, 'e': 14, 'f': 2, 'g': 1, 'h': 2, 'i': 4, 'l': 2, 'n': 6, 'o': 3, 'r': 2, 's': 2, 't': 5, 'u': 1, 'v': 4, 'w': 2, 'x': 1 }, - wrapped = index ? _(array).chain() : chain(array); - - var actual = wrapped - .chain() - .map(function(value) { return value.split(''); }) - .flatten() - .reduce(function(object, chr) { - object[chr] || (object[chr] = 0); - object[chr]++; - return object; - }, {}) - .value(); - - assert.deepStrictEqual(actual, expected); - - array = [1, 2, 3, 4, 5, 6]; - wrapped = index ? _(array).chain() : chain(array); - actual = wrapped - .chain() - .filter(function(n) { return n % 2 != 0; }) - .reject(function(n) { return n % 3 == 0; }) - .sortBy(function(n) { return -n; }) - .value(); - - assert.deepStrictEqual(actual, [5, 1]); - - array = [3, 4]; - wrapped = index ? _(array).chain() : chain(array); - actual = wrapped - .reverse() - .concat([2, 1]) - .unshift(5) - .tap(function(value) { value.pop(); }) - .map(square) - .value(); - - assert.deepStrictEqual(actual, [25, 16, 9, 4]); - }); - }); -}); diff --git a/libs/nanofn/test/chunk.test.js b/libs/nanofn/test/chunk.test.js deleted file mode 100644 index f8bdc69d2..000000000 --- a/libs/nanofn/test/chunk.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubArray } from './utils.js'; -import chunk from '../chunk.js'; - -describe('chunk', function() { - var array = [0, 1, 2, 3, 4, 5]; - - it('should return chunked arrays', function() { - var actual = chunk(array, 3); - assert.deepStrictEqual(actual, [[0, 1, 2], [3, 4, 5]]); - }); - - it('should return the last chunk as remaining elements', function() { - var actual = chunk(array, 4); - assert.deepStrictEqual(actual, [[0, 1, 2, 3], [4, 5]]); - }); - - it('should treat falsey `size` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? [[0], [1], [2], [3], [4], [5]] : []; - }); - - var actual = lodashStable.map(falsey, function(size, index) { - return index ? chunk(array, size) : chunk(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should ensure the minimum `size` is `0`', function() { - var values = lodashStable.reject(falsey, lodashStable.isUndefined).concat(-1, -Infinity), - expected = lodashStable.map(values, stubArray); - - var actual = lodashStable.map(values, function(n) { - return chunk(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should coerce `size` to an integer', function() { - assert.deepStrictEqual(chunk(array, array.length / 4), [[0], [1], [2], [3], [4], [5]]); - }); -}); diff --git a/libs/nanofn/test/clamp.js b/libs/nanofn/test/clamp.js deleted file mode 100644 index 911f57e9d..000000000 --- a/libs/nanofn/test/clamp.js +++ /dev/null @@ -1,58 +0,0 @@ -import assert from 'assert'; -import clamp from '../clamp.js'; - -describe('clamp', function() { - it('should work with a `max`', function() { - assert.strictEqual(clamp(5, 3), 3); - assert.strictEqual(clamp(1, 3), 1); - }); - - it('should clamp negative numbers', function() { - assert.strictEqual(clamp(-10, -5, 5), -5); - assert.strictEqual(clamp(-10.2, -5.5, 5.5), -5.5); - assert.strictEqual(clamp(-Infinity, -5, 5), -5); - }); - - it('should clamp positive numbers', function() { - assert.strictEqual(clamp(10, -5, 5), 5); - assert.strictEqual(clamp(10.6, -5.6, 5.4), 5.4); - assert.strictEqual(clamp(Infinity, -5, 5), 5); - }); - - it('should not alter negative numbers in range', function() { - assert.strictEqual(clamp(-4, -5, 5), -4); - assert.strictEqual(clamp(-5, -5, 5), -5); - assert.strictEqual(clamp(-5.5, -5.6, 5.6), -5.5); - }); - - it('should not alter positive numbers in range', function() { - assert.strictEqual(clamp(4, -5, 5), 4); - assert.strictEqual(clamp(5, -5, 5), 5); - assert.strictEqual(clamp(4.5, -5.1, 5.2), 4.5); - }); - - it('should not alter `0` in range', function() { - assert.strictEqual(1 / clamp(0, -5, 5), Infinity); - }); - - it('should clamp to `0`', function() { - assert.strictEqual(1 / clamp(-10, 0, 5), Infinity); - }); - - it('should not alter `-0` in range', function() { - assert.strictEqual(1 / clamp(-0, -5, 5), -Infinity); - }); - - it('should clamp to `-0`', function() { - assert.strictEqual(1 / clamp(-10, -0, 5), -Infinity); - }); - - it('should return `NaN` when `number` is `NaN`', function() { - assert.deepStrictEqual(clamp(NaN, -5, 5), NaN); - }); - - it('should coerce `min` and `max` of `NaN` to `0`', function() { - assert.deepStrictEqual(clamp(1, -5, NaN), 0); - assert.deepStrictEqual(clamp(-1, NaN, 5), 0); - }); -}); diff --git a/libs/nanofn/test/clone-methods.js b/libs/nanofn/test/clone-methods.js deleted file mode 100644 index b3f086d4d..000000000 --- a/libs/nanofn/test/clone-methods.js +++ /dev/null @@ -1,429 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - map, - set, - realm, - body, - asyncFunc, - genFunc, - errors, - _, - LARGE_ARRAY_SIZE, - isNpm, - mapCaches, - arrayBuffer, - stubTrue, - objectProto, - symbol, - defineProperty, - getSymbols, - document, - arrayViews, - slice, - noop, -} from './utils.js'; - -import cloneDeep from '../cloneDeep.js'; -import cloneDeepWith from '../cloneDeepWith.js'; -import last from '../last.js'; - -describe('clone methods', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 1; - Foo.c = function() {}; - - if (Map) { - var map = new Map; - map.set('a', 1); - map.set('b', 2); - } - if (Set) { - var set = new Set; - set.add(1); - set.add(2); - } - var objects = { - '`arguments` objects': arguments, - 'arrays': ['a', ''], - 'array-like objects': { '0': 'a', 'length': 1 }, - 'booleans': false, - 'boolean objects': Object(false), - 'date objects': new Date, - 'Foo instances': new Foo, - 'objects': { 'a': 0, 'b': 1, 'c': 2 }, - 'objects with object values': { 'a': /a/, 'b': ['B'], 'c': { 'C': 1 } }, - 'objects from another document': realm.object || {}, - 'maps': map, - 'null values': null, - 'numbers': 0, - 'number objects': Object(0), - 'regexes': /a/gim, - 'sets': set, - 'strings': 'a', - 'string objects': Object('a'), - 'undefined values': undefined - }; - - objects.arrays.length = 3; - - var uncloneable = { - 'DOM elements': body, - 'functions': Foo, - 'async functions': asyncFunc, - 'generator functions': genFunc, - 'the `Proxy` constructor': Proxy - }; - - lodashStable.each(errors, function(error) { - uncloneable[error.name + 's'] = error; - }); - - it('`_.clone` should perform a shallow clone', function() { - var array = [{ 'a': 0 }, { 'b': 1 }], - actual = _.clone(array); - - assert.deepStrictEqual(actual, array); - assert.ok(actual !== array && actual[0] === array[0]); - }); - - it('`_.cloneDeep` should deep clone objects with circular references', function() { - var object = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': {} - }; - - object.foo.b.c.d = object; - object.bar.b = object.foo.b; - - var actual = cloneDeep(object); - assert.ok(actual.bar.b === actual.foo.b && actual === actual.foo.b.c.d && actual !== object); - }); - - it('`_.cloneDeep` should deep clone objects with lots of circular references', function() { - var cyclical = {}; - lodashStable.times(LARGE_ARRAY_SIZE + 1, function(index) { - cyclical['v' + index] = [index ? cyclical['v' + (index - 1)] : cyclical]; - }); - - var clone = cloneDeep(cyclical), - actual = clone['v' + LARGE_ARRAY_SIZE][0]; - - assert.strictEqual(actual, clone['v' + (LARGE_ARRAY_SIZE - 1)]); - assert.notStrictEqual(actual, cyclical['v' + (LARGE_ARRAY_SIZE - 1)]); - }); - - it('`_.cloneDeepWith` should provide `stack` to `customizer`', function() { - var actual; - - cloneDeepWith({ 'a': 1 }, function() { - actual = last(arguments); - }); - - assert.ok(isNpm - ? actual.constructor.name == 'Stack' - : actual instanceof mapCaches.Stack - ); - }); - - lodashStable.each(['clone', 'cloneDeep'], function(methodName) { - var func = _[methodName], - isDeep = methodName == 'cloneDeep'; - - lodashStable.forOwn(objects, function(object, kind) { - it('`_.' + methodName + '` should clone ' + kind, function() { - var actual = func(object); - assert.ok(lodashStable.isEqual(actual, object)); - - if (lodashStable.isObject(object)) { - assert.notStrictEqual(actual, object); - } else { - assert.strictEqual(actual, object); - } - }); - }); - - it('`_.' + methodName + '` should clone array buffers', function() { - if (ArrayBuffer) { - var actual = func(arrayBuffer); - assert.strictEqual(actual.byteLength, arrayBuffer.byteLength); - assert.notStrictEqual(actual, arrayBuffer); - } - }); - - it('`_.' + methodName + '` should clone buffers', function() { - if (Buffer) { - var buffer = new Buffer([1, 2]), - actual = func(buffer); - - assert.strictEqual(actual.byteLength, buffer.byteLength); - assert.strictEqual(actual.inspect(), buffer.inspect()); - assert.notStrictEqual(actual, buffer); - - buffer[0] = 2; - assert.strictEqual(actual[0], isDeep ? 2 : 1); - } - }); - - it('`_.' + methodName + '` should clone `index` and `input` array properties', function() { - var array = /c/.exec('abcde'), - actual = func(array); - - assert.strictEqual(actual.index, 2); - assert.strictEqual(actual.input, 'abcde'); - }); - - it('`_.' + methodName + '` should clone `lastIndex` regexp property', function() { - var regexp = /c/g; - regexp.exec('abcde'); - - assert.strictEqual(func(regexp).lastIndex, 3); - }); - - it('`_.' + methodName + '` should clone expando properties', function() { - var values = lodashStable.map([false, true, 1, 'a'], function(value) { - var object = Object(value); - object.a = 1; - return object; - }); - - var expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return func(value).a === 1; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should clone prototype objects', function() { - var actual = func(Foo.prototype); - - assert.ok(!(actual instanceof Foo)); - assert.deepStrictEqual(actual, { 'b': 1 }); - }); - - it('`_.' + methodName + '` should set the `[[Prototype]]` of a clone', function() { - assert.ok(func(new Foo) instanceof Foo); - }); - - it('`_.' + methodName + '` should set the `[[Prototype]]` of a clone even when the `constructor` is incorrect', function() { - Foo.prototype.constructor = Object; - assert.ok(func(new Foo) instanceof Foo); - Foo.prototype.constructor = Foo; - }); - - it('`_.' + methodName + '` should ensure `value` constructor is a function before using its `[[Prototype]]`', function() { - Foo.prototype.constructor = null; - assert.ok(!(func(new Foo) instanceof Foo)); - Foo.prototype.constructor = Foo; - }); - - it('`_.' + methodName + '` should clone properties that shadow those on `Object.prototype`', function() { - var object = { - 'constructor': objectProto.constructor, - 'hasOwnProperty': objectProto.hasOwnProperty, - 'isPrototypeOf': objectProto.isPrototypeOf, - 'propertyIsEnumerable': objectProto.propertyIsEnumerable, - 'toLocaleString': objectProto.toLocaleString, - 'toString': objectProto.toString, - 'valueOf': objectProto.valueOf - }; - - var actual = func(object); - - assert.deepStrictEqual(actual, object); - assert.notStrictEqual(actual, object); - }); - - it('`_.' + methodName + '` should clone symbol properties', function() { - function Foo() { - this[symbol] = { 'c': 1 }; - } - - if (Symbol) { - var symbol2 = Symbol('b'); - Foo.prototype[symbol2] = 2; - - var symbol3 = Symbol('c'); - defineProperty(Foo.prototype, symbol3, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 3 - }); - - var object = { 'a': { 'b': new Foo } }; - object[symbol] = { 'b': 1 }; - - var actual = func(object); - if (isDeep) { - assert.notStrictEqual(actual[symbol], object[symbol]); - assert.notStrictEqual(actual.a, object.a); - } else { - assert.strictEqual(actual[symbol], object[symbol]); - assert.strictEqual(actual.a, object.a); - } - assert.deepStrictEqual(actual[symbol], object[symbol]); - assert.deepStrictEqual(getSymbols(actual.a.b), [symbol]); - assert.deepStrictEqual(actual.a.b[symbol], object.a.b[symbol]); - assert.deepStrictEqual(actual.a.b[symbol2], object.a.b[symbol2]); - assert.deepStrictEqual(actual.a.b[symbol3], object.a.b[symbol3]); - } - }); - - it('`_.' + methodName + '` should clone symbol objects', function() { - if (Symbol) { - assert.strictEqual(func(symbol), symbol); - - var object = Object(symbol), - actual = func(object); - - assert.strictEqual(typeof actual, 'object'); - assert.strictEqual(typeof actual.valueOf(), 'symbol'); - assert.notStrictEqual(actual, object); - } - }); - - it('`_.' + methodName + '` should not clone symbol primitives', function() { - if (Symbol) { - assert.strictEqual(func(symbol), symbol); - } - }); - - it('`_.' + methodName + '` should not error on DOM elements', function() { - if (document) { - var element = document.createElement('div'); - - try { - assert.deepStrictEqual(func(element), {}); - } catch (e) { - assert.ok(false, e.message); - } - } - }); - - it('`_.' + methodName + '` should create an object from the same realm as `value`', function() { - var props = []; - - var objects = lodashStable.transform(_, function(result, value, key) { - if (lodashStable.startsWith(key, '_') && lodashStable.isObject(value) && - !lodashStable.isArguments(value) && !lodashStable.isElement(value) && - !lodashStable.isFunction(value)) { - props.push(lodashStable.capitalize(lodashStable.camelCase(key))); - result.push(value); - } - }, []); - - var expected = lodashStable.map(objects, stubTrue); - - var actual = lodashStable.map(objects, function(object) { - var Ctor = object.constructor, - result = func(object); - - return result !== object && ((result instanceof Ctor) || !(new Ctor instanceof Ctor)); - }); - - assert.deepStrictEqual(actual, expected, props.join(', ')); - }); - - it('`_.' + methodName + '` should perform a ' + (isDeep ? 'deep' : 'shallow') + ' clone when used as an iteratee for methods like `_.map`', function() { - var expected = [{ 'a': [0] }, { 'b': [1] }], - actual = lodashStable.map(expected, func); - - assert.deepStrictEqual(actual, expected); - - if (isDeep) { - assert.ok(actual[0] !== expected[0] && actual[0].a !== expected[0].a && actual[1].b !== expected[1].b); - } else { - assert.ok(actual[0] !== expected[0] && actual[0].a === expected[0].a && actual[1].b === expected[1].b); - } - }); - - it('`_.' + methodName + '` should return a unwrapped value when chaining', function() { - var object = objects.objects, - actual = _(object)[methodName](); - - assert.deepEqual(actual, object); - assert.notStrictEqual(actual, object); - }); - - lodashStable.each(arrayViews, function(type) { - it('`_.' + methodName + '` should clone ' + type + ' values', function() { - var Ctor = root[type]; - - lodashStable.times(2, function(index) { - if (Ctor) { - var buffer = new ArrayBuffer(24), - view = index ? new Ctor(buffer, 8, 1) : new Ctor(buffer), - actual = func(view); - - assert.deepStrictEqual(actual, view); - assert.notStrictEqual(actual, view); - assert.strictEqual(actual.buffer === view.buffer, !isDeep); - assert.strictEqual(actual.byteOffset, view.byteOffset); - assert.strictEqual(actual.length, view.length); - } - }); - }); - }); - - lodashStable.forOwn(uncloneable, function(value, key) { - it('`_.' + methodName + '` should not clone ' + key, function() { - if (value) { - var object = { 'a': value, 'b': { 'c': value } }, - actual = func(object), - expected = value === Foo ? { 'c': Foo.c } : {}; - - assert.deepStrictEqual(actual, object); - assert.notStrictEqual(actual, object); - assert.deepStrictEqual(func(value), expected); - } - }); - }); - }); - - lodashStable.each(['cloneWith', 'cloneDeepWith'], function(methodName) { - var func = _[methodName], - isDeep = methodName == 'cloneDeepWith'; - - it('`_.' + methodName + '` should provide correct `customizer` arguments', function() { - var argsList = [], - object = new Foo; - - func(object, function() { - var length = arguments.length, - args = slice.call(arguments, 0, length - (length > 1 ? 1 : 0)); - - argsList.push(args); - }); - - assert.deepStrictEqual(argsList, isDeep ? [[object], [1, 'a', object]] : [[object]]); - }); - - it('`_.' + methodName + '` should handle cloning when `customizer` returns `undefined`', function() { - var actual = func({ 'a': { 'b': 'c' } }, noop); - assert.deepStrictEqual(actual, { 'a': { 'b': 'c' } }); - }); - - lodashStable.forOwn(uncloneable, function(value, key) { - it('`_.' + methodName + '` should work with a `customizer` callback and ' + key, function() { - var customizer = function(value) { - return lodashStable.isPlainObject(value) ? undefined : value; - }; - - var actual = func(value, customizer); - assert.strictEqual(actual, value); - - var object = { 'a': value, 'b': { 'c': value } }; - actual = func(object, customizer); - - assert.deepStrictEqual(actual, object); - assert.notStrictEqual(actual, object); - }); - }); - }); -}); diff --git a/libs/nanofn/test/compact.js b/libs/nanofn/test/compact.js deleted file mode 100644 index 2c3935863..000000000 --- a/libs/nanofn/test/compact.js +++ /dev/null @@ -1,42 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, _, falsey } from './utils.js'; -import compact from '../compact.js'; -import slice from '../slice.js'; - -describe('compact', function() { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE).concat(null); - - it('should filter falsey values', function() { - var array = ['0', '1', '2']; - assert.deepStrictEqual(compact(falsey.concat(array)), array); - }); - - it('should work when in-between lazy operators', function() { - var actual = _(falsey).thru(slice).compact().thru(slice).value(); - assert.deepEqual(actual, []); - - actual = _(falsey).thru(slice).push(true, 1).compact().push('a').value(); - assert.deepEqual(actual, [true, 1, 'a']); - }); - - it('should work in a lazy sequence', function() { - var actual = _(largeArray).slice(1).compact().reverse().take().value(); - assert.deepEqual(actual, _.take(compact(slice(largeArray, 1)).reverse())); - }); - - it('should work in a lazy sequence with a custom `_.iteratee`', function() { - var iteratee = _.iteratee, - pass = false; - - _.iteratee = identity; - - try { - var actual = _(largeArray).slice(1).compact().value(); - pass = lodashStable.isEqual(actual, compact(slice(largeArray, 1))); - } catch (e) {console.log(e);} - - assert.ok(pass); - _.iteratee = iteratee; - }); -}); diff --git a/libs/nanofn/test/concat.js b/libs/nanofn/test/concat.js deleted file mode 100644 index d66561982..000000000 --- a/libs/nanofn/test/concat.js +++ /dev/null @@ -1,65 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import concat from '../concat.js'; - -describe('concat', function() { - it('should shallow clone `array`', function() { - var array = [1, 2, 3], - actual = concat(array); - - assert.deepStrictEqual(actual, array); - assert.notStrictEqual(actual, array); - }); - - it('should concat arrays and values', function() { - var array = [1], - actual = concat(array, 2, [3], [[4]]); - - assert.deepStrictEqual(actual, [1, 2, 3, [4]]); - assert.deepStrictEqual(array, [1]); - }); - - it('should cast non-array `array` values to arrays', function() { - var values = [, null, undefined, false, true, 1, NaN, 'a']; - - var expected = lodashStable.map(values, function(value, index) { - return index ? [value] : []; - }); - - var actual = lodashStable.map(values, function(value, index) { - return index ? concat(value) : concat(); - }); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(values, function(value) { - return [value, 2, [3]]; - }); - - actual = lodashStable.map(values, function(value) { - return concat(value, [2], [[3]]); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should treat sparse arrays as dense', function() { - var expected = [], - actual = concat(Array(1), Array(1)); - - expected.push(undefined, undefined); - - assert.ok('0'in actual); - assert.ok('1' in actual); - assert.deepStrictEqual(actual, expected); - }); - - it('should return a new wrapped array', function() { - var array = [1], - wrapped = _(array).concat([2, 3]), - actual = wrapped.value(); - - assert.deepEqual(array, [1]); - assert.deepEqual(actual, [1, 2, 3]); - }); -}); diff --git a/libs/nanofn/test/cond.js b/libs/nanofn/test/cond.js deleted file mode 100644 index e3594ab46..000000000 --- a/libs/nanofn/test/cond.js +++ /dev/null @@ -1,65 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, stubA, stubB, stubC, slice, stubFalse, stubTrue } from './utils.js'; - -describe('cond', function() { - it('should create a conditional function', function() { - var cond = _.cond([ - [lodashStable.matches({ 'a': 1 }), stubA], - [lodashStable.matchesProperty('b', 1), stubB], - [lodashStable.property('c'), stubC] - ]); - - assert.strictEqual(cond({ 'a': 1, 'b': 2, 'c': 3 }), 'a'); - assert.strictEqual(cond({ 'a': 0, 'b': 1, 'c': 2 }), 'b'); - assert.strictEqual(cond({ 'a': -1, 'b': 0, 'c': 1 }), 'c'); - }); - - it('should provide arguments to functions', function() { - var args1, - args2, - expected = ['a', 'b', 'c']; - - var cond = _.cond([[ - function() { args1 || (args1 = slice.call(arguments)); return true; }, - function() { args2 || (args2 = slice.call(arguments)); } - ]]); - - cond('a', 'b', 'c'); - - assert.deepStrictEqual(args1, expected); - assert.deepStrictEqual(args2, expected); - }); - - it('should work with predicate shorthands', function() { - var cond = _.cond([ - [{ 'a': 1 }, stubA], - [['b', 1], stubB], - ['c', stubC] - ]); - - assert.strictEqual(cond({ 'a': 1, 'b': 2, 'c': 3 }), 'a'); - assert.strictEqual(cond({ 'a': 0, 'b': 1, 'c': 2 }), 'b'); - assert.strictEqual(cond({ 'a': -1, 'b': 0, 'c': 1 }), 'c'); - }); - - it('should return `undefined` when no condition is met', function() { - var cond = _.cond([[stubFalse, stubA]]); - assert.strictEqual(cond({ 'a': 1 }), undefined); - }); - - it('should throw a TypeError if `pairs` is not composed of functions', function() { - lodashStable.each([false, true], function(value) { - assert.throws(function() { _.cond([[stubTrue, value]])(); }, TypeError); - }); - }); - - it('should use `this` binding of function for `pairs`', function() { - var cond = _.cond([ - [function(a) { return this[a]; }, function(a, b) { return this[b]; }] - ]); - - var object = { 'cond': cond, 'a': 1, 'b': 2 }; - assert.strictEqual(object.cond('a', 'b'), 2); - }); -}); diff --git a/libs/nanofn/test/conforms-methods.js b/libs/nanofn/test/conforms-methods.js deleted file mode 100644 index c28e8f8b5..000000000 --- a/libs/nanofn/test/conforms-methods.js +++ /dev/null @@ -1,153 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, stubFalse, stubTrue, empties } from './utils.js'; -import conformsTo from '../conformsTo.js'; - -describe('conforms methods', function() { - lodashStable.each(['conforms', 'conformsTo'], function(methodName) { - var isConforms = methodName == 'conforms'; - - function conforms(source) { - return isConforms ? _.conforms(source) : function(object) { - return conformsTo(object, source); - }; - } - - it('`_.' + methodName + '` should check if `object` conforms to `source`', function() { - var objects = [ - { 'a': 1, 'b': 8 }, - { 'a': 2, 'b': 4 }, - { 'a': 3, 'b': 16 } - ]; - - var par = conforms({ - 'b': function(value) { return value > 4; } - }); - - var actual = lodashStable.filter(objects, par); - assert.deepStrictEqual(actual, [objects[0], objects[2]]); - - par = conforms({ - 'b': function(value) { return value > 8; }, - 'a': function(value) { return value > 1; } - }); - - actual = lodashStable.filter(objects, par); - assert.deepStrictEqual(actual, [objects[2]]); - }); - - it('`_.' + methodName + '` should not match by inherited `source` properties', function() { - function Foo() { - this.a = function(value) { - return value > 1; - }; - } - Foo.prototype.b = function(value) { - return value > 8; - }; - - var objects = [ - { 'a': 1, 'b': 8 }, - { 'a': 2, 'b': 4 }, - { 'a': 3, 'b': 16 } - ]; - - var par = conforms(new Foo), - actual = lodashStable.filter(objects, par); - - assert.deepStrictEqual(actual, [objects[1], objects[2]]); - }); - - it('`_.' + methodName + '` should not invoke `source` predicates for missing `object` properties', function() { - var count = 0; - - var par = conforms({ - 'a': function() { count++; return true; } - }); - - assert.strictEqual(par({}), false); - assert.strictEqual(count, 0); - }); - - it('`_.' + methodName + '` should work with a function for `object`', function() { - function Foo() {} - Foo.a = 1; - - function Bar() {} - Bar.a = 2; - - var par = conforms({ - 'a': function(value) { return value > 1; } - }); - - assert.strictEqual(par(Foo), false); - assert.strictEqual(par(Bar), true); - }); - - it('`_.' + methodName + '` should work with a function for `source`', function() { - function Foo() {} - Foo.a = function(value) { return value > 1; }; - - var objects = [{ 'a': 1 }, { 'a': 2 }], - actual = lodashStable.filter(objects, conforms(Foo)); - - assert.deepStrictEqual(actual, [objects[1]]); - }); - - it('`_.' + methodName + '` should work with a non-plain `object`', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var par = conforms({ - 'b': function(value) { return value > 1; } - }); - - assert.strictEqual(par(new Foo), true); - }); - - it('`_.' + methodName + '` should return `false` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - var par = conforms({ - 'a': function(value) { return value > 1; } - }); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? par(value) : par(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` when comparing an empty `source` to a nullish `object`', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubTrue), - par = conforms({}); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? par(value) : par(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` when comparing an empty `source`', function() { - var object = { 'a': 1 }, - expected = lodashStable.map(empties, stubTrue); - - var actual = lodashStable.map(empties, function(value) { - var par = conforms(value); - return par(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/conforms.js b/libs/nanofn/test/conforms.js deleted file mode 100644 index 204694a37..000000000 --- a/libs/nanofn/test/conforms.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import conforms from '../conforms.js'; - -describe('conforms', function() { - it('should not change behavior if `source` is modified', function() { - var object = { 'a': 2 }, - source = { 'a': function(value) { return value > 1; } }, - par = conforms(source); - - assert.strictEqual(par(object), true); - - source.a = function(value) { return value < 2; }; - assert.strictEqual(par(object), true); - }); -}); diff --git a/libs/nanofn/test/constant.js b/libs/nanofn/test/constant.js deleted file mode 100644 index 00151ad67..000000000 --- a/libs/nanofn/test/constant.js +++ /dev/null @@ -1,40 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, _, falsey, stubTrue } from './utils.js'; - -describe('constant', function() { - it('should create a function that returns `value`', function() { - var object = { 'a': 1 }, - values = Array(2).concat(empties, true, 1, 'a'), - constant = _.constant(object); - - var results = lodashStable.map(values, function(value, index) { - if (index < 2) { - return index ? constant.call({}) : constant(); - } - return constant(value); - }); - - assert.ok(lodashStable.every(results, function(result) { - return result === object; - })); - }); - - it('should work with falsey values', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - var constant = index ? _.constant(value) : _.constant(), - result = constant(); - - return (result === value) || (result !== result && value !== value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return a wrapped value when chaining', function() { - var wrapped = _(true).constant(); - assert.ok(wrapped instanceof _); - }); -}); diff --git a/libs/nanofn/test/countBy.js b/libs/nanofn/test/countBy.js deleted file mode 100644 index b3e7a2779..000000000 --- a/libs/nanofn/test/countBy.js +++ /dev/null @@ -1,66 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE } from './utils.js'; -import countBy from '../countBy.js'; - -describe('countBy', function() { - var array = [6.1, 4.2, 6.3]; - - it('should transform keys by `iteratee`', function() { - var actual = countBy(array, Math.floor); - assert.deepStrictEqual(actual, { '4': 1, '6': 2 }); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var array = [4, 6, 6], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant({ '4': 1, '6': 2 })); - - var actual = lodashStable.map(values, function(value, index) { - return index ? countBy(array, value) : countBy(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var actual = countBy(['one', 'two', 'three'], 'length'); - assert.deepStrictEqual(actual, { '3': 2, '5': 1 }); - }); - - it('should only add values to own, not inherited, properties', function() { - var actual = countBy(array, function(n) { - return Math.floor(n) > 4 ? 'hasOwnProperty' : 'constructor'; - }); - - assert.deepStrictEqual(actual.constructor, 1); - assert.deepStrictEqual(actual.hasOwnProperty, 2); - }); - - it('should work with a number for `iteratee`', function() { - var array = [ - [1, 'a'], - [2, 'a'], - [2, 'b'] - ]; - - assert.deepStrictEqual(countBy(array, 0), { '1': 1, '2': 2 }); - assert.deepStrictEqual(countBy(array, 1), { 'a': 2, 'b': 1 }); - }); - - it('should work with an object for `collection`', function() { - var actual = countBy({ 'a': 6.1, 'b': 4.2, 'c': 6.3 }, Math.floor); - assert.deepStrictEqual(actual, { '4': 1, '6': 2 }); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE).concat( - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 2), LARGE_ARRAY_SIZE), - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 1.5), LARGE_ARRAY_SIZE) - ); - - var actual = _(array).countBy().map(square).filter(isEven).take().value(); - - assert.deepEqual(actual, _.take(_.filter(_.map(countBy(array), square), isEven))); - }); -}); diff --git a/libs/nanofn/test/create.test.js b/libs/nanofn/test/create.test.js deleted file mode 100644 index fef0be6de..000000000 --- a/libs/nanofn/test/create.test.js +++ /dev/null @@ -1,99 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, primitives, stubTrue } from './utils.js'; -import create from '../create.js'; -import keys from '../keys.js'; - -describe('create', function() { - function Shape() { - this.x = 0; - this.y = 0; - } - - function Circle() { - Shape.call(this); - } - - it('should create an object that inherits from the given `prototype` object', function() { - Circle.prototype = create(Shape.prototype); - Circle.prototype.constructor = Circle; - - var actual = new Circle; - - assert.ok(actual instanceof Circle); - assert.ok(actual instanceof Shape); - assert.notStrictEqual(Circle.prototype, Shape.prototype); - }); - - it('should assign `properties` to the created object', function() { - var expected = { 'constructor': Circle, 'radius': 0 }; - var properties = Object.keys(expected); - Circle.prototype = create(Shape.prototype, expected); - - var actual = new Circle; - - assert.ok(actual instanceof Circle); - assert.ok(actual instanceof Shape); - assert.deepStrictEqual(Object.keys(Circle.prototype), properties); - properties.forEach((property) => { - assert.strictEqual(Circle.prototype[property], expected[property]); - }); - }); - - it('should assign own properties', function() { - function Foo() { - this.a = 1; - this.c = 3; - } - Foo.prototype.b = 2; - - var actual = create({}, new Foo); - var expected = { 'a': 1, 'c': 3 }; - var properties = Object.keys(expected); - - assert.deepStrictEqual(Object.keys(actual), properties); - properties.forEach((property) => { - assert.strictEqual(actual[property], expected[property]); - }); - }); - - it('should assign properties that shadow those of `prototype`', function() { - function Foo() { - this.a = 1; - } - var object = create(new Foo, { 'a': 1 }); - assert.deepStrictEqual(lodashStable.keys(object), ['a']); - }); - - it('should accept a falsey `prototype`', function() { - var actual = lodashStable.map(falsey, function(prototype, index) { - return index ? create(prototype) : create(); - }); - - actual.forEach((value) => { - assert.ok(lodashStable.isObject(value)); - }); - }); - - it('should accept a primitive `prototype`', function() { - var actual = lodashStable.map(primitives, function(value, index) { - return index ? create(value) : create(); - }); - - actual.forEach((value) => { - assert.ok(lodashStable.isObject(value)); - }); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [{ 'a': 1 }, { 'a': 1 }, { 'a': 1 }], - expected = lodashStable.map(array, stubTrue), - objects = lodashStable.map(array, create); - - var actual = lodashStable.map(objects, function(object) { - return object.a === 1 && !keys(object).length; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/curry-methods.js b/libs/nanofn/test/curry-methods.js deleted file mode 100644 index e742e0315..000000000 --- a/libs/nanofn/test/curry-methods.js +++ /dev/null @@ -1,52 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, slice } from './utils.js'; -import curry from '../curry.js'; - -describe('curry methods', function() { - lodashStable.each(['curry', 'curryRight'], function(methodName) { - var func = _[methodName], - fn = function(a, b) { return slice.call(arguments); }, - isCurry = methodName == 'curry'; - - it('`_.' + methodName + '` should not error on functions with the same name as lodash methods', function() { - function run(a, b) { - return a + b; - } - - var curried = func(run); - - try { - var actual = curried(1)(2); - } catch (e) {} - - assert.strictEqual(actual, 3); - }); - - it('`_.' + methodName + '` should work for function names that shadow those on `Object.prototype`', function() { - var curried = curry(function hasOwnProperty(a, b, c) { - return [a, b, c]; - }); - - var expected = [1, 2, 3]; - - assert.deepStrictEqual(curried(1)(2)(3), expected); - }); - - it('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', function() { - var array = [fn, fn, fn], - object = { 'a': fn, 'b': fn, 'c': fn }; - - lodashStable.each([array, object], function(collection) { - var curries = lodashStable.map(collection, func), - expected = lodashStable.map(collection, lodashStable.constant(isCurry ? ['a', 'b'] : ['b', 'a'])); - - var actual = lodashStable.map(curries, function(curried) { - return curried('a')('b'); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - }); -}); diff --git a/libs/nanofn/test/curry.js b/libs/nanofn/test/curry.js deleted file mode 100644 index 5b8ab7364..000000000 --- a/libs/nanofn/test/curry.js +++ /dev/null @@ -1,135 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, stubArray } from './utils.js'; -import curry from '../curry.js'; -import placeholder from '../placeholder.js'; -import bind from '../bind.js'; -import partial from '../partial.js'; -import partialRight from '../partialRight.js'; - -describe('curry', function() { - function fn(a, b, c, d) { - return slice.call(arguments); - } - - it('should curry based on the number of arguments given', function() { - var curried = curry(fn), - expected = [1, 2, 3, 4]; - - assert.deepStrictEqual(curried(1)(2)(3)(4), expected); - assert.deepStrictEqual(curried(1, 2)(3, 4), expected); - assert.deepStrictEqual(curried(1, 2, 3, 4), expected); - }); - - it('should allow specifying `arity`', function() { - var curried = curry(fn, 3), - expected = [1, 2, 3]; - - assert.deepStrictEqual(curried(1)(2, 3), expected); - assert.deepStrictEqual(curried(1, 2)(3), expected); - assert.deepStrictEqual(curried(1, 2, 3), expected); - }); - - it('should coerce `arity` to an integer', function() { - var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, stubArray); - - var actual = lodashStable.map(values, function(arity) { - return curry(fn, arity)(); - }); - - assert.deepStrictEqual(actual, expected); - assert.deepStrictEqual(curry(fn, '2')(1)(2), [1, 2]); - }); - - it('should support placeholders', function() { - var curried = curry(fn), - ph = curried.placeholder; - - assert.deepStrictEqual(curried(1)(ph, 3)(ph, 4)(2), [1, 2, 3, 4]); - assert.deepStrictEqual(curried(ph, 2)(1)(ph, 4)(3), [1, 2, 3, 4]); - assert.deepStrictEqual(curried(ph, ph, 3)(ph, 2)(ph, 4)(1), [1, 2, 3, 4]); - assert.deepStrictEqual(curried(ph, ph, ph, 4)(ph, ph, 3)(ph, 2)(1), [1, 2, 3, 4]); - }); - - it('should persist placeholders', function() { - var curried = curry(fn), - ph = curried.placeholder, - actual = curried(ph, ph, ph, 'd')('a')(ph)('b')('c'); - - assert.deepStrictEqual(actual, ['a', 'b', 'c', 'd']); - }); - - it('should use `_.placeholder` when set', function() { - var curried = curry(fn), - _ph = placeholder = {}, - ph = curried.placeholder; - - assert.deepEqual(curried(1)(_ph, 3)(ph, 4), [1, ph, 3, 4]); - delete placeholder; - }); - - it('should provide additional arguments after reaching the target arity', function() { - var curried = curry(fn, 3); - assert.deepStrictEqual(curried(1)(2, 3, 4), [1, 2, 3, 4]); - assert.deepStrictEqual(curried(1, 2)(3, 4, 5), [1, 2, 3, 4, 5]); - assert.deepStrictEqual(curried(1, 2, 3, 4, 5, 6), [1, 2, 3, 4, 5, 6]); - }); - - it('should create a function with a `length` of `0`', function() { - lodashStable.times(2, function(index) { - var curried = index ? curry(fn, 4) : curry(fn); - assert.strictEqual(curried.length, 0); - assert.strictEqual(curried(1).length, 0); - assert.strictEqual(curried(1, 2).length, 0); - }); - }); - - it('should ensure `new curried` is an instance of `func`', function() { - function Foo(value) { - return value && object; - } - - var curried = curry(Foo), - object = {}; - - assert.ok(new curried(false) instanceof Foo); - assert.strictEqual(new curried(true), object); - }); - - it('should use `this` binding of function', function() { - var fn = function(a, b, c) { - var value = this || {}; - return [value[a], value[b], value[c]]; - }; - - var object = { 'a': 1, 'b': 2, 'c': 3 }, - expected = [1, 2, 3]; - - assert.deepStrictEqual(curry(bind(fn, object), 3)('a')('b')('c'), expected); - assert.deepStrictEqual(curry(bind(fn, object), 3)('a', 'b')('c'), expected); - assert.deepStrictEqual(curry(bind(fn, object), 3)('a', 'b', 'c'), expected); - - assert.deepStrictEqual(bind(curry(fn), object)('a')('b')('c'), Array(3)); - assert.deepStrictEqual(bind(curry(fn), object)('a', 'b')('c'), Array(3)); - assert.deepStrictEqual(bind(curry(fn), object)('a', 'b', 'c'), expected); - - object.curried = curry(fn); - assert.deepStrictEqual(object.curried('a')('b')('c'), Array(3)); - assert.deepStrictEqual(object.curried('a', 'b')('c'), Array(3)); - assert.deepStrictEqual(object.curried('a', 'b', 'c'), expected); - }); - - it('should work with partialed methods', function() { - var curried = curry(fn), - expected = [1, 2, 3, 4]; - - var a = partial(curried, 1), - b = bind(a, null, 2), - c = partialRight(b, 4), - d = partialRight(b(3), 4); - - assert.deepStrictEqual(c(3), expected); - assert.deepStrictEqual(d(), expected); - }); -}); diff --git a/libs/nanofn/test/curryRight.js b/libs/nanofn/test/curryRight.js deleted file mode 100644 index 21f6acdb7..000000000 --- a/libs/nanofn/test/curryRight.js +++ /dev/null @@ -1,136 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, stubArray } from './utils.js'; -import curryRight from '../curryRight.js'; -import placeholder from '../placeholder.js'; -import bind from '../bind.js'; -import partialRight from '../partialRight.js'; -import partial from '../partial.js'; - -describe('curryRight', function() { - function fn(a, b, c, d) { - return slice.call(arguments); - } - - it('should curry based on the number of arguments given', function() { - var curried = curryRight(fn), - expected = [1, 2, 3, 4]; - - assert.deepStrictEqual(curried(4)(3)(2)(1), expected); - assert.deepStrictEqual(curried(3, 4)(1, 2), expected); - assert.deepStrictEqual(curried(1, 2, 3, 4), expected); - }); - - it('should allow specifying `arity`', function() { - var curried = curryRight(fn, 3), - expected = [1, 2, 3]; - - assert.deepStrictEqual(curried(3)(1, 2), expected); - assert.deepStrictEqual(curried(2, 3)(1), expected); - assert.deepStrictEqual(curried(1, 2, 3), expected); - }); - - it('should coerce `arity` to an integer', function() { - var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, stubArray); - - var actual = lodashStable.map(values, function(arity) { - return curryRight(fn, arity)(); - }); - - assert.deepStrictEqual(actual, expected); - assert.deepStrictEqual(curryRight(fn, '2')(1)(2), [2, 1]); - }); - - it('should support placeholders', function() { - var curried = curryRight(fn), - expected = [1, 2, 3, 4], - ph = curried.placeholder; - - assert.deepStrictEqual(curried(4)(2, ph)(1, ph)(3), expected); - assert.deepStrictEqual(curried(3, ph)(4)(1, ph)(2), expected); - assert.deepStrictEqual(curried(ph, ph, 4)(ph, 3)(ph, 2)(1), expected); - assert.deepStrictEqual(curried(ph, ph, ph, 4)(ph, ph, 3)(ph, 2)(1), expected); - }); - - it('should persist placeholders', function() { - var curried = curryRight(fn), - ph = curried.placeholder, - actual = curried('a', ph, ph, ph)('b')(ph)('c')('d'); - - assert.deepStrictEqual(actual, ['a', 'b', 'c', 'd']); - }); - - it('should use `_.placeholder` when set', function() { - var curried = curryRight(fn), - _ph = placeholder = {}, - ph = curried.placeholder; - - assert.deepEqual(curried(4)(2, _ph)(1, ph), [1, 2, ph, 4]); - delete placeholder; - }); - - it('should provide additional arguments after reaching the target arity', function() { - var curried = curryRight(fn, 3); - assert.deepStrictEqual(curried(4)(1, 2, 3), [1, 2, 3, 4]); - assert.deepStrictEqual(curried(4, 5)(1, 2, 3), [1, 2, 3, 4, 5]); - assert.deepStrictEqual(curried(1, 2, 3, 4, 5, 6), [1, 2, 3, 4, 5, 6]); - }); - - it('should create a function with a `length` of `0`', function() { - lodashStable.times(2, function(index) { - var curried = index ? curryRight(fn, 4) : curryRight(fn); - assert.strictEqual(curried.length, 0); - assert.strictEqual(curried(4).length, 0); - assert.strictEqual(curried(3, 4).length, 0); - }); - }); - - it('should ensure `new curried` is an instance of `func`', function() { - function Foo(value) { - return value && object; - } - - var curried = curryRight(Foo), - object = {}; - - assert.ok(new curried(false) instanceof Foo); - assert.strictEqual(new curried(true), object); - }); - - it('should use `this` binding of function', function() { - var fn = function(a, b, c) { - var value = this || {}; - return [value[a], value[b], value[c]]; - }; - - var object = { 'a': 1, 'b': 2, 'c': 3 }, - expected = [1, 2, 3]; - - assert.deepStrictEqual(curryRight(bind(fn, object), 3)('c')('b')('a'), expected); - assert.deepStrictEqual(curryRight(bind(fn, object), 3)('b', 'c')('a'), expected); - assert.deepStrictEqual(curryRight(bind(fn, object), 3)('a', 'b', 'c'), expected); - - assert.deepStrictEqual(bind(curryRight(fn), object)('c')('b')('a'), Array(3)); - assert.deepStrictEqual(bind(curryRight(fn), object)('b', 'c')('a'), Array(3)); - assert.deepStrictEqual(bind(curryRight(fn), object)('a', 'b', 'c'), expected); - - object.curried = curryRight(fn); - assert.deepStrictEqual(object.curried('c')('b')('a'), Array(3)); - assert.deepStrictEqual(object.curried('b', 'c')('a'), Array(3)); - assert.deepStrictEqual(object.curried('a', 'b', 'c'), expected); - }); - - it('should work with partialed methods', function() { - var curried = curryRight(fn), - expected = [1, 2, 3, 4]; - - var a = partialRight(curried, 4), - b = partialRight(a, 3), - c = bind(b, null, 1), - d = partial(b(2), 1); - - assert.deepStrictEqual(c(2), expected); - assert.deepStrictEqual(d(), expected); - }); -}); diff --git a/libs/nanofn/test/custom-_.iteratee-methods.js b/libs/nanofn/test/custom-_.iteratee-methods.js deleted file mode 100644 index 0571d77ab..000000000 --- a/libs/nanofn/test/custom-_.iteratee-methods.js +++ /dev/null @@ -1,270 +0,0 @@ -import assert from 'assert'; -import partial from '../partial.js'; -import property from '../property.js'; -import iteratee from '../iteratee.js'; - -describe('custom `_.iteratee` methods', function() { - var array = ['one', 'two', 'three'], - getPropA = partial(property, 'a'), - getPropB = partial(property, 'b'), - getLength = partial(property, 'length'), - iteratee = iteratee; - - var getSum = function() { - return function(result, object) { - return result + object.a; - }; - }; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 0 }, - { 'a': 1, 'b': 1 } - ]; - - it('`_.countBy` should use `_.iteratee` internally', function() { - iteratee = getLength; - assert.deepEqual(_.countBy(array), { '3': 2, '5': 1 }); - iteratee = iteratee; - }); - - it('`_.differenceBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.differenceBy(objects, [objects[1]]), [objects[0]]); - iteratee = iteratee; - }); - - it('`_.dropRightWhile` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.dropRightWhile(objects), objects.slice(0, 2)); - iteratee = iteratee; - }); - - it('`_.dropWhile` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.dropWhile(objects.reverse()).reverse(), objects.reverse().slice(0, 2)); - iteratee = iteratee; - }); - - it('`_.every` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.every(objects.slice(1)), true); - iteratee = iteratee; - }); - - it('`_.filter` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - iteratee = getPropA; - assert.deepEqual(_.filter(objects), [objects[1]]); - iteratee = iteratee; - }); - - it('`_.find` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.find(objects), objects[1]); - iteratee = iteratee; - }); - - it('`_.findIndex` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.findIndex(objects), 1); - iteratee = iteratee; - }); - - it('`_.findLast` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.findLast(objects), objects[2]); - iteratee = iteratee; - }); - - it('`_.findLastIndex` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.findLastIndex(objects), 2); - iteratee = iteratee; - }); - - it('`_.findKey` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.strictEqual(_.findKey(objects), '2'); - iteratee = iteratee; - }); - - it('`_.findLastKey` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.strictEqual(_.findLastKey(objects), '2'); - iteratee = iteratee; - }); - - it('`_.groupBy` should use `_.iteratee` internally', function() { - iteratee = getLength; - assert.deepEqual(_.groupBy(array), { '3': ['one', 'two'], '5': ['three'] }); - iteratee = iteratee; - }); - - it('`_.intersectionBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.intersectionBy(objects, [objects[2]]), [objects[1]]); - iteratee = iteratee; - }); - - it('`_.keyBy` should use `_.iteratee` internally', function() { - iteratee = getLength; - assert.deepEqual(_.keyBy(array), { '3': 'two', '5': 'three' }); - iteratee = iteratee; - }); - - it('`_.map` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.map(objects), [0, 1, 1]); - iteratee = iteratee; - }); - - it('`_.mapKeys` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.mapKeys({ 'a': { 'b': 2 } }), { '2': { 'b': 2 } }); - iteratee = iteratee; - }); - - it('`_.mapValues` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.mapValues({ 'a': { 'b': 2 } }), { 'a': 2 }); - iteratee = iteratee; - }); - - it('`_.maxBy` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.maxBy(objects), objects[2]); - iteratee = iteratee; - }); - - it('`_.meanBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.strictEqual(_.meanBy(objects), 2 / 3); - iteratee = iteratee; - }); - - it('`_.minBy` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.minBy(objects), objects[0]); - iteratee = iteratee; - }); - - it('`_.partition` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 1 }, { 'a': 1 }, { 'b': 2 }]; - - iteratee = getPropA; - assert.deepEqual(_.partition(objects), [objects.slice(0, 2), objects.slice(2)]); - iteratee = iteratee; - }); - - it('`_.pullAllBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.pullAllBy(objects.slice(), [{ 'a': 1, 'b': 0 }]), [objects[0]]); - iteratee = iteratee; - }); - - it('`_.reduce` should use `_.iteratee` internally', function() { - iteratee = getSum; - assert.strictEqual(_.reduce(objects, undefined, 0), 2); - iteratee = iteratee; - }); - - it('`_.reduceRight` should use `_.iteratee` internally', function() { - iteratee = getSum; - assert.strictEqual(_.reduceRight(objects, undefined, 0), 2); - iteratee = iteratee; - }); - - it('`_.reject` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - iteratee = getPropA; - assert.deepEqual(_.reject(objects), [objects[0]]); - iteratee = iteratee; - }); - - it('`_.remove` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - iteratee = getPropA; - _.remove(objects); - assert.deepEqual(objects, [{ 'a': 0 }]); - iteratee = iteratee; - }); - - it('`_.some` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.strictEqual(_.some(objects), true); - iteratee = iteratee; - }); - - it('`_.sortBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.sortBy(objects.slice().reverse()), [objects[0], objects[2], objects[1]]); - iteratee = iteratee; - }); - - it('`_.sortedIndexBy` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 30 }, { 'a': 50 }]; - - iteratee = getPropA; - assert.strictEqual(_.sortedIndexBy(objects, { 'a': 40 }), 1); - iteratee = iteratee; - }); - - it('`_.sortedLastIndexBy` should use `_.iteratee` internally', function() { - var objects = [{ 'a': 30 }, { 'a': 50 }]; - - iteratee = getPropA; - assert.strictEqual(_.sortedLastIndexBy(objects, { 'a': 40 }), 1); - iteratee = iteratee; - }); - - it('`_.sumBy` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.strictEqual(_.sumBy(objects), 1); - iteratee = iteratee; - }); - - it('`_.takeRightWhile` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.takeRightWhile(objects), objects.slice(2)); - iteratee = iteratee; - }); - - it('`_.takeWhile` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.takeWhile(objects.reverse()), objects.reverse().slice(2)); - iteratee = iteratee; - }); - - it('`_.transform` should use `_.iteratee` internally', function() { - iteratee = function() { - return function(result, object) { - result.sum += object.a; - }; - }; - - assert.deepEqual(_.transform(objects, undefined, { 'sum': 0 }), { 'sum': 2 }); - iteratee = iteratee; - }); - - it('`_.uniqBy` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.uniqBy(objects), [objects[0], objects[2]]); - iteratee = iteratee; - }); - - it('`_.unionBy` should use `_.iteratee` internally', function() { - iteratee = getPropB; - assert.deepEqual(_.unionBy(objects.slice(0, 1), [objects[2]]), [objects[0], objects[2]]); - iteratee = iteratee; - }); - - it('`_.xorBy` should use `_.iteratee` internally', function() { - iteratee = getPropA; - assert.deepEqual(_.xorBy(objects, objects.slice(1)), [objects[0]]); - iteratee = iteratee; - }); -}); diff --git a/libs/nanofn/test/debounce-and-throttle.js b/libs/nanofn/test/debounce-and-throttle.js deleted file mode 100644 index ece01eaa6..000000000 --- a/libs/nanofn/test/debounce-and-throttle.js +++ /dev/null @@ -1,167 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, noop, push, isModularize } from './utils.js'; -import runInContext from '../runInContext.js'; - -describe('debounce and throttle', function() { - lodashStable.each(['debounce', 'throttle'], function(methodName) { - var func = _[methodName], - isDebounce = methodName == 'debounce'; - - it('`_.' + methodName + '` should not error for non-object `options` values', function() { - func(noop, 32, 1); - assert.ok(true); - }); - - it('`_.' + methodName + '` should use a default `wait` of `0`', function(done) { - var callCount = 0, - funced = func(function() { callCount++; }); - - funced(); - - setTimeout(function() { - funced(); - assert.strictEqual(callCount, isDebounce ? 1 : 2); - done(); - }, 32); - }); - - it('`_.' + methodName + '` should invoke `func` with the correct `this` binding', function(done) { - var actual = [], - object = { 'funced': func(function() { actual.push(this); }, 32) }, - expected = lodashStable.times(isDebounce ? 1 : 2, lodashStable.constant(object)); - - object.funced(); - if (!isDebounce) { - object.funced(); - } - setTimeout(function() { - assert.deepStrictEqual(actual, expected); - done(); - }, 64); - }); - - it('`_.' + methodName + '` supports recursive calls', function(done) { - var actual = [], - args = lodashStable.map(['a', 'b', 'c'], function(chr) { return [{}, chr]; }), - expected = args.slice(), - queue = args.slice(); - - var funced = func(function() { - var current = [this]; - push.apply(current, arguments); - actual.push(current); - - var next = queue.shift(); - if (next) { - funced.call(next[0], next[1]); - } - }, 32); - - var next = queue.shift(); - funced.call(next[0], next[1]); - assert.deepStrictEqual(actual, expected.slice(0, isDebounce ? 0 : 1)); - - setTimeout(function() { - assert.deepStrictEqual(actual, expected.slice(0, actual.length)); - done(); - }, 256); - }); - - it('`_.' + methodName + '` should work if the system time is set backwards', function(done) { - if (!isModularize) { - var callCount = 0, - dateCount = 0; - - var lodash = runInContext({ - 'Date': { - 'now': function() { - return ++dateCount == 4 - ? +new Date(2012, 3, 23, 23, 27, 18) - : +new Date; - } - } - }); - - var funced = lodash[methodName](function() { - callCount++; - }, 32); - - funced(); - - setTimeout(function() { - funced(); - assert.strictEqual(callCount, isDebounce ? 1 : 2); - done(); - }, 64); - } - else { - done(); - } - }); - - it('`_.' + methodName + '` should support cancelling delayed calls', function(done) { - var callCount = 0; - - var funced = func(function() { - callCount++; - }, 32, { 'leading': false }); - - funced(); - funced.cancel(); - - setTimeout(function() { - assert.strictEqual(callCount, 0); - done(); - }, 64); - }); - - it('`_.' + methodName + '` should reset `lastCalled` after cancelling', function(done) { - var callCount = 0; - - var funced = func(function() { - return ++callCount; - }, 32, { 'leading': true }); - - assert.strictEqual(funced(), 1); - funced.cancel(); - - assert.strictEqual(funced(), 2); - funced(); - - setTimeout(function() { - assert.strictEqual(callCount, 3); - done(); - }, 64); - }); - - it('`_.' + methodName + '` should support flushing delayed calls', function(done) { - var callCount = 0; - - var funced = func(function() { - return ++callCount; - }, 32, { 'leading': false }); - - funced(); - assert.strictEqual(funced.flush(), 1); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - done(); - }, 64); - }); - - it('`_.' + methodName + '` should noop `cancel` and `flush` when nothing is queued', function(done) { - var callCount = 0, - funced = func(function() { callCount++; }, 32); - - funced.cancel(); - assert.strictEqual(funced.flush(), undefined); - - setTimeout(function() { - assert.strictEqual(callCount, 0); - done(); - }, 64); - }); - }); -}); diff --git a/libs/nanofn/test/debounce.test.js b/libs/nanofn/test/debounce.test.js deleted file mode 100644 index 184d9b91d..000000000 --- a/libs/nanofn/test/debounce.test.js +++ /dev/null @@ -1,250 +0,0 @@ -import assert from 'assert'; -import { identity, argv, isPhantom, push } from './utils.js'; -import debounce from '../debounce.js'; - -describe('debounce', function() { - it('should debounce a function', function(done) { - var callCount = 0; - - var debounced = debounce(function(value) { - ++callCount; - return value; - }, 32); - - var results = [debounced('a'), debounced('b'), debounced('c')]; - assert.deepStrictEqual(results, [undefined, undefined, undefined]); - assert.strictEqual(callCount, 0); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - - var results = [debounced('d'), debounced('e'), debounced('f')]; - assert.deepStrictEqual(results, ['c', 'c', 'c']); - assert.strictEqual(callCount, 1); - }, 128); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 256); - }); - - it('subsequent debounced calls return the last `func` result', function(done) { - var debounced = debounce(identity, 32); - debounced('a'); - - setTimeout(function() { - assert.notStrictEqual(debounced('b'), 'b'); - }, 64); - - setTimeout(function() { - assert.notStrictEqual(debounced('c'), 'c'); - done(); - }, 128); - }); - - it('should not immediately call `func` when `wait` is `0`', function(done) { - var callCount = 0, - debounced = debounce(function() { ++callCount; }, 0); - - debounced(); - debounced(); - assert.strictEqual(callCount, 0); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - done(); - }, 5); - }); - - it('should apply default options', function(done) { - var callCount = 0, - debounced = debounce(function() { callCount++; }, 32, {}); - - debounced(); - assert.strictEqual(callCount, 0); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - done(); - }, 64); - }); - - it('should support a `leading` option', function(done) { - var callCounts = [0, 0]; - - var withLeading = debounce(function() { - callCounts[0]++; - }, 32, { 'leading': true }); - - var withLeadingAndTrailing = debounce(function() { - callCounts[1]++; - }, 32, { 'leading': true }); - - withLeading(); - assert.strictEqual(callCounts[0], 1); - - withLeadingAndTrailing(); - withLeadingAndTrailing(); - assert.strictEqual(callCounts[1], 1); - - setTimeout(function() { - assert.deepStrictEqual(callCounts, [1, 2]); - - withLeading(); - assert.strictEqual(callCounts[0], 2); - - done(); - }, 64); - }); - - it('subsequent leading debounced calls return the last `func` result', function(done) { - var debounced = debounce(identity, 32, { 'leading': true, 'trailing': false }), - results = [debounced('a'), debounced('b')]; - - assert.deepStrictEqual(results, ['a', 'a']); - - setTimeout(function() { - var results = [debounced('c'), debounced('d')]; - assert.deepStrictEqual(results, ['c', 'c']); - done(); - }, 64); - }); - - it('should support a `trailing` option', function(done) { - var withCount = 0, - withoutCount = 0; - - var withTrailing = debounce(function() { - withCount++; - }, 32, { 'trailing': true }); - - var withoutTrailing = debounce(function() { - withoutCount++; - }, 32, { 'trailing': false }); - - withTrailing(); - assert.strictEqual(withCount, 0); - - withoutTrailing(); - assert.strictEqual(withoutCount, 0); - - setTimeout(function() { - assert.strictEqual(withCount, 1); - assert.strictEqual(withoutCount, 0); - done(); - }, 64); - }); - - it('should support a `maxWait` option', function(done) { - var callCount = 0; - - var debounced = debounce(function(value) { - ++callCount; - return value; - }, 32, { 'maxWait': 64 }); - - debounced(); - debounced(); - assert.strictEqual(callCount, 0); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - debounced(); - debounced(); - assert.strictEqual(callCount, 1); - }, 128); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 256); - }); - - it('should support `maxWait` in a tight loop', function(done) { - var limit = (argv || isPhantom) ? 1000 : 320, - withCount = 0, - withoutCount = 0; - - var withMaxWait = debounce(function() { - withCount++; - }, 64, { 'maxWait': 128 }); - - var withoutMaxWait = debounce(function() { - withoutCount++; - }, 96); - - var start = +new Date; - while ((new Date - start) < limit) { - withMaxWait(); - withoutMaxWait(); - } - var actual = [Boolean(withoutCount), Boolean(withCount)]; - setTimeout(function() { - assert.deepStrictEqual(actual, [false, true]); - done(); - }, 1); - }); - - it('should queue a trailing call for subsequent debounced calls after `maxWait`', function(done) { - var callCount = 0; - - var debounced = debounce(function() { - ++callCount; - }, 200, { 'maxWait': 200 }); - - debounced(); - - setTimeout(debounced, 190); - setTimeout(debounced, 200); - setTimeout(debounced, 210); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 500); - }); - - it('should cancel `maxDelayed` when `delayed` is invoked', function(done) { - var callCount = 0; - - var debounced = debounce(function() { - callCount++; - }, 32, { 'maxWait': 64 }); - - debounced(); - - setTimeout(function() { - debounced(); - assert.strictEqual(callCount, 1); - }, 128); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 192); - }); - - it('should invoke the trailing call with the correct arguments and `this` binding', function(done) { - var actual, - callCount = 0, - object = {}; - - var debounced = debounce(function(value) { - actual = [this]; - push.apply(actual, arguments); - return ++callCount != 2; - }, 32, { 'leading': true, 'maxWait': 64 }); - - while (true) { - if (!debounced.call(object, 'a')) { - break; - } - } - setTimeout(function() { - assert.strictEqual(callCount, 2); - assert.deepStrictEqual(actual, [object, 'a']); - done(); - }, 64); - }); -}); diff --git a/libs/nanofn/test/deburr.test.js b/libs/nanofn/test/deburr.test.js deleted file mode 100644 index 5ab176f4a..000000000 --- a/libs/nanofn/test/deburr.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { burredLetters, deburredLetters, comboMarks } from './utils.js'; -import deburr from '../deburr.js'; - -describe('deburr', function() { - it('should convert Latin Unicode letters to basic Latin', function() { - var actual = lodashStable.map(burredLetters, deburr); - assert.deepStrictEqual(actual, deburredLetters); - }); - - it('should not deburr Latin mathematical operators', function() { - var operators = ['\xd7', '\xf7'], - actual = lodashStable.map(operators, deburr); - - assert.deepStrictEqual(actual, operators); - }); - - it('should deburr combining diacritical marks', function() { - var expected = lodashStable.map(comboMarks, lodashStable.constant('ei')); - - var actual = lodashStable.map(comboMarks, function(chr) { - return deburr('e' + chr + 'i'); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/defaultTo.test.js b/libs/nanofn/test/defaultTo.test.js deleted file mode 100644 index 5d6dc5f3a..000000000 --- a/libs/nanofn/test/defaultTo.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey } from './utils.js'; -import defaultTo from '../defaultTo.js'; - -describe('defaultTo', function() { - it('should return a default value if `value` is `NaN` or nullish', function() { - var expected = lodashStable.map(falsey, function(value) { - return (value == null || value !== value) ? 1 : value; - }); - - var actual = lodashStable.map(falsey, function(value) { - return defaultTo(value, 1); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/defaults.test.js b/libs/nanofn/test/defaults.test.js deleted file mode 100644 index 867f31d80..000000000 --- a/libs/nanofn/test/defaults.test.js +++ /dev/null @@ -1,66 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { objectProto } from './utils.js'; -import defaults from '../defaults.js'; - -describe('defaults', function() { - it('should assign source properties if missing on `object`', function() { - var actual = defaults({ 'a': 1 }, { 'a': 2, 'b': 2 }); - assert.deepStrictEqual(actual, { 'a': 1, 'b': 2 }); - }); - - it('should accept multiple sources', function() { - var expected = { 'a': 1, 'b': 2, 'c': 3 }, - actual = defaults({ 'a': 1, 'b': 2 }, { 'b': 3 }, { 'c': 3 }); - - assert.deepStrictEqual(actual, expected); - - actual = defaults({ 'a': 1, 'b': 2 }, { 'b': 3, 'c': 3 }, { 'c': 2 }); - assert.deepStrictEqual(actual, expected); - }); - - it('should not overwrite `null` values', function() { - var actual = defaults({ 'a': null }, { 'a': 1 }); - assert.strictEqual(actual.a, null); - }); - - it('should overwrite `undefined` values', function() { - var actual = defaults({ 'a': undefined }, { 'a': 1 }); - assert.strictEqual(actual.a, 1); - }); - - it('should assign `undefined` values', function() { - var source = { 'a': undefined, 'b': 1 }, - actual = defaults({}, source); - - assert.deepStrictEqual(actual, { 'a': undefined, 'b': 1 }); - }); - - it('should assign properties that shadow those on `Object.prototype`', function() { - var object = { - 'constructor': objectProto.constructor, - 'hasOwnProperty': objectProto.hasOwnProperty, - 'isPrototypeOf': objectProto.isPrototypeOf, - 'propertyIsEnumerable': objectProto.propertyIsEnumerable, - 'toLocaleString': objectProto.toLocaleString, - 'toString': objectProto.toString, - 'valueOf': objectProto.valueOf - }; - - var source = { - 'constructor': 1, - 'hasOwnProperty': 2, - 'isPrototypeOf': 3, - 'propertyIsEnumerable': 4, - 'toLocaleString': 5, - 'toString': 6, - 'valueOf': 7 - }; - - var expected = lodashStable.clone(source); - assert.deepStrictEqual(defaults({}, source), expected); - - expected = lodashStable.clone(object); - assert.deepStrictEqual(defaults({}, object, source), expected); - }); -}); diff --git a/libs/nanofn/test/defaultsDeep.js b/libs/nanofn/test/defaultsDeep.js deleted file mode 100644 index a4a9ff2fb..000000000 --- a/libs/nanofn/test/defaultsDeep.js +++ /dev/null @@ -1,101 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop } from './utils.js'; -import defaultsDeep from '../defaultsDeep.js'; - -describe('defaultsDeep', function() { - it('should deep assign source properties if missing on `object`', function() { - var object = { 'a': { 'b': 2 }, 'd': 4 }, - source = { 'a': { 'b': 3, 'c': 3 }, 'e': 5 }, - expected = { 'a': { 'b': 2, 'c': 3 }, 'd': 4, 'e': 5 }; - - assert.deepStrictEqual(defaultsDeep(object, source), expected); - }); - - it('should accept multiple sources', function() { - var source1 = { 'a': { 'b': 3 } }, - source2 = { 'a': { 'c': 3 } }, - source3 = { 'a': { 'b': 3, 'c': 3 } }, - source4 = { 'a': { 'c': 4 } }, - expected = { 'a': { 'b': 2, 'c': 3 } }; - - assert.deepStrictEqual(defaultsDeep({ 'a': { 'b': 2 } }, source1, source2), expected); - assert.deepStrictEqual(defaultsDeep({ 'a': { 'b': 2 } }, source3, source4), expected); - }); - - it('should not overwrite `null` values', function() { - var object = { 'a': { 'b': null } }, - source = { 'a': { 'b': 2 } }, - actual = defaultsDeep(object, source); - - assert.strictEqual(actual.a.b, null); - }); - - it('should not overwrite regexp values', function() { - var object = { 'a': { 'b': /x/ } }, - source = { 'a': { 'b': /y/ } }, - actual = defaultsDeep(object, source); - - assert.deepStrictEqual(actual.a.b, /x/); - }); - - it('should not convert function properties to objects', function() { - var actual = defaultsDeep({}, { 'a': noop }); - assert.strictEqual(actual.a, noop); - - actual = defaultsDeep({}, { 'a': { 'b': noop } }); - assert.strictEqual(actual.a.b, noop); - }); - - it('should overwrite `undefined` values', function() { - var object = { 'a': { 'b': undefined } }, - source = { 'a': { 'b': 2 } }, - actual = defaultsDeep(object, source); - - assert.strictEqual(actual.a.b, 2); - }); - - it('should assign `undefined` values', function() { - var source = { 'a': undefined, 'b': { 'c': undefined, 'd': 1 } }, - expected = lodashStable.cloneDeep(source), - actual = defaultsDeep({}, source); - - assert.deepStrictEqual(actual, expected); - }); - - it('should merge sources containing circular references', function() { - var object = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': { 'a': 2 } - }; - - var source = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': {} - }; - - object.foo.b.c.d = object; - source.foo.b.c.d = source; - source.bar.b = source.foo.b; - - var actual = defaultsDeep(object, source); - - assert.strictEqual(actual.bar.b, actual.foo.b); - assert.strictEqual(actual.foo.b.c.d, actual.foo.b.c.d.foo.b.c.d); - }); - - it('should not modify sources', function() { - var source1 = { 'a': 1, 'b': { 'c': 2 } }, - source2 = { 'b': { 'c': 3, 'd': 3 } }, - actual = defaultsDeep({}, source1, source2); - - assert.deepStrictEqual(actual, { 'a': 1, 'b': { 'c': 2, 'd': 3 } }); - assert.deepStrictEqual(source1, { 'a': 1, 'b': { 'c': 2 } }); - assert.deepStrictEqual(source2, { 'b': { 'c': 3, 'd': 3 } }); - }); - - it('should not attempt a merge of a string into an array', function() { - var actual = defaultsDeep({ 'a': ['abc'] }, { 'a': 'abc' }); - assert.deepStrictEqual(actual.a, ['abc']); - }); -}); diff --git a/libs/nanofn/test/defer.test.js b/libs/nanofn/test/defer.test.js deleted file mode 100644 index 421fab372..000000000 --- a/libs/nanofn/test/defer.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import defer from '../defer.js'; - -describe('defer', function() { - it('should defer `func` execution', function(done) { - var pass = false; - defer(function() { pass = true; }); - - setTimeout(function() { - assert.ok(pass); - done(); - }, 32); - }); - - it('should provide additional arguments to `func`', function(done) { - var args; - - defer(function() { - args = slice.call(arguments); - }, 1, 2); - - setTimeout(function() { - assert.deepStrictEqual(args, [1, 2]); - done(); - }, 32); - }); - - it('should be cancelable', function(done) { - var pass = true, - timerId = defer(function() { pass = false; }); - - clearTimeout(timerId); - - setTimeout(function() { - assert.ok(pass); - done(); - }, 32); - }); -}); diff --git a/libs/nanofn/test/delay.js b/libs/nanofn/test/delay.js deleted file mode 100644 index ef3ebcae4..000000000 --- a/libs/nanofn/test/delay.js +++ /dev/null @@ -1,67 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import delay from '../delay.js'; - -describe('delay', function() { - it('should delay `func` execution', function(done) { - var pass = false; - delay(function() { pass = true; }, 32); - - setTimeout(function() { - assert.ok(!pass); - }, 1); - - setTimeout(function() { - assert.ok(pass); - done(); - }, 64); - }); - - it('should provide additional arguments to `func`', function(done) { - var args; - - delay(function() { - args = slice.call(arguments); - }, 32, 1, 2); - - setTimeout(function() { - assert.deepStrictEqual(args, [1, 2]); - done(); - }, 64); - }); - - it('should use a default `wait` of `0`', function(done) { - var pass = false; - delay(function() { pass = true; }); - - assert.ok(!pass); - - setTimeout(function() { - assert.ok(pass); - done(); - }, 0); - }); - - it('should be cancelable', function(done) { - var pass = true, - timerId = delay(function() { pass = false; }, 32); - - clearTimeout(timerId); - - setTimeout(function() { - assert.ok(pass); - done(); - }, 64); - }); - - it('should work with mocked `setTimeout`', function() { - var pass = false, - setTimeout = root.setTimeout; - - setProperty(root, 'setTimeout', function(func) { func(); }); - delay(function() { pass = true; }, 32); - setProperty(root, 'setTimeout', setTimeout); - - assert.ok(pass); - }); -}); diff --git a/libs/nanofn/test/difference-methods.js b/libs/nanofn/test/difference-methods.js deleted file mode 100644 index 6591193cf..000000000 --- a/libs/nanofn/test/difference-methods.js +++ /dev/null @@ -1,85 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, LARGE_ARRAY_SIZE, stubOne, stubNaN, args } from './utils.js'; - -describe('difference methods', function() { - lodashStable.each(['difference', 'differenceBy', 'differenceWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should return the difference of two arrays', function() { - var actual = func([2, 1], [2, 3]); - assert.deepStrictEqual(actual, [1]); - }); - - it('`_.' + methodName + '` should return the difference of multiple arrays', function() { - var actual = func([2, 1, 2, 3], [3, 4], [3, 2]); - assert.deepStrictEqual(actual, [1]); - }); - - it('`_.' + methodName + '` should treat `-0` as `0`', function() { - var array = [-0, 0]; - - var actual = lodashStable.map(array, function(value) { - return func(array, [value]); - }); - - assert.deepStrictEqual(actual, [[], []]); - - actual = lodashStable.map(func([-0, 1], [1]), lodashStable.toString); - assert.deepStrictEqual(actual, ['0']); - }); - - it('`_.' + methodName + '` should match `NaN`', function() { - assert.deepStrictEqual(func([1, NaN, 3], [NaN, 5, NaN]), [1, 3]); - }); - - it('`_.' + methodName + '` should work with large arrays', function() { - var array1 = lodashStable.range(LARGE_ARRAY_SIZE + 1), - array2 = lodashStable.range(LARGE_ARRAY_SIZE), - a = {}, - b = {}, - c = {}; - - array1.push(a, b, c); - array2.push(b, c, a); - - assert.deepStrictEqual(func(array1, array2), [LARGE_ARRAY_SIZE]); - }); - - it('`_.' + methodName + '` should work with large arrays of `-0` as `0`', function() { - var array = [-0, 0]; - - var actual = lodashStable.map(array, function(value) { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(value)); - return func(array, largeArray); - }); - - assert.deepStrictEqual(actual, [[], []]); - - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubOne); - actual = lodashStable.map(func([-0, 1], largeArray), lodashStable.toString); - assert.deepStrictEqual(actual, ['0']); - }); - - it('`_.' + methodName + '` should work with large arrays of `NaN`', function() { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubNaN); - assert.deepStrictEqual(func([1, NaN, 3], largeArray), [1, 3]); - }); - - it('`_.' + methodName + '` should work with large arrays of objects', function() { - var object1 = {}, - object2 = {}, - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(object1)); - - assert.deepStrictEqual(func([object1, object2], largeArray), [object2]); - }); - - it('`_.' + methodName + '` should ignore values that are not array-like', function() { - var array = [1, null, 3]; - - assert.deepStrictEqual(func(args, 3, { '0': 1 }), [1, 2, 3]); - assert.deepStrictEqual(func(null, array, 1), []); - assert.deepStrictEqual(func(array, args, null), [null]); - }); - }); -}); diff --git a/libs/nanofn/test/differenceBy.js b/libs/nanofn/test/differenceBy.js deleted file mode 100644 index af5ca665b..000000000 --- a/libs/nanofn/test/differenceBy.js +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import differenceBy from '../differenceBy.js'; - -describe('differenceBy', function() { - it('should accept an `iteratee`', function() { - var actual = differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); - assert.deepStrictEqual(actual, [1.2]); - - actual = differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); - assert.deepStrictEqual(actual, [{ 'x': 2 }]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - differenceBy([2.1, 1.2], [2.3, 3.4], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [2.3]); - }); -}); diff --git a/libs/nanofn/test/differenceWith.test.js b/libs/nanofn/test/differenceWith.test.js deleted file mode 100644 index 1c7c49d40..000000000 --- a/libs/nanofn/test/differenceWith.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, stubOne } from './utils.js'; -import differenceWith from '../differenceWith.js'; - -describe('differenceWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], - actual = differenceWith(objects, [{ 'x': 1, 'y': 2 }], lodashStable.isEqual); - - assert.deepStrictEqual(actual, [objects[1]]); - }); - - it('should preserve the sign of `0`', function() { - var array = [-0, 1], - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubOne), - others = [[1], largeArray], - expected = lodashStable.map(others, lodashStable.constant(['-0'])); - - var actual = lodashStable.map(others, function(other) { - return lodashStable.map(differenceWith(array, other, lodashStable.eq), lodashStable.toString); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/divide.test.js b/libs/nanofn/test/divide.test.js deleted file mode 100644 index 495a6bb70..000000000 --- a/libs/nanofn/test/divide.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import divide from '../divide.js'; - -describe('divide', function() { - it('should divide two numbers', function() { - assert.strictEqual(divide(6, 4), 1.5); - assert.strictEqual(divide(-6, 4), -1.5); - assert.strictEqual(divide(-6, -4), 1.5); - }); - - it('should coerce arguments to numbers', function() { - assert.strictEqual(divide('6', '4'), 1.5); - assert.deepStrictEqual(divide('x', 'y'), NaN); - }); -}); diff --git a/libs/nanofn/test/drop.test.js b/libs/nanofn/test/drop.test.js deleted file mode 100644 index 5011c70c0..000000000 --- a/libs/nanofn/test/drop.test.js +++ /dev/null @@ -1,62 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import drop from '../drop.js'; - -describe('drop', function() { - var array = [1, 2, 3]; - - it('should drop the first two elements', function() { - assert.deepStrictEqual(drop(array, 2), [3]); - }); - - it('should treat falsey `n` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? [2, 3] : array; - }); - - var actual = lodashStable.map(falsey, function(n) { - return drop(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return all elements when `n` < `1`', function() { - lodashStable.each([0, -1, -Infinity], function(n) { - assert.deepStrictEqual(drop(array, n), array); - }); - }); - - it('should return an empty array when `n` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - assert.deepStrictEqual(drop(array, n), []); - }); - }); - - it('should coerce `n` to an integer', function() { - assert.deepStrictEqual(drop(array, 1.6), [2, 3]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - predicate = function(value) { values.push(value); return isEven(value); }, - values = [], - actual = _(array).drop(2).drop().value(); - - assert.deepEqual(actual, array.slice(3)); - - actual = _(array).filter(predicate).drop(2).drop().value(); - assert.deepEqual(values, array); - assert.deepEqual(actual, drop(drop(_.filter(array, predicate), 2))); - - actual = _(array).drop(2).dropRight().drop().dropRight(2).value(); - assert.deepEqual(actual, _.dropRight(drop(_.dropRight(drop(array, 2))), 2)); - - values = []; - - actual = _(array).drop().filter(predicate).drop(2).dropRight().drop().dropRight(2).value(); - assert.deepEqual(values, array.slice(1)); - assert.deepEqual(actual, _.dropRight(drop(_.dropRight(drop(_.filter(drop(array), predicate), 2))), 2)); - }); -}); diff --git a/libs/nanofn/test/dropRight.test.js b/libs/nanofn/test/dropRight.test.js deleted file mode 100644 index 040ecc6cf..000000000 --- a/libs/nanofn/test/dropRight.test.js +++ /dev/null @@ -1,62 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import dropRight from '../dropRight.js'; - -describe('dropRight', function() { - var array = [1, 2, 3]; - - it('should drop the last two elements', function() { - assert.deepStrictEqual(dropRight(array, 2), [1]); - }); - - it('should treat falsey `n` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? [1, 2] : array; - }); - - var actual = lodashStable.map(falsey, function(n) { - return dropRight(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return all elements when `n` < `1`', function() { - lodashStable.each([0, -1, -Infinity], function(n) { - assert.deepStrictEqual(dropRight(array, n), array); - }); - }); - - it('should return an empty array when `n` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - assert.deepStrictEqual(dropRight(array, n), []); - }); - }); - - it('should coerce `n` to an integer', function() { - assert.deepStrictEqual(dropRight(array, 1.6), [1, 2]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - predicate = function(value) { values.push(value); return isEven(value); }, - values = [], - actual = _(array).dropRight(2).dropRight().value(); - - assert.deepEqual(actual, array.slice(0, -3)); - - actual = _(array).filter(predicate).dropRight(2).dropRight().value(); - assert.deepEqual(values, array); - assert.deepEqual(actual, dropRight(dropRight(_.filter(array, predicate), 2))); - - actual = _(array).dropRight(2).drop().dropRight().drop(2).value(); - assert.deepEqual(actual, _.drop(dropRight(_.drop(dropRight(array, 2))), 2)); - - values = []; - - actual = _(array).dropRight().filter(predicate).dropRight(2).drop().dropRight().drop(2).value(); - assert.deepEqual(values, array.slice(0, -1)); - assert.deepEqual(actual, _.drop(dropRight(_.drop(dropRight(_.filter(dropRight(array), predicate), 2))), 2)); - }); -}); diff --git a/libs/nanofn/test/dropRightWhile.js b/libs/nanofn/test/dropRightWhile.js deleted file mode 100644 index 07dceadde..000000000 --- a/libs/nanofn/test/dropRightWhile.js +++ /dev/null @@ -1,52 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import dropRightWhile from '../dropRightWhile.js'; - -describe('dropRightWhile', function() { - var array = [1, 2, 3, 4]; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 1 }, - { 'a': 2, 'b': 2 } - ]; - - it('should drop elements while `predicate` returns truthy', function() { - var actual = dropRightWhile(array, function(n) { - return n > 2; - }); - - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('should provide correct `predicate` arguments', function() { - var args; - - dropRightWhile(array, function() { - args = slice.call(arguments); - }); - - assert.deepStrictEqual(args, [4, 3, array]); - }); - - it('should work with `_.matches` shorthands', function() { - assert.deepStrictEqual(dropRightWhile(objects, { 'b': 2 }), objects.slice(0, 2)); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - assert.deepStrictEqual(dropRightWhile(objects, ['b', 2]), objects.slice(0, 2)); - }); - - it('should work with `_.property` shorthands', function() { - assert.deepStrictEqual(dropRightWhile(objects, 'b'), objects.slice(0, 1)); - }); - - it('should return a wrapped value when chaining', function() { - var wrapped = _(array).dropRightWhile(function(n) { - return n > 2; - }); - - assert.ok(wrapped instanceof _); - assert.deepEqual(wrapped.value(), [1, 2]); - }); -}); diff --git a/libs/nanofn/test/dropWhile.js b/libs/nanofn/test/dropWhile.js deleted file mode 100644 index f02088104..000000000 --- a/libs/nanofn/test/dropWhile.js +++ /dev/null @@ -1,67 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, LARGE_ARRAY_SIZE } from './utils.js'; -import dropWhile from '../dropWhile.js'; - -describe('dropWhile', function() { - var array = [1, 2, 3, 4]; - - var objects = [ - { 'a': 2, 'b': 2 }, - { 'a': 1, 'b': 1 }, - { 'a': 0, 'b': 0 } - ]; - - it('should drop elements while `predicate` returns truthy', function() { - var actual = dropWhile(array, function(n) { - return n < 3; - }); - - assert.deepStrictEqual(actual, [3, 4]); - }); - - it('should provide correct `predicate` arguments', function() { - var args; - - dropWhile(array, function() { - args = slice.call(arguments); - }); - - assert.deepStrictEqual(args, [1, 0, array]); - }); - - it('should work with `_.matches` shorthands', function() { - assert.deepStrictEqual(dropWhile(objects, { 'b': 2 }), objects.slice(1)); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - assert.deepStrictEqual(dropWhile(objects, ['b', 2]), objects.slice(1)); - }); - - it('should work with `_.property` shorthands', function() { - assert.deepStrictEqual(dropWhile(objects, 'b'), objects.slice(2)); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 3), - predicate = function(n) { return n < 3; }, - expected = dropWhile(array, predicate), - wrapped = _(array).dropWhile(predicate); - - assert.deepEqual(wrapped.value(), expected); - assert.deepEqual(wrapped.reverse().value(), expected.slice().reverse()); - assert.strictEqual(wrapped.last(), _.last(expected)); - }); - - it('should work in a lazy sequence with `drop`', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 3); - - var actual = _(array) - .dropWhile(function(n) { return n == 1; }) - .drop() - .dropWhile(function(n) { return n == 3; }) - .value(); - - assert.deepEqual(actual, array.slice(3)); - }); -}); diff --git a/libs/nanofn/test/endsWith.test.js b/libs/nanofn/test/endsWith.test.js deleted file mode 100644 index ceb9dddd4..000000000 --- a/libs/nanofn/test/endsWith.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { MAX_SAFE_INTEGER, falsey, stubTrue } from './utils.js'; -import endsWith from '../endsWith.js'; - -describe('endsWith', function() { - var string = 'abc'; - - it('should return `true` if a string ends with `target`', function() { - assert.strictEqual(endsWith(string, 'c'), true); - }); - - it('should return `false` if a string does not end with `target`', function() { - assert.strictEqual(endsWith(string, 'b'), false); - }); - - it('should work with a `position`', function() { - assert.strictEqual(endsWith(string, 'b', 2), true); - }); - - it('should work with `position` >= `length`', function() { - lodashStable.each([3, 5, MAX_SAFE_INTEGER, Infinity], function(position) { - assert.strictEqual(endsWith(string, 'c', position), true); - }); - }); - - it('should treat falsey `position` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(position) { - return endsWith(string, position === undefined ? 'c' : '', position); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should treat a negative `position` as `0`', function() { - lodashStable.each([-1, -3, -Infinity], function(position) { - assert.ok(lodashStable.every(string, function(chr) { - return !endsWith(string, chr, position); - })); - assert.strictEqual(endsWith(string, '', position), true); - }); - }); - - it('should coerce `position` to an integer', function() { - assert.strictEqual(endsWith(string, 'ab', 2.2), true); - }); -}); diff --git a/libs/nanofn/test/eq.test.js b/libs/nanofn/test/eq.test.js deleted file mode 100644 index ec0c7adad..000000000 --- a/libs/nanofn/test/eq.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import assert from 'assert'; -import eq from '../eq.js'; - -describe('eq', function() { - it('should perform a `SameValueZero` comparison of two values', function() { - assert.strictEqual(eq(), true); - assert.strictEqual(eq(undefined), true); - assert.strictEqual(eq(0, -0), true); - assert.strictEqual(eq(NaN, NaN), true); - assert.strictEqual(eq(1, 1), true); - - assert.strictEqual(eq(null, undefined), false); - assert.strictEqual(eq(1, Object(1)), false); - assert.strictEqual(eq(1, '1'), false); - assert.strictEqual(eq(1, '1'), false); - - var object = { 'a': 1 }; - assert.strictEqual(eq(object, object), true); - assert.strictEqual(eq(object, { 'a': 1 }), false); - }); -}); diff --git a/libs/nanofn/test/escape.test.js b/libs/nanofn/test/escape.test.js deleted file mode 100644 index f5b7dbaba..000000000 --- a/libs/nanofn/test/escape.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import escape from '../escape.js'; -import unescape from '../unescape.js'; - -describe('escape', function() { - var escaped = '&<>"'/', - unescaped = '&<>"\'/'; - - escaped += escaped; - unescaped += unescaped; - - it('should escape values', function() { - assert.strictEqual(escape(unescaped), escaped); - }); - - it('should handle strings with nothing to escape', function() { - assert.strictEqual(escape('abc'), 'abc'); - }); - - it('should escape the same characters unescaped by `_.unescape`', function() { - assert.strictEqual(escape(unescape(escaped)), escaped); - }); - - lodashStable.each(['`', '/'], function(chr) { - it('should not escape the "' + chr + '" character', function() { - assert.strictEqual(escape(chr), chr); - }); - }); -}); diff --git a/libs/nanofn/test/escapeRegExp.test.js b/libs/nanofn/test/escapeRegExp.test.js deleted file mode 100644 index 3fa706274..000000000 --- a/libs/nanofn/test/escapeRegExp.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubString } from './utils.js'; -import escapeRegExp from '../escapeRegExp.js'; - -describe('escapeRegExp', function() { - var escaped = '\\^\\$\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\', - unescaped = '^$.*+?()[]{}|\\'; - - it('should escape values', function() { - assert.strictEqual(escapeRegExp(unescaped + unescaped), escaped + escaped); - }); - - it('should handle strings with nothing to escape', function() { - assert.strictEqual(escapeRegExp('abc'), 'abc'); - }); - - it('should return an empty string for empty values', function() { - var values = [, null, undefined, ''], - expected = lodashStable.map(values, stubString); - - var actual = lodashStable.map(values, function(value, index) { - return index ? escapeRegExp(value) : escapeRegExp(); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/every.js b/libs/nanofn/test/every.js deleted file mode 100644 index 76052aa9f..000000000 --- a/libs/nanofn/test/every.js +++ /dev/null @@ -1,74 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, empties, stubTrue, stubFalse } from './utils.js'; -import every from '../every.js'; - -describe('every', function() { - it('should return `true` if `predicate` returns truthy for all elements', function() { - assert.strictEqual(lodashStable.every([true, 1, 'a'], identity), true); - }); - - it('should return `true` for empty collections', function() { - var expected = lodashStable.map(empties, stubTrue); - - var actual = lodashStable.map(empties, function(value) { - try { - return every(value, identity); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` as soon as `predicate` returns falsey', function() { - var count = 0; - - assert.strictEqual(every([true, null, true], function(value) { - count++; - return value; - }), false); - - assert.strictEqual(count, 2); - }); - - it('should work with collections of `undefined` values (test in IE < 9)', function() { - assert.strictEqual(every([undefined, undefined, undefined], identity), false); - }); - - it('should use `_.identity` when `predicate` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value, index) { - var array = [0]; - return index ? every(array, value) : every(array); - }); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(values, stubTrue); - actual = lodashStable.map(values, function(value, index) { - var array = [1]; - return index ? every(array, value) : every(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 0, 'b': 1 }, { 'a': 1, 'b': 2 }]; - assert.strictEqual(every(objects, 'a'), false); - assert.strictEqual(every(objects, 'b'), true); - }); - - it('should work with `_.matches` shorthands', function() { - var objects = [{ 'a': 0, 'b': 0 }, { 'a': 0, 'b': 1 }]; - assert.strictEqual(every(objects, { 'a': 0 }), true); - assert.strictEqual(every(objects, { 'b': 1 }), false); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map([[1]], every); - assert.deepStrictEqual(actual, [true]); - }); -}); diff --git a/libs/nanofn/test/exit-early.js b/libs/nanofn/test/exit-early.js deleted file mode 100644 index 090d6c893..000000000 --- a/libs/nanofn/test/exit-early.js +++ /dev/null @@ -1,37 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('exit early', function() { - lodashStable.each(['_baseEach', 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'transform'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` can exit early when iterating arrays', function() { - if (func) { - var array = [1, 2, 3], - values = []; - - func(array, function(value, other) { - values.push(lodashStable.isArray(value) ? other : value); - return false; - }); - - assert.deepStrictEqual(values, [lodashStable.endsWith(methodName, 'Right') ? 3 : 1]); - } - }); - - it('`_.' + methodName + '` can exit early when iterating objects', function() { - if (func) { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - values = []; - - func(object, function(value, other) { - values.push(lodashStable.isArray(value) ? other : value); - return false; - }); - - assert.strictEqual(values.length, 1); - } - }); - }); -}); diff --git a/libs/nanofn/test/extremum-methods.js b/libs/nanofn/test/extremum-methods.js deleted file mode 100644 index 6dad236bd..000000000 --- a/libs/nanofn/test/extremum-methods.js +++ /dev/null @@ -1,64 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('extremum methods', function() { - lodashStable.each(['max', 'maxBy', 'min', 'minBy'], function(methodName) { - var func = _[methodName], - isMax = /^max/.test(methodName); - - it('`_.' + methodName + '` should work with Date objects', function() { - var curr = new Date, - past = new Date(0); - - assert.strictEqual(func([curr, past]), isMax ? curr : past); - }); - - it('`_.' + methodName + '` should work with extremely large arrays', function() { - var array = lodashStable.range(0, 5e5); - assert.strictEqual(func(array), isMax ? 499999 : 0); - }); - - it('`_.' + methodName + '` should work when chaining on an array with only one value', function() { - var actual = _([40])[methodName](); - assert.strictEqual(actual, 40); - }); - }); - - lodashStable.each(['maxBy', 'minBy'], function(methodName) { - var array = [1, 2, 3], - func = _[methodName], - isMax = methodName == 'maxBy'; - - it('`_.' + methodName + '` should work with an `iteratee`', function() { - var actual = func(array, function(n) { - return -n; - }); - - assert.strictEqual(actual, isMax ? 1 : 3); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }], - actual = func(objects, 'a'); - - assert.deepStrictEqual(actual, objects[isMax ? 1 : 2]); - - var arrays = [[2], [3], [1]]; - actual = func(arrays, 0); - - assert.deepStrictEqual(actual, arrays[isMax ? 1 : 2]); - }); - - it('`_.' + methodName + '` should work when `iteratee` returns +/-Infinity', function() { - var value = isMax ? -Infinity : Infinity, - object = { 'a': value }; - - var actual = func([object, { 'a': value }], function(object) { - return object.a; - }); - - assert.strictEqual(actual, object); - }); - }); -}); diff --git a/libs/nanofn/test/fill.js b/libs/nanofn/test/fill.js deleted file mode 100644 index 518e368a7..000000000 --- a/libs/nanofn/test/fill.js +++ /dev/null @@ -1,128 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey } from './utils.js'; -import fill from '../fill.js'; - -describe('fill', function() { - it('should use a default `start` of `0` and a default `end` of `length`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a'), ['a', 'a', 'a']); - }); - - it('should use `undefined` for `value` if not given', function() { - var array = [1, 2, 3], - actual = fill(array); - - assert.deepStrictEqual(actual, Array(3)); - assert.ok(lodashStable.every(actual, function(value, index) { - return index in actual; - })); - }); - - it('should work with a positive `start`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', 1), [1, 'a', 'a']); - }); - - it('should work with a `start` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(start) { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', start), [1, 2, 3]); - }); - }); - - it('should treat falsey `start` values as `0`', function() { - var expected = lodashStable.map(falsey, lodashStable.constant(['a', 'a', 'a'])); - - var actual = lodashStable.map(falsey, function(start) { - var array = [1, 2, 3]; - return fill(array, 'a', start); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with a negative `start`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', -1), [1, 2, 'a']); - }); - - it('should work with a negative `start` <= negative `length`', function() { - lodashStable.each([-3, -4, -Infinity], function(start) { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', start), ['a', 'a', 'a']); - }); - }); - - it('should work with `start` >= `end`', function() { - lodashStable.each([2, 3], function(start) { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', start, 2), [1, 2, 3]); - }); - }); - - it('should work with a positive `end`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', 0, 1), ['a', 2, 3]); - }); - - it('should work with a `end` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(end) { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', 0, end), ['a', 'a', 'a']); - }); - }); - - it('should treat falsey `end` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? ['a', 'a', 'a'] : [1, 2, 3]; - }); - - var actual = lodashStable.map(falsey, function(end) { - var array = [1, 2, 3]; - return fill(array, 'a', 0, end); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with a negative `end`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', 0, -1), ['a', 'a', 3]); - }); - - it('should work with a negative `end` <= negative `length`', function() { - lodashStable.each([-3, -4, -Infinity], function(end) { - var array = [1, 2, 3]; - assert.deepStrictEqual(fill(array, 'a', 0, end), [1, 2, 3]); - }); - }); - - it('should coerce `start` and `end` to integers', function() { - var positions = [[0.1, 1.6], ['0', 1], [0, '1'], ['1'], [NaN, 1], [1, NaN]]; - - var actual = lodashStable.map(positions, function(pos) { - var array = [1, 2, 3]; - return fill.apply(_, [array, 'a'].concat(pos)); - }); - - assert.deepStrictEqual(actual, [['a', 2, 3], ['a', 2, 3], ['a', 2, 3], [1, 'a', 'a'], ['a', 2, 3], [1, 2, 3]]); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2], [3, 4]], - actual = lodashStable.map(array, fill); - - assert.deepStrictEqual(actual, [[0, 0], [1, 1]]); - }); - - it('should return a wrapped value when chaining', function() { - var array = [1, 2, 3], - wrapped = _(array).fill('a'), - actual = wrapped.value(); - - assert.ok(wrapped instanceof _); - assert.strictEqual(actual, array); - assert.deepEqual(actual, ['a', 'a', 'a']); - }); -}); diff --git a/libs/nanofn/test/filter-methods.js b/libs/nanofn/test/filter-methods.js deleted file mode 100644 index 2e98afc09..000000000 --- a/libs/nanofn/test/filter-methods.js +++ /dev/null @@ -1,100 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, LARGE_ARRAY_SIZE, isEven, square } from './utils.js'; - -describe('filter methods', function() { - lodashStable.each(['filter', 'reject'], function(methodName) { - var array = [1, 2, 3, 4], - func = _[methodName], - isFilter = methodName == 'filter', - objects = [{ 'a': 0 }, { 'a': 1 }]; - - it('`_.' + methodName + '` should not modify the resulting value from within `predicate`', function() { - var actual = func([0], function(value, index, array) { - array[index] = 1; - return isFilter; - }); - - assert.deepStrictEqual(actual, [0]); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - assert.deepStrictEqual(func(objects, 'a'), [objects[isFilter ? 1 : 0]]); - }); - - it('`_.' + methodName + '` should work with `_.matches` shorthands', function() { - assert.deepStrictEqual(func(objects, objects[1]), [objects[isFilter ? 1 : 0]]); - }); - - it('`_.' + methodName + '` should not modify wrapped values', function() { - var wrapped = _(array); - - var actual = wrapped[methodName](function(n) { - return n < 3; - }); - - assert.deepEqual(actual.value(), isFilter ? [1, 2] : [3, 4]); - - actual = wrapped[methodName](function(n) { - return n > 2; - }); - - assert.deepEqual(actual.value(), isFilter ? [3, 4] : [1, 2]); - }); - - it('`_.' + methodName + '` should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE + 1), - predicate = function(value) { return isFilter ? isEven(value) : !isEven(value); }; - - var object = lodashStable.zipObject(lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return ['key' + index, index]; - })); - - var actual = _(array).slice(1).map(square)[methodName](predicate).value(); - assert.deepEqual(actual, _[methodName](lodashStable.map(array.slice(1), square), predicate)); - - actual = _(object).mapValues(square)[methodName](predicate).value(); - assert.deepEqual(actual, _[methodName](lodashStable.mapValues(object, square), predicate)); - }); - - it('`_.' + methodName + '` should provide correct `predicate` arguments in a lazy sequence', function() { - var args, - array = lodashStable.range(LARGE_ARRAY_SIZE + 1), - expected = [1, 0, lodashStable.map(array.slice(1), square)]; - - _(array).slice(1)[methodName](function(value, index, array) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, [1, 0, array.slice(1)]); - - args = undefined; - _(array).slice(1).map(square)[methodName](function(value, index, array) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - - args = undefined; - _(array).slice(1).map(square)[methodName](function(value, index) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - - args = undefined; - _(array).slice(1).map(square)[methodName](function(value) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, [1]); - - args = undefined; - _(array).slice(1).map(square)[methodName](function() { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - }); - }); -}); diff --git a/libs/nanofn/test/filter.test.js b/libs/nanofn/test/filter.test.js deleted file mode 100644 index cff7d2555..000000000 --- a/libs/nanofn/test/filter.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import assert from 'assert'; -import { isEven } from './utils.js'; -import filter from '../filter.js'; - -describe('filter', function() { - var array = [1, 2, 3]; - - it('should return elements `predicate` returns truthy for', function() { - assert.deepStrictEqual(filter(array, isEven), [2]); - }); -}); diff --git a/libs/nanofn/test/find-and-findLast.js b/libs/nanofn/test/find-and-findLast.js deleted file mode 100644 index e55725e97..000000000 --- a/libs/nanofn/test/find-and-findLast.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, square, isEven } from './utils.js'; - -describe('find and findLast', function() { - lodashStable.each(['find', 'findLast'], function(methodName) { - var isFind = methodName == 'find'; - - it('`_.' + methodName + '` should support shortcut fusion', function() { - var findCount = 0, - mapCount = 0, - array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - iteratee = function(value) { mapCount++; return square(value); }, - predicate = function(value) { findCount++; return isEven(value); }, - actual = _(array).map(iteratee)[methodName](predicate); - - assert.strictEqual(findCount, isFind ? 2 : 1); - assert.strictEqual(mapCount, isFind ? 2 : 1); - assert.strictEqual(actual, isFind ? 4 : square(LARGE_ARRAY_SIZE)); - }); - }); -}); diff --git a/libs/nanofn/test/find-and-includes.js b/libs/nanofn/test/find-and-includes.js deleted file mode 100644 index b6978b13b..000000000 --- a/libs/nanofn/test/find-and-includes.js +++ /dev/null @@ -1,103 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, identity, args, falsey } from './utils.js'; - -describe('find and includes', function() { - lodashStable.each(['includes', 'find'], function(methodName) { - var func = _[methodName], - isIncludes = methodName == 'includes', - resolve = methodName == 'find' ? lodashStable.curry(lodashStable.eq) : identity; - - lodashStable.each({ - 'an `arguments` object': args, - 'an array': [1, 2, 3] - }, - function(collection, key) { - var values = lodashStable.toArray(collection); - - it('`_.' + methodName + '` should work with ' + key + ' and a positive `fromIndex`', function() { - var expected = [ - isIncludes || values[2], - isIncludes ? false : undefined - ]; - - var actual = [ - func(collection, resolve(values[2]), 2), - func(collection, resolve(values[1]), 2) - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with ' + key + ' and a `fromIndex` >= `length`', function() { - var indexes = [4, 6, Math.pow(2, 32), Infinity]; - - var expected = lodashStable.map(indexes, function() { - var result = isIncludes ? false : undefined; - return [result, result, result]; - }); - - var actual = lodashStable.map(indexes, function(fromIndex) { - return [ - func(collection, resolve(1), fromIndex), - func(collection, resolve(undefined), fromIndex), - func(collection, resolve(''), fromIndex) - ]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with ' + key + ' and treat falsey `fromIndex` values as `0`', function() { - var expected = lodashStable.map(falsey, lodashStable.constant(isIncludes || values[0])); - - var actual = lodashStable.map(falsey, function(fromIndex) { - return func(collection, resolve(values[0]), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with ' + key + ' and coerce `fromIndex` to an integer', function() { - var expected = [ - isIncludes || values[0], - isIncludes || values[0], - isIncludes ? false : undefined - ]; - - var actual = [ - func(collection, resolve(values[0]), 0.1), - func(collection, resolve(values[0]), NaN), - func(collection, resolve(values[0]), '1') - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with ' + key + ' and a negative `fromIndex`', function() { - var expected = [ - isIncludes || values[2], - isIncludes ? false : undefined - ]; - - var actual = [ - func(collection, resolve(values[2]), -1), - func(collection, resolve(values[1]), -1) - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with ' + key + ' and a negative `fromIndex` <= `-length`', function() { - var indexes = [-4, -6, -Infinity], - expected = lodashStable.map(indexes, lodashStable.constant(isIncludes || values[0])); - - var actual = lodashStable.map(indexes, function(fromIndex) { - return func(collection, resolve(values[0]), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - }); -}); diff --git a/libs/nanofn/test/find-methods.js b/libs/nanofn/test/find-methods.js deleted file mode 100644 index 8a0c24767..000000000 --- a/libs/nanofn/test/find-methods.js +++ /dev/null @@ -1,139 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, empties, LARGE_ARRAY_SIZE, slice } from './utils.js'; -import each from '../each.js'; - -describe('find methods', function() { - lodashStable.each(['find', 'findIndex', 'findKey', 'findLast', 'findLastIndex', 'findLastKey'], function(methodName) { - var array = [1, 2, 3, 4], - func = _[methodName]; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 1 }, - { 'a': 2, 'b': 2 } - ]; - - var expected = ({ - 'find': [objects[1], undefined, objects[2]], - 'findIndex': [1, -1, 2], - 'findKey': ['1', undefined, '2'], - 'findLast': [objects[2], undefined, objects[2]], - 'findLastIndex': [2, -1, 2], - 'findLastKey': ['2', undefined, '2'] - })[methodName]; - - it('`_.' + methodName + '` should return the found value', function() { - assert.strictEqual(func(objects, function(object) { return object.a; }), expected[0]); - }); - - it('`_.' + methodName + '` should return `' + expected[1] + '` if value is not found', function() { - assert.strictEqual(func(objects, function(object) { return object.a === 3; }), expected[1]); - }); - - it('`_.' + methodName + '` should work with `_.matches` shorthands', function() { - assert.strictEqual(func(objects, { 'b': 2 }), expected[2]); - }); - - it('`_.' + methodName + '` should work with `_.matchesProperty` shorthands', function() { - assert.strictEqual(func(objects, ['b', 2]), expected[2]); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - assert.strictEqual(func(objects, 'b'), expected[0]); - }); - - it('`_.' + methodName + '` should return `' + expected[1] + '` for empty collections', function() { - var emptyValues = lodashStable.endsWith(methodName, 'Index') ? lodashStable.reject(empties, lodashStable.isPlainObject) : empties, - expecting = lodashStable.map(emptyValues, lodashStable.constant(expected[1])); - - var actual = lodashStable.map(emptyValues, function(value) { - try { - return func(value, { 'a': 3 }); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expecting); - }); - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var expected = ({ - 'find': 1, - 'findIndex': 0, - 'findKey': '0', - 'findLast': 4, - 'findLastIndex': 3, - 'findLastKey': '3' - })[methodName]; - - assert.strictEqual(_(array)[methodName](), expected); - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() { - assert.ok(_(array).chain()[methodName]() instanceof _); - }); - - it('`_.' + methodName + '` should not execute immediately when explicitly chaining', function() { - var wrapped = _(array).chain()[methodName](); - assert.strictEqual(wrapped.__wrapped__, array); - }); - - it('`_.' + methodName + '` should work in a lazy sequence', function() { - var largeArray = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - smallArray = array; - - lodashStable.times(2, function(index) { - var array = index ? largeArray : smallArray, - wrapped = _(array).filter(isEven); - - assert.strictEqual(wrapped[methodName](), func(lodashStable.filter(array, isEven))); - }); - }); - }), - function() { - each(['find', 'findIndex', 'findLast', 'findLastIndex'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should provide correct `predicate` arguments for arrays', function() { - var args, - array = ['a']; - - func(array, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, ['a', 0, array]); - }); - }); - - each(['find', 'findKey', 'findLast', 'findLastKey'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should work with an object for `collection`', function() { - var actual = func({ 'a': 1, 'b': 2, 'c': 3 }, function(n) { - return n < 3; - }); - - var expected = ({ - 'find': 1, - 'findKey': 'a', - 'findLast': 2, - 'findLastKey': 'b' - })[methodName]; - - assert.strictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should provide correct `predicate` arguments for objects', function() { - var args, - object = { 'a': 1 }; - - func(object, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [1, 'a', object]); - }); - }); - } -}); diff --git a/libs/nanofn/test/findLast.test.js b/libs/nanofn/test/findLast.test.js deleted file mode 100644 index b303b55f5..000000000 --- a/libs/nanofn/test/findLast.test.js +++ /dev/null @@ -1,99 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, falsey } from './utils.js'; -import findLast from '../findLast.js'; - -describe('findLast', function() { - var resolve = lodashStable.curry(lodashStable.eq); - - lodashStable.each({ - 'an `arguments` object': args, - 'an array': [1, 2, 3] - }, - function(collection, key) { - var values = lodashStable.toArray(collection); - - it('should work with ' + key + ' and a positive `fromIndex`', function() { - var expected = [ - values[1], - undefined - ]; - - var actual = [ - findLast(collection, resolve(values[1]), 1), - findLast(collection, resolve(values[2]), 1) - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with ' + key + ' and a `fromIndex` >= `length`', function() { - var indexes = [4, 6, Math.pow(2, 32), Infinity]; - - var expected = lodashStable.map(indexes, lodashStable.constant([values[0], undefined, undefined])); - - var actual = lodashStable.map(indexes, function(fromIndex) { - return [ - findLast(collection, resolve(1), fromIndex), - findLast(collection, resolve(undefined), fromIndex), - findLast(collection, resolve(''), fromIndex) - ]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with ' + key + ' and treat falsey `fromIndex` values correctly', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? values[3] : undefined; - }); - - var actual = lodashStable.map(falsey, function(fromIndex) { - return findLast(collection, resolve(values[3]), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with ' + key + ' and coerce `fromIndex` to an integer', function() { - var expected = [ - values[0], - values[0], - undefined - ]; - - var actual = [ - findLast(collection, resolve(values[0]), 0.1), - findLast(collection, resolve(values[0]), NaN), - findLast(collection, resolve(values[2]), '1') - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with ' + key + ' and a negative `fromIndex`', function() { - var expected = [ - values[1], - undefined - ]; - - var actual = [ - findLast(collection, resolve(values[1]), -2), - findLast(collection, resolve(values[2]), -2) - ]; - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with ' + key + ' and a negative `fromIndex` <= `-length`', function() { - var indexes = [-4, -6, -Infinity], - expected = lodashStable.map(indexes, lodashStable.constant(values[0])); - - var actual = lodashStable.map(indexes, function(fromIndex) { - return findLast(collection, resolve(values[0]), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/findLastIndex-and-lastIndexOf.test.js b/libs/nanofn/test/findLastIndex-and-lastIndexOf.test.js deleted file mode 100644 index e28803e39..000000000 --- a/libs/nanofn/test/findLastIndex-and-lastIndexOf.test.js +++ /dev/null @@ -1,72 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, stubZero, falsey } from './utils.js'; -import findLastIndex from '../findLastIndex.js'; -import lastIndexOf from '../lastIndexOf.js'; - -const methods = { - findLastIndex, - lastIndexOf -}; - -describe('findLastIndex and lastIndexOf', function() { - lodashStable.each(['findLastIndex', 'lastIndexOf'], function(methodName) { - var array = [1, 2, 3, 1, 2, 3], - func = methods[methodName], - resolve = methodName == 'findLastIndex' ? lodashStable.curry(lodashStable.eq) : identity; - - it('`_.' + methodName + '` should return the index of the last matched value', function() { - assert.strictEqual(func(array, resolve(3)), 5); - }); - - it('`_.' + methodName + '` should work with a positive `fromIndex`', function() { - assert.strictEqual(func(array, resolve(1), 2), 0); - }); - - it('`_.' + methodName + '` should work with a `fromIndex` >= `length`', function() { - var values = [6, 8, Math.pow(2, 32), Infinity], - expected = lodashStable.map(values, lodashStable.constant([-1, 3, -1])); - - var actual = lodashStable.map(values, function(fromIndex) { - return [ - func(array, resolve(undefined), fromIndex), - func(array, resolve(1), fromIndex), - func(array, resolve(''), fromIndex) - ]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with a negative `fromIndex`', function() { - assert.strictEqual(func(array, resolve(2), -3), 1); - }); - - it('`_.' + methodName + '` should work with a negative `fromIndex` <= `-length`', function() { - var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, stubZero); - - var actual = lodashStable.map(values, function(fromIndex) { - return func(array, resolve(1), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should treat falsey `fromIndex` values correctly', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? 5 : -1; - }); - - var actual = lodashStable.map(falsey, function(fromIndex) { - return func(array, resolve(3), fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should coerce `fromIndex` to an integer', function() { - assert.strictEqual(func(array, resolve(2), 4.2), 4); - }); - }); -}); diff --git a/libs/nanofn/test/flatMap-methods.js b/libs/nanofn/test/flatMap-methods.js deleted file mode 100644 index 4508e0a2b..000000000 --- a/libs/nanofn/test/flatMap-methods.js +++ /dev/null @@ -1,72 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, identity, falsey, stubArray } from './utils.js'; - -describe('flatMap methods', function() { - lodashStable.each(['flatMap', 'flatMapDeep', 'flatMapDepth'], function(methodName) { - var func = _[methodName], - array = [1, 2, 3, 4]; - - function duplicate(n) { - return [n, n]; - } - - it('`_.' + methodName + '` should map values in `array` to a new flattened array', function() { - var actual = func(array, duplicate), - expected = lodashStable.flatten(lodashStable.map(array, duplicate)); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - var objects = [{ 'a': [1, 2] }, { 'a': [3, 4] }]; - assert.deepStrictEqual(func(objects, 'a'), array); - }); - - it('`_.' + methodName + '` should iterate over own string keyed properties of objects', function() { - function Foo() { - this.a = [1, 2]; - } - Foo.prototype.b = [3, 4]; - - var actual = func(new Foo, identity); - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('`_.' + methodName + '` should use `_.identity` when `iteratee` is nullish', function() { - var array = [[1, 2], [3, 4]], - object = { 'a': [1, 2], 'b': [3, 4] }, - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([1, 2, 3, 4])); - - lodashStable.each([array, object], function(collection) { - var actual = lodashStable.map(values, function(value, index) { - return index ? func(collection, value) : func(collection); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should accept a falsey `collection`', function() { - var expected = lodashStable.map(falsey, stubArray); - - var actual = lodashStable.map(falsey, function(collection, index) { - try { - return index ? func(collection) : func(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should treat number values for `collection` as empty', function() { - assert.deepStrictEqual(func(1), []); - }); - - it('`_.' + methodName + '` should work with objects with non-number length properties', function() { - var object = { 'length': [1, 2] }; - assert.deepStrictEqual(func(object, identity), [1, 2]); - }); - }); -}); diff --git a/libs/nanofn/test/flatMapDepth.js b/libs/nanofn/test/flatMapDepth.js deleted file mode 100644 index 365ce8fcb..000000000 --- a/libs/nanofn/test/flatMapDepth.js +++ /dev/null @@ -1,33 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity } from './utils.js'; -import flatMapDepth from '../flatMapDepth.js'; - -describe('flatMapDepth', function() { - var array = [1, [2, [3, [4]], 5]]; - - it('should use a default `depth` of `1`', function() { - assert.deepStrictEqual(flatMapDepth(array, identity), [1, 2, [3, [4]], 5]); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([1, 2, [3, [4]], 5])); - - var actual = lodashStable.map(values, function(value, index) { - return index ? flatMapDepth(array, value) : flatMapDepth(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should treat a `depth` of < `1` as a shallow clone', function() { - lodashStable.each([-1, 0], function(depth) { - assert.deepStrictEqual(flatMapDepth(array, identity, depth), [1, [2, [3, [4]], 5]]); - }); - }); - - it('should coerce `depth` to an integer', function() { - assert.deepStrictEqual(flatMapDepth(array, identity, 2.2), [1, 2, 3, [4], 5]); - }); -}); diff --git a/libs/nanofn/test/flatten-methods.js b/libs/nanofn/test/flatten-methods.js deleted file mode 100644 index 63b01e8c4..000000000 --- a/libs/nanofn/test/flatten-methods.js +++ /dev/null @@ -1,106 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, _ } from './utils.js'; -import flatten from '../flatten.js'; -import flattenDeep from '../flattenDeep.js'; -import flattenDepth from '../flattenDepth.js'; - -describe('flatten methods', function() { - var array = [1, [2, [3, [4]], 5]], - methodNames = ['flatten', 'flattenDeep', 'flattenDepth']; - - it('should flatten `arguments` objects', function() { - var array = [args, [args]]; - - assert.deepStrictEqual(flatten(array), [1, 2, 3, args]); - assert.deepStrictEqual(flattenDeep(array), [1, 2, 3, 1, 2, 3]); - assert.deepStrictEqual(flattenDepth(array, 2), [1, 2, 3, 1, 2, 3]); - }); - - it('should treat sparse arrays as dense', function() { - var array = [[1, 2, 3], Array(3)], - expected = [1, 2, 3]; - - expected.push(undefined, undefined, undefined); - - lodashStable.each(methodNames, function(methodName) { - var actual = _[methodName](array); - assert.deepStrictEqual(actual, expected); - assert.ok('4' in actual); - }); - }); - - it('should flatten objects with a truthy `Symbol.isConcatSpreadable` value', function() { - if (Symbol && Symbol.isConcatSpreadable) { - var object = { '0': 'a', 'length': 1 }, - array = [object], - expected = lodashStable.map(methodNames, lodashStable.constant(['a'])); - - object[Symbol.isConcatSpreadable] = true; - - var actual = lodashStable.map(methodNames, function(methodName) { - return _[methodName](array); - }); - - assert.deepStrictEqual(actual, expected); - } - }); - - it('should work with extremely large arrays', function() { - lodashStable.times(3, function(index) { - var expected = Array(5e5); - try { - var func = flatten; - if (index == 1) { - func = flattenDeep; - } else if (index == 2) { - func = flattenDepth; - } - assert.deepStrictEqual(func([expected]), expected); - } catch (e) { - assert.ok(false, e.message); - } - }); - }); - - it('should work with empty arrays', function() { - var array = [[], [[]], [[], [[[]]]]]; - - assert.deepStrictEqual(flatten(array), [[], [], [[[]]]]); - assert.deepStrictEqual(flattenDeep(array), []); - assert.deepStrictEqual(flattenDepth(array, 2), [[[]]]); - }); - - it('should support flattening of nested arrays', function() { - assert.deepStrictEqual(flatten(array), [1, 2, [3, [4]], 5]); - assert.deepStrictEqual(flattenDeep(array), [1, 2, 3, 4, 5]); - assert.deepStrictEqual(flattenDepth(array, 2), [1, 2, 3, [4], 5]); - }); - - it('should return an empty array for non array-like objects', function() { - var expected = [], - nonArray = { '0': 'a' }; - - assert.deepStrictEqual(flatten(nonArray), expected); - assert.deepStrictEqual(flattenDeep(nonArray), expected); - assert.deepStrictEqual(flattenDepth(nonArray, 2), expected); - }); - - it('should return a wrapped value when chaining', function() { - var wrapped = _(array), - actual = wrapped.flatten(); - - assert.ok(actual instanceof _); - assert.deepEqual(actual.value(), [1, 2, [3, [4]], 5]); - - actual = wrapped.flattenDeep(); - - assert.ok(actual instanceof _); - assert.deepEqual(actual.value(), [1, 2, 3, 4, 5]); - - actual = wrapped.flattenDepth(2); - - assert.ok(actual instanceof _); - assert.deepEqual(actual.value(), [1, 2, 3, [4], 5]); - }); -}); diff --git a/libs/nanofn/test/flattenDepth.js b/libs/nanofn/test/flattenDepth.js deleted file mode 100644 index 6b6374e8d..000000000 --- a/libs/nanofn/test/flattenDepth.js +++ /dev/null @@ -1,21 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import flattenDepth from '../flattenDepth.js'; - -describe('flattenDepth', function() { - var array = [1, [2, [3, [4]], 5]]; - - it('should use a default `depth` of `1`', function() { - assert.deepStrictEqual(flattenDepth(array), [1, 2, [3, [4]], 5]); - }); - - it('should treat a `depth` of < `1` as a shallow clone', function() { - lodashStable.each([-1, 0], function(depth) { - assert.deepStrictEqual(flattenDepth(array, depth), [1, [2, [3, [4]], 5]]); - }); - }); - - it('should coerce `depth` to an integer', function() { - assert.deepStrictEqual(flattenDepth(array, 2.2), [1, 2, 3, [4], 5]); - }); -}); diff --git a/libs/nanofn/test/flip.test.js b/libs/nanofn/test/flip.test.js deleted file mode 100644 index c8423ece4..000000000 --- a/libs/nanofn/test/flip.test.js +++ /dev/null @@ -1,14 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import flip from '../flip.js'; - -describe('flip', function() { - function fn() { - return slice.call(arguments); - } - - it('should flip arguments provided to `func`', function() { - var flipped = flip(fn); - assert.deepStrictEqual(flipped('a', 'b', 'c', 'd'), ['d', 'c', 'b', 'a']); - }); -}); diff --git a/libs/nanofn/test/flow-methods.test.js b/libs/nanofn/test/flow-methods.test.js deleted file mode 100644 index c1706ab1e..000000000 --- a/libs/nanofn/test/flow-methods.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { add, square, noop, identity } from './utils.js'; -import head from '../head.js'; -import map from '../map.js'; -import uniq from '../uniq.js'; -import flow from '../flow.js'; -import flowRight from '../flowRight.js'; - -const methods = { - flow, - flowRight -} - -describe('flow methods', function() { - lodashStable.each(['flow', 'flowRight'], function(methodName) { - var func = methods[methodName], - isFlow = methodName == 'flow'; - - it('`_.' + methodName + '` should supply each function with the return value of the previous', function() { - var fixed = function(n) { return n.toFixed(1); }, - combined = isFlow ? func(add, square, fixed) : func(fixed, square, add); - - assert.strictEqual(combined(1, 2), '9.0'); - }); - - it('`_.' + methodName + '` should return a new function', function() { - assert.notStrictEqual(func(noop), noop); - }); - - it('`_.' + methodName + '` should work with a curried function and `_.head`', function() { - var curried = lodashStable.curry(identity); - - var combined = isFlow - ? func(head, curried) - : func(curried, head); - - assert.strictEqual(combined([1]), 1); - }); - - it('`_.' + methodName + '` should work with curried functions with placeholders', function() { - var curried = lodashStable.curry(lodashStable.ary(map, 2), 2), - getProp = curried(curried.placeholder, (value) => value.a), - objects = [{ 'a': 1 }, { 'a': 2 }, { 'a': 1 }]; - - var combined = isFlow - ? func(getProp, uniq) - : func(uniq, getProp); - - assert.deepStrictEqual(combined(objects), [1, 2]); - }); - }); -}); diff --git a/libs/nanofn/test/forEach.test.js b/libs/nanofn/test/forEach.test.js deleted file mode 100644 index 8770ffdf9..000000000 --- a/libs/nanofn/test/forEach.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import each from '../each.js'; -import forEach from '../forEach.js'; - -describe('forEach', function() { - it('should be aliased', function() { - assert.strictEqual(each, forEach); - }); -}); diff --git a/libs/nanofn/test/forEachRight.test.js b/libs/nanofn/test/forEachRight.test.js deleted file mode 100644 index 29494d9a4..000000000 --- a/libs/nanofn/test/forEachRight.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import eachRight from '../eachRight.js'; -import forEachRight from '../forEachRight.js'; - -describe('forEachRight', function() { - it('should be aliased', function() { - assert.strictEqual(eachRight, forEachRight); - }); -}); diff --git a/libs/nanofn/test/forIn-methods.js b/libs/nanofn/test/forIn-methods.js deleted file mode 100644 index f806201db..000000000 --- a/libs/nanofn/test/forIn-methods.js +++ /dev/null @@ -1,20 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('forIn methods', function() { - lodashStable.each(['forIn', 'forInRight'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` iterates over inherited string keyed properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var keys = []; - func(new Foo, function(value, key) { keys.push(key); }); - assert.deepStrictEqual(keys.sort(), ['a', 'b']); - }); - }); -}); diff --git a/libs/nanofn/test/forOwn-methods.js b/libs/nanofn/test/forOwn-methods.js deleted file mode 100644 index a8a4fbbef..000000000 --- a/libs/nanofn/test/forOwn-methods.js +++ /dev/null @@ -1,17 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('forOwn methods', function() { - lodashStable.each(['forOwn', 'forOwnRight'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should iterate over `length` properties', function() { - var object = { '0': 'zero', '1': 'one', 'length': 2 }, - props = []; - - func(object, function(value, prop) { props.push(prop); }); - assert.deepStrictEqual(props.sort(), ['0', '1', 'length']); - }); - }); -}); diff --git a/libs/nanofn/test/fromPairs.js b/libs/nanofn/test/fromPairs.js deleted file mode 100644 index 5e94ad131..000000000 --- a/libs/nanofn/test/fromPairs.js +++ /dev/null @@ -1,47 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubObject, LARGE_ARRAY_SIZE } from './utils.js'; -import fromPairs from '../fromPairs.js'; -import toPairs from '../toPairs.js'; - -describe('fromPairs', function() { - it('should accept a two dimensional array', function() { - var array = [['a', 1], ['b', 2]], - object = { 'a': 1, 'b': 2 }, - actual = fromPairs(array); - - assert.deepStrictEqual(actual, object); - }); - - it('should accept a falsey `array`', function() { - var expected = lodashStable.map(falsey, stubObject); - - var actual = lodashStable.map(falsey, function(array, index) { - try { - return index ? fromPairs(array) : fromPairs(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not support deep paths', function() { - var actual = fromPairs([['a.b', 1]]); - assert.deepStrictEqual(actual, { 'a.b': 1 }); - }); - - it('should support consuming the return value of `_.toPairs`', function() { - var object = { 'a.b': 1 }; - assert.deepStrictEqual(fromPairs(toPairs(object)), object); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return ['key' + index, index]; - }); - - var actual = _(array).fromPairs().map(square).filter(isEven).take().value(); - - assert.deepEqual(actual, _.take(_.filter(_.map(fromPairs(array), square), isEven))); - }); -}); diff --git a/libs/nanofn/test/functions.test.js b/libs/nanofn/test/functions.test.js deleted file mode 100644 index 1d1daeeb1..000000000 --- a/libs/nanofn/test/functions.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import { identity, noop } from './utils.js'; -import functions from '../functions.js'; - -describe('functions', function() { - it('should return the function names of an object', function() { - var object = { 'a': 'a', 'b': identity, 'c': /x/, 'd': noop }, - actual = functions(object).sort(); - - assert.deepStrictEqual(actual, ['b', 'd']); - }); - - it('should not include inherited functions', function() { - function Foo() { - this.a = identity; - this.b = 'b'; - } - Foo.prototype.c = noop; - - assert.deepStrictEqual(functions(new Foo), ['a']); - }); -}); diff --git a/libs/nanofn/test/get-and-result.js b/libs/nanofn/test/get-and-result.js deleted file mode 100644 index 194f40f68..000000000 --- a/libs/nanofn/test/get-and-result.js +++ /dev/null @@ -1,148 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, symbol, noop, numberProto, empties } from './utils.js'; - -describe('get and result', function() { - lodashStable.each(['get', 'result'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should get string keyed property values', function() { - var object = { 'a': 1 }; - - lodashStable.each(['a', ['a']], function(path) { - assert.strictEqual(func(object, path), 1); - }); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - return func(object, key); - }); - - assert.deepStrictEqual(actual, ['a', 'a', 'b', 'b']); - }); - - it('`_.' + methodName + '` should get symbol keyed property values', function() { - if (Symbol) { - var object = {}; - object[symbol] = 1; - - assert.strictEqual(func(object, symbol), 1); - } - }); - - it('`_.' + methodName + '` should get deep property values', function() { - var object = { 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(func(object, path), 2); - }); - }); - - it('`_.' + methodName + '` should get a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - assert.strictEqual(func(object, path), 1); - }); - }); - - it('`_.' + methodName + '` should not coerce array paths to strings', function() { - var object = { 'a,b,c': 3, 'a': { 'b': { 'c': 4 } } }; - assert.strictEqual(func(object, ['a', 'b', 'c']), 4); - }); - - it('`_.' + methodName + '` should not ignore empty brackets', function() { - var object = { 'a': { '': 1 } }; - assert.strictEqual(func(object, 'a[]'), 1); - }); - - it('`_.' + methodName + '` should handle empty paths', function() { - lodashStable.each([['', ''], [[], ['']]], function(pair) { - assert.strictEqual(func({}, pair[0]), undefined); - assert.strictEqual(func({ '': 3 }, pair[1]), 3); - }); - }); - - it('`_.' + methodName + '` should handle complex paths', function() { - var object = { 'a': { '-1.23': { '["b"]': { 'c': { "['d']": { '\ne\n': { 'f': { 'g': 8 } } } } } } } }; - - var paths = [ - 'a[-1.23]["[\\"b\\"]"].c[\'[\\\'d\\\']\'][\ne\n][f].g', - ['a', '-1.23', '["b"]', 'c', "['d']", '\ne\n', 'f', 'g'] - ]; - - lodashStable.each(paths, function(path) { - assert.strictEqual(func(object, path), 8); - }); - }); - - it('`_.' + methodName + '` should return `undefined` when `object` is nullish', function() { - lodashStable.each(['constructor', ['constructor']], function(path) { - assert.strictEqual(func(null, path), undefined); - assert.strictEqual(func(undefined, path), undefined); - }); - }); - - it('`_.' + methodName + '` should return `undefined` for deep paths when `object` is nullish', function() { - var values = [null, undefined], - expected = lodashStable.map(values, noop), - paths = ['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']]; - - lodashStable.each(paths, function(path) { - var actual = lodashStable.map(values, function(value) { - return func(value, path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should return `undefined` if parts of `path` are missing', function() { - var object = { 'a': [, null] }; - - lodashStable.each(['a[1].b.c', ['a', '1', 'b', 'c']], function(path) { - assert.strictEqual(func(object, path), undefined); - }); - }); - - it('`_.' + methodName + '` should be able to return `null` values', function() { - var object = { 'a': { 'b': null } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(func(object, path), null); - }); - }); - - it('`_.' + methodName + '` should follow `path` over non-plain objects', function() { - var paths = ['a.b', ['a', 'b']]; - - lodashStable.each(paths, function(path) { - numberProto.a = { 'b': 2 }; - assert.strictEqual(func(0, path), 2); - delete numberProto.a; - }); - }); - - it('`_.' + methodName + '` should return the default value for `undefined` values', function() { - var object = { 'a': {} }, - values = empties.concat(true, new Date, 1, /x/, 'a'), - expected = lodashStable.map(values, function(value) { return [value, value]; }); - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var actual = lodashStable.map(values, function(value) { - return [func(object, path, value), func(null, path, value)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should return the default value when `path` is empty', function() { - assert.strictEqual(func({}, [], 'a'), 'a'); - }); - }); -}); diff --git a/libs/nanofn/test/groupBy.js b/libs/nanofn/test/groupBy.js deleted file mode 100644 index e20b12316..000000000 --- a/libs/nanofn/test/groupBy.js +++ /dev/null @@ -1,68 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE } from './utils.js'; -import groupBy from '../groupBy.js'; - -describe('groupBy', function() { - var array = [6.1, 4.2, 6.3]; - - it('should transform keys by `iteratee`', function() { - var actual = groupBy(array, Math.floor); - assert.deepStrictEqual(actual, { '4': [4.2], '6': [6.1, 6.3] }); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var array = [6, 4, 6], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant({ '4': [4], '6': [6, 6] })); - - var actual = lodashStable.map(values, function(value, index) { - return index ? groupBy(array, value) : groupBy(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var actual = groupBy(['one', 'two', 'three'], 'length'); - assert.deepStrictEqual(actual, { '3': ['one', 'two'], '5': ['three'] }); - }); - - it('should only add values to own, not inherited, properties', function() { - var actual = groupBy(array, function(n) { - return Math.floor(n) > 4 ? 'hasOwnProperty' : 'constructor'; - }); - - assert.deepStrictEqual(actual.constructor, [4.2]); - assert.deepStrictEqual(actual.hasOwnProperty, [6.1, 6.3]); - }); - - it('should work with a number for `iteratee`', function() { - var array = [ - [1, 'a'], - [2, 'a'], - [2, 'b'] - ]; - - assert.deepStrictEqual(groupBy(array, 0), { '1': [[1, 'a']], '2': [[2, 'a'], [2, 'b']] }); - assert.deepStrictEqual(groupBy(array, 1), { 'a': [[1, 'a'], [2, 'a']], 'b': [[2, 'b']] }); - }); - - it('should work with an object for `collection`', function() { - var actual = groupBy({ 'a': 6.1, 'b': 4.2, 'c': 6.3 }, Math.floor); - assert.deepStrictEqual(actual, { '4': [4.2], '6': [6.1, 6.3] }); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE).concat( - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 2), LARGE_ARRAY_SIZE), - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 1.5), LARGE_ARRAY_SIZE) - ); - - var iteratee = function(value) { value.push(value[0]); return value; }, - predicate = function(value) { return isEven(value[0]); }, - actual = _(array).groupBy().map(iteratee).filter(predicate).take().value(); - - assert.deepEqual(actual, _.take(_.filter(lodashStable.map(groupBy(array), iteratee), predicate))); - }); -}); diff --git a/libs/nanofn/test/gt.test.js b/libs/nanofn/test/gt.test.js deleted file mode 100644 index c46995770..000000000 --- a/libs/nanofn/test/gt.test.js +++ /dev/null @@ -1,16 +0,0 @@ -import assert from 'assert'; -import gt from '../gt.js'; - -describe('gt', function() { - it('should return `true` if `value` > `other`', function() { - assert.strictEqual(gt(3, 1), true); - assert.strictEqual(gt('def', 'abc'), true); - }); - - it('should return `false` if `value` is <= `other`', function() { - assert.strictEqual(gt(1, 3), false); - assert.strictEqual(gt(3, 3), false); - assert.strictEqual(gt('abc', 'def'), false); - assert.strictEqual(gt('def', 'def'), false); - }); -}); diff --git a/libs/nanofn/test/gte.test.js b/libs/nanofn/test/gte.test.js deleted file mode 100644 index d49ffaa2b..000000000 --- a/libs/nanofn/test/gte.test.js +++ /dev/null @@ -1,16 +0,0 @@ -import assert from 'assert'; -import gte from '../gte.js'; - -describe('gte', function() { - it('should return `true` if `value` >= `other`', function() { - assert.strictEqual(gte(3, 1), true); - assert.strictEqual(gte(3, 3), true); - assert.strictEqual(gte('def', 'abc'), true); - assert.strictEqual(gte('def', 'def'), true); - }); - - it('should return `false` if `value` is less than `other`', function() { - assert.strictEqual(gte(1, 3), false); - assert.strictEqual(gte('abc', 'def'), false); - }); -}); diff --git a/libs/nanofn/test/has-methods.js b/libs/nanofn/test/has-methods.js deleted file mode 100644 index ebd01b7cb..000000000 --- a/libs/nanofn/test/has-methods.js +++ /dev/null @@ -1,205 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, toArgs, stubTrue, args, symbol, defineProperty, stubFalse } from './utils.js'; - -describe('has methods', function() { - lodashStable.each(['has', 'hasIn'], function(methodName) { - var func = _[methodName], - isHas = methodName == 'has', - sparseArgs = toArgs([1]), - sparseArray = Array(1), - sparseString = Object('a'); - - delete sparseArgs[0]; - delete sparseString[0]; - - it('`_.' + methodName + '` should check for own properties', function() { - var object = { 'a': 1 }; - - lodashStable.each(['a', ['a']], function(path) { - assert.strictEqual(func(object, path), true); - }); - }); - - it('`_.' + methodName + '` should not use the `hasOwnProperty` method of `object`', function() { - var object = { 'hasOwnProperty': null, 'a': 1 }; - assert.strictEqual(func(object, 'a'), true); - }); - - it('`_.' + methodName + '` should support deep paths', function() { - var object = { 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(func(object, path), true); - }); - - lodashStable.each(['a.a', ['a', 'a']], function(path) { - assert.strictEqual(func(object, path), false); - }); - }); - - it('`_.' + methodName + '` should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var object = { 'null': 1 , 'undefined': 2, 'fn': 3, '[object Object]': 4 }, - paths = [null, undefined, fn, {}], - expected = lodashStable.map(paths, stubTrue); - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - return func(object, index ? [path] : path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should work with `arguments` objects', function() { - assert.strictEqual(func(args, 1), true); - }); - - it('`_.' + methodName + '` should work with a non-string `path`', function() { - var array = [1, 2, 3]; - - lodashStable.each([1, [1]], function(path) { - assert.strictEqual(func(array, path), true); - }); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)], - expected = lodashStable.map(props, stubTrue); - - var actual = lodashStable.map(props, function(key) { - return func(object, key); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with a symbol `path`', function() { - function Foo() {} - - if (Symbol) { - Foo.prototype[symbol] = 1; - - var symbol2 = Symbol('b'); - defineProperty(Foo.prototype, symbol2, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 2 - }); - - var object = isHas ? Foo.prototype : new Foo; - assert.strictEqual(func(object, symbol), true); - assert.strictEqual(func(object, symbol2), true); - } - }); - - it('`_.' + methodName + '` should check for a key over a path', function() { - var object = { 'a.b': 1 }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - assert.strictEqual(func(object, path), true); - }); - }); - - it('`_.' + methodName + '` should return `true` for indexes of sparse values', function() { - var values = [sparseArgs, sparseArray, sparseString], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return func(value, 0); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` for indexes of sparse values with deep paths', function() { - var values = [sparseArgs, sparseArray, sparseString], - expected = lodashStable.map(values, lodashStable.constant([true, true])); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.map(['a[0]', ['a', '0']], function(path) { - return func({ 'a': value }, path); - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for inherited properties', function() { - function Foo() {} - Foo.prototype.a = 1; - - lodashStable.each(['a', ['a']], function(path) { - assert.strictEqual(func(new Foo, path), !isHas); - }); - }); - - it('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for nested inherited properties', function() { - function Foo() {} - Foo.prototype.a = { 'b': 1 }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(func(new Foo, path), !isHas); - }); - }); - - it('`_.' + methodName + '` should return `false` when `object` is nullish', function() { - var values = [null, undefined], - expected = lodashStable.map(values, stubFalse); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var actual = lodashStable.map(values, function(value) { - return func(value, path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should return `false` for deep paths when `object` is nullish', function() { - var values = [null, undefined], - expected = lodashStable.map(values, stubFalse); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var actual = lodashStable.map(values, function(value) { - return func(value, path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should return `false` for nullish values of nested objects', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var actual = lodashStable.map(values, function(value, index) { - var object = index ? { 'a': value } : {}; - return func(object, path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should return `false` over sparse values of deep paths', function() { - var values = [sparseArgs, sparseArray, sparseString], - expected = lodashStable.map(values, lodashStable.constant([false, false])); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.map(['a[0].b', ['a', '0', 'b']], function(path) { - return func({ 'a': value }, path); - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/head.js b/libs/nanofn/test/head.js deleted file mode 100644 index c04a788d5..000000000 --- a/libs/nanofn/test/head.js +++ /dev/null @@ -1,62 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { arrayProto, LARGE_ARRAY_SIZE } from './utils.js'; -import head from '../head.js'; -import first from '../first.js'; - -describe('head', function() { - var array = [1, 2, 3, 4]; - - it('should return the first element', function() { - assert.strictEqual(head(array), 1); - }); - - it('should return `undefined` when querying empty arrays', function() { - arrayProto[0] = 1; - assert.strictEqual(head([]), undefined); - arrayProto.length = 0; - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, head); - - assert.deepStrictEqual(actual, [1, 4, 7]); - }); - - it('should be aliased', function() { - assert.strictEqual(first, head); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - var wrapped = _(array); - assert.strictEqual(wrapped.head(), 1); - assert.strictEqual(wrapped.first(), 1); - }); - - it('should return a wrapped value when explicitly chaining', function() { - var wrapped = _(array).chain(); - assert.ok(wrapped.head() instanceof _); - assert.ok(wrapped.first() instanceof _); - }); - - it('should not execute immediately when explicitly chaining', function() { - var wrapped = _(array).chain(); - assert.strictEqual(wrapped.head().__wrapped__, array); - assert.strictEqual(wrapped.first().__wrapped__, array); - }); - - it('should work in a lazy sequence', function() { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE), - smallArray = array; - - lodashStable.each(['head', 'first'], function(methodName) { - lodashStable.times(2, function(index) { - var array = index ? largeArray : smallArray, - actual = _(array).filter(isEven)[methodName](); - - assert.strictEqual(actual, _[methodName](_.filter(array, isEven))); - }); - }); - }); -}); diff --git a/libs/nanofn/test/identity.js b/libs/nanofn/test/identity.js deleted file mode 100644 index ced20b853..000000000 --- a/libs/nanofn/test/identity.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import identity from '../identity.js'; - -describe('identity', function() { - it('should return the first argument given', function() { - var object = { 'name': 'fred' }; - assert.strictEqual(identity(object), object); - }); -}); diff --git a/libs/nanofn/test/inRange.js b/libs/nanofn/test/inRange.js deleted file mode 100644 index 2efe128c4..000000000 --- a/libs/nanofn/test/inRange.js +++ /dev/null @@ -1,54 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; -import inRange from '../inRange.js'; - -describe('inRange', function() { - it('should work with an `end`', function() { - assert.strictEqual(inRange(3, 5), true); - assert.strictEqual(inRange(5, 5), false); - assert.strictEqual(inRange(6, 5), false); - }); - - it('should work with a `start` and `end`', function() { - assert.strictEqual(inRange(1, 1, 5), true); - assert.strictEqual(inRange(3, 1, 5), true); - assert.strictEqual(inRange(0, 1, 5), false); - assert.strictEqual(inRange(5, 1, 5), false); - }); - - it('should treat falsey `start` as `0`', function() { - lodashStable.each(falsey, function(value, index) { - if (index) { - assert.strictEqual(inRange(0, value), false); - assert.strictEqual(inRange(0, value, 1), true); - } else { - assert.strictEqual(inRange(0), false); - } - }); - }); - - it('should swap `start` and `end` when `start` > `end`', function() { - assert.strictEqual(inRange(2, 5, 1), true); - assert.strictEqual(inRange(-3, -2, -6), true); - }); - - it('should work with a floating point `n` value', function() { - assert.strictEqual(inRange(0.5, 5), true); - assert.strictEqual(inRange(1.2, 1, 5), true); - assert.strictEqual(inRange(5.2, 5), false); - assert.strictEqual(inRange(0.5, 1, 5), false); - }); - - it('should coerce arguments to finite numbers', function() { - var actual = [ - inRange(0, '1'), - inRange(0, '0', 1), - inRange(0, 0, '1'), - inRange(0, NaN, 1), - inRange(-1, -1, NaN) - ]; - - assert.deepStrictEqual(actual, lodashStable.map(actual, stubTrue)); - }); -}); diff --git a/libs/nanofn/test/includes.js b/libs/nanofn/test/includes.js deleted file mode 100644 index b9147a80c..000000000 --- a/libs/nanofn/test/includes.js +++ /dev/null @@ -1,95 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, stubFalse } from './utils.js'; -import includes from '../includes.js'; - -describe('includes', function() { - (function() { - lodashStable.each({ - 'an `arguments` object': arguments, - 'an array': [1, 2, 3, 4], - 'an object': { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - 'a string': '1234' - }, - function(collection, key) { - it('should work with ' + key + ' and return `true` for matched values', function() { - assert.strictEqual(includes(collection, 3), true); - }); - - it('should work with ' + key + ' and return `false` for unmatched values', function() { - assert.strictEqual(includes(collection, 5), false); - }); - - it('should work with ' + key + ' and floor `position` values', function() { - assert.strictEqual(includes(collection, 2, 1.2), true); - }); - - it('should work with ' + key + ' and return an unwrapped value implicitly when chaining', function() { - assert.strictEqual(_(collection).includes(3), true); - }); - - it('should work with ' + key + ' and return a wrapped value when explicitly chaining', function() { - assert.ok(_(collection).chain().includes(3) instanceof _); - }); - }); - - lodashStable.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - it('should work with a string ' + key + ' for `collection`', function() { - assert.strictEqual(includes(collection, 'bc'), true); - assert.strictEqual(includes(collection, 'd'), false); - }); - }); - - it('should return `false` for empty collections', function() { - var expected = lodashStable.map(empties, stubFalse); - - var actual = lodashStable.map(empties, function(value) { - try { - return includes(value); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with a string and a `fromIndex` >= `length`', function() { - var string = '1234', - length = string.length, - indexes = [4, 6, Math.pow(2, 32), Infinity]; - - var expected = lodashStable.map(indexes, function(index) { - return [false, false, index == length]; - }); - - var actual = lodashStable.map(indexes, function(fromIndex) { - return [ - includes(string, 1, fromIndex), - includes(string, undefined, fromIndex), - includes(string, '', fromIndex) - ]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should match `NaN`', function() { - assert.strictEqual(includes([1, NaN, 3], NaN), true); - }); - - it('should match `-0` as `0`', function() { - assert.strictEqual(includes([-0], 0), true); - assert.strictEqual(includes([0], -0), true); - }); - - it('should work as an iteratee for methods like `_.every`', function() { - var array = [2, 3, 1], - values = [1, 2, 3]; - - assert.ok(lodashStable.every(values, lodashStable.partial(includes, array))); - }); - })(1, 2, 3, 4); -}); diff --git a/libs/nanofn/test/indexOf-methods.js b/libs/nanofn/test/indexOf-methods.js deleted file mode 100644 index 05b506f33..000000000 --- a/libs/nanofn/test/indexOf-methods.js +++ /dev/null @@ -1,63 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, falsey } from './utils.js'; - -describe('indexOf methods', function() { - lodashStable.each(['indexOf', 'lastIndexOf', 'sortedIndexOf', 'sortedLastIndexOf'], function(methodName) { - var func = _[methodName], - isIndexOf = !/last/i.test(methodName), - isSorted = /^sorted/.test(methodName); - - it('`_.' + methodName + '` should accept a falsey `array`', function() { - var expected = lodashStable.map(falsey, lodashStable.constant(-1)); - - var actual = lodashStable.map(falsey, function(array, index) { - try { - return index ? func(array) : func(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `-1` for an unmatched value', function() { - var array = [1, 2, 3], - empty = []; - - assert.strictEqual(func(array, 4), -1); - assert.strictEqual(func(array, 4, true), -1); - assert.strictEqual(func(array, undefined, true), -1); - - assert.strictEqual(func(empty, undefined), -1); - assert.strictEqual(func(empty, undefined, true), -1); - }); - - it('`_.' + methodName + '` should not match values on empty arrays', function() { - var array = []; - array[-1] = 0; - - assert.strictEqual(func(array, undefined), -1); - assert.strictEqual(func(array, 0, true), -1); - }); - - it('`_.' + methodName + '` should match `NaN`', function() { - var array = isSorted - ? [1, 2, NaN, NaN] - : [1, NaN, 3, NaN, 5, NaN]; - - if (isSorted) { - assert.strictEqual(func(array, NaN, true), isIndexOf ? 2 : 3); - } - else { - assert.strictEqual(func(array, NaN), isIndexOf ? 1 : 5); - assert.strictEqual(func(array, NaN, 2), isIndexOf ? 3 : 1); - assert.strictEqual(func(array, NaN, -2), isIndexOf ? 5 : 3); - } - }); - - it('`_.' + methodName + '` should match `-0` as `0`', function() { - assert.strictEqual(func([-0], 0), 0); - assert.strictEqual(func([0], -0), 0); - }); - }); -}); diff --git a/libs/nanofn/test/indexOf.test.js b/libs/nanofn/test/indexOf.test.js deleted file mode 100644 index 49fc80861..000000000 --- a/libs/nanofn/test/indexOf.test.js +++ /dev/null @@ -1,60 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubZero, falsey } from './utils.js'; -import indexOf from '../indexOf.js'; - -describe('indexOf', function() { - var array = [1, 2, 3, 1, 2, 3]; - - it('`_.indexOf` should return the index of the first matched value', function() { - assert.strictEqual(indexOf(array, 3), 2); - }); - - it('`_.indexOf` should work with a positive `fromIndex`', function() { - assert.strictEqual(indexOf(array, 1, 2), 3); - }); - - it('`_.indexOf` should work with a `fromIndex` >= `length`', function() { - var values = [6, 8, Math.pow(2, 32), Infinity], - expected = lodashStable.map(values, lodashStable.constant([-1, -1, -1])); - - var actual = lodashStable.map(values, function(fromIndex) { - return [ - indexOf(array, undefined, fromIndex), - indexOf(array, 1, fromIndex), - indexOf(array, '', fromIndex) - ]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.indexOf` should work with a negative `fromIndex`', function() { - assert.strictEqual(indexOf(array, 2, -3), 4); - }); - - it('`_.indexOf` should work with a negative `fromIndex` <= `-length`', function() { - var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, stubZero); - - var actual = lodashStable.map(values, function(fromIndex) { - return indexOf(array, 1, fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.indexOf` should treat falsey `fromIndex` values as `0`', function() { - var expected = lodashStable.map(falsey, stubZero); - - var actual = lodashStable.map(falsey, function(fromIndex) { - return indexOf(array, 1, fromIndex); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.indexOf` should coerce `fromIndex` to an integer', function() { - assert.strictEqual(indexOf(array, 2, 1.2), 1); - }); -}); diff --git a/libs/nanofn/test/initial.js b/libs/nanofn/test/initial.js deleted file mode 100644 index c2891ca85..000000000 --- a/libs/nanofn/test/initial.js +++ /dev/null @@ -1,61 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubArray, LARGE_ARRAY_SIZE } from './utils.js'; -import initial from '../initial.js'; - -describe('initial', function() { - var array = [1, 2, 3]; - - it('should accept a falsey `array`', function() { - var expected = lodashStable.map(falsey, stubArray); - - var actual = lodashStable.map(falsey, function(array, index) { - try { - return index ? initial(array) : initial(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should exclude last element', function() { - assert.deepStrictEqual(initial(array), [1, 2]); - }); - - it('should return an empty when querying empty arrays', function() { - assert.deepStrictEqual(initial([]), []); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, initial); - - assert.deepStrictEqual(actual, [[1, 2], [4, 5], [7, 8]]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - values = []; - - var actual = _(array).initial().filter(function(value) { - values.push(value); - return false; - }) - .value(); - - assert.deepEqual(actual, []); - assert.deepEqual(values, initial(array)); - - values = []; - - actual = _(array).filter(function(value) { - values.push(value); - return isEven(value); - }) - .initial() - .value(); - - assert.deepEqual(actual, initial(lodashStable.filter(array, isEven))); - assert.deepEqual(values, array); - }); -}); diff --git a/libs/nanofn/test/intersection-methods.js b/libs/nanofn/test/intersection-methods.js deleted file mode 100644 index d90104da7..000000000 --- a/libs/nanofn/test/intersection-methods.js +++ /dev/null @@ -1,91 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, args, LARGE_ARRAY_SIZE, stubNaN } from './utils.js'; - -describe('intersection methods', function() { - lodashStable.each(['intersection', 'intersectionBy', 'intersectionWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should return the intersection of two arrays', function() { - var actual = func([2, 1], [2, 3]); - assert.deepStrictEqual(actual, [2]); - }); - - it('`_.' + methodName + '` should return the intersection of multiple arrays', function() { - var actual = func([2, 1, 2, 3], [3, 4], [3, 2]); - assert.deepStrictEqual(actual, [3]); - }); - - it('`_.' + methodName + '` should return an array of unique values', function() { - var actual = func([1, 1, 3, 2, 2], [5, 2, 2, 1, 4], [2, 1, 1]); - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('`_.' + methodName + '` should work with a single array', function() { - var actual = func([1, 1, 3, 2, 2]); - assert.deepStrictEqual(actual, [1, 3, 2]); - }); - - it('`_.' + methodName + '` should work with `arguments` objects', function() { - var array = [0, 1, null, 3], - expected = [1, 3]; - - assert.deepStrictEqual(func(array, args), expected); - assert.deepStrictEqual(func(args, array), expected); - }); - - it('`_.' + methodName + '` should treat `-0` as `0`', function() { - var values = [-0, 0], - expected = lodashStable.map(values, lodashStable.constant(['0'])); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.map(func(values, [value]), lodashStable.toString); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should match `NaN`', function() { - var actual = func([1, NaN, 3], [NaN, 5, NaN]); - assert.deepStrictEqual(actual, [NaN]); - }); - - it('`_.' + methodName + '` should work with large arrays of `-0` as `0`', function() { - var values = [-0, 0], - expected = lodashStable.map(values, lodashStable.constant(['0'])); - - var actual = lodashStable.map(values, function(value) { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(value)); - return lodashStable.map(func(values, largeArray), lodashStable.toString); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with large arrays of `NaN`', function() { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubNaN); - assert.deepStrictEqual(func([1, NaN, 3], largeArray), [NaN]); - }); - - it('`_.' + methodName + '` should work with large arrays of objects', function() { - var object = {}, - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(object)); - - assert.deepStrictEqual(func([object], largeArray), [object]); - assert.deepStrictEqual(func(lodashStable.range(LARGE_ARRAY_SIZE), [1]), [1]); - }); - - it('`_.' + methodName + '` should treat values that are not arrays or `arguments` objects as empty', function() { - var array = [0, 1, null, 3]; - assert.deepStrictEqual(func(array, 3, { '0': 1 }, null), []); - assert.deepStrictEqual(func(null, array, null, [2, 3]), []); - assert.deepStrictEqual(func(array, null, args, null), []); - }); - - it('`_.' + methodName + '` should return a wrapped value when chaining', function() { - var wrapped = _([1, 3, 2])[methodName]([5, 2, 1, 4]); - assert.ok(wrapped instanceof _); - assert.deepEqual(wrapped.value(), [1, 2]); - }); - }); -}); diff --git a/libs/nanofn/test/intersectionBy.js b/libs/nanofn/test/intersectionBy.js deleted file mode 100644 index c2a988f1c..000000000 --- a/libs/nanofn/test/intersectionBy.js +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import intersectionBy from '../intersectionBy.js'; - -describe('intersectionBy', function() { - it('should accept an `iteratee`', function() { - var actual = intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); - assert.deepStrictEqual(actual, [2.1]); - - actual = intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - assert.deepStrictEqual(actual, [{ 'x': 1 }]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - intersectionBy([2.1, 1.2], [2.3, 3.4], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [2.3]); - }); -}); diff --git a/libs/nanofn/test/intersectionWith.test.js b/libs/nanofn/test/intersectionWith.test.js deleted file mode 100644 index 72b3cbee3..000000000 --- a/libs/nanofn/test/intersectionWith.test.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, stubZero } from './utils.js'; -import intersectionWith from '../intersectionWith.js'; - -describe('intersectionWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], - others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }], - actual = intersectionWith(objects, others, lodashStable.isEqual); - - assert.deepStrictEqual(actual, [objects[0]]); - }); - - it('should preserve the sign of `0`', function() { - var array = [-0], - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubZero), - others = [[0], largeArray], - expected = lodashStable.map(others, lodashStable.constant(['-0'])); - - var actual = lodashStable.map(others, function(other) { - return lodashStable.map(intersectionWith(array, other, lodashStable.eq), lodashStable.toString); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/invert.test.js b/libs/nanofn/test/invert.test.js deleted file mode 100644 index 5fbfd22f2..000000000 --- a/libs/nanofn/test/invert.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import assert from 'assert'; -import invert from '../invert.js'; - -describe('invert', function() { - it('should invert an object', function() { - var object = { 'a': 1, 'b': 2 }, - actual = invert(object); - - assert.deepStrictEqual(actual, { '1': 'a', '2': 'b' }); - assert.deepStrictEqual(invert(actual), { 'a': '1', 'b': '2' }); - }); - - it('should work with values that shadow keys on `Object.prototype`', function() { - var object = { 'a': 'hasOwnProperty', 'b': 'constructor' }; - assert.deepStrictEqual(invert(object), { 'hasOwnProperty': 'a', 'constructor': 'b' }); - }); - - it('should work with an object that has a `length` property', function() { - var object = { '0': 'a', '1': 'b', 'length': 2 }; - assert.deepStrictEqual(invert(object), { 'a': '0', 'b': '1', '2': 'length' }); - }); - - it('should return a wrapped value when chaining', function() { - var object = { 'a': 1, 'b': 2 }, - wrapped = _(object).invert(); - - assert.ok(wrapped instanceof _); - assert.deepEqual(wrapped.value(), { '1': 'a', '2': 'b' }); - }); -}); diff --git a/libs/nanofn/test/invertBy.js b/libs/nanofn/test/invertBy.js deleted file mode 100644 index 42379222e..000000000 --- a/libs/nanofn/test/invertBy.js +++ /dev/null @@ -1,42 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import invertBy from '../invertBy.js'; - -describe('invertBy', function() { - var object = { 'a': 1, 'b': 2, 'c': 1 }; - - it('should transform keys by `iteratee`', function() { - var expected = { 'group1': ['a', 'c'], 'group2': ['b'] }; - - var actual = invertBy(object, function(value) { - return 'group' + value; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant({ '1': ['a', 'c'], '2': ['b'] })); - - var actual = lodashStable.map(values, function(value, index) { - return index ? invertBy(object, value) : invertBy(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should only add multiple values to own, not inherited, properties', function() { - var object = { 'a': 'hasOwnProperty', 'b': 'constructor' }, - expected = { 'hasOwnProperty': ['a'], 'constructor': ['b'] }; - - assert.ok(lodashStable.isEqual(invertBy(object), expected)); - }); - - it('should return a wrapped value when chaining', function() { - var wrapped = _(object).invertBy(); - - assert.ok(wrapped instanceof _); - assert.deepEqual(wrapped.value(), { '1': ['a', 'c'], '2': ['b'] }); - }); -}); diff --git a/libs/nanofn/test/invoke.js b/libs/nanofn/test/invoke.js deleted file mode 100644 index 4d046a80e..000000000 --- a/libs/nanofn/test/invoke.js +++ /dev/null @@ -1,71 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop, stubA, stubB, stubOne } from './utils.js'; -import invoke from '../invoke.js'; - -describe('invoke', function() { - it('should invoke a method on `object`', function() { - var object = { 'a': lodashStable.constant('A') }, - actual = invoke(object, 'a'); - - assert.strictEqual(actual, 'A'); - }); - - it('should support invoking with arguments', function() { - var object = { 'a': function(a, b) { return [a, b]; } }, - actual = invoke(object, 'a', 1, 2); - - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('should not error on nullish elements', function() { - var values = [null, undefined], - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(value) { - try { - return invoke(value, 'a.b', 1, 2); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should preserve the sign of `0`', function() { - var object = { '-0': stubA, '0': stubB }, - props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - return invoke(object, key); - }); - - assert.deepStrictEqual(actual, ['a', 'a', 'b', 'b']); - }); - - it('should support deep paths', function() { - var object = { 'a': { 'b': function(a, b) { return [a, b]; } } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var actual = invoke(object, path, 1, 2); - assert.deepStrictEqual(actual, [1, 2]); - }); - }); - - it('should invoke deep property methods with the correct `this` binding', function() { - var object = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.deepStrictEqual(invoke(object, path), 1); - }); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - var object = { 'a': stubOne }; - assert.strictEqual(_(object).invoke('a'), 1); - }); - - it('should return a wrapped value when explicitly chaining', function() { - var object = { 'a': stubOne }; - assert.ok(_(object).chain().invoke('a') instanceof _); - }); -}); diff --git a/libs/nanofn/test/invokeMap.js b/libs/nanofn/test/invokeMap.js deleted file mode 100644 index bb3ba944f..000000000 --- a/libs/nanofn/test/invokeMap.js +++ /dev/null @@ -1,105 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, stubOne } from './utils.js'; -import invokeMap from '../invokeMap.js'; - -describe('invokeMap', function() { - it('should invoke a methods on each element of `collection`', function() { - var array = ['a', 'b', 'c'], - actual = invokeMap(array, 'toUpperCase'); - - assert.deepStrictEqual(actual, ['A', 'B', 'C']); - }); - - it('should support invoking with arguments', function() { - var array = [function() { return slice.call(arguments); }], - actual = invokeMap(array, 'call', null, 'a', 'b', 'c'); - - assert.deepStrictEqual(actual, [['a', 'b', 'c']]); - }); - - it('should work with a function for `methodName`', function() { - var array = ['a', 'b', 'c']; - - var actual = invokeMap(array, function(left, right) { - return left + this.toUpperCase() + right; - }, '(', ')'); - - assert.deepStrictEqual(actual, ['(A)', '(B)', '(C)']); - }); - - it('should work with an object for `collection`', function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - actual = invokeMap(object, 'toFixed', 1); - - assert.deepStrictEqual(actual, ['1.0', '2.0', '3.0']); - }); - - it('should treat number values for `collection` as empty', function() { - assert.deepStrictEqual(invokeMap(1), []); - }); - - it('should not error on nullish elements', function() { - var array = ['a', null, undefined, 'd']; - - try { - var actual = invokeMap(array, 'toUpperCase'); - } catch (e) {} - - assert.deepStrictEqual(actual, ['A', undefined, undefined, 'D']); - }); - - it('should not error on elements with missing properties', function() { - var objects = lodashStable.map([null, undefined, stubOne], function(value) { - return { 'a': value }; - }); - - var expected = lodashStable.map(objects, function(object) { - return object.a ? object.a() : undefined; - }); - - try { - var actual = invokeMap(objects, 'a'); - } catch (e) {} - - assert.deepStrictEqual(actual, expected); - }); - - it('should invoke deep property methods with the correct `this` binding', function() { - var object = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.deepStrictEqual(invokeMap([object], path), [1]); - }); - }); - - it('should return a wrapped value when chaining', function() { - var array = ['a', 'b', 'c'], - wrapped = _(array), - actual = wrapped.invokeMap('toUpperCase'); - - assert.ok(actual instanceof _); - assert.deepEqual(actual.valueOf(), ['A', 'B', 'C']); - - actual = wrapped.invokeMap(function(left, right) { - return left + this.toUpperCase() + right; - }, '(', ')'); - - assert.ok(actual instanceof _); - assert.deepEqual(actual.valueOf(), ['(A)', '(B)', '(C)']); - }); - - it('should support shortcut fusion', function() { - var count = 0, - method = function() { count++; return this.index; }; - - var array = lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return { 'index': index, 'method': method }; - }); - - var actual = _(array).invokeMap('method').take(1).value(); - - assert.strictEqual(count, 1); - assert.deepEqual(actual, [0]); - }); -}); diff --git a/libs/nanofn/test/isArguments.test.js b/libs/nanofn/test/isArguments.test.js deleted file mode 100644 index 87c62a980..000000000 --- a/libs/nanofn/test/isArguments.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, strictArgs, falsey, stubFalse, slice, noop, symbol, realm } from './utils.js'; -import isArguments from '../isArguments.js'; - -describe('isArguments', function() { - it('should return `true` for `arguments` objects', function() { - assert.strictEqual(isArguments(args), true); - assert.strictEqual(isArguments(strictArgs), true); - }); - - it('should return `false` for non `arguments` objects', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isArguments(value) : isArguments(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isArguments([1, 2, 3]), false); - assert.strictEqual(isArguments(true), false); - assert.strictEqual(isArguments(new Date), false); - assert.strictEqual(isArguments(new Error), false); - assert.strictEqual(isArguments(_), false); - assert.strictEqual(isArguments(slice), false); - assert.strictEqual(isArguments({ '0': 1, 'callee': noop, 'length': 1 }), false); - assert.strictEqual(isArguments(1), false); - assert.strictEqual(isArguments(/x/), false); - assert.strictEqual(isArguments('a'), false); - assert.strictEqual(isArguments(symbol), false); - }); - - it('should work with an `arguments` object from another realm', function() { - if (realm.arguments) { - assert.strictEqual(isArguments(realm.arguments), true); - } - }); -}); diff --git a/libs/nanofn/test/isArray.js b/libs/nanofn/test/isArray.js deleted file mode 100644 index 552796755..000000000 --- a/libs/nanofn/test/isArray.js +++ /dev/null @@ -1,38 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isArray from '../isArray.js'; - -describe('isArray', function() { - it('should return `true` for arrays', function() { - assert.strictEqual(isArray([1, 2, 3]), true); - }); - - it('should return `false` for non-arrays', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isArray(value) : isArray(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isArray(args), false); - assert.strictEqual(isArray(true), false); - assert.strictEqual(isArray(new Date), false); - assert.strictEqual(isArray(new Error), false); - assert.strictEqual(isArray(_), false); - assert.strictEqual(isArray(slice), false); - assert.strictEqual(isArray({ '0': 1, 'length': 1 }), false); - assert.strictEqual(isArray(1), false); - assert.strictEqual(isArray(/x/), false); - assert.strictEqual(isArray('a'), false); - assert.strictEqual(isArray(symbol), false); - }); - - it('should work with an array from another realm', function() { - if (realm.array) { - assert.strictEqual(isArray(realm.array), true); - } - }); -}); diff --git a/libs/nanofn/test/isArrayBuffer.test.js b/libs/nanofn/test/isArrayBuffer.test.js deleted file mode 100644 index 7ac1bf098..000000000 --- a/libs/nanofn/test/isArrayBuffer.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { arrayBuffer, falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isArrayBuffer from '../isArrayBuffer.js'; - -describe('isArrayBuffer', function() { - it('should return `true` for array buffers', function() { - if (ArrayBuffer) { - assert.strictEqual(isArrayBuffer(arrayBuffer), true); - } - }); - - it('should return `false` for non array buffers', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isArrayBuffer(value) : isArrayBuffer(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isArrayBuffer(args), false); - assert.strictEqual(isArrayBuffer([1]), false); - assert.strictEqual(isArrayBuffer(true), false); - assert.strictEqual(isArrayBuffer(new Date), false); - assert.strictEqual(isArrayBuffer(new Error), false); - assert.strictEqual(isArrayBuffer(_), false); - assert.strictEqual(isArrayBuffer(slice), false); - assert.strictEqual(isArrayBuffer({ 'a': 1 }), false); - assert.strictEqual(isArrayBuffer(1), false); - assert.strictEqual(isArrayBuffer(/x/), false); - assert.strictEqual(isArrayBuffer('a'), false); - assert.strictEqual(isArrayBuffer(symbol), false); - }); - - it('should work with array buffers from another realm', function() { - if (realm.arrayBuffer) { - assert.strictEqual(isArrayBuffer(realm.arrayBuffer), true); - } - }); -}); diff --git a/libs/nanofn/test/isArrayLike.test.js b/libs/nanofn/test/isArrayLike.test.js deleted file mode 100644 index 6e332dd2d..000000000 --- a/libs/nanofn/test/isArrayLike.test.js +++ /dev/null @@ -1,48 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, stubTrue, falsey, asyncFunc, genFunc, slice, symbol, realm } from './utils.js'; -import isArrayLike from '../isArrayLike.js'; - -describe('isArrayLike', function() { - it('should return `true` for array-like values', function() { - var values = [args, [1, 2, 3], { '0': 'a', 'length': 1 }, 'a'], - expected = lodashStable.map(values, stubTrue), - actual = lodashStable.map(values, isArrayLike); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-arrays', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === ''; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isArrayLike(value) : isArrayLike(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isArrayLike(true), false); - assert.strictEqual(isArrayLike(new Date), false); - assert.strictEqual(isArrayLike(new Error), false); - assert.strictEqual(isArrayLike(_), false); - assert.strictEqual(isArrayLike(asyncFunc), false); - assert.strictEqual(isArrayLike(genFunc), false); - assert.strictEqual(isArrayLike(slice), false); - assert.strictEqual(isArrayLike({ 'a': 1 }), false); - assert.strictEqual(isArrayLike(1), false); - assert.strictEqual(isArrayLike(/x/), false); - assert.strictEqual(isArrayLike(symbol), false); - }); - - it('should work with an array from another realm', function() { - if (realm.object) { - var values = [realm.arguments, realm.array, realm.string], - expected = lodashStable.map(values, stubTrue), - actual = lodashStable.map(values, isArrayLike); - - assert.deepStrictEqual(actual, expected); - } - }); -}); diff --git a/libs/nanofn/test/isBoolean.test.js b/libs/nanofn/test/isBoolean.test.js deleted file mode 100644 index 6f6c2e3d4..000000000 --- a/libs/nanofn/test/isBoolean.test.js +++ /dev/null @@ -1,43 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isBoolean from '../isBoolean.js'; - -describe('isBoolean', function() { - it('should return `true` for booleans', function() { - assert.strictEqual(isBoolean(true), true); - assert.strictEqual(isBoolean(false), true); - assert.strictEqual(isBoolean(Object(true)), true); - assert.strictEqual(isBoolean(Object(false)), true); - }); - - it('should return `false` for non-booleans', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === false; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isBoolean(value) : isBoolean(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isBoolean(args), false); - assert.strictEqual(isBoolean([1, 2, 3]), false); - assert.strictEqual(isBoolean(new Date), false); - assert.strictEqual(isBoolean(new Error), false); - assert.strictEqual(isBoolean(_), false); - assert.strictEqual(isBoolean(slice), false); - assert.strictEqual(isBoolean({ 'a': 1 }), false); - assert.strictEqual(isBoolean(1), false); - assert.strictEqual(isBoolean(/x/), false); - assert.strictEqual(isBoolean('a'), false); - assert.strictEqual(isBoolean(symbol), false); - }); - - it('should work with a boolean from another realm', function() { - if (realm.boolean) { - assert.strictEqual(isBoolean(realm.boolean), true); - } - }); -}); diff --git a/libs/nanofn/test/isBuffer.test.js b/libs/nanofn/test/isBuffer.test.js deleted file mode 100644 index a81af76f8..000000000 --- a/libs/nanofn/test/isBuffer.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubFalse, args, slice, symbol, isStrict, lodashBizarro } from './utils.js'; -import isBuffer from '../isBuffer.js'; - -describe('isBuffer', function() { - it('should return `true` for buffers', function() { - if (Buffer) { - assert.strictEqual(isBuffer(new Buffer(2)), true); - } - }); - - it('should return `false` for non-buffers', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isBuffer(value) : isBuffer(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isBuffer(args), false); - assert.strictEqual(isBuffer([1]), false); - assert.strictEqual(isBuffer(true), false); - assert.strictEqual(isBuffer(new Date), false); - assert.strictEqual(isBuffer(new Error), false); - assert.strictEqual(isBuffer(_), false); - assert.strictEqual(isBuffer(slice), false); - assert.strictEqual(isBuffer({ 'a': 1 }), false); - assert.strictEqual(isBuffer(1), false); - assert.strictEqual(isBuffer(/x/), false); - assert.strictEqual(isBuffer('a'), false); - assert.strictEqual(isBuffer(symbol), false); - }); - - it('should return `false` if `Buffer` is not defined', function() { - if (!isStrict && Buffer && lodashBizarro) { - assert.strictEqual(lodashBizarro.isBuffer(new Buffer(2)), false); - } - }); -}); diff --git a/libs/nanofn/test/isDate.test.js b/libs/nanofn/test/isDate.test.js deleted file mode 100644 index 8da8064c2..000000000 --- a/libs/nanofn/test/isDate.test.js +++ /dev/null @@ -1,38 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isDate from '../isDate.js'; - -describe('isDate', function() { - it('should return `true` for dates', function() { - assert.strictEqual(isDate(new Date), true); - }); - - it('should return `false` for non-dates', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isDate(value) : isDate(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isDate(args), false); - assert.strictEqual(isDate([1, 2, 3]), false); - assert.strictEqual(isDate(true), false); - assert.strictEqual(isDate(new Error), false); - assert.strictEqual(isDate(_), false); - assert.strictEqual(isDate(slice), false); - assert.strictEqual(isDate({ 'a': 1 }), false); - assert.strictEqual(isDate(1), false); - assert.strictEqual(isDate(/x/), false); - assert.strictEqual(isDate('a'), false); - assert.strictEqual(isDate(symbol), false); - }); - - it('should work with a date object from another realm', function() { - if (realm.date) { - assert.strictEqual(isDate(realm.date), true); - } - }); -}); diff --git a/libs/nanofn/test/isElement.test.js b/libs/nanofn/test/isElement.test.js deleted file mode 100644 index c5e8833d7..000000000 --- a/libs/nanofn/test/isElement.test.js +++ /dev/null @@ -1,58 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { document, body, falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isElement from '../isElement.js'; - -describe('isElement', function() { - it('should return `true` for elements', function() { - if (document) { - assert.strictEqual(isElement(body), true); - } - }); - - it('should return `true` for non-plain objects', function() { - function Foo() { - this.nodeType = 1; - } - - assert.strictEqual(isElement(new Foo), true); - }); - - it('should return `false` for non DOM elements', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isElement(value) : isElement(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isElement(args), false); - assert.strictEqual(isElement([1, 2, 3]), false); - assert.strictEqual(isElement(true), false); - assert.strictEqual(isElement(new Date), false); - assert.strictEqual(isElement(new Error), false); - assert.strictEqual(isElement(_), false); - assert.strictEqual(isElement(slice), false); - assert.strictEqual(isElement({ 'a': 1 }), false); - assert.strictEqual(isElement(1), false); - assert.strictEqual(isElement(/x/), false); - assert.strictEqual(isElement('a'), false); - assert.strictEqual(isElement(symbol), false); - }); - - it('should return `false` for plain objects', function() { - assert.strictEqual(isElement({ 'nodeType': 1 }), false); - assert.strictEqual(isElement({ 'nodeType': Object(1) }), false); - assert.strictEqual(isElement({ 'nodeType': true }), false); - assert.strictEqual(isElement({ 'nodeType': [1] }), false); - assert.strictEqual(isElement({ 'nodeType': '1' }), false); - assert.strictEqual(isElement({ 'nodeType': '001' }), false); - }); - - it('should work with a DOM element from another realm', function() { - if (realm.element) { - assert.strictEqual(isElement(realm.element), true); - } - }); -}); diff --git a/libs/nanofn/test/isEmpty.js b/libs/nanofn/test/isEmpty.js deleted file mode 100644 index 05c8770ab..000000000 --- a/libs/nanofn/test/isEmpty.js +++ /dev/null @@ -1,119 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - empties, - stubTrue, - slice, - symbol, - args, - push, - arrayProto, - realm, - MAX_SAFE_INTEGER, -} from './utils.js'; - -import isEmpty from '../isEmpty.js'; - -describe('isEmpty', function() { - it('should return `true` for empty values', function() { - var expected = lodashStable.map(empties, stubTrue), - actual = lodashStable.map(empties, isEmpty); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isEmpty(true), true); - assert.strictEqual(isEmpty(slice), true); - assert.strictEqual(isEmpty(1), true); - assert.strictEqual(isEmpty(NaN), true); - assert.strictEqual(isEmpty(/x/), true); - assert.strictEqual(isEmpty(symbol), true); - assert.strictEqual(isEmpty(), true); - - if (Buffer) { - assert.strictEqual(isEmpty(new Buffer(0)), true); - assert.strictEqual(isEmpty(new Buffer(1)), false); - } - }); - - it('should return `false` for non-empty values', function() { - assert.strictEqual(isEmpty([0]), false); - assert.strictEqual(isEmpty({ 'a': 0 }), false); - assert.strictEqual(isEmpty('a'), false); - }); - - it('should work with an object that has a `length` property', function() { - assert.strictEqual(isEmpty({ 'length': 0 }), false); - }); - - it('should work with `arguments` objects', function() { - assert.strictEqual(isEmpty(args), false); - }); - - it('should work with prototype objects', function() { - function Foo() {} - Foo.prototype = { 'constructor': Foo }; - - assert.strictEqual(isEmpty(Foo.prototype), true); - - Foo.prototype.a = 1; - assert.strictEqual(isEmpty(Foo.prototype), false); - }); - - it('should work with jQuery/MooTools DOM query collections', function() { - function Foo(elements) { - push.apply(this, elements); - } - Foo.prototype = { 'length': 0, 'splice': arrayProto.splice }; - - assert.strictEqual(isEmpty(new Foo([])), true); - }); - - it('should work with maps', function() { - if (Map) { - lodashStable.each([new Map, realm.map], function(map) { - assert.strictEqual(isEmpty(map), true); - map.set('a', 1); - assert.strictEqual(isEmpty(map), false); - map.clear(); - }); - } - }); - - it('should work with sets', function() { - if (Set) { - lodashStable.each([new Set, realm.set], function(set) { - assert.strictEqual(isEmpty(set), true); - set.add(1); - assert.strictEqual(isEmpty(set), false); - set.clear(); - }); - } - }); - - it('should not treat objects with negative lengths as array-like', function() { - function Foo() {} - Foo.prototype.length = -1; - - assert.strictEqual(isEmpty(new Foo), true); - }); - - it('should not treat objects with lengths larger than `MAX_SAFE_INTEGER` as array-like', function() { - function Foo() {} - Foo.prototype.length = MAX_SAFE_INTEGER + 1; - - assert.strictEqual(isEmpty(new Foo), true); - }); - - it('should not treat objects with non-number lengths as array-like', function() { - assert.strictEqual(isEmpty({ 'length': '0' }), false); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - assert.strictEqual(_({}).isEmpty(), true); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_({}).chain().isEmpty() instanceof _); - }); -}); diff --git a/libs/nanofn/test/isEqual.js b/libs/nanofn/test/isEqual.js deleted file mode 100644 index 66056d7e5..000000000 --- a/libs/nanofn/test/isEqual.js +++ /dev/null @@ -1,700 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - noop, - create, - args, - realm, - arrayViews, - map, - promise, - set, - defineProperty, - document, - stubFalse, -} from './utils.js'; - -import isEqual from '../isEqual.js'; - -describe('isEqual', function() { - var symbol1 = Symbol ? Symbol('a') : true, - symbol2 = Symbol ? Symbol('b') : false; - - it('should compare primitives', function() { - var pairs = [ - [1, 1, true], [1, Object(1), true], [1, '1', false], [1, 2, false], - [-0, -0, true], [0, 0, true], [0, Object(0), true], [Object(0), Object(0), true], [-0, 0, true], [0, '0', false], [0, null, false], - [NaN, NaN, true], [NaN, Object(NaN), true], [Object(NaN), Object(NaN), true], [NaN, 'a', false], [NaN, Infinity, false], - ['a', 'a', true], ['a', Object('a'), true], [Object('a'), Object('a'), true], ['a', 'b', false], ['a', ['a'], false], - [true, true, true], [true, Object(true), true], [Object(true), Object(true), true], [true, 1, false], [true, 'a', false], - [false, false, true], [false, Object(false), true], [Object(false), Object(false), true], [false, 0, false], [false, '', false], - [symbol1, symbol1, true], [symbol1, Object(symbol1), true], [Object(symbol1), Object(symbol1), true], [symbol1, symbol2, false], - [null, null, true], [null, undefined, false], [null, {}, false], [null, '', false], - [undefined, undefined, true], [undefined, null, false], [undefined, '', false] - ]; - - var expected = lodashStable.map(pairs, function(pair) { - return pair[2]; - }); - - var actual = lodashStable.map(pairs, function(pair) { - return isEqual(pair[0], pair[1]); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should compare arrays', function() { - var array1 = [true, null, 1, 'a', undefined], - array2 = [true, null, 1, 'a', undefined]; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = [[1, 2, 3], new Date(2012, 4, 23), /x/, { 'e': 1 }]; - array2 = [[1, 2, 3], new Date(2012, 4, 23), /x/, { 'e': 1 }]; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = [1]; - array1[2] = 3; - - array2 = [1]; - array2[1] = undefined; - array2[2] = 3; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = [Object(1), false, Object('a'), /x/, new Date(2012, 4, 23), ['a', 'b', [Object('c')]], { 'a': 1 }]; - array2 = [1, Object(false), 'a', /x/, new Date(2012, 4, 23), ['a', Object('b'), ['c']], { 'a': 1 }]; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = [1, 2, 3]; - array2 = [3, 2, 1]; - - assert.strictEqual(isEqual(array1, array2), false); - - array1 = [1, 2]; - array2 = [1, 2, 3]; - - assert.strictEqual(isEqual(array1, array2), false); - }); - - it('should treat arrays with identical values but different non-index properties as equal', function() { - var array1 = [1, 2, 3], - array2 = [1, 2, 3]; - - array1.every = array1.filter = array1.forEach = - array1.indexOf = array1.lastIndexOf = array1.map = - array1.some = array1.reduce = array1.reduceRight = null; - - array2.concat = array2.join = array2.pop = - array2.reverse = array2.shift = array2.slice = - array2.sort = array2.splice = array2.unshift = null; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = [1, 2, 3]; - array1.a = 1; - - array2 = [1, 2, 3]; - array2.b = 1; - - assert.strictEqual(isEqual(array1, array2), true); - - array1 = /c/.exec('abcde'); - array2 = ['c']; - - assert.strictEqual(isEqual(array1, array2), true); - }); - - it('should compare sparse arrays', function() { - var array = Array(1); - - assert.strictEqual(isEqual(array, Array(1)), true); - assert.strictEqual(isEqual(array, [undefined]), true); - assert.strictEqual(isEqual(array, Array(2)), false); - }); - - it('should compare plain objects', function() { - var object1 = { 'a': true, 'b': null, 'c': 1, 'd': 'a', 'e': undefined }, - object2 = { 'a': true, 'b': null, 'c': 1, 'd': 'a', 'e': undefined }; - - assert.strictEqual(isEqual(object1, object2), true); - - object1 = { 'a': [1, 2, 3], 'b': new Date(2012, 4, 23), 'c': /x/, 'd': { 'e': 1 } }; - object2 = { 'a': [1, 2, 3], 'b': new Date(2012, 4, 23), 'c': /x/, 'd': { 'e': 1 } }; - - assert.strictEqual(isEqual(object1, object2), true); - - object1 = { 'a': 1, 'b': 2, 'c': 3 }; - object2 = { 'a': 3, 'b': 2, 'c': 1 }; - - assert.strictEqual(isEqual(object1, object2), false); - - object1 = { 'a': 1, 'b': 2, 'c': 3 }; - object2 = { 'd': 1, 'e': 2, 'f': 3 }; - - assert.strictEqual(isEqual(object1, object2), false); - - object1 = { 'a': 1, 'b': 2 }; - object2 = { 'a': 1, 'b': 2, 'c': 3 }; - - assert.strictEqual(isEqual(object1, object2), false); - }); - - it('should compare objects regardless of key order', function() { - var object1 = { 'a': 1, 'b': 2, 'c': 3 }, - object2 = { 'c': 3, 'a': 1, 'b': 2 }; - - assert.strictEqual(isEqual(object1, object2), true); - }); - - it('should compare nested objects', function() { - var object1 = { - 'a': [1, 2, 3], - 'b': true, - 'c': Object(1), - 'd': 'a', - 'e': { - 'f': ['a', Object('b'), 'c'], - 'g': Object(false), - 'h': new Date(2012, 4, 23), - 'i': noop, - 'j': 'a' - } - }; - - var object2 = { - 'a': [1, Object(2), 3], - 'b': Object(true), - 'c': 1, - 'd': Object('a'), - 'e': { - 'f': ['a', 'b', 'c'], - 'g': false, - 'h': new Date(2012, 4, 23), - 'i': noop, - 'j': 'a' - } - }; - - assert.strictEqual(isEqual(object1, object2), true); - }); - - it('should compare object instances', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.a = 1; - - function Bar() { - this.a = 1; - } - Bar.prototype.a = 2; - - assert.strictEqual(isEqual(new Foo, new Foo), true); - assert.strictEqual(isEqual(new Foo, new Bar), false); - assert.strictEqual(isEqual({ 'a': 1 }, new Foo), false); - assert.strictEqual(isEqual({ 'a': 2 }, new Bar), false); - }); - - it('should compare objects with constructor properties', function() { - assert.strictEqual(isEqual({ 'constructor': 1 }, { 'constructor': 1 }), true); - assert.strictEqual(isEqual({ 'constructor': 1 }, { 'constructor': '1' }), false); - assert.strictEqual(isEqual({ 'constructor': [1] }, { 'constructor': [1] }), true); - assert.strictEqual(isEqual({ 'constructor': [1] }, { 'constructor': ['1'] }), false); - assert.strictEqual(isEqual({ 'constructor': Object }, {}), false); - }); - - it('should compare arrays with circular references', function() { - var array1 = [], - array2 = []; - - array1.push(array1); - array2.push(array2); - - assert.strictEqual(isEqual(array1, array2), true); - - array1.push('b'); - array2.push('b'); - - assert.strictEqual(isEqual(array1, array2), true); - - array1.push('c'); - array2.push('d'); - - assert.strictEqual(isEqual(array1, array2), false); - - array1 = ['a', 'b', 'c']; - array1[1] = array1; - array2 = ['a', ['a', 'b', 'c'], 'c']; - - assert.strictEqual(isEqual(array1, array2), false); - }); - - it('should have transitive equivalence for circular references of arrays', function() { - var array1 = [], - array2 = [array1], - array3 = [array2]; - - array1[0] = array1; - - assert.strictEqual(isEqual(array1, array2), true); - assert.strictEqual(isEqual(array2, array3), true); - assert.strictEqual(isEqual(array1, array3), true); - }); - - it('should compare objects with circular references', function() { - var object1 = {}, - object2 = {}; - - object1.a = object1; - object2.a = object2; - - assert.strictEqual(isEqual(object1, object2), true); - - object1.b = 0; - object2.b = Object(0); - - assert.strictEqual(isEqual(object1, object2), true); - - object1.c = Object(1); - object2.c = Object(2); - - assert.strictEqual(isEqual(object1, object2), false); - - object1 = { 'a': 1, 'b': 2, 'c': 3 }; - object1.b = object1; - object2 = { 'a': 1, 'b': { 'a': 1, 'b': 2, 'c': 3 }, 'c': 3 }; - - assert.strictEqual(isEqual(object1, object2), false); - }); - - it('should have transitive equivalence for circular references of objects', function() { - var object1 = {}, - object2 = { 'a': object1 }, - object3 = { 'a': object2 }; - - object1.a = object1; - - assert.strictEqual(isEqual(object1, object2), true); - assert.strictEqual(isEqual(object2, object3), true); - assert.strictEqual(isEqual(object1, object3), true); - }); - - it('should compare objects with multiple circular references', function() { - var array1 = [{}], - array2 = [{}]; - - (array1[0].a = array1).push(array1); - (array2[0].a = array2).push(array2); - - assert.strictEqual(isEqual(array1, array2), true); - - array1[0].b = 0; - array2[0].b = Object(0); - - assert.strictEqual(isEqual(array1, array2), true); - - array1[0].c = Object(1); - array2[0].c = Object(2); - - assert.strictEqual(isEqual(array1, array2), false); - }); - - it('should compare objects with complex circular references', function() { - var object1 = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': { 'a': 2 } - }; - - var object2 = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': { 'a': 2 } - }; - - object1.foo.b.c.d = object1; - object1.bar.b = object1.foo.b; - - object2.foo.b.c.d = object2; - object2.bar.b = object2.foo.b; - - assert.strictEqual(isEqual(object1, object2), true); - }); - - it('should compare objects with shared property values', function() { - var object1 = { - 'a': [1, 2] - }; - - var object2 = { - 'a': [1, 2], - 'b': [1, 2] - }; - - object1.b = object1.a; - - assert.strictEqual(isEqual(object1, object2), true); - }); - - it('should treat objects created by `Object.create(null)` like plain objects', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.constructor = null; - - var object1 = create(null); - object1.a = 1; - - var object2 = { 'a': 1 }; - - assert.strictEqual(isEqual(object1, object2), true); - assert.strictEqual(isEqual(new Foo, object2), false); - }); - - it('should avoid common type coercions', function() { - assert.strictEqual(isEqual(true, Object(false)), false); - assert.strictEqual(isEqual(Object(false), Object(0)), false); - assert.strictEqual(isEqual(false, Object('')), false); - assert.strictEqual(isEqual(Object(36), Object('36')), false); - assert.strictEqual(isEqual(0, ''), false); - assert.strictEqual(isEqual(1, true), false); - assert.strictEqual(isEqual(1337756400000, new Date(2012, 4, 23)), false); - assert.strictEqual(isEqual('36', 36), false); - assert.strictEqual(isEqual(36, '36'), false); - }); - - it('should compare `arguments` objects', function() { - var args1 = (function() { return arguments; }()), - args2 = (function() { return arguments; }()), - args3 = (function() { return arguments; }(1, 2)); - - assert.strictEqual(isEqual(args1, args2), true); - assert.strictEqual(isEqual(args1, args3), false); - }); - - it('should treat `arguments` objects like `Object` objects', function() { - var object = { '0': 1, '1': 2, '2': 3 }; - - function Foo() {} - Foo.prototype = object; - - assert.strictEqual(isEqual(args, object), true); - assert.strictEqual(isEqual(object, args), true); - assert.strictEqual(isEqual(args, new Foo), false); - assert.strictEqual(isEqual(new Foo, args), false); - }); - - it('should compare array buffers', function() { - if (ArrayBuffer) { - var buffer = new Int8Array([-1]).buffer; - - assert.strictEqual(isEqual(buffer, new Uint8Array([255]).buffer), true); - assert.strictEqual(isEqual(buffer, new ArrayBuffer(1)), false); - } - }); - - it('should compare array views', function() { - lodashStable.times(2, function(index) { - var ns = index ? realm : root; - - var pairs = lodashStable.map(arrayViews, function(type, viewIndex) { - var otherType = arrayViews[(viewIndex + 1) % arrayViews.length], - CtorA = ns[type] || function(n) { this.n = n; }, - CtorB = ns[otherType] || function(n) { this.n = n; }, - bufferA = ns[type] ? new ns.ArrayBuffer(8) : 8, - bufferB = ns[otherType] ? new ns.ArrayBuffer(8) : 8, - bufferC = ns[otherType] ? new ns.ArrayBuffer(16) : 16; - - return [new CtorA(bufferA), new CtorA(bufferA), new CtorB(bufferB), new CtorB(bufferC)]; - }); - - var expected = lodashStable.map(pairs, lodashStable.constant([true, false, false])); - - var actual = lodashStable.map(pairs, function(pair) { - return [isEqual(pair[0], pair[1]), isEqual(pair[0], pair[2]), isEqual(pair[2], pair[3])]; - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should compare buffers', function() { - if (Buffer) { - var buffer = new Buffer([1]); - - assert.strictEqual(isEqual(buffer, new Buffer([1])), true); - assert.strictEqual(isEqual(buffer, new Buffer([2])), false); - assert.strictEqual(isEqual(buffer, new Uint8Array([1])), false); - } - }); - - it('should compare date objects', function() { - var date = new Date(2012, 4, 23); - - assert.strictEqual(isEqual(date, new Date(2012, 4, 23)), true); - assert.strictEqual(isEqual(new Date('a'), new Date('b')), true); - assert.strictEqual(isEqual(date, new Date(2013, 3, 25)), false); - assert.strictEqual(isEqual(date, { 'getTime': lodashStable.constant(+date) }), false); - }); - - it('should compare error objects', function() { - var pairs = lodashStable.map([ - 'Error', - 'EvalError', - 'RangeError', - 'ReferenceError', - 'SyntaxError', - 'TypeError', - 'URIError' - ], function(type, index, errorTypes) { - var otherType = errorTypes[++index % errorTypes.length], - CtorA = root[type], - CtorB = root[otherType]; - - return [new CtorA('a'), new CtorA('a'), new CtorB('a'), new CtorB('b')]; - }); - - var expected = lodashStable.map(pairs, lodashStable.constant([true, false, false])); - - var actual = lodashStable.map(pairs, function(pair) { - return [isEqual(pair[0], pair[1]), isEqual(pair[0], pair[2]), isEqual(pair[2], pair[3])]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should compare functions', function() { - function a() { return 1 + 2; } - function b() { return 1 + 2; } - - assert.strictEqual(isEqual(a, a), true); - assert.strictEqual(isEqual(a, b), false); - }); - - it('should compare maps', function() { - if (Map) { - lodashStable.each([[map, new Map], [map, realm.map]], function(maps) { - var map1 = maps[0], - map2 = maps[1]; - - map1.set('a', 1); - map2.set('b', 2); - assert.strictEqual(isEqual(map1, map2), false); - - map1.set('b', 2); - map2.set('a', 1); - assert.strictEqual(isEqual(map1, map2), true); - - map1.delete('a'); - map1.set('a', 1); - assert.strictEqual(isEqual(map1, map2), true); - - map2.delete('a'); - assert.strictEqual(isEqual(map1, map2), false); - - map1.clear(); - map2.clear(); - }); - } - }); - - it('should compare maps with circular references', function() { - if (Map) { - var map1 = new Map, - map2 = new Map; - - map1.set('a', map1); - map2.set('a', map2); - assert.strictEqual(isEqual(map1, map2), true); - - map1.set('b', 1); - map2.set('b', 2); - assert.strictEqual(isEqual(map1, map2), false); - } - }); - - it('should compare promises by reference', function() { - if (promise) { - lodashStable.each([[promise, Promise.resolve(1)], [promise, realm.promise]], function(promises) { - var promise1 = promises[0], - promise2 = promises[1]; - - assert.strictEqual(isEqual(promise1, promise2), false); - assert.strictEqual(isEqual(promise1, promise1), true); - }); - } - }); - - it('should compare regexes', function() { - assert.strictEqual(isEqual(/x/gim, /x/gim), true); - assert.strictEqual(isEqual(/x/gim, /x/mgi), true); - assert.strictEqual(isEqual(/x/gi, /x/g), false); - assert.strictEqual(isEqual(/x/, /y/), false); - assert.strictEqual(isEqual(/x/g, { 'global': true, 'ignoreCase': false, 'multiline': false, 'source': 'x' }), false); - }); - - it('should compare sets', function() { - if (Set) { - lodashStable.each([[set, new Set], [set, realm.set]], function(sets) { - var set1 = sets[0], - set2 = sets[1]; - - set1.add(1); - set2.add(2); - assert.strictEqual(isEqual(set1, set2), false); - - set1.add(2); - set2.add(1); - assert.strictEqual(isEqual(set1, set2), true); - - set1.delete(1); - set1.add(1); - assert.strictEqual(isEqual(set1, set2), true); - - set2.delete(1); - assert.strictEqual(isEqual(set1, set2), false); - - set1.clear(); - set2.clear(); - }); - } - }); - - it('should compare sets with circular references', function() { - if (Set) { - var set1 = new Set, - set2 = new Set; - - set1.add(set1); - set2.add(set2); - assert.strictEqual(isEqual(set1, set2), true); - - set1.add(1); - set2.add(2); - assert.strictEqual(isEqual(set1, set2), false); - } - }); - - it('should compare symbol properties', function() { - if (Symbol) { - var object1 = { 'a': 1 }, - object2 = { 'a': 1 }; - - object1[symbol1] = { 'a': { 'b': 2 } }; - object2[symbol1] = { 'a': { 'b': 2 } }; - - defineProperty(object2, symbol2, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 2 - }); - - assert.strictEqual(isEqual(object1, object2), true); - - object2[symbol1] = { 'a': 1 }; - assert.strictEqual(isEqual(object1, object2), false); - - delete object2[symbol1]; - object2[Symbol('a')] = { 'a': { 'b': 2 } }; - assert.strictEqual(isEqual(object1, object2), false); - } - }); - - it('should compare wrapped values', function() { - var stamp = +new Date; - - var values = [ - [[1, 2], [1, 2], [1, 2, 3]], - [true, true, false], - [new Date(stamp), new Date(stamp), new Date(stamp - 100)], - [{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2 }, { 'a': 1, 'b': 1 }], - [1, 1, 2], - [NaN, NaN, Infinity], - [/x/, /x/, /x/i], - ['a', 'a', 'A'] - ]; - - lodashStable.each(values, function(vals) { - var wrapped1 = _(vals[0]), - wrapped2 = _(vals[1]), - actual = wrapped1.isEqual(wrapped2); - - assert.strictEqual(actual, true); - assert.strictEqual(isEqual(_(actual), _(true)), true); - - wrapped1 = _(vals[0]); - wrapped2 = _(vals[2]); - - actual = wrapped1.isEqual(wrapped2); - assert.strictEqual(actual, false); - assert.strictEqual(isEqual(_(actual), _(false)), true); - }); - }); - - it('should compare wrapped and non-wrapped values', function() { - var object1 = _({ 'a': 1, 'b': 2 }), - object2 = { 'a': 1, 'b': 2 }; - - assert.strictEqual(object1.isEqual(object2), true); - assert.strictEqual(isEqual(object1, object2), true); - - object1 = _({ 'a': 1, 'b': 2 }); - object2 = { 'a': 1, 'b': 1 }; - - assert.strictEqual(object1.isEqual(object2), false); - assert.strictEqual(isEqual(object1, object2), false); - }); - - it('should work as an iteratee for `_.every`', function() { - var actual = lodashStable.every([1, 1, 1], lodashStable.partial(isEqual, 1)); - assert.ok(actual); - }); - - it('should not error on DOM elements', function() { - if (document) { - var element1 = document.createElement('div'), - element2 = element1.cloneNode(true); - - try { - assert.strictEqual(isEqual(element1, element2), false); - } catch (e) { - assert.ok(false, e.message); - } - } - }); - - it('should return `true` for like-objects from different documents', function() { - if (realm.object) { - assert.strictEqual(isEqual([1], realm.array), true); - assert.strictEqual(isEqual([2], realm.array), false); - assert.strictEqual(isEqual({ 'a': 1 }, realm.object), true); - assert.strictEqual(isEqual({ 'a': 2 }, realm.object), false); - } - }); - - it('should return `false` for objects with custom `toString` methods', function() { - var primitive, - object = { 'toString': function() { return primitive; } }, - values = [true, null, 1, 'a', undefined], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - primitive = value; - return isEqual(object, value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - assert.strictEqual(_('a').isEqual('a'), true); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_('a').chain().isEqual('a') instanceof _); - }); -}); diff --git a/libs/nanofn/test/isEqualWith.js b/libs/nanofn/test/isEqualWith.js deleted file mode 100644 index 312e3e485..000000000 --- a/libs/nanofn/test/isEqualWith.js +++ /dev/null @@ -1,128 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, noop, stubC, falsey, stubFalse } from './utils.js'; -import isEqualWith from '../isEqualWith.js'; -import isString from '../isString.js'; -import without from '../without.js'; -import partial from '../partial.js'; - -describe('isEqualWith', function() { - it('should provide correct `customizer` arguments', function() { - var argsList = [], - object1 = { 'a': [1, 2], 'b': null }, - object2 = { 'a': [1, 2], 'b': null }; - - object1.b = object2; - object2.b = object1; - - var expected = [ - [object1, object2], - [object1.a, object2.a, 'a', object1, object2], - [object1.a[0], object2.a[0], 0, object1.a, object2.a], - [object1.a[1], object2.a[1], 1, object1.a, object2.a], - [object1.b, object2.b, 'b', object1.b, object2.b] - ]; - - isEqualWith(object1, object2, function() { - var length = arguments.length, - args = slice.call(arguments, 0, length - (length > 2 ? 1 : 0)); - - argsList.push(args); - }); - - assert.deepStrictEqual(argsList, expected); - }); - - it('should handle comparisons when `customizer` returns `undefined`', function() { - assert.strictEqual(isEqualWith('a', 'a', noop), true); - assert.strictEqual(isEqualWith(['a'], ['a'], noop), true); - assert.strictEqual(isEqualWith({ '0': 'a' }, { '0': 'a' }, noop), true); - }); - - it('should not handle comparisons when `customizer` returns `true`', function() { - var customizer = function(value) { - return isString(value) || undefined; - }; - - assert.strictEqual(isEqualWith('a', 'b', customizer), true); - assert.strictEqual(isEqualWith(['a'], ['b'], customizer), true); - assert.strictEqual(isEqualWith({ '0': 'a' }, { '0': 'b' }, customizer), true); - }); - - it('should not handle comparisons when `customizer` returns `false`', function() { - var customizer = function(value) { - return isString(value) ? false : undefined; - }; - - assert.strictEqual(isEqualWith('a', 'a', customizer), false); - assert.strictEqual(isEqualWith(['a'], ['a'], customizer), false); - assert.strictEqual(isEqualWith({ '0': 'a' }, { '0': 'a' }, customizer), false); - }); - - it('should return a boolean value even when `customizer` does not', function() { - var actual = isEqualWith('a', 'b', stubC); - assert.strictEqual(actual, true); - - var values = without(falsey, undefined), - expected = lodashStable.map(values, stubFalse); - - actual = []; - lodashStable.each(values, function(value) { - actual.push(isEqualWith('a', 'a', lodashStable.constant(value))); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should ensure `customizer` is a function', function() { - var array = [1, 2, 3], - eq = partial(isEqualWith, array), - actual = lodashStable.map([array, [1, 0, 3]], eq); - - assert.deepStrictEqual(actual, [true, false]); - }); - - it('should call `customizer` for values maps and sets', function() { - var value = { 'a': { 'b': 2 } }; - - if (Map) { - var map1 = new Map; - map1.set('a', value); - - var map2 = new Map; - map2.set('a', value); - } - if (Set) { - var set1 = new Set; - set1.add(value); - - var set2 = new Set; - set2.add(value); - } - lodashStable.each([[map1, map2], [set1, set2]], function(pair, index) { - if (pair[0]) { - var argsList = [], - array = lodashStable.toArray(pair[0]); - - var expected = [ - [pair[0], pair[1]], - [array[0], array[0], 0, array, array], - [array[0][0], array[0][0], 0, array[0], array[0]], - [array[0][1], array[0][1], 1, array[0], array[0]] - ]; - - if (index) { - expected.length = 2; - } - isEqualWith(pair[0], pair[1], function() { - var length = arguments.length, - args = slice.call(arguments, 0, length - (length > 2 ? 1 : 0)); - - argsList.push(args); - }); - - assert.deepStrictEqual(argsList, expected, index ? 'Set' : 'Map'); - } - }); - }); -}); diff --git a/libs/nanofn/test/isError.test.js b/libs/nanofn/test/isError.test.js deleted file mode 100644 index 0805b588e..000000000 --- a/libs/nanofn/test/isError.test.js +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - errors, - stubTrue, - CustomError, - falsey, - stubFalse, - args, - slice, - symbol, - realm, -} from './utils.js'; - -import isError from '../isError.js'; - -describe('isError', function() { - it('should return `true` for error objects', function() { - var expected = lodashStable.map(errors, stubTrue); - - var actual = lodashStable.map(errors, function(error) { - return isError(error) === true; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `true` for subclassed values', function() { - assert.strictEqual(isError(new CustomError('x')), true); - }); - - it('should return `false` for non error objects', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isError(value) : isError(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isError(args), false); - assert.strictEqual(isError([1, 2, 3]), false); - assert.strictEqual(isError(true), false); - assert.strictEqual(isError(new Date), false); - assert.strictEqual(isError(_), false); - assert.strictEqual(isError(slice), false); - assert.strictEqual(isError({ 'a': 1 }), false); - assert.strictEqual(isError(1), false); - assert.strictEqual(isError(/x/), false); - assert.strictEqual(isError('a'), false); - assert.strictEqual(isError(symbol), false); - }); - - it('should return `false` for plain objects', function() { - assert.strictEqual(isError({ 'name': 'Error', 'message': '' }), false); - }); - - it('should work with an error object from another realm', function() { - if (realm.errors) { - var expected = lodashStable.map(realm.errors, stubTrue); - - var actual = lodashStable.map(realm.errors, function(error) { - return isError(error) === true; - }); - - assert.deepStrictEqual(actual, expected); - } - }); -}); diff --git a/libs/nanofn/test/isFinite.js b/libs/nanofn/test/isFinite.js deleted file mode 100644 index f5c8ec688..000000000 --- a/libs/nanofn/test/isFinite.js +++ /dev/null @@ -1,48 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue, stubFalse, args, symbol } from './utils.js'; -import isFinite from '../isFinite.js'; - -describe('isFinite', function() { - it('should return `true` for finite values', function() { - var values = [0, 1, 3.14, -1], - expected = lodashStable.map(values, stubTrue), - actual = lodashStable.map(values, isFinite); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-finite values', function() { - var values = [NaN, Infinity, -Infinity, Object(1)], - expected = lodashStable.map(values, stubFalse), - actual = lodashStable.map(values, isFinite); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-numeric values', function() { - var values = [undefined, [], true, '', ' ', '2px'], - expected = lodashStable.map(values, stubFalse), - actual = lodashStable.map(values, isFinite); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isFinite(args), false); - assert.strictEqual(isFinite([1, 2, 3]), false); - assert.strictEqual(isFinite(true), false); - assert.strictEqual(isFinite(new Date), false); - assert.strictEqual(isFinite(new Error), false); - assert.strictEqual(isFinite({ 'a': 1 }), false); - assert.strictEqual(isFinite(/x/), false); - assert.strictEqual(isFinite('a'), false); - assert.strictEqual(isFinite(symbol), false); - }); - - it('should return `false` for numeric string values', function() { - var values = ['2', '0', '08'], - expected = lodashStable.map(values, stubFalse), - actual = lodashStable.map(values, isFinite); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/isFunction.js b/libs/nanofn/test/isFunction.js deleted file mode 100644 index be051d63c..000000000 --- a/libs/nanofn/test/isFunction.js +++ /dev/null @@ -1,83 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - slice, - asyncFunc, - genFunc, - arrayViews, - objToString, - funcTag, - falsey, - stubFalse, - args, - symbol, - document, - realm, -} from './utils.js'; - -import isFunction from '../isFunction.js'; - -describe('isFunction', function() { - it('should return `true` for functions', function() { - assert.strictEqual(isFunction(_), true); - assert.strictEqual(isFunction(slice), true); - }); - - it('should return `true` for async functions', function() { - assert.strictEqual(isFunction(asyncFunc), typeof asyncFunc === 'function'); - }); - - it('should return `true` for generator functions', function() { - assert.strictEqual(isFunction(genFunc), typeof genFunc === 'function'); - }); - - it('should return `true` for the `Proxy` constructor', function() { - if (Proxy) { - assert.strictEqual(isFunction(Proxy), true); - } - }); - - it('should return `true` for array view constructors', function() { - var expected = lodashStable.map(arrayViews, function(type) { - return objToString.call(root[type]) == funcTag; - }); - - var actual = lodashStable.map(arrayViews, function(type) { - return isFunction(root[type]); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-functions', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isFunction(value) : isFunction(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isFunction(args), false); - assert.strictEqual(isFunction([1, 2, 3]), false); - assert.strictEqual(isFunction(true), false); - assert.strictEqual(isFunction(new Date), false); - assert.strictEqual(isFunction(new Error), false); - assert.strictEqual(isFunction({ 'a': 1 }), false); - assert.strictEqual(isFunction(1), false); - assert.strictEqual(isFunction(/x/), false); - assert.strictEqual(isFunction('a'), false); - assert.strictEqual(isFunction(symbol), false); - - if (document) { - assert.strictEqual(isFunction(document.getElementsByTagName('body')), false); - } - }); - - it('should work with a function from another realm', function() { - if (realm.function) { - assert.strictEqual(isFunction(realm.function), true); - } - }); -}); diff --git a/libs/nanofn/test/isIndex.test.js b/libs/nanofn/test/isIndex.test.js deleted file mode 100644 index 486eef29e..000000000 --- a/libs/nanofn/test/isIndex.test.js +++ /dev/null @@ -1,34 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { MAX_SAFE_INTEGER, stubTrue, stubFalse } from './utils.js'; -import _isIndex from '../.internal/isIndex.js'; - -describe('isIndex', function() { - var func = _isIndex; - - it('should return `true` for indexes', function() { - if (func) { - var values = [[0], ['0'], ['1'], [3, 4], [MAX_SAFE_INTEGER - 1]], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(args) { - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - } - }); - - it('should return `false` for non-indexes', function() { - if (func) { - var values = [['1abc'], ['07'], ['0001'], [-1], [3, 3], [1.1], [MAX_SAFE_INTEGER]], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(args) { - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - } - }); -}); diff --git a/libs/nanofn/test/isInteger-methods.js b/libs/nanofn/test/isInteger-methods.js deleted file mode 100644 index 9c12c6840..000000000 --- a/libs/nanofn/test/isInteger-methods.js +++ /dev/null @@ -1,55 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, stubTrue, MAX_INTEGER, stubFalse, falsey, args, symbol } from './utils.js'; - -describe('isInteger methods', function() { - lodashStable.each(['isInteger', 'isSafeInteger'], function(methodName) { - var func = _[methodName], - isSafe = methodName == 'isSafeInteger'; - - it('`_.' + methodName + '` should return `true` for integer values', function() { - var values = [-1, 0, 1], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return func(value); - }); - - assert.deepStrictEqual(actual, expected); - assert.strictEqual(func(MAX_INTEGER), !isSafe); - }); - - it('should return `false` for non-integer number values', function() { - var values = [NaN, Infinity, -Infinity, Object(1), 3.14], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - return func(value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-numeric values', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === 0; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? func(value) : func(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(func(args), false); - assert.strictEqual(func([1, 2, 3]), false); - assert.strictEqual(func(true), false); - assert.strictEqual(func(new Date), false); - assert.strictEqual(func(new Error), false); - assert.strictEqual(func({ 'a': 1 }), false); - assert.strictEqual(func(/x/), false); - assert.strictEqual(func('a'), false); - assert.strictEqual(func(symbol), false); - }); - }); -}); diff --git a/libs/nanofn/test/isIterateeCall.js b/libs/nanofn/test/isIterateeCall.js deleted file mode 100644 index 86b4de524..000000000 --- a/libs/nanofn/test/isIterateeCall.js +++ /dev/null @@ -1,47 +0,0 @@ -import assert from 'assert'; -import { MAX_SAFE_INTEGER } from './utils.js'; -import _isIterateeCall from '../.internal/isIterateeCall.js'; - -describe('isIterateeCall', function() { - var array = [1], - func = _isIterateeCall, - object = { 'a': 1 }; - - it('should return `true` for iteratee calls', function() { - function Foo() {} - Foo.prototype.a = 1; - - if (func) { - assert.strictEqual(func(1, 0, array), true); - assert.strictEqual(func(1, 'a', object), true); - assert.strictEqual(func(1, 'a', new Foo), true); - } - }); - - it('should return `false` for non-iteratee calls', function() { - if (func) { - assert.strictEqual(func(2, 0, array), false); - assert.strictEqual(func(1, 1.1, array), false); - assert.strictEqual(func(1, 0, { 'length': MAX_SAFE_INTEGER + 1 }), false); - assert.strictEqual(func(1, 'b', object), false); - } - }); - - it('should work with `NaN` values', function() { - if (func) { - assert.strictEqual(func(NaN, 0, [NaN]), true); - assert.strictEqual(func(NaN, 'a', { 'a': NaN }), true); - } - }); - - it('should not error when `index` is an object without a `toString` method', function() { - if (func) { - try { - var actual = func(1, { 'toString': null }, [1]); - } catch (e) { - var message = e.message; - } - assert.strictEqual(actual, false, message || ''); - } - }); -}); diff --git a/libs/nanofn/test/isLength.test.js b/libs/nanofn/test/isLength.test.js deleted file mode 100644 index 3978c0cb5..000000000 --- a/libs/nanofn/test/isLength.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { MAX_SAFE_INTEGER, stubTrue, stubFalse } from './utils.js'; -import isLength from '../isLength.js'; - -describe('isLength', function() { - it('should return `true` for lengths', function() { - var values = [0, 3, MAX_SAFE_INTEGER], - expected = lodashStable.map(values, stubTrue), - actual = lodashStable.map(values, isLength); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-lengths', function() { - var values = [-1, '1', 1.1, MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, stubFalse), - actual = lodashStable.map(values, isLength); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/isMap.test.js b/libs/nanofn/test/isMap.test.js deleted file mode 100644 index 32fb80fff..000000000 --- a/libs/nanofn/test/isMap.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { map, falsey, stubFalse, args, slice, symbol, weakMap, realm } from './utils.js'; -import isMap from '../isMap.js'; - -describe('isMap', function() { - it('should return `true` for maps', function() { - if (Map) { - assert.strictEqual(isMap(map), true); - } - }); - - it('should return `false` for non-maps', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isMap(value) : isMap(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isMap(args), false); - assert.strictEqual(isMap([1, 2, 3]), false); - assert.strictEqual(isMap(true), false); - assert.strictEqual(isMap(new Date), false); - assert.strictEqual(isMap(new Error), false); - assert.strictEqual(isMap(_), false); - assert.strictEqual(isMap(slice), false); - assert.strictEqual(isMap({ 'a': 1 }), false); - assert.strictEqual(isMap(1), false); - assert.strictEqual(isMap(/x/), false); - assert.strictEqual(isMap('a'), false); - assert.strictEqual(isMap(symbol), false); - assert.strictEqual(isMap(weakMap), false); - }); - - it('should work for objects with a non-function `constructor` (test in IE 11)', function() { - var values = [false, true], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - return isMap({ 'constructor': value }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with maps from another realm', function() { - if (realm.map) { - assert.strictEqual(isMap(realm.map), true); - } - }); -}); diff --git a/libs/nanofn/test/isMatchWith.js b/libs/nanofn/test/isMatchWith.js deleted file mode 100644 index a7941d658..000000000 --- a/libs/nanofn/test/isMatchWith.js +++ /dev/null @@ -1,137 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, noop, stubA, falsey, stubFalse, isNpm, mapCaches } from './utils.js'; -import isMatchWith from '../isMatchWith.js'; -import isString from '../isString.js'; -import last from '../last.js'; -import partial from '../partial.js'; - -describe('isMatchWith', function() { - it('should provide correct `customizer` arguments', function() { - var argsList = [], - object1 = { 'a': [1, 2], 'b': null }, - object2 = { 'a': [1, 2], 'b': null }; - - object1.b = object2; - object2.b = object1; - - var expected = [ - [object1.a, object2.a, 'a', object1, object2], - [object1.a[0], object2.a[0], 0, object1.a, object2.a], - [object1.a[1], object2.a[1], 1, object1.a, object2.a], - [object1.b, object2.b, 'b', object1, object2], - [object1.b.a, object2.b.a, 'a', object1.b, object2.b], - [object1.b.a[0], object2.b.a[0], 0, object1.b.a, object2.b.a], - [object1.b.a[1], object2.b.a[1], 1, object1.b.a, object2.b.a], - [object1.b.b, object2.b.b, 'b', object1.b, object2.b] - ]; - - isMatchWith(object1, object2, function() { - argsList.push(slice.call(arguments, 0, -1)); - }); - - assert.deepStrictEqual(argsList, expected); - }); - - it('should handle comparisons when `customizer` returns `undefined`', function() { - assert.strictEqual(isMatchWith({ 'a': 1 }, { 'a': 1 }, noop), true); - }); - - it('should not handle comparisons when `customizer` returns `true`', function() { - var customizer = function(value) { - return isString(value) || undefined; - }; - - assert.strictEqual(isMatchWith(['a'], ['b'], customizer), true); - assert.strictEqual(isMatchWith({ '0': 'a' }, { '0': 'b' }, customizer), true); - }); - - it('should not handle comparisons when `customizer` returns `false`', function() { - var customizer = function(value) { - return isString(value) ? false : undefined; - }; - - assert.strictEqual(isMatchWith(['a'], ['a'], customizer), false); - assert.strictEqual(isMatchWith({ '0': 'a' }, { '0': 'a' }, customizer), false); - }); - - it('should return a boolean value even when `customizer` does not', function() { - var object = { 'a': 1 }, - actual = isMatchWith(object, { 'a': 1 }, stubA); - - assert.strictEqual(actual, true); - - var expected = lodashStable.map(falsey, stubFalse); - - actual = []; - lodashStable.each(falsey, function(value) { - actual.push(isMatchWith(object, { 'a': 2 }, lodashStable.constant(value))); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should provide `stack` to `customizer`', function() { - var actual; - - isMatchWith({ 'a': 1 }, { 'a': 1 }, function() { - actual = last(arguments); - }); - - assert.ok(isNpm - ? actual.constructor.name == 'Stack' - : actual instanceof mapCaches.Stack - ); - }); - - it('should ensure `customizer` is a function', function() { - var object = { 'a': 1 }, - matches = partial(isMatchWith, object), - actual = lodashStable.map([object, { 'a': 2 }], matches); - - assert.deepStrictEqual(actual, [true, false]); - }); - - it('should call `customizer` for values maps and sets', function() { - var value = { 'a': { 'b': 2 } }; - - if (Map) { - var map1 = new Map; - map1.set('a', value); - - var map2 = new Map; - map2.set('a', value); - } - if (Set) { - var set1 = new Set; - set1.add(value); - - var set2 = new Set; - set2.add(value); - } - lodashStable.each([[map1, map2], [set1, set2]], function(pair, index) { - if (pair[0]) { - var argsList = [], - array = lodashStable.toArray(pair[0]), - object1 = { 'a': pair[0] }, - object2 = { 'a': pair[1] }; - - var expected = [ - [pair[0], pair[1], 'a', object1, object2], - [array[0], array[0], 0, array, array], - [array[0][0], array[0][0], 0, array[0], array[0]], - [array[0][1], array[0][1], 1, array[0], array[0]] - ]; - - if (index) { - expected.length = 2; - } - isMatchWith({ 'a': pair[0] }, { 'a': pair[1] }, function() { - argsList.push(slice.call(arguments, 0, -1)); - }); - - assert.deepStrictEqual(argsList, expected, index ? 'Set' : 'Map'); - } - }); - }); -}); diff --git a/libs/nanofn/test/isNaN.js b/libs/nanofn/test/isNaN.js deleted file mode 100644 index 27529eac3..000000000 --- a/libs/nanofn/test/isNaN.js +++ /dev/null @@ -1,43 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isNaN from '../isNaN.js'; - -describe('isNaN', function() { - it('should return `true` for NaNs', function() { - assert.strictEqual(isNaN(NaN), true); - assert.strictEqual(isNaN(Object(NaN)), true); - }); - - it('should return `false` for non-NaNs', function() { - var expected = lodashStable.map(falsey, function(value) { - return value !== value; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isNaN(value) : isNaN(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isNaN(args), false); - assert.strictEqual(isNaN([1, 2, 3]), false); - assert.strictEqual(isNaN(true), false); - assert.strictEqual(isNaN(new Date), false); - assert.strictEqual(isNaN(new Error), false); - assert.strictEqual(isNaN(_), false); - assert.strictEqual(isNaN(slice), false); - assert.strictEqual(isNaN({ 'a': 1 }), false); - assert.strictEqual(isNaN(1), false); - assert.strictEqual(isNaN(Object(1)), false); - assert.strictEqual(isNaN(/x/), false); - assert.strictEqual(isNaN('a'), false); - assert.strictEqual(isNaN(symbol), false); - }); - - it('should work with `NaN` from another realm', function() { - if (realm.object) { - assert.strictEqual(isNaN(realm.nan), true); - } - }); -}); diff --git a/libs/nanofn/test/isNative.js b/libs/nanofn/test/isNative.js deleted file mode 100644 index c5f999485..000000000 --- a/libs/nanofn/test/isNative.js +++ /dev/null @@ -1,92 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - body, - create, - slice, - falsey, - stubFalse, - args, - symbol, - realm, - amd, - filePath, - emptyObject, - interopRequire, -} from './utils.js'; - -import isNative from '../isNative.js'; -import runInContext from '../runInContext.js'; -import _baseEach from '../.internal/baseEach.js'; - -describe('isNative', function() { - it('should return `true` for native methods', function() { - var values = [Array, body && body.cloneNode, create, root.encodeURI, Promise, slice, Uint8Array], - expected = lodashStable.map(values, Boolean), - actual = lodashStable.map(values, isNative); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non-native methods', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isNative(value) : isNative(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isNative(args), false); - assert.strictEqual(isNative([1, 2, 3]), false); - assert.strictEqual(isNative(true), false); - assert.strictEqual(isNative(new Date), false); - assert.strictEqual(isNative(new Error), false); - assert.strictEqual(isNative(_), false); - assert.strictEqual(isNative({ 'a': 1 }), false); - assert.strictEqual(isNative(1), false); - assert.strictEqual(isNative(/x/), false); - assert.strictEqual(isNative('a'), false); - assert.strictEqual(isNative(symbol), false); - }); - - it('should work with native functions from another realm', function() { - if (realm.element) { - assert.strictEqual(isNative(realm.element.cloneNode), true); - } - if (realm.object) { - assert.strictEqual(isNative(realm.object.valueOf), true); - } - }); - - it('should throw an error if core-js is detected', function() { - var lodash = runInContext({ - '__core-js_shared__': {} - }); - - assert.raises(function() { lodash.isNative(noop); }); - }); - - it('should detect methods masquerading as native (test in Node.js)', function() { - if (!amd && _baseEach) { - var path = require('path'), - basePath = path.dirname(filePath), - uid = 'e0gvgyrad1jor', - coreKey = '__core-js_shared__', - fakeSrcKey = 'Symbol(src)_1.' + uid; - - root[coreKey] = { 'keys': { 'IE_PROTO': 'Symbol(IE_PROTO)_3.' + uid } }; - emptyObject(require.cache); - - var baseIsNative = interopRequire(path.join(basePath, '_baseIsNative')); - assert.strictEqual(baseIsNative(slice), true); - - slice[fakeSrcKey] = slice + ''; - assert.strictEqual(baseIsNative(slice), false); - - delete slice[fakeSrcKey]; - delete root[coreKey]; - } - }); -}); diff --git a/libs/nanofn/test/isNil.test.js b/libs/nanofn/test/isNil.test.js deleted file mode 100644 index 3bd067be2..000000000 --- a/libs/nanofn/test/isNil.test.js +++ /dev/null @@ -1,47 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isNil from '../isNil.js'; - -describe('isNil', function() { - it('should return `true` for nullish values', function() { - assert.strictEqual(isNil(null), true); - assert.strictEqual(isNil(), true); - assert.strictEqual(isNil(undefined), true); - }); - - it('should return `false` for non-nullish values', function() { - var expected = lodashStable.map(falsey, function(value) { - return value == null; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isNil(value) : isNil(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isNil(args), false); - assert.strictEqual(isNil([1, 2, 3]), false); - assert.strictEqual(isNil(true), false); - assert.strictEqual(isNil(new Date), false); - assert.strictEqual(isNil(new Error), false); - assert.strictEqual(isNil(_), false); - assert.strictEqual(isNil(slice), false); - assert.strictEqual(isNil({ 'a': 1 }), false); - assert.strictEqual(isNil(1), false); - assert.strictEqual(isNil(/x/), false); - assert.strictEqual(isNil('a'), false); - - if (Symbol) { - assert.strictEqual(isNil(symbol), false); - } - }); - - it('should work with nils from another realm', function() { - if (realm.object) { - assert.strictEqual(isNil(realm.null), true); - assert.strictEqual(isNil(realm.undefined), true); - } - }); -}); diff --git a/libs/nanofn/test/isNull.test.js b/libs/nanofn/test/isNull.test.js deleted file mode 100644 index 239e4c826..000000000 --- a/libs/nanofn/test/isNull.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isNull from '../isNull.js'; - -describe('isNull', function() { - it('should return `true` for `null` values', function() { - assert.strictEqual(isNull(null), true); - }); - - it('should return `false` for non `null` values', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === null; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isNull(value) : isNull(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isNull(args), false); - assert.strictEqual(isNull([1, 2, 3]), false); - assert.strictEqual(isNull(true), false); - assert.strictEqual(isNull(new Date), false); - assert.strictEqual(isNull(new Error), false); - assert.strictEqual(isNull(_), false); - assert.strictEqual(isNull(slice), false); - assert.strictEqual(isNull({ 'a': 1 }), false); - assert.strictEqual(isNull(1), false); - assert.strictEqual(isNull(/x/), false); - assert.strictEqual(isNull('a'), false); - assert.strictEqual(isNull(symbol), false); - }); - - it('should work with nulls from another realm', function() { - if (realm.object) { - assert.strictEqual(isNull(realm.null), true); - } - }); -}); diff --git a/libs/nanofn/test/isNumber.test.js b/libs/nanofn/test/isNumber.test.js deleted file mode 100644 index fd9ff6bb3..000000000 --- a/libs/nanofn/test/isNumber.test.js +++ /dev/null @@ -1,42 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isNumber from '../isNumber.js'; - -describe('isNumber', function() { - it('should return `true` for numbers', function() { - assert.strictEqual(isNumber(0), true); - assert.strictEqual(isNumber(Object(0)), true); - assert.strictEqual(isNumber(NaN), true); - }); - - it('should return `false` for non-numbers', function() { - var expected = lodashStable.map(falsey, function(value) { - return typeof value === 'number'; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isNumber(value) : isNumber(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isNumber(args), false); - assert.strictEqual(isNumber([1, 2, 3]), false); - assert.strictEqual(isNumber(true), false); - assert.strictEqual(isNumber(new Date), false); - assert.strictEqual(isNumber(new Error), false); - assert.strictEqual(isNumber(_), false); - assert.strictEqual(isNumber(slice), false); - assert.strictEqual(isNumber({ 'a': 1 }), false); - assert.strictEqual(isNumber(/x/), false); - assert.strictEqual(isNumber('a'), false); - assert.strictEqual(isNumber(symbol), false); - }); - - it('should work with numbers from another realm', function() { - if (realm.number) { - assert.strictEqual(isNumber(realm.number), true); - } - }); -}); diff --git a/libs/nanofn/test/isObject.test.js b/libs/nanofn/test/isObject.test.js deleted file mode 100644 index 8e24f532a..000000000 --- a/libs/nanofn/test/isObject.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, slice, document, body, symbol, falsey, stubFalse, realm } from './utils.js'; -import isObject from '../isObject.js'; - -describe('isObject', function() { - it('should return `true` for objects', function() { - assert.strictEqual(isObject(args), true); - assert.strictEqual(isObject([1, 2, 3]), true); - assert.strictEqual(isObject(Object(false)), true); - assert.strictEqual(isObject(new Date), true); - assert.strictEqual(isObject(new Error), true); - assert.strictEqual(isObject(_), true); - assert.strictEqual(isObject(slice), true); - assert.strictEqual(isObject({ 'a': 1 }), true); - assert.strictEqual(isObject(Object(0)), true); - assert.strictEqual(isObject(/x/), true); - assert.strictEqual(isObject(Object('a')), true); - - if (document) { - assert.strictEqual(isObject(body), true); - } - if (Symbol) { - assert.strictEqual(isObject(Object(symbol)), true); - } - }); - - it('should return `false` for non-objects', function() { - var values = falsey.concat(true, 1, 'a', symbol), - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value, index) { - return index ? isObject(value) : isObject(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with objects from another realm', function() { - if (realm.element) { - assert.strictEqual(isObject(realm.element), true); - } - if (realm.object) { - assert.strictEqual(isObject(realm.boolean), true); - assert.strictEqual(isObject(realm.date), true); - assert.strictEqual(isObject(realm.function), true); - assert.strictEqual(isObject(realm.number), true); - assert.strictEqual(isObject(realm.object), true); - assert.strictEqual(isObject(realm.regexp), true); - assert.strictEqual(isObject(realm.string), true); - } - }); -}); diff --git a/libs/nanofn/test/isObjectLike.test.js b/libs/nanofn/test/isObjectLike.test.js deleted file mode 100644 index 516d87b23..000000000 --- a/libs/nanofn/test/isObjectLike.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, falsey, slice, symbol, stubFalse, realm } from './utils.js'; -import isObjectLike from '../isObjectLike.js'; - -describe('isObjectLike', function() { - it('should return `true` for objects', function() { - assert.strictEqual(isObjectLike(args), true); - assert.strictEqual(isObjectLike([1, 2, 3]), true); - assert.strictEqual(isObjectLike(Object(false)), true); - assert.strictEqual(isObjectLike(new Date), true); - assert.strictEqual(isObjectLike(new Error), true); - assert.strictEqual(isObjectLike({ 'a': 1 }), true); - assert.strictEqual(isObjectLike(Object(0)), true); - assert.strictEqual(isObjectLike(/x/), true); - assert.strictEqual(isObjectLike(Object('a')), true); - }); - - it('should return `false` for non-objects', function() { - var values = falsey.concat(true, _, slice, 1, 'a', symbol), - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value, index) { - return index ? isObjectLike(value) : isObjectLike(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with objects from another realm', function() { - if (realm.object) { - assert.strictEqual(isObjectLike(realm.boolean), true); - assert.strictEqual(isObjectLike(realm.date), true); - assert.strictEqual(isObjectLike(realm.number), true); - assert.strictEqual(isObjectLike(realm.object), true); - assert.strictEqual(isObjectLike(realm.regexp), true); - assert.strictEqual(isObjectLike(realm.string), true); - } - }); -}); diff --git a/libs/nanofn/test/isPlainObject.js b/libs/nanofn/test/isPlainObject.js deleted file mode 100644 index a50ba7b98..000000000 --- a/libs/nanofn/test/isPlainObject.js +++ /dev/null @@ -1,114 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - document, - create, - objectProto, - falsey, - stubFalse, - symbol, - defineProperty, - realm, -} from './utils.js'; - -import isPlainObject from '../isPlainObject.js'; - -describe('isPlainObject', function() { - var element = document && document.createElement('div'); - - it('should detect plain objects', function() { - function Foo(a) { - this.a = 1; - } - - assert.strictEqual(isPlainObject({}), true); - assert.strictEqual(isPlainObject({ 'a': 1 }), true); - assert.strictEqual(isPlainObject({ 'constructor': Foo }), true); - assert.strictEqual(isPlainObject([1, 2, 3]), false); - assert.strictEqual(isPlainObject(new Foo(1)), false); - }); - - it('should return `true` for objects with a `[[Prototype]]` of `null`', function() { - var object = create(null); - assert.strictEqual(isPlainObject(object), true); - - object.constructor = objectProto.constructor; - assert.strictEqual(isPlainObject(object), true); - }); - - it('should return `true` for objects with a `valueOf` property', function() { - assert.strictEqual(isPlainObject({ 'valueOf': 0 }), true); - }); - - it('should return `true` for objects with a writable `Symbol.toStringTag` property', function() { - if (Symbol && Symbol.toStringTag) { - var object = {}; - object[Symbol.toStringTag] = 'X'; - - assert.deepStrictEqual(isPlainObject(object), true); - } - }); - - it('should return `false` for objects with a custom `[[Prototype]]`', function() { - var object = create({ 'a': 1 }); - assert.strictEqual(isPlainObject(object), false); - }); - - it('should return `false` for DOM elements', function() { - if (element) { - assert.strictEqual(isPlainObject(element), false); - } - }); - - it('should return `false` for non-Object objects', function() { - assert.strictEqual(isPlainObject(arguments), false); - assert.strictEqual(isPlainObject(Error), false); - assert.strictEqual(isPlainObject(Math), false); - }); - - it('should return `false` for non-objects', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isPlainObject(value) : isPlainObject(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isPlainObject(true), false); - assert.strictEqual(isPlainObject('a'), false); - assert.strictEqual(isPlainObject(symbol), false); - }); - - it('should return `false` for objects with a read-only `Symbol.toStringTag` property', function() { - if (Symbol && Symbol.toStringTag) { - var object = {}; - defineProperty(object, Symbol.toStringTag, { - 'configurable': true, - 'enumerable': false, - 'writable': false, - 'value': 'X' - }); - - assert.deepStrictEqual(isPlainObject(object), false); - } - }); - - it('should not mutate `value`', function() { - if (Symbol && Symbol.toStringTag) { - var proto = {}; - proto[Symbol.toStringTag] = undefined; - var object = create(proto); - - assert.strictEqual(isPlainObject(object), false); - assert.ok(!lodashStable.has(object, Symbol.toStringTag)); - } - }); - - it('should work with objects from another realm', function() { - if (realm.object) { - assert.strictEqual(isPlainObject(realm.object), true); - } - }); -}); diff --git a/libs/nanofn/test/isRegExp.test.js b/libs/nanofn/test/isRegExp.test.js deleted file mode 100644 index 507cdd474..000000000 --- a/libs/nanofn/test/isRegExp.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isRegExp from '../isRegExp.js'; - -describe('isRegExp', function() { - it('should return `true` for regexes', function() { - assert.strictEqual(isRegExp(/x/), true); - assert.strictEqual(isRegExp(RegExp('x')), true); - }); - - it('should return `false` for non-regexes', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isRegExp(value) : isRegExp(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isRegExp(args), false); - assert.strictEqual(isRegExp([1, 2, 3]), false); - assert.strictEqual(isRegExp(true), false); - assert.strictEqual(isRegExp(new Date), false); - assert.strictEqual(isRegExp(new Error), false); - assert.strictEqual(isRegExp(_), false); - assert.strictEqual(isRegExp(slice), false); - assert.strictEqual(isRegExp({ 'a': 1 }), false); - assert.strictEqual(isRegExp(1), false); - assert.strictEqual(isRegExp('a'), false); - assert.strictEqual(isRegExp(symbol), false); - }); - - it('should work with regexes from another realm', function() { - if (realm.regexp) { - assert.strictEqual(isRegExp(realm.regexp), true); - } - }); -}); diff --git a/libs/nanofn/test/isSet.test.js b/libs/nanofn/test/isSet.test.js deleted file mode 100644 index 49d9d9065..000000000 --- a/libs/nanofn/test/isSet.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { set, falsey, stubFalse, args, slice, symbol, weakSet, realm } from './utils.js'; -import isSet from '../isSet.js'; - -describe('isSet', function() { - it('should return `true` for sets', function() { - if (Set) { - assert.strictEqual(isSet(set), true); - } - }); - - it('should return `false` for non-sets', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isSet(value) : isSet(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isSet(args), false); - assert.strictEqual(isSet([1, 2, 3]), false); - assert.strictEqual(isSet(true), false); - assert.strictEqual(isSet(new Date), false); - assert.strictEqual(isSet(new Error), false); - assert.strictEqual(isSet(_), false); - assert.strictEqual(isSet(slice), false); - assert.strictEqual(isSet({ 'a': 1 }), false); - assert.strictEqual(isSet(1), false); - assert.strictEqual(isSet(/x/), false); - assert.strictEqual(isSet('a'), false); - assert.strictEqual(isSet(symbol), false); - assert.strictEqual(isSet(weakSet), false); - }); - - it('should work for objects with a non-function `constructor` (test in IE 11)', function() { - var values = [false, true], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - return isSet({ 'constructor': value }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with weak sets from another realm', function() { - if (realm.set) { - assert.strictEqual(isSet(realm.set), true); - } - }); -}); diff --git a/libs/nanofn/test/isString.test.js b/libs/nanofn/test/isString.test.js deleted file mode 100644 index e046d507f..000000000 --- a/libs/nanofn/test/isString.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isString from '../isString.js'; - -describe('isString', function() { - it('should return `true` for strings', function() { - assert.strictEqual(isString('a'), true); - assert.strictEqual(isString(Object('a')), true); - }); - - it('should return `false` for non-strings', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === ''; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isString(value) : isString(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isString(args), false); - assert.strictEqual(isString([1, 2, 3]), false); - assert.strictEqual(isString(true), false); - assert.strictEqual(isString(new Date), false); - assert.strictEqual(isString(new Error), false); - assert.strictEqual(isString(_), false); - assert.strictEqual(isString(slice), false); - assert.strictEqual(isString({ '0': 1, 'length': 1 }), false); - assert.strictEqual(isString(1), false); - assert.strictEqual(isString(/x/), false); - assert.strictEqual(isString(symbol), false); - }); - - it('should work with strings from another realm', function() { - if (realm.string) { - assert.strictEqual(isString(realm.string), true); - } - }); -}); diff --git a/libs/nanofn/test/isSymbol.test.js b/libs/nanofn/test/isSymbol.test.js deleted file mode 100644 index bf546c649..000000000 --- a/libs/nanofn/test/isSymbol.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { symbol, falsey, stubFalse, args, slice, realm } from './utils.js'; -import isSymbol from '../isSymbol.js'; - -describe('isSymbol', function() { - it('should return `true` for symbols', function() { - if (Symbol) { - assert.strictEqual(isSymbol(symbol), true); - assert.strictEqual(isSymbol(Object(symbol)), true); - } - }); - - it('should return `false` for non-symbols', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isSymbol(value) : isSymbol(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isSymbol(args), false); - assert.strictEqual(isSymbol([1, 2, 3]), false); - assert.strictEqual(isSymbol(true), false); - assert.strictEqual(isSymbol(new Date), false); - assert.strictEqual(isSymbol(new Error), false); - assert.strictEqual(isSymbol(_), false); - assert.strictEqual(isSymbol(slice), false); - assert.strictEqual(isSymbol({ '0': 1, 'length': 1 }), false); - assert.strictEqual(isSymbol(1), false); - assert.strictEqual(isSymbol(/x/), false); - assert.strictEqual(isSymbol('a'), false); - }); - - it('should work with symbols from another realm', function() { - if (Symbol && realm.symbol) { - assert.strictEqual(isSymbol(realm.symbol), true); - } - }); -}); diff --git a/libs/nanofn/test/isType-checks.js b/libs/nanofn/test/isType-checks.js deleted file mode 100644 index 909669721..000000000 --- a/libs/nanofn/test/isType-checks.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { objToString, objectTag, _, xml } from './utils.js'; - -describe('isType checks', function() { - it('should return `false` for subclassed values', function() { - var funcs = [ - 'isArray', 'isBoolean', 'isDate', 'isFunction', - 'isNumber', 'isRegExp', 'isString' - ]; - - lodashStable.each(funcs, function(methodName) { - function Foo() {} - Foo.prototype = root[methodName.slice(2)].prototype; - - var object = new Foo; - if (objToString.call(object) == objectTag) { - assert.strictEqual(_[methodName](object), false, '`_.' + methodName + '` returns `false`'); - } - }); - }); - - it('should not error on host objects (test in IE)', function() { - var funcs = [ - 'isArguments', 'isArray', 'isArrayBuffer', 'isArrayLike', 'isBoolean', - 'isBuffer', 'isDate', 'isElement', 'isError', 'isFinite', 'isFunction', - 'isInteger', 'isMap', 'isNaN', 'isNil', 'isNull', 'isNumber', 'isObject', - 'isObjectLike', 'isRegExp', 'isSet', 'isSafeInteger', 'isString', - 'isUndefined', 'isWeakMap', 'isWeakSet' - ]; - - lodashStable.each(funcs, function(methodName) { - if (xml) { - _[methodName](xml); - assert.ok(true, '`_.' + methodName + '` should not error'); - } - }); - }); -}); diff --git a/libs/nanofn/test/isTypedArray.js b/libs/nanofn/test/isTypedArray.js deleted file mode 100644 index 3c0d8be2e..000000000 --- a/libs/nanofn/test/isTypedArray.js +++ /dev/null @@ -1,59 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { typedArrays, falsey, stubFalse, args, slice, symbol, realm } from './utils.js'; -import isTypedArray from '../isTypedArray.js'; - -describe('isTypedArray', function() { - it('should return `true` for typed arrays', function() { - var expected = lodashStable.map(typedArrays, function(type) { - return type in root; - }); - - var actual = lodashStable.map(typedArrays, function(type) { - var Ctor = root[type]; - return Ctor ? isTypedArray(new Ctor(new ArrayBuffer(8))) : false; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `false` for non typed arrays', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isTypedArray(value) : isTypedArray(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isTypedArray(args), false); - assert.strictEqual(isTypedArray([1, 2, 3]), false); - assert.strictEqual(isTypedArray(true), false); - assert.strictEqual(isTypedArray(new Date), false); - assert.strictEqual(isTypedArray(new Error), false); - assert.strictEqual(isTypedArray(_), false); - assert.strictEqual(isTypedArray(slice), false); - assert.strictEqual(isTypedArray({ 'a': 1 }), false); - assert.strictEqual(isTypedArray(1), false); - assert.strictEqual(isTypedArray(/x/), false); - assert.strictEqual(isTypedArray('a'), false); - assert.strictEqual(isTypedArray(symbol), false); - }); - - it('should work with typed arrays from another realm', function() { - if (realm.object) { - var props = lodashStable.invokeMap(typedArrays, 'toLowerCase'); - - var expected = lodashStable.map(props, function(key) { - return realm[key] !== undefined; - }); - - var actual = lodashStable.map(props, function(key) { - var value = realm[key]; - return value ? isTypedArray(value) : false; - }); - - assert.deepStrictEqual(actual, expected); - } - }); -}); diff --git a/libs/nanofn/test/isUndefined.test.js b/libs/nanofn/test/isUndefined.test.js deleted file mode 100644 index 4f8c1fceb..000000000 --- a/libs/nanofn/test/isUndefined.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, args, slice, symbol, realm } from './utils.js'; -import isUndefined from '../isUndefined.js'; - -describe('isUndefined', function() { - it('should return `true` for `undefined` values', function() { - assert.strictEqual(isUndefined(), true); - assert.strictEqual(isUndefined(undefined), true); - }); - - it('should return `false` for non `undefined` values', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined; - }); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isUndefined(value) : isUndefined(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isUndefined(args), false); - assert.strictEqual(isUndefined([1, 2, 3]), false); - assert.strictEqual(isUndefined(true), false); - assert.strictEqual(isUndefined(new Date), false); - assert.strictEqual(isUndefined(new Error), false); - assert.strictEqual(isUndefined(_), false); - assert.strictEqual(isUndefined(slice), false); - assert.strictEqual(isUndefined({ 'a': 1 }), false); - assert.strictEqual(isUndefined(1), false); - assert.strictEqual(isUndefined(/x/), false); - assert.strictEqual(isUndefined('a'), false); - - if (Symbol) { - assert.strictEqual(isUndefined(symbol), false); - } - }); - - it('should work with `undefined` from another realm', function() { - if (realm.object) { - assert.strictEqual(isUndefined(realm.undefined), true); - } - }); -}); diff --git a/libs/nanofn/test/isWeakMap.test.js b/libs/nanofn/test/isWeakMap.test.js deleted file mode 100644 index f0c153207..000000000 --- a/libs/nanofn/test/isWeakMap.test.js +++ /dev/null @@ -1,53 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { weakMap, falsey, stubFalse, args, slice, map, symbol, realm } from './utils.js'; -import isWeakMap from '../isWeakMap.js'; - -describe('isWeakMap', function() { - it('should return `true` for weak maps', function() { - if (WeakMap) { - assert.strictEqual(isWeakMap(weakMap), true); - } - }); - - it('should return `false` for non weak maps', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isWeakMap(value) : isWeakMap(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isWeakMap(args), false); - assert.strictEqual(isWeakMap([1, 2, 3]), false); - assert.strictEqual(isWeakMap(true), false); - assert.strictEqual(isWeakMap(new Date), false); - assert.strictEqual(isWeakMap(new Error), false); - assert.strictEqual(isWeakMap(_), false); - assert.strictEqual(isWeakMap(slice), false); - assert.strictEqual(isWeakMap({ 'a': 1 }), false); - assert.strictEqual(isWeakMap(map), false); - assert.strictEqual(isWeakMap(1), false); - assert.strictEqual(isWeakMap(/x/), false); - assert.strictEqual(isWeakMap('a'), false); - assert.strictEqual(isWeakMap(symbol), false); - }); - - it('should work for objects with a non-function `constructor` (test in IE 11)', function() { - var values = [false, true], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - return isWeakMap({ 'constructor': value }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with weak maps from another realm', function() { - if (realm.weakMap) { - assert.strictEqual(isWeakMap(realm.weakMap), true); - } - }); -}); diff --git a/libs/nanofn/test/isWeakSet.test.js b/libs/nanofn/test/isWeakSet.test.js deleted file mode 100644 index a974bf1f5..000000000 --- a/libs/nanofn/test/isWeakSet.test.js +++ /dev/null @@ -1,42 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { weakSet, falsey, stubFalse, args, slice, set, symbol, realm } from './utils.js'; -import isWeakSet from '../isWeakSet.js'; - -describe('isWeakSet', function() { - it('should return `true` for weak sets', function() { - if (WeakSet) { - assert.strictEqual(isWeakSet(weakSet), true); - } - }); - - it('should return `false` for non weak sets', function() { - var expected = lodashStable.map(falsey, stubFalse); - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? isWeakSet(value) : isWeakSet(); - }); - - assert.deepStrictEqual(actual, expected); - - assert.strictEqual(isWeakSet(args), false); - assert.strictEqual(isWeakSet([1, 2, 3]), false); - assert.strictEqual(isWeakSet(true), false); - assert.strictEqual(isWeakSet(new Date), false); - assert.strictEqual(isWeakSet(new Error), false); - assert.strictEqual(isWeakSet(_), false); - assert.strictEqual(isWeakSet(slice), false); - assert.strictEqual(isWeakSet({ 'a': 1 }), false); - assert.strictEqual(isWeakSet(1), false); - assert.strictEqual(isWeakSet(/x/), false); - assert.strictEqual(isWeakSet('a'), false); - assert.strictEqual(isWeakSet(set), false); - assert.strictEqual(isWeakSet(symbol), false); - }); - - it('should work with weak sets from another realm', function() { - if (realm.weakSet) { - assert.strictEqual(isWeakSet(realm.weakSet), true); - } - }); -}); diff --git a/libs/nanofn/test/iteratee.js b/libs/nanofn/test/iteratee.js deleted file mode 100644 index fd653dd2e..000000000 --- a/libs/nanofn/test/iteratee.js +++ /dev/null @@ -1,164 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, _, isNpm, push, stubFalse } from './utils.js'; -import partial from '../partial.js'; -import partialRight from '../partialRight.js'; -import map from '../map.js'; - -describe('iteratee', function() { - it('should provide arguments to `func`', function() { - var fn = function() { return slice.call(arguments); }, - iteratee = _.iteratee(fn), - actual = iteratee('a', 'b', 'c', 'd', 'e', 'f'); - - assert.deepStrictEqual(actual, ['a', 'b', 'c', 'd', 'e', 'f']); - }); - - it('should return `_.identity` when `func` is nullish', function() { - var object = {}, - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([!isNpm && _.identity, object])); - - var actual = lodashStable.map(values, function(value, index) { - var identity = index ? _.iteratee(value) : _.iteratee(); - return [!isNpm && identity, identity(object)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an iteratee created by `_.matches` when `func` is an object', function() { - var matches = _.iteratee({ 'a': 1, 'b': 2 }); - assert.strictEqual(matches({ 'a': 1, 'b': 2, 'c': 3 }), true); - assert.strictEqual(matches({ 'b': 2 }), false); - }); - - it('should not change `_.matches` behavior if `source` is modified', function() { - var sources = [ - { 'a': { 'b': 2, 'c': 3 } }, - { 'a': 1, 'b': 2 }, - { 'a': 1 } - ]; - - lodashStable.each(sources, function(source, index) { - var object = lodashStable.cloneDeep(source), - matches = _.iteratee(source); - - assert.strictEqual(matches(object), true); - - if (index) { - source.a = 2; - source.b = 1; - source.c = 3; - } else { - source.a.b = 1; - source.a.c = 2; - source.a.d = 3; - } - assert.strictEqual(matches(object), true); - assert.strictEqual(matches(source), false); - }); - }); - - it('should return an iteratee created by `_.matchesProperty` when `func` is an array', function() { - var array = ['a', undefined], - matches = _.iteratee([0, 'a']); - - assert.strictEqual(matches(array), true); - - matches = _.iteratee(['0', 'a']); - assert.strictEqual(matches(array), true); - - matches = _.iteratee([1, undefined]); - assert.strictEqual(matches(array), true); - }); - - it('should support deep paths for `_.matchesProperty` shorthands', function() { - var object = { 'a': { 'b': { 'c': 1, 'd': 2 } } }, - matches = _.iteratee(['a.b', { 'c': 1 }]); - - assert.strictEqual(matches(object), true); - }); - - it('should not change `_.matchesProperty` behavior if `source` is modified', function() { - var sources = [ - { 'a': { 'b': 2, 'c': 3 } }, - { 'a': 1, 'b': 2 }, - { 'a': 1 } - ]; - - lodashStable.each(sources, function(source, index) { - var object = { 'a': lodashStable.cloneDeep(source) }, - matches = _.iteratee(['a', source]); - - assert.strictEqual(matches(object), true); - - if (index) { - source.a = 2; - source.b = 1; - source.c = 3; - } else { - source.a.b = 1; - source.a.c = 2; - source.a.d = 3; - } - assert.strictEqual(matches(object), true); - assert.strictEqual(matches({ 'a': source }), false); - }); - }); - - it('should return an iteratee created by `_.property` when `func` is a number or string', function() { - var array = ['a'], - prop = _.iteratee(0); - - assert.strictEqual(prop(array), 'a'); - - prop = _.iteratee('0'); - assert.strictEqual(prop(array), 'a'); - }); - - it('should support deep paths for `_.property` shorthands', function() { - var object = { 'a': { 'b': 2 } }, - prop = _.iteratee('a.b'); - - assert.strictEqual(prop(object), 2); - }); - - it('should work with functions created by `_.partial` and `_.partialRight`', function() { - var fn = function() { - var result = [this.a]; - push.apply(result, arguments); - return result; - }; - - var expected = [1, 2, 3], - object = { 'a': 1 , 'iteratee': _.iteratee(partial(fn, 2)) }; - - assert.deepStrictEqual(object.iteratee(3), expected); - - object.iteratee = _.iteratee(partialRight(fn, 3)); - assert.deepStrictEqual(object.iteratee(2), expected); - }); - - it('should use internal `iteratee` if external is unavailable', function() { - var iteratee = _.iteratee; - delete _.iteratee; - - assert.deepStrictEqual(map([{ 'a': 1 }], 'a'), [1]); - - _.iteratee = iteratee; - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var fn = function() { return this instanceof Number; }, - array = [fn, fn, fn], - iteratees = lodashStable.map(array, _.iteratee), - expected = lodashStable.map(array, stubFalse); - - var actual = lodashStable.map(iteratees, function(iteratee) { - return iteratee(); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/iteration-methods.js b/libs/nanofn/test/iteration-methods.js deleted file mode 100644 index 67c73e821..000000000 --- a/libs/nanofn/test/iteration-methods.js +++ /dev/null @@ -1,340 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, slice, isNpm, noop, MAX_SAFE_INTEGER, stubTrue } from './utils.js'; - -describe('iteration methods', function() { - var methods = [ - '_baseEach', - 'countBy', - 'every', - 'filter', - 'find', - 'findIndex', - 'findKey', - 'findLast', - 'findLastIndex', - 'findLastKey', - 'forEach', - 'forEachRight', - 'forIn', - 'forInRight', - 'forOwn', - 'forOwnRight', - 'groupBy', - 'keyBy', - 'map', - 'mapKeys', - 'mapValues', - 'maxBy', - 'minBy', - 'omitBy', - 'partition', - 'pickBy', - 'reject', - 'some' - ]; - - var arrayMethods = [ - 'findIndex', - 'findLastIndex', - 'maxBy', - 'minBy' - ]; - - var collectionMethods = [ - '_baseEach', - 'countBy', - 'every', - 'filter', - 'find', - 'findLast', - 'forEach', - 'forEachRight', - 'groupBy', - 'keyBy', - 'map', - 'partition', - 'reduce', - 'reduceRight', - 'reject', - 'some' - ]; - - var forInMethods = [ - 'forIn', - 'forInRight', - 'omitBy', - 'pickBy' - ]; - - var iterationMethods = [ - '_baseEach', - 'forEach', - 'forEachRight', - 'forIn', - 'forInRight', - 'forOwn', - 'forOwnRight' - ]; - - var objectMethods = [ - 'findKey', - 'findLastKey', - 'forIn', - 'forInRight', - 'forOwn', - 'forOwnRight', - 'mapKeys', - 'mapValues', - 'omitBy', - 'pickBy' - ]; - - var rightMethods = [ - 'findLast', - 'findLastIndex', - 'findLastKey', - 'forEachRight', - 'forInRight', - 'forOwnRight' - ]; - - var unwrappedMethods = [ - 'each', - 'eachRight', - 'every', - 'find', - 'findIndex', - 'findKey', - 'findLast', - 'findLastIndex', - 'findLastKey', - 'forEach', - 'forEachRight', - 'forIn', - 'forInRight', - 'forOwn', - 'forOwnRight', - 'max', - 'maxBy', - 'min', - 'minBy', - 'some' - ]; - - lodashStable.each(methods, function(methodName) { - var array = [1, 2, 3], - func = _[methodName], - isBy = /(^partition|By)$/.test(methodName), - isFind = /^find/.test(methodName), - isOmitPick = /^(?:omit|pick)By$/.test(methodName), - isSome = methodName == 'some'; - - it('`_.' + methodName + '` should provide correct iteratee arguments', function() { - if (func) { - var args, - expected = [1, 0, array]; - - func(array, function() { - args || (args = slice.call(arguments)); - }); - - if (lodashStable.includes(rightMethods, methodName)) { - expected[0] = 3; - expected[1] = 2; - } - if (lodashStable.includes(objectMethods, methodName)) { - expected[1] += ''; - } - if (isBy) { - expected.length = isOmitPick ? 2 : 1; - } - assert.deepStrictEqual(args, expected); - } - }); - - it('`_.' + methodName + '` should treat sparse arrays as dense', function() { - if (func) { - var array = [1]; - array[2] = 3; - - var expected = lodashStable.includes(objectMethods, methodName) - ? [[1, '0', array], [undefined, '1', array], [3, '2', array]] - : [[1, 0, array], [undefined, 1, array], [3, 2, array]]; - - if (isBy) { - expected = lodashStable.map(expected, function(args) { - return args.slice(0, isOmitPick ? 2 : 1); - }); - } - else if (lodashStable.includes(objectMethods, methodName)) { - expected = lodashStable.map(expected, function(args) { - args[1] += ''; - return args; - }); - } - if (lodashStable.includes(rightMethods, methodName)) { - expected.reverse(); - } - var argsList = []; - func(array, function() { - argsList.push(slice.call(arguments)); - return !(isFind || isSome); - }); - - assert.deepStrictEqual(argsList, expected); - } - }); - }); - - lodashStable.each(lodashStable.difference(methods, objectMethods), function(methodName) { - var array = [1, 2, 3], - func = _[methodName], - isEvery = methodName == 'every'; - - array.a = 1; - - it('`_.' + methodName + '` should not iterate custom properties on arrays', function() { - if (func) { - var keys = []; - func(array, function(value, key) { - keys.push(key); - return isEvery; - }); - - assert.ok(!lodashStable.includes(keys, 'a')); - } - }); - }); - - lodashStable.each(lodashStable.difference(methods, unwrappedMethods), function(methodName) { - var array = [1, 2, 3], - isBaseEach = methodName == '_baseEach'; - - it('`_.' + methodName + '` should return a wrapped value when implicitly chaining', function() { - if (!(isBaseEach || isNpm)) { - var wrapped = _(array)[methodName](noop); - assert.ok(wrapped instanceof _); - } - }); - }); - - lodashStable.each(unwrappedMethods, function(methodName) { - var array = [1, 2, 3]; - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var actual = _(array)[methodName](noop); - assert.notOk(actual instanceof _); - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() { - var wrapped = _(array).chain(), - actual = wrapped[methodName](noop); - - assert.ok(actual instanceof _); - assert.notStrictEqual(actual, wrapped); - }); - }); - - lodashStable.each(lodashStable.difference(methods, arrayMethods, forInMethods), function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` iterates over own string keyed properties of objects', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - if (func) { - var values = []; - func(new Foo, function(value) { values.push(value); }); - assert.deepStrictEqual(values, [1]); - } - }); - }); - - lodashStable.each(iterationMethods, function(methodName) { - var array = [1, 2, 3], - func = _[methodName]; - - it('`_.' + methodName + '` should return the collection', function() { - if (func) { - assert.strictEqual(func(array, Boolean), array); - } - }); - }); - - lodashStable.each(collectionMethods, function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should use `isArrayLike` to determine whether a value is array-like', function() { - if (func) { - var isIteratedAsObject = function(object) { - var result = false; - func(object, function() { result = true; }, 0); - return result; - }; - - var values = [-1, '1', 1.1, Object(1), MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(length) { - return isIteratedAsObject({ 'length': length }); - }); - - var Foo = function(a) {}; - Foo.a = 1; - - assert.deepStrictEqual(actual, expected); - assert.ok(isIteratedAsObject(Foo)); - assert.ok(!isIteratedAsObject({ 'length': 0 })); - } - }); - }); - - lodashStable.each(methods, function(methodName) { - var func = _[methodName], - isFind = /^find/.test(methodName), - isSome = methodName == 'some', - isReduce = /^reduce/.test(methodName); - - it('`_.' + methodName + '` should ignore changes to `length`', function() { - if (func) { - var count = 0, - array = [1]; - - func(array, function() { - if (++count == 1) { - array.push(2); - } - return !(isFind || isSome); - }, isReduce ? array : null); - - assert.strictEqual(count, 1); - } - }); - }); - - lodashStable.each(lodashStable.difference(lodashStable.union(methods, collectionMethods), arrayMethods), function(methodName) { - var func = _[methodName], - isFind = /^find/.test(methodName), - isSome = methodName == 'some', - isReduce = /^reduce/.test(methodName); - - it('`_.' + methodName + '` should ignore added `object` properties', function() { - if (func) { - var count = 0, - object = { 'a': 1 }; - - func(object, function() { - if (++count == 1) { - object.b = 2; - } - return !(isFind || isSome); - }, isReduce ? object : null); - - assert.strictEqual(count, 1); - } - }); - }); -}); diff --git a/libs/nanofn/test/join.js b/libs/nanofn/test/join.js deleted file mode 100644 index a8f672f8b..000000000 --- a/libs/nanofn/test/join.js +++ /dev/null @@ -1,20 +0,0 @@ -import assert from 'assert'; -import join from '../join.js'; - -describe('join', function() { - var array = ['a', 'b', 'c']; - - it('should return join all array elements into a string', function() { - assert.strictEqual(join(array, '~'), 'a~b~c'); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - var wrapped = _(array); - assert.strictEqual(wrapped.join('~'), 'a~b~c'); - assert.strictEqual(wrapped.value(), array); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_(array).chain().join('~') instanceof _); - }); -}); diff --git a/libs/nanofn/test/keyBy.js b/libs/nanofn/test/keyBy.js deleted file mode 100644 index 997c1015b..000000000 --- a/libs/nanofn/test/keyBy.js +++ /dev/null @@ -1,76 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE } from './utils.js'; -import keyBy from '../keyBy.js'; - -describe('keyBy', function() { - var array = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } - ]; - - it('should transform keys by `iteratee`', function() { - var expected = { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }; - - var actual = keyBy(array, function(object) { - return String.fromCharCode(object.code); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var array = [4, 6, 6], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant({ '4': 4, '6': 6 })); - - var actual = lodashStable.map(values, function(value, index) { - return index ? keyBy(array, value) : keyBy(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var expected = { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }, - actual = keyBy(array, 'dir'); - - assert.deepStrictEqual(actual, expected); - }); - - it('should only add values to own, not inherited, properties', function() { - var actual = keyBy([6.1, 4.2, 6.3], function(n) { - return Math.floor(n) > 4 ? 'hasOwnProperty' : 'constructor'; - }); - - assert.deepStrictEqual(actual.constructor, 4.2); - assert.deepStrictEqual(actual.hasOwnProperty, 6.3); - }); - - it('should work with a number for `iteratee`', function() { - var array = [ - [1, 'a'], - [2, 'a'], - [2, 'b'] - ]; - - assert.deepStrictEqual(keyBy(array, 0), { '1': [1, 'a'], '2': [2, 'b'] }); - assert.deepStrictEqual(keyBy(array, 1), { 'a': [2, 'a'], 'b': [2, 'b'] }); - }); - - it('should work with an object for `collection`', function() { - var actual = keyBy({ 'a': 6.1, 'b': 4.2, 'c': 6.3 }, Math.floor); - assert.deepStrictEqual(actual, { '4': 4.2, '6': 6.3 }); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE).concat( - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 2), LARGE_ARRAY_SIZE), - lodashStable.range(Math.floor(LARGE_ARRAY_SIZE / 1.5), LARGE_ARRAY_SIZE) - ); - - var actual = _(array).keyBy().map(square).filter(isEven).take().value(); - - assert.deepEqual(actual, _.take(_.filter(_.map(keyBy(array), square), isEven))); - }); -}); diff --git a/libs/nanofn/test/keys-methods.js b/libs/nanofn/test/keys-methods.js deleted file mode 100644 index e45e9b320..000000000 --- a/libs/nanofn/test/keys-methods.js +++ /dev/null @@ -1,183 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - _, - arrayProto, - args, - strictArgs, - objectProto, - stringProto, - primitives, - numberProto, - stubArray, -} from './utils.js'; - -describe('keys methods', function() { - lodashStable.each(['keys', 'keysIn'], function(methodName) { - var func = _[methodName], - isKeys = methodName == 'keys'; - - it('`_.' + methodName + '` should return the string keyed property names of `object`', function() { - var actual = func({ 'a': 1, 'b': 1 }).sort(); - - assert.deepStrictEqual(actual, ['a', 'b']); - }); - - it('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var expected = isKeys ? ['a'] : ['a', 'b'], - actual = func(new Foo).sort(); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should treat sparse arrays as dense', function() { - var array = [1]; - array[2] = 3; - - var actual = func(array).sort(); - - assert.deepStrictEqual(actual, ['0', '1', '2']); - }); - - it('`_.' + methodName + '` should return keys for custom properties on arrays', function() { - var array = [1]; - array.a = 1; - - var actual = func(array).sort(); - - assert.deepStrictEqual(actual, ['0', 'a']); - }); - - it('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of arrays', function() { - arrayProto.a = 1; - - var expected = isKeys ? ['0'] : ['0', 'a'], - actual = func([1]).sort(); - - assert.deepStrictEqual(actual, expected); - - delete arrayProto.a; - }); - - it('`_.' + methodName + '` should work with `arguments` objects', function() { - var values = [args, strictArgs], - expected = lodashStable.map(values, lodashStable.constant(['0', '1', '2'])); - - var actual = lodashStable.map(values, function(value) { - return func(value).sort(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return keys for custom properties on `arguments` objects', function() { - var values = [args, strictArgs], - expected = lodashStable.map(values, lodashStable.constant(['0', '1', '2', 'a'])); - - var actual = lodashStable.map(values, function(value) { - value.a = 1; - var result = func(value).sort(); - delete value.a; - return result; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of `arguments` objects', function() { - var values = [args, strictArgs], - expected = lodashStable.map(values, lodashStable.constant(isKeys ? ['0', '1', '2'] : ['0', '1', '2', 'a'])); - - var actual = lodashStable.map(values, function(value) { - objectProto.a = 1; - var result = func(value).sort(); - delete objectProto.a; - return result; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with string objects', function() { - var actual = func(Object('abc')).sort(); - - assert.deepStrictEqual(actual, ['0', '1', '2']); - }); - - it('`_.' + methodName + '` should return keys for custom properties on string objects', function() { - var object = Object('a'); - object.a = 1; - - var actual = func(object).sort(); - - assert.deepStrictEqual(actual, ['0', 'a']); - }); - - it('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of string objects', function() { - stringProto.a = 1; - - var expected = isKeys ? ['0'] : ['0', 'a'], - actual = func(Object('a')).sort(); - - assert.deepStrictEqual(actual, expected); - - delete stringProto.a; - }); - - it('`_.' + methodName + '` should work with array-like objects', function() { - var object = { '0': 'a', 'length': 1 }, - actual = func(object).sort(); - - assert.deepStrictEqual(actual, ['0', 'length']); - }); - - it('`_.' + methodName + '` should coerce primitives to objects (test in IE 9)', function() { - var expected = lodashStable.map(primitives, function(value) { - return typeof value === 'string' ? ['0'] : []; - }); - - var actual = lodashStable.map(primitives, func); - assert.deepStrictEqual(actual, expected); - - // IE 9 doesn't box numbers in for-in loops. - numberProto.a = 1; - assert.deepStrictEqual(func(0), isKeys ? [] : ['a']); - delete numberProto.a; - }); - - it('`_.' + methodName + '` skips the `constructor` property on prototype objects', function() { - function Foo() {} - Foo.prototype.a = 1; - - var expected = ['a']; - assert.deepStrictEqual(func(Foo.prototype), expected); - - Foo.prototype = { 'constructor': Foo, 'a': 1 }; - assert.deepStrictEqual(func(Foo.prototype), expected); - - var Fake = { 'prototype': {} }; - Fake.prototype.constructor = Fake; - assert.deepStrictEqual(func(Fake.prototype), ['constructor']); - }); - - it('`_.' + methodName + '` should return an empty array when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubArray); - - var actual = lodashStable.map(values, function(value, index) { - objectProto.a = 1; - var result = index ? func(value) : func(); - delete objectProto.a; - return result; - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/last.js b/libs/nanofn/test/last.js deleted file mode 100644 index fef570ec9..000000000 --- a/libs/nanofn/test/last.js +++ /dev/null @@ -1,51 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE } from './utils.js'; -import last from '../last.js'; - -describe('last', function() { - var array = [1, 2, 3, 4]; - - it('should return the last element', function() { - assert.strictEqual(last(array), 4); - }); - - it('should return `undefined` when querying empty arrays', function() { - var array = []; - array['-1'] = 1; - - assert.strictEqual(last([]), undefined); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, last); - - assert.deepStrictEqual(actual, [3, 6, 9]); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - assert.strictEqual(_(array).last(), 4); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_(array).chain().last() instanceof _); - }); - - it('should not execute immediately when explicitly chaining', function() { - var wrapped = _(array).chain().last(); - assert.strictEqual(wrapped.__wrapped__, array); - }); - - it('should work in a lazy sequence', function() { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE), - smallArray = array; - - lodashStable.times(2, function(index) { - var array = index ? largeArray : smallArray, - wrapped = _(array).filter(isEven); - - assert.strictEqual(wrapped.last(), last(_.filter(array, isEven))); - }); - }); -}); diff --git a/libs/nanofn/test/lodash(...)-methods-that-return-new-wrapped-values.js b/libs/nanofn/test/lodash(...)-methods-that-return-new-wrapped-values.js deleted file mode 100644 index b66c54c60..000000000 --- a/libs/nanofn/test/lodash(...)-methods-that-return-new-wrapped-values.js +++ /dev/null @@ -1,45 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -describe('lodash(...) methods that return new wrapped values', function() { - var funcs = [ - 'castArray', - 'concat', - 'difference', - 'differenceBy', - 'differenceWith', - 'intersection', - 'intersectionBy', - 'intersectionWith', - 'pull', - 'pullAll', - 'pullAt', - 'sampleSize', - 'shuffle', - 'slice', - 'splice', - 'split', - 'toArray', - 'union', - 'unionBy', - 'unionWith', - 'uniq', - 'uniqBy', - 'uniqWith', - 'words', - 'xor', - 'xorBy', - 'xorWith' - ]; - - lodashStable.each(funcs, function(methodName) { - it('`_(...).' + methodName + '` should return a new wrapped value', function() { - var value = methodName == 'split' ? 'abc' : [1, 2, 3], - wrapped = _(value), - actual = wrapped[methodName](); - - assert.ok(actual instanceof _); - assert.notStrictEqual(actual, wrapped); - }); - }); -}); diff --git a/libs/nanofn/test/lodash(...)-methods-that-return-the-wrapped-modified-array.js b/libs/nanofn/test/lodash(...)-methods-that-return-the-wrapped-modified-array.js deleted file mode 100644 index d58eeff84..000000000 --- a/libs/nanofn/test/lodash(...)-methods-that-return-the-wrapped-modified-array.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -describe('lodash(...) methods that return the wrapped modified array', function() { - var funcs = [ - 'push', - 'reverse', - 'sort', - 'unshift' - ]; - - lodashStable.each(funcs, function(methodName) { - it('`_(...).' + methodName + '` should return a new wrapper', function() { - var array = [1, 2, 3], - wrapped = _(array), - actual = wrapped[methodName](); - - assert.ok(actual instanceof _); - assert.notStrictEqual(actual, wrapped); - }); - }); -}); diff --git a/libs/nanofn/test/lodash(...)-methods-that-return-unwrapped-values.js b/libs/nanofn/test/lodash(...)-methods-that-return-unwrapped-values.js deleted file mode 100644 index 7b906e1ed..000000000 --- a/libs/nanofn/test/lodash(...)-methods-that-return-unwrapped-values.js +++ /dev/null @@ -1,112 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -describe('lodash(...) methods that return unwrapped values', function() { - var funcs = [ - 'add', - 'camelCase', - 'capitalize', - 'ceil', - 'clone', - 'deburr', - 'defaultTo', - 'divide', - 'endsWith', - 'escape', - 'escapeRegExp', - 'every', - 'find', - 'floor', - 'has', - 'hasIn', - 'head', - 'includes', - 'isArguments', - 'isArray', - 'isArrayBuffer', - 'isArrayLike', - 'isBoolean', - 'isBuffer', - 'isDate', - 'isElement', - 'isEmpty', - 'isEqual', - 'isError', - 'isFinite', - 'isFunction', - 'isInteger', - 'isMap', - 'isNaN', - 'isNative', - 'isNil', - 'isNull', - 'isNumber', - 'isObject', - 'isObjectLike', - 'isPlainObject', - 'isRegExp', - 'isSafeInteger', - 'isSet', - 'isString', - 'isUndefined', - 'isWeakMap', - 'isWeakSet', - 'join', - 'kebabCase', - 'last', - 'lowerCase', - 'lowerFirst', - 'max', - 'maxBy', - 'min', - 'minBy', - 'multiply', - 'nth', - 'pad', - 'padEnd', - 'padStart', - 'parseInt', - 'pop', - 'random', - 'reduce', - 'reduceRight', - 'repeat', - 'replace', - 'round', - 'sample', - 'shift', - 'size', - 'snakeCase', - 'some', - 'startCase', - 'startsWith', - 'subtract', - 'sum', - 'toFinite', - 'toInteger', - 'toLower', - 'toNumber', - 'toSafeInteger', - 'toString', - 'toUpper', - 'trim', - 'trimEnd', - 'trimStart', - 'truncate', - 'unescape', - 'upperCase', - 'upperFirst' - ]; - - lodashStable.each(funcs, function(methodName) { - it('`_(...).' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var actual = _()[methodName](); - assert.notOk(actual instanceof _); - }); - - it('`_(...).' + methodName + '` should return a wrapped value when explicitly chaining', function() { - var actual = _().chain()[methodName](); - assert.ok(actual instanceof _); - }); - }); -}); diff --git a/libs/nanofn/test/lodash(...).commit.js b/libs/nanofn/test/lodash(...).commit.js deleted file mode 100644 index 94a7acb08..000000000 --- a/libs/nanofn/test/lodash(...).commit.js +++ /dev/null @@ -1,21 +0,0 @@ -import assert from 'assert'; - -describe('lodash(...).commit', function() { - it('should execute the chained sequence and returns the wrapped result', function() { - var array = [1], - wrapped = _(array).push(2).push(3); - - assert.deepEqual(array, [1]); - - var otherWrapper = wrapped.commit(); - assert.ok(otherWrapper instanceof _); - assert.deepEqual(otherWrapper.value(), [1, 2, 3]); - assert.deepEqual(wrapped.value(), [1, 2, 3, 2, 3]); - }); - - it('should track the `__chain__` value of a wrapper', function() { - var wrapped = _([1]).chain().commit().head(); - assert.ok(wrapped instanceof _); - assert.strictEqual(wrapped.value(), 1); - }); -}); diff --git a/libs/nanofn/test/lodash(...).next.js b/libs/nanofn/test/lodash(...).next.js deleted file mode 100644 index e3019ba35..000000000 --- a/libs/nanofn/test/lodash(...).next.js +++ /dev/null @@ -1,74 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, isNpm, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import toArray from '../toArray.js'; -import filter from '../filter.js'; - -describe('lodash(...).next', function() { - lodashStable.each([false, true], function(implicit) { - function chain(value) { - return implicit ? _(value) : _.chain(value); - } - - var chainType = 'in an ' + (implicit ? 'implicit' : 'explict') + ' chain'; - - it('should follow the iterator protocol ' + chainType, function() { - var wrapped = chain([1, 2]); - - assert.deepEqual(wrapped.next(), { 'done': false, 'value': 1 }); - assert.deepEqual(wrapped.next(), { 'done': false, 'value': 2 }); - assert.deepEqual(wrapped.next(), { 'done': true, 'value': undefined }); - }); - - it('should act as an iterable ' + chainType, function() { - if (!isNpm && Symbol && Symbol.iterator) { - var array = [1, 2], - wrapped = chain(array); - - assert.strictEqual(wrapped[Symbol.iterator](), wrapped); - assert.deepStrictEqual(lodashStable.toArray(wrapped), array); - } - }); - - it('should use `_.toArray` to generate the iterable result ' + chainType, function() { - if (!isNpm && Array.from) { - var hearts = '\ud83d\udc95', - values = [[1], { 'a': 1 }, hearts]; - - lodashStable.each(values, function(value) { - var wrapped = chain(value); - assert.deepStrictEqual(Array.from(wrapped), toArray(value)); - }); - } - }); - - it('should reset the iterator correctly ' + chainType, function() { - if (!isNpm && Symbol && Symbol.iterator) { - var array = [1, 2], - wrapped = chain(array); - - assert.deepStrictEqual(lodashStable.toArray(wrapped), array); - assert.deepStrictEqual(lodashStable.toArray(wrapped), [], 'produces an empty array for exhausted iterator'); - - var other = wrapped.filter(); - assert.deepStrictEqual(lodashStable.toArray(other), array, 'reset for new chain segments'); - assert.deepStrictEqual(lodashStable.toArray(wrapped), [], 'iterator is still exhausted'); - } - }); - - it('should work in a lazy sequence ' + chainType, function() { - if (!isNpm && Symbol && Symbol.iterator) { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - predicate = function(value) { values.push(value); return isEven(value); }, - values = [], - wrapped = chain(array); - - assert.deepStrictEqual(lodashStable.toArray(wrapped), array); - - wrapped = wrapped.filter(predicate); - assert.deepStrictEqual(lodashStable.toArray(wrapped), filter(array, isEven), 'reset for new lazy chain segments'); - assert.deepStrictEqual(values, array, 'memoizes iterator values'); - } - }); - }); -}); diff --git a/libs/nanofn/test/lodash(...).plant.js b/libs/nanofn/test/lodash(...).plant.js deleted file mode 100644 index 191eecaa3..000000000 --- a/libs/nanofn/test/lodash(...).plant.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { square, isNpm } from './utils.js'; -import compact from '../compact.js'; - -describe('lodash(...).plant', function() { - it('should clone the chained sequence planting `value` as the wrapped value', function() { - var array1 = [5, null, 3, null, 1], - array2 = [10, null, 8, null, 6], - wrapped1 = _(array1).thru(compact).map(square).takeRight(2).sort(), - wrapped2 = wrapped1.plant(array2); - - assert.deepEqual(wrapped2.value(), [36, 64]); - assert.deepEqual(wrapped1.value(), [1, 9]); - }); - - it('should clone `chainAll` settings', function() { - var array1 = [2, 4], - array2 = [6, 8], - wrapped1 = _(array1).chain().map(square), - wrapped2 = wrapped1.plant(array2); - - assert.deepEqual(wrapped2.head().value(), 36); - }); - - it('should reset iterator data on cloned sequences', function() { - if (!isNpm && Symbol && Symbol.iterator) { - var array1 = [2, 4], - array2 = [6, 8], - wrapped1 = _(array1).map(square); - - assert.deepStrictEqual(lodashStable.toArray(wrapped1), [4, 16]); - assert.deepStrictEqual(lodashStable.toArray(wrapped1), []); - - var wrapped2 = wrapped1.plant(array2); - assert.deepStrictEqual(lodashStable.toArray(wrapped2), [36, 64]); - } - }); -}); diff --git a/libs/nanofn/test/lodash(...).pop.js b/libs/nanofn/test/lodash(...).pop.js deleted file mode 100644 index a06c0cb27..000000000 --- a/libs/nanofn/test/lodash(...).pop.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).pop', function() { - it('should remove elements from the end of `array`', function() { - var array = [1, 2], - wrapped = _(array); - - assert.strictEqual(wrapped.pop(), 2); - assert.deepEqual(wrapped.value(), [1]); - assert.strictEqual(wrapped.pop(), 1); - - var actual = wrapped.value(); - assert.strictEqual(actual, array); - assert.deepEqual(actual, []); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).pop() : _().pop(); - return result === undefined; - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).push.js b/libs/nanofn/test/lodash(...).push.js deleted file mode 100644 index f29b124cb..000000000 --- a/libs/nanofn/test/lodash(...).push.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).push', function() { - it('should append elements to `array`', function() { - var array = [1], - wrapped = _(array).push(2, 3), - actual = wrapped.value(); - - assert.strictEqual(actual, array); - assert.deepEqual(actual, [1, 2, 3]); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).push(1).value() : _().push(1).value(); - return lodashStable.eq(result, value); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).shift.js b/libs/nanofn/test/lodash(...).shift.js deleted file mode 100644 index b6920283a..000000000 --- a/libs/nanofn/test/lodash(...).shift.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).shift', function() { - it('should remove elements from the front of `array`', function() { - var array = [1, 2], - wrapped = _(array); - - assert.strictEqual(wrapped.shift(), 1); - assert.deepEqual(wrapped.value(), [2]); - assert.strictEqual(wrapped.shift(), 2); - - var actual = wrapped.value(); - assert.strictEqual(actual, array); - assert.deepEqual(actual, []); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).shift() : _().shift(); - return result === undefined; - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).sort.js b/libs/nanofn/test/lodash(...).sort.js deleted file mode 100644 index e10d5f5a2..000000000 --- a/libs/nanofn/test/lodash(...).sort.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).sort', function() { - it('should return the wrapped sorted `array`', function() { - var array = [3, 1, 2], - wrapped = _(array).sort(), - actual = wrapped.value(); - - assert.strictEqual(actual, array); - assert.deepEqual(actual, [1, 2, 3]); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).sort().value() : _().sort().value(); - return lodashStable.eq(result, value); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).splice.js b/libs/nanofn/test/lodash(...).splice.js deleted file mode 100644 index 8e300b39d..000000000 --- a/libs/nanofn/test/lodash(...).splice.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).splice', function() { - it('should support removing and inserting elements', function() { - var array = [1, 2], - wrapped = _(array); - - assert.deepEqual(wrapped.splice(1, 1, 3).value(), [2]); - assert.deepEqual(wrapped.value(), [1, 3]); - assert.deepEqual(wrapped.splice(0, 2).value(), [1, 3]); - - var actual = wrapped.value(); - assert.strictEqual(actual, array); - assert.deepEqual(actual, []); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).splice(0, 1).value() : _().splice(0, 1).value(); - return lodashStable.isEqual(result, []); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).unshift.js b/libs/nanofn/test/lodash(...).unshift.js deleted file mode 100644 index f679c4fd8..000000000 --- a/libs/nanofn/test/lodash(...).unshift.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubTrue } from './utils.js'; - -describe('lodash(...).unshift', function() { - it('should prepend elements to `array`', function() { - var array = [3], - wrapped = _(array).unshift(1, 2), - actual = wrapped.value(); - - assert.strictEqual(actual, array); - assert.deepEqual(actual, [1, 2, 3]); - }); - - it('should accept falsey arguments', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(value, index) { - try { - var result = index ? _(value).unshift(1).value() : _().unshift(1).value(); - return lodashStable.eq(result, value); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/lodash(...).value.js b/libs/nanofn/test/lodash(...).value.js deleted file mode 100644 index a883d23fc..000000000 --- a/libs/nanofn/test/lodash(...).value.js +++ /dev/null @@ -1,33 +0,0 @@ -import assert from 'assert'; -import { isNpm } from './utils.js'; -import prototype from '../prototype.js'; - -describe('lodash(...).value', function() { - it('should execute the chained sequence and extract the unwrapped value', function() { - var array = [1], - wrapped = _(array).push(2).push(3); - - assert.deepEqual(array, [1]); - assert.deepEqual(wrapped.value(), [1, 2, 3]); - assert.deepEqual(wrapped.value(), [1, 2, 3, 2, 3]); - assert.deepEqual(array, [1, 2, 3, 2, 3]); - }); - - it('should return the `valueOf` result of the wrapped value', function() { - var wrapped = _(123); - assert.strictEqual(Number(wrapped), 123); - }); - - it('should stringify the wrapped value when used by `JSON.stringify`', function() { - if (!isNpm && JSON) { - var wrapped = _([1, 2, 3]); - assert.strictEqual(JSON.stringify(wrapped), '[1,2,3]'); - } - }); - - it('should be aliased', function() { - var expected = prototype.value; - assert.strictEqual(prototype.toJSON, expected); - assert.strictEqual(prototype.valueOf, expected); - }); -}); diff --git a/libs/nanofn/test/lodash-constructor.js b/libs/nanofn/test/lodash-constructor.js deleted file mode 100644 index c59556eb7..000000000 --- a/libs/nanofn/test/lodash-constructor.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, stubTrue, isNpm, lodashBizarro } from './utils.js'; - -describe('lodash constructor', function() { - var values = empties.concat(true, 1, 'a'), - expected = lodashStable.map(values, stubTrue); - - it('should create a new instance when called without the `new` operator', function() { - var actual = lodashStable.map(values, function(value) { - return _(value) instanceof _; - }); - - assert.deepEqual(actual, expected); - }); - - it('should return the given `lodash` instances', function() { - var actual = lodashStable.map(values, function(value) { - var wrapped = _(value); - return _(wrapped) === wrapped; - }); - - assert.deepEqual(actual, expected); - }); - - it('should convert foreign wrapped values to `lodash` instances', function() { - if (!isNpm && lodashBizarro) { - var actual = lodashStable.map(values, function(value) { - var wrapped = _(lodashBizarro(value)), - unwrapped = wrapped.value(); - - return wrapped instanceof _ && - ((unwrapped === value) || (unwrapped !== unwrapped && value !== value)); - }); - - assert.deepStrictEqual(actual, expected); - } - }); -}); diff --git a/libs/nanofn/test/lodash-methods.js b/libs/nanofn/test/lodash-methods.js deleted file mode 100644 index 2a92a00ba..000000000 --- a/libs/nanofn/test/lodash-methods.js +++ /dev/null @@ -1,194 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, falsey, stubArray, oldDash, stubTrue, FUNC_ERROR_TEXT } from './utils.js'; -import functions from '../functions.js'; -import bind from '../bind.js'; - -describe('lodash methods', function() { - var allMethods = lodashStable.reject(functions(_).sort(), function(methodName) { - return lodashStable.startsWith(methodName, '_'); - }); - - var checkFuncs = [ - 'after', - 'ary', - 'before', - 'bind', - 'curry', - 'curryRight', - 'debounce', - 'defer', - 'delay', - 'flip', - 'flow', - 'flowRight', - 'memoize', - 'negate', - 'once', - 'partial', - 'partialRight', - 'rearg', - 'rest', - 'spread', - 'throttle', - 'unary' - ]; - - var noBinding = [ - 'flip', - 'memoize', - 'negate', - 'once', - 'overArgs', - 'partial', - 'partialRight', - 'rearg', - 'rest', - 'spread' - ]; - - var rejectFalsey = [ - 'tap', - 'thru' - ].concat(checkFuncs); - - var returnArrays = [ - 'at', - 'chunk', - 'compact', - 'difference', - 'drop', - 'filter', - 'flatten', - 'functions', - 'initial', - 'intersection', - 'invokeMap', - 'keys', - 'map', - 'orderBy', - 'pull', - 'pullAll', - 'pullAt', - 'range', - 'rangeRight', - 'reject', - 'remove', - 'shuffle', - 'sortBy', - 'tail', - 'take', - 'times', - 'toArray', - 'toPairs', - 'toPairsIn', - 'union', - 'uniq', - 'values', - 'without', - 'xor', - 'zip' - ]; - - var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey); - - it('should accept falsey arguments', function() { - var arrays = lodashStable.map(falsey, stubArray); - - lodashStable.each(acceptFalsey, function(methodName) { - var expected = arrays, - func = _[methodName]; - - var actual = lodashStable.map(falsey, function(value, index) { - return index ? func(value) : func(); - }); - - if (methodName == 'noConflict') { - root._ = oldDash; - } - else if (methodName == 'pull' || methodName == 'pullAll') { - expected = falsey; - } - if (lodashStable.includes(returnArrays, methodName) && methodName != 'sample') { - assert.deepStrictEqual(actual, expected, '_.' + methodName + ' returns an array'); - } - assert.ok(true, '`_.' + methodName + '` accepts falsey arguments'); - }); - - // Skip tests for missing methods of modularized builds. - lodashStable.each(['chain', 'noConflict', 'runInContext'], function(methodName) { - if (!_[methodName]) {} - }); - }); - - it('should return an array', function() { - var array = [1, 2, 3]; - - lodashStable.each(returnArrays, function(methodName) { - var actual, - func = _[methodName]; - - switch (methodName) { - case 'invokeMap': - actual = func(array, 'toFixed'); - break; - case 'sample': - actual = func(array, 1); - break; - default: - actual = func(array); - } - assert.ok(lodashStable.isArray(actual), '_.' + methodName + ' returns an array'); - - var isPull = methodName == 'pull' || methodName == 'pullAll'; - assert.strictEqual(actual === array, isPull, '_.' + methodName + ' should ' + (isPull ? '' : 'not ') + 'return the given array'); - }); - }); - - it('should throw an error for falsey arguments', function() { - lodashStable.each(rejectFalsey, function(methodName) { - var expected = lodashStable.map(falsey, stubTrue), - func = _[methodName]; - - var actual = lodashStable.map(falsey, function(value, index) { - var pass = !index && /^(?:backflow|compose|cond|flow(Right)?|over(?:Every|Some)?)$/.test(methodName); - - try { - index ? func(value) : func(); - } catch (e) { - pass = !pass && (e instanceof TypeError) && - (!lodashStable.includes(checkFuncs, methodName) || (e.message == FUNC_ERROR_TEXT)); - } - return pass; - }); - - assert.deepStrictEqual(actual, expected, '`_.' + methodName + '` rejects falsey arguments'); - }); - }); - - it('should use `this` binding of function', function() { - lodashStable.each(noBinding, function(methodName) { - var fn = function() { return this.a; }, - func = _[methodName], - isNegate = methodName == 'negate', - object = { 'a': 1 }, - expected = isNegate ? false : 1; - - var wrapper = func(bind(fn, object)); - assert.strictEqual(wrapper(), expected, '`_.' + methodName + '` can consume a bound function'); - - wrapper = bind(func(fn), object); - assert.strictEqual(wrapper(), expected, '`_.' + methodName + '` can be bound'); - - object.wrapper = func(fn); - assert.strictEqual(object.wrapper(), expected, '`_.' + methodName + '` uses the `this` of its parent object'); - }); - }); - - it('should not contain minified method names (test production builds)', function() { - var shortNames = ['_', 'at', 'eq', 'gt', 'lt']; - assert.ok(lodashStable.every(functions(_), function(methodName) { - return methodName.length > 2 || lodashStable.includes(shortNames, methodName); - })); - }); -}); diff --git a/libs/nanofn/test/lodash.methodName.js b/libs/nanofn/test/lodash.methodName.js deleted file mode 100644 index 632684595..000000000 --- a/libs/nanofn/test/lodash.methodName.js +++ /dev/null @@ -1,75 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, empties } from './utils.js'; - -lodashStable.each(['find', 'findIndex', 'findKey', 'findLast', 'findLastIndex', 'findLastKey'], function(methodName) { - describe('lodash.' + methodName); - - var array = [1, 2, 3, 4], - func = _[methodName]; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 1 }, - { 'a': 2, 'b': 2 } - ]; - - var expected = ({ - 'find': [objects[1], undefined, objects[2]], - 'findIndex': [1, -1, 2], - 'findKey': ['1', undefined, '2'], - 'findLast': [objects[2], undefined, objects[2]], - 'findLastIndex': [2, -1, 2], - 'findLastKey': ['2', undefined, '2'] - })[methodName]; - - it('`_.' + methodName + '` should return the found value', function() { - assert.strictEqual(func(objects, function(object) { return object.a; }), expected[0]); - }); - - it('`_.' + methodName + '` should return `' + expected[1] + '` if value is not found', function() { - assert.strictEqual(func(objects, function(object) { return object.a === 3; }), expected[1]); - }); - - it('`_.' + methodName + '` should work with `_.matches` shorthands', function() { - assert.strictEqual(func(objects, { 'b': 2 }), expected[2]); - }); - - it('`_.' + methodName + '` should work with `_.matchesProperty` shorthands', function() { - assert.strictEqual(func(objects, ['b', 2]), expected[2]); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - assert.strictEqual(func(objects, 'b'), expected[0]); - }); - - it('`_.' + methodName + '` should return `' + expected[1] + '` for empty collections', function() { - var emptyValues = lodashStable.endsWith(methodName, 'Index') ? lodashStable.reject(empties, lodashStable.isPlainObject) : empties, - expecting = lodashStable.map(emptyValues, lodashStable.constant(expected[1])); - - var actual = lodashStable.map(emptyValues, function(value) { - try { - return func(value, { 'a': 3 }); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expecting); - }); - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var expected = ({ - 'find': 1, - 'findIndex': 0, - 'findKey': '0', - 'findLast': 4, - 'findLastIndex': 3, - 'findLastKey': '3' - })[methodName]; - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() {}); - - it('`_.' + methodName + '` should not execute immediately when explicitly chaining', function() {}); - - it('`_.' + methodName + '` should work in a lazy sequence', function() {}); -}); diff --git a/libs/nanofn/test/lowerCase.test.js b/libs/nanofn/test/lowerCase.test.js deleted file mode 100644 index eca2b7726..000000000 --- a/libs/nanofn/test/lowerCase.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import lowerCase from '../lowerCase.js'; - -describe('lowerCase', function() { - it('should lowercase as space-separated words', function() { - assert.strictEqual(lowerCase('--Foo-Bar--'), 'foo bar'); - assert.strictEqual(lowerCase('fooBar'), 'foo bar'); - assert.strictEqual(lowerCase('__FOO_BAR__'), 'foo bar'); - }); -}); diff --git a/libs/nanofn/test/lowerFirst.test.js b/libs/nanofn/test/lowerFirst.test.js deleted file mode 100644 index 665e7e71e..000000000 --- a/libs/nanofn/test/lowerFirst.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import lowerFirst from '../lowerFirst.js'; - -describe('lowerFirst', function() { - it('should lowercase only the first character', function() { - assert.strictEqual(lowerFirst('fred'), 'fred'); - assert.strictEqual(lowerFirst('Fred'), 'fred'); - assert.strictEqual(lowerFirst('FRED'), 'fRED'); - }); -}); diff --git a/libs/nanofn/test/lt.test.js b/libs/nanofn/test/lt.test.js deleted file mode 100644 index 6b4590cb5..000000000 --- a/libs/nanofn/test/lt.test.js +++ /dev/null @@ -1,16 +0,0 @@ -import assert from 'assert'; -import lt from '../lt.js'; - -describe('lt', function() { - it('should return `true` if `value` is less than `other`', function() { - assert.strictEqual(lt(1, 3), true); - assert.strictEqual(lt('abc', 'def'), true); - }); - - it('should return `false` if `value` >= `other`', function() { - assert.strictEqual(lt(3, 1), false); - assert.strictEqual(lt(3, 3), false); - assert.strictEqual(lt('def', 'abc'), false); - assert.strictEqual(lt('def', 'def'), false); - }); -}); diff --git a/libs/nanofn/test/lte.test.js b/libs/nanofn/test/lte.test.js deleted file mode 100644 index 010a4fefc..000000000 --- a/libs/nanofn/test/lte.test.js +++ /dev/null @@ -1,17 +0,0 @@ -import assert from 'assert'; -import lte from '../lte.js'; -import lt from '../lt.js'; - -describe('lte', function() { - it('should return `true` if `value` is <= `other`', function() { - assert.strictEqual(lte(1, 3), true); - assert.strictEqual(lte(3, 3), true); - assert.strictEqual(lte('abc', 'def'), true); - assert.strictEqual(lte('def', 'def'), true); - }); - - it('should return `false` if `value` > `other`', function() { - assert.strictEqual(lt(3, 1), false); - assert.strictEqual(lt('def', 'abc'), false); - }); -}); diff --git a/libs/nanofn/test/map-caches.js b/libs/nanofn/test/map-caches.js deleted file mode 100644 index 08c2c9af3..000000000 --- a/libs/nanofn/test/map-caches.js +++ /dev/null @@ -1,63 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { symbol, noop, mapCaches, LARGE_ARRAY_SIZE } from './utils.js'; - -describe('map caches', function() { - var keys = [null, undefined, false, true, 1, -Infinity, NaN, {}, 'a', symbol || noop]; - - var pairs = lodashStable.map(keys, function(key, index) { - var lastIndex = keys.length - 1; - return [key, keys[lastIndex - index]]; - }); - - function createCaches(pairs) { - var largeStack = new mapCaches.Stack(pairs), - length = pairs ? pairs.length : 0; - - lodashStable.times(LARGE_ARRAY_SIZE - length, function() { - largeStack.set({}, {}); - }); - - return { - 'hashes': new mapCaches.Hash(pairs), - 'list caches': new mapCaches.ListCache(pairs), - 'map caches': new mapCaches.MapCache(pairs), - 'stack caches': new mapCaches.Stack(pairs), - 'large stacks': largeStack - }; - } - - lodashStable.forOwn(createCaches(pairs), function(cache, kind) { - var isLarge = /^large/.test(kind); - - it('should implement a `Map` interface for ' + kind, function() { - lodashStable.each(keys, function(key, index) { - var value = pairs[index][1]; - - assert.deepStrictEqual(cache.get(key), value); - assert.strictEqual(cache.has(key), true); - assert.strictEqual(cache.delete(key), true); - assert.strictEqual(cache.has(key), false); - assert.strictEqual(cache.get(key), undefined); - assert.strictEqual(cache.delete(key), false); - assert.strictEqual(cache.set(key, value), cache); - assert.strictEqual(cache.has(key), true); - }); - - assert.strictEqual(cache.size, isLarge ? LARGE_ARRAY_SIZE : keys.length); - assert.strictEqual(cache.clear(), undefined); - assert.ok(lodashStable.every(keys, function(key) { - return !cache.has(key); - })); - }); - }); - - lodashStable.forOwn(createCaches(), function(cache, kind) { - it('should support changing values of ' + kind, function() { - lodashStable.each(keys, function(key) { - cache.set(key, 1).set(key, 2); - assert.strictEqual(cache.get(key), 2); - }); - }); - }); -}); diff --git a/libs/nanofn/test/map.js b/libs/nanofn/test/map.js deleted file mode 100644 index c41b9756b..000000000 --- a/libs/nanofn/test/map.js +++ /dev/null @@ -1,122 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, falsey, stubArray, document, noop, LARGE_ARRAY_SIZE, square } from './utils.js'; -import map from '../map.js'; - -describe('map', function() { - var array = [1, 2]; - - it('should map values in `collection` to a new array', function() { - var object = { 'a': 1, 'b': 2 }, - expected = ['1', '2']; - - assert.deepStrictEqual(map(array, String), expected); - assert.deepStrictEqual(map(object, String), expected); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 'x' }, { 'a': 'y' }]; - assert.deepStrictEqual(map(objects, 'a'), ['x', 'y']); - }); - - it('should iterate over own string keyed properties of objects', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var actual = map(new Foo, identity); - assert.deepStrictEqual(actual, [1]); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var object = { 'a': 1, 'b': 2 }, - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([1, 2])); - - lodashStable.each([array, object], function(collection) { - var actual = lodashStable.map(values, function(value, index) { - return index ? map(collection, value) : map(collection); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should accept a falsey `collection`', function() { - var expected = lodashStable.map(falsey, stubArray); - - var actual = lodashStable.map(falsey, function(collection, index) { - try { - return index ? map(collection) : map(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should treat number values for `collection` as empty', function() { - assert.deepStrictEqual(map(1), []); - }); - - it('should treat a nodelist as an array-like object', function() { - if (document) { - var actual = map(document.getElementsByTagName('body'), function(element) { - return element.nodeName.toLowerCase(); - }); - - assert.deepStrictEqual(actual, ['body']); - } - }); - - it('should work with objects with non-number length properties', function() { - var value = { 'value': 'x' }, - object = { 'length': { 'value': 'x' } }; - - assert.deepStrictEqual(map(object, identity), [value]); - }); - - it('should return a wrapped value when chaining', function() { - assert.ok(_(array).map(noop) instanceof _); - }); - - it('should provide correct `predicate` arguments in a lazy sequence', function() { - var args, - array = lodashStable.range(LARGE_ARRAY_SIZE + 1), - expected = [1, 0, map(array.slice(1), square)]; - - _(array).slice(1).map(function(value, index, array) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, [1, 0, array.slice(1)]); - - args = undefined; - _(array).slice(1).map(square).map(function(value, index, array) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - - args = undefined; - _(array).slice(1).map(square).map(function(value, index) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - - args = undefined; - _(array).slice(1).map(square).map(function(value) { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, [1]); - - args = undefined; - _(array).slice(1).map(square).map(function() { - args || (args = slice.call(arguments)); - }).value(); - - assert.deepEqual(args, expected); - }); -}); diff --git a/libs/nanofn/test/mapKeys-and-mapValues.js b/libs/nanofn/test/mapKeys-and-mapValues.js deleted file mode 100644 index 8ba86f7c8..000000000 --- a/libs/nanofn/test/mapKeys-and-mapValues.js +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, falsey, stubObject, noop } from './utils.js'; - -describe('mapKeys and mapValues', function() { - lodashStable.each(['mapKeys', 'mapValues'], function(methodName) { - var func = _[methodName], - object = { 'a': 1, 'b': 2 }; - - it('`_.' + methodName + '` should iterate over own string keyed properties of objects', function() { - function Foo() { - this.a = 'a'; - } - Foo.prototype.b = 'b'; - - var actual = func(new Foo, function(value, key) { return key; }); - assert.deepStrictEqual(actual, { 'a': 'a' }); - }); - - it('`_.' + methodName + '` should accept a falsey `object`', function() { - var expected = lodashStable.map(falsey, stubObject); - - var actual = lodashStable.map(falsey, function(object, index) { - try { - return index ? func(object) : func(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return a wrapped value when chaining', function() { - assert.ok(_(object)[methodName](noop) instanceof _); - }); - }); -}); diff --git a/libs/nanofn/test/mapKeys.js b/libs/nanofn/test/mapKeys.js deleted file mode 100644 index a40f90a6f..000000000 --- a/libs/nanofn/test/mapKeys.js +++ /dev/null @@ -1,35 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import mapKeys from '../mapKeys.js'; - -describe('mapKeys', function() { - var array = [1, 2], - object = { 'a': 1, 'b': 2 }; - - it('should map keys in `object` to a new object', function() { - var actual = mapKeys(object, String); - assert.deepStrictEqual(actual, { '1': 1, '2': 2 }); - }); - - it('should treat arrays like objects', function() { - var actual = mapKeys(array, String); - assert.deepStrictEqual(actual, { '1': 1, '2': 2 }); - }); - - it('should work with `_.property` shorthands', function() { - var actual = mapKeys({ 'a': { 'b': 'c' } }, 'b'); - assert.deepStrictEqual(actual, { 'c': { 'b': 'c' } }); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var object = { 'a': 1, 'b': 2 }, - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant({ '1': 1, '2': 2 })); - - var actual = lodashStable.map(values, function(value, index) { - return index ? mapKeys(object, value) : mapKeys(object); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/mapValues.js b/libs/nanofn/test/mapValues.js deleted file mode 100644 index 64b5cdc89..000000000 --- a/libs/nanofn/test/mapValues.js +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import mapValues from '../mapValues.js'; - -describe('mapValues', function() { - var array = [1, 2], - object = { 'a': 1, 'b': 2 }; - - it('should map values in `object` to a new object', function() { - var actual = mapValues(object, String); - assert.deepStrictEqual(actual, { 'a': '1', 'b': '2' }); - }); - - it('should treat arrays like objects', function() { - var actual = mapValues(array, String); - assert.deepStrictEqual(actual, { '0': '1', '1': '2' }); - }); - - it('should work with `_.property` shorthands', function() { - var actual = mapValues({ 'a': { 'b': 2 } }, 'b'); - assert.deepStrictEqual(actual, { 'a': 2 }); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var object = { 'a': 1, 'b': 2 }, - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([true, false])); - - var actual = lodashStable.map(values, function(value, index) { - var result = index ? mapValues(object, value) : mapValues(object); - return [lodashStable.isEqual(result, object), result === object]; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/matches-methods.js b/libs/nanofn/test/matches-methods.js deleted file mode 100644 index 721fdfad5..000000000 --- a/libs/nanofn/test/matches-methods.js +++ /dev/null @@ -1,294 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, stubTrue, noop, numberProto, stubFalse, empties } from './utils.js'; -import isMatch from '../isMatch.js'; - -describe('matches methods', function() { - lodashStable.each(['matches', 'isMatch'], function(methodName) { - var isMatches = methodName == 'matches'; - - function matches(source) { - return isMatches ? _.matches(source) : function(object) { - return isMatch(object, source); - }; - } - - it('`_.' + methodName + '` should perform a deep comparison between `source` and `object`', function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - par = matches({ 'a': 1 }); - - assert.strictEqual(par(object), true); - - par = matches({ 'b': 1 }); - assert.strictEqual(par(object), false); - - par = matches({ 'a': 1, 'c': 3 }); - assert.strictEqual(par(object), true); - - par = matches({ 'c': 3, 'd': 4 }); - assert.strictEqual(par(object), false); - - object = { 'a': { 'b': { 'c': 1, 'd': 2 }, 'e': 3 }, 'f': 4 }; - par = matches({ 'a': { 'b': { 'c': 1 } } }); - - assert.strictEqual(par(object), true); - }); - - it('`_.' + methodName + '` should match inherited string keyed `object` properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var object = { 'a': new Foo }, - par = matches({ 'a': { 'b': 2 } }); - - assert.strictEqual(par(object), true); - }); - - it('`_.' + methodName + '` should not match by inherited `source` properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], - source = new Foo, - actual = lodashStable.map(objects, matches(source)), - expected = lodashStable.map(objects, stubTrue); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should compare a variety of `source` property values', function() { - var object1 = { 'a': false, 'b': true, 'c': '3', 'd': 4, 'e': [5], 'f': { 'g': 6 } }, - object2 = { 'a': 0, 'b': 1, 'c': 3, 'd': '4', 'e': ['5'], 'f': { 'g': '6' } }, - par = matches(object1); - - assert.strictEqual(par(object1), true); - assert.strictEqual(par(object2), false); - }); - - it('`_.' + methodName + '` should match `-0` as `0`', function() { - var object1 = { 'a': -0 }, - object2 = { 'a': 0 }, - par = matches(object1); - - assert.strictEqual(par(object2), true); - - par = matches(object2); - assert.strictEqual(par(object1), true); - }); - - it('`_.' + methodName + '` should compare functions by reference', function() { - var object1 = { 'a': lodashStable.noop }, - object2 = { 'a': noop }, - object3 = { 'a': {} }, - par = matches(object1); - - assert.strictEqual(par(object1), true); - assert.strictEqual(par(object2), false); - assert.strictEqual(par(object3), false); - }); - - it('`_.' + methodName + '` should work with a function for `object`', function() { - function Foo() {} - Foo.a = { 'b': 2, 'c': 3 }; - - var par = matches({ 'a': { 'b': 2 } }); - assert.strictEqual(par(Foo), true); - }); - - it('`_.' + methodName + '` should work with a function for `source`', function() { - function Foo() {} - Foo.a = 1; - Foo.b = function() {}; - Foo.c = 3; - - var objects = [{ 'a': 1 }, { 'a': 1, 'b': Foo.b, 'c': 3 }], - actual = lodashStable.map(objects, matches(Foo)); - - assert.deepStrictEqual(actual, [false, true]); - }); - - it('`_.' + methodName + '` should work with a non-plain `object`', function() { - function Foo(object) { lodashStable.assign(this, object); } - - var object = new Foo({ 'a': new Foo({ 'b': 2, 'c': 3 }) }), - par = matches({ 'a': { 'b': 2 } }); - - assert.strictEqual(par(object), true); - }); - - it('`_.' + methodName + '` should partial match arrays', function() { - var objects = [{ 'a': ['b'] }, { 'a': ['c', 'd'] }], - actual = lodashStable.filter(objects, matches({ 'a': ['d'] })); - - assert.deepStrictEqual(actual, [objects[1]]); - - actual = lodashStable.filter(objects, matches({ 'a': ['b', 'd'] })); - assert.deepStrictEqual(actual, []); - - actual = lodashStable.filter(objects, matches({ 'a': ['d', 'b'] })); - assert.deepStrictEqual(actual, []); - }); - - it('`_.' + methodName + '` should partial match arrays with duplicate values', function() { - var objects = [{ 'a': [1, 2] }, { 'a': [2, 2] }], - actual = lodashStable.filter(objects, matches({ 'a': [2, 2] })); - - assert.deepStrictEqual(actual, [objects[1]]); - }); - - it('should partial match arrays of objects', function() { - var objects = [ - { 'a': [{ 'b': 1, 'c': 2 }, { 'b': 4, 'c': 5, 'd': 6 }] }, - { 'a': [{ 'b': 1, 'c': 2 }, { 'b': 4, 'c': 6, 'd': 7 }] } - ]; - - var actual = lodashStable.filter(objects, matches({ 'a': [{ 'b': 1 }, { 'b': 4, 'c': 5 }] })); - assert.deepStrictEqual(actual, [objects[0]]); - }); - - it('`_.' + methodName + '` should partial match maps', function() { - if (Map) { - var objects = [{ 'a': new Map }, { 'a': new Map }]; - objects[0].a.set('a', 1); - objects[1].a.set('a', 1); - objects[1].a.set('b', 2); - - var map = new Map; - map.set('b', 2); - var actual = lodashStable.filter(objects, matches({ 'a': map })); - - assert.deepStrictEqual(actual, [objects[1]]); - - map.delete('b'); - actual = lodashStable.filter(objects, matches({ 'a': map })); - - assert.deepStrictEqual(actual, objects); - - map.set('c', 3); - actual = lodashStable.filter(objects, matches({ 'a': map })); - - assert.deepStrictEqual(actual, []); - } - }); - - it('`_.' + methodName + '` should partial match sets', function() { - if (Set) { - var objects = [{ 'a': new Set }, { 'a': new Set }]; - objects[0].a.add(1); - objects[1].a.add(1); - objects[1].a.add(2); - - var set = new Set; - set.add(2); - var actual = lodashStable.filter(objects, matches({ 'a': set })); - - assert.deepStrictEqual(actual, [objects[1]]); - - set.delete(2); - actual = lodashStable.filter(objects, matches({ 'a': set })); - - assert.deepStrictEqual(actual, objects); - - set.add(3); - actual = lodashStable.filter(objects, matches({ 'a': set })); - - assert.deepStrictEqual(actual, []); - } - }); - - it('`_.' + methodName + '` should match `undefined` values', function() { - var objects = [{ 'a': 1 }, { 'a': 1, 'b': 1 }, { 'a': 1, 'b': undefined }], - actual = lodashStable.map(objects, matches({ 'b': undefined })), - expected = [false, false, true]; - - assert.deepStrictEqual(actual, expected); - - actual = lodashStable.map(objects, matches({ 'a': 1, 'b': undefined })); - - assert.deepStrictEqual(actual, expected); - - objects = [{ 'a': { 'b': 2 } }, { 'a': { 'b': 2, 'c': 3 } }, { 'a': { 'b': 2, 'c': undefined } }]; - actual = lodashStable.map(objects, matches({ 'a': { 'c': undefined } })); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should match `undefined` values on primitives', function() { - numberProto.a = 1; - numberProto.b = undefined; - - try { - var par = matches({ 'b': undefined }); - assert.strictEqual(par(1), true); - } catch (e) { - assert.ok(false, e.message); - } - try { - par = matches({ 'a': 1, 'b': undefined }); - assert.strictEqual(par(1), true); - } catch (e) { - assert.ok(false, e.message); - } - numberProto.a = { 'b': 1, 'c': undefined }; - try { - par = matches({ 'a': { 'c': undefined } }); - assert.strictEqual(par(1), true); - } catch (e) { - assert.ok(false, e.message); - } - delete numberProto.a; - delete numberProto.b; - }); - - it('`_.' + methodName + '` should return `false` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse), - par = matches({ 'a': 1 }); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? par(value) : par(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` when comparing an empty `source`', function() { - var object = { 'a': 1 }, - expected = lodashStable.map(empties, stubTrue); - - var actual = lodashStable.map(empties, function(value) { - var par = matches(value); - return par(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` when comparing an empty `source` to a nullish `object`', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubTrue), - par = matches({}); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? par(value) : par(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should return `true` when comparing a `source` of empty arrays and objects', function() { - var objects = [{ 'a': [1], 'b': { 'c': 1 } }, { 'a': [2, 3], 'b': { 'd': 2 } }], - actual = lodashStable.filter(objects, matches({ 'a': [], 'b': {} })); - - assert.deepStrictEqual(actual, objects); - }); - }); -}); diff --git a/libs/nanofn/test/matches.js b/libs/nanofn/test/matches.js deleted file mode 100644 index 5901655ee..000000000 --- a/libs/nanofn/test/matches.js +++ /dev/null @@ -1,32 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import matches from '../matches.js'; - -describe('matches', function() { - it('should not change behavior if `source` is modified', function() { - var sources = [ - { 'a': { 'b': 2, 'c': 3 } }, - { 'a': 1, 'b': 2 }, - { 'a': 1 } - ]; - - lodashStable.each(sources, function(source, index) { - var object = lodashStable.cloneDeep(source), - par = matches(source); - - assert.strictEqual(par(object), true); - - if (index) { - source.a = 2; - source.b = 1; - source.c = 3; - } else { - source.a.b = 1; - source.a.c = 2; - source.a.d = 3; - } - assert.strictEqual(par(object), true); - assert.strictEqual(par(source), false); - }); - }); -}); diff --git a/libs/nanofn/test/matchesProperty.js b/libs/nanofn/test/matchesProperty.js deleted file mode 100644 index 23eb04218..000000000 --- a/libs/nanofn/test/matchesProperty.js +++ /dev/null @@ -1,368 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue, stubFalse, noop, numberProto } from './utils.js'; -import matchesProperty from '../matchesProperty.js'; - -describe('matchesProperty', function() { - it('should create a function that performs a deep comparison between a property value and `srcValue`', function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - matches = matchesProperty('a', 1); - - assert.strictEqual(matches.length, 1); - assert.strictEqual(matches(object), true); - - matches = matchesProperty('b', 3); - assert.strictEqual(matches(object), false); - - matches = matchesProperty('a', { 'a': 1, 'c': 3 }); - assert.strictEqual(matches({ 'a': object }), true); - - matches = matchesProperty('a', { 'c': 3, 'd': 4 }); - assert.strictEqual(matches(object), false); - - object = { 'a': { 'b': { 'c': 1, 'd': 2 }, 'e': 3 }, 'f': 4 }; - matches = matchesProperty('a', { 'b': { 'c': 1 } }); - - assert.strictEqual(matches(object), true); - }); - - it('should support deep paths', function() { - var object = { 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var matches = matchesProperty(path, 2); - assert.strictEqual(matches(object), true); - }); - }); - - it('should work with a non-string `path`', function() { - var array = [1, 2, 3]; - - lodashStable.each([1, [1]], function(path) { - var matches = matchesProperty(path, 2); - assert.strictEqual(matches(array), true); - }); - }); - - it('should preserve the sign of `0`', function() { - var object1 = { '-0': 'a' }, - object2 = { '0': 'b' }, - pairs = [[object1, object2], [object1, object2], [object2, object1], [object2, object1]], - props = [-0, Object(-0), 0, Object(0)], - values = ['a', 'a', 'b', 'b'], - expected = lodashStable.map(props, lodashStable.constant([true, false])); - - var actual = lodashStable.map(props, function(key, index) { - var matches = matchesProperty(key, values[index]), - pair = pairs[index]; - - return [matches(pair[0]), matches(pair[1])]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, - paths = [null, undefined, fn, {}], - expected = lodashStable.map(paths, stubTrue); - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - var matches = matchesProperty(index ? [path] : path, object[path]); - return matches(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should match a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - var matches = matchesProperty(path, 1); - assert.strictEqual(matches(object), true); - }); - }); - - it('should return `false` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var matches = matchesProperty(path, 1); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? matches(value) : matches(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `false` for deep paths when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var matches = matchesProperty(path, 1); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? matches(value) : matches(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `false` if parts of `path` are missing', function() { - var object = {}; - - lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) { - var matches = matchesProperty(path, 1); - assert.strictEqual(matches(object), false); - }); - }); - - it('should match inherited string keyed `srcValue` properties', function() { - function Foo() {} - Foo.prototype.b = 2; - - var object = { 'a': new Foo }; - - lodashStable.each(['a', ['a']], function(path) { - var matches = matchesProperty(path, { 'b': 2 }); - assert.strictEqual(matches(object), true); - }); - }); - - it('should not match by inherited `srcValue` properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 2 } }], - expected = lodashStable.map(objects, stubTrue); - - lodashStable.each(['a', ['a']], function(path) { - assert.deepStrictEqual(lodashStable.map(objects, matchesProperty(path, new Foo)), expected); - }); - }); - - it('should compare a variety of values', function() { - var object1 = { 'a': false, 'b': true, 'c': '3', 'd': 4, 'e': [5], 'f': { 'g': 6 } }, - object2 = { 'a': 0, 'b': 1, 'c': 3, 'd': '4', 'e': ['5'], 'f': { 'g': '6' } }, - matches = matchesProperty('a', object1); - - assert.strictEqual(matches({ 'a': object1 }), true); - assert.strictEqual(matches({ 'a': object2 }), false); - }); - - it('should match `-0` as `0`', function() { - var matches = matchesProperty('a', -0); - assert.strictEqual(matches({ 'a': 0 }), true); - - matches = matchesProperty('a', 0); - assert.strictEqual(matches({ 'a': -0 }), true); - }); - - it('should compare functions by reference', function() { - var object1 = { 'a': lodashStable.noop }, - object2 = { 'a': noop }, - object3 = { 'a': {} }, - matches = matchesProperty('a', object1); - - assert.strictEqual(matches({ 'a': object1 }), true); - assert.strictEqual(matches({ 'a': object2 }), false); - assert.strictEqual(matches({ 'a': object3 }), false); - }); - - it('should work with a function for `srcValue`', function() { - function Foo() {} - Foo.a = 1; - Foo.b = function() {}; - Foo.c = 3; - - var objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': Foo.b, 'c': 3 } }], - actual = lodashStable.map(objects, matchesProperty('a', Foo)); - - assert.deepStrictEqual(actual, [false, true]); - }); - - it('should work with a non-plain `srcValue`', function() { - function Foo(object) { lodashStable.assign(this, object); } - - var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), - matches = matchesProperty('a', { 'b': 1 }); - - assert.strictEqual(matches(object), true); - }); - - it('should partial match arrays', function() { - var objects = [{ 'a': ['b'] }, { 'a': ['c', 'd'] }], - actual = lodashStable.filter(objects, matchesProperty('a', ['d'])); - - assert.deepStrictEqual(actual, [objects[1]]); - - actual = lodashStable.filter(objects, matchesProperty('a', ['b', 'd'])); - assert.deepStrictEqual(actual, []); - - actual = lodashStable.filter(objects, matchesProperty('a', ['d', 'b'])); - assert.deepStrictEqual(actual, []); - }); - - it('should partial match arrays with duplicate values', function() { - var objects = [{ 'a': [1, 2] }, { 'a': [2, 2] }], - actual = lodashStable.filter(objects, matchesProperty('a', [2, 2])); - - assert.deepStrictEqual(actual, [objects[1]]); - }); - - it('should partial match arrays of objects', function() { - var objects = [ - { 'a': [{ 'a': 1, 'b': 2 }, { 'a': 4, 'b': 5, 'c': 6 }] }, - { 'a': [{ 'a': 1, 'b': 2 }, { 'a': 4, 'b': 6, 'c': 7 }] } - ]; - - var actual = lodashStable.filter(objects, matchesProperty('a', [{ 'a': 1 }, { 'a': 4, 'b': 5 }])); - assert.deepStrictEqual(actual, [objects[0]]); - }); - it('should partial match maps', function() { - if (Map) { - var objects = [{ 'a': new Map }, { 'a': new Map }]; - objects[0].a.set('a', 1); - objects[1].a.set('a', 1); - objects[1].a.set('b', 2); - - var map = new Map; - map.set('b', 2); - var actual = lodashStable.filter(objects, matchesProperty('a', map)); - - assert.deepStrictEqual(actual, [objects[1]]); - - map.delete('b'); - actual = lodashStable.filter(objects, matchesProperty('a', map)); - - assert.deepStrictEqual(actual, objects); - - map.set('c', 3); - actual = lodashStable.filter(objects, matchesProperty('a', map)); - - assert.deepStrictEqual(actual, []); - } - }); - - it('should partial match sets', function() { - if (Set) { - var objects = [{ 'a': new Set }, { 'a': new Set }]; - objects[0].a.add(1); - objects[1].a.add(1); - objects[1].a.add(2); - - var set = new Set; - set.add(2); - var actual = lodashStable.filter(objects, matchesProperty('a', set)); - - assert.deepStrictEqual(actual, [objects[1]]); - - set.delete(2); - actual = lodashStable.filter(objects, matchesProperty('a', set)); - - assert.deepStrictEqual(actual, objects); - - set.add(3); - actual = lodashStable.filter(objects, matchesProperty('a', set)); - - assert.deepStrictEqual(actual, []); - } - }); - - it('should match `undefined` values', function() { - var objects = [{ 'a': 1 }, { 'a': 1, 'b': 1 }, { 'a': 1, 'b': undefined }], - actual = lodashStable.map(objects, matchesProperty('b', undefined)), - expected = [false, false, true]; - - assert.deepStrictEqual(actual, expected); - - objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 1 } }, { 'a': { 'a': 1, 'b': undefined } }]; - actual = lodashStable.map(objects, matchesProperty('a', { 'b': undefined })); - - assert.deepStrictEqual(actual, expected); - }); - - it('should match `undefined` values of nested objects', function() { - var object = { 'a': { 'b': undefined } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var matches = matchesProperty(path, undefined); - assert.strictEqual(matches(object), true); - }); - - lodashStable.each(['a.a', ['a', 'a']], function(path) { - var matches = matchesProperty(path, undefined); - assert.strictEqual(matches(object), false); - }); - }); - - it('should match `undefined` values on primitives', function() { - numberProto.a = 1; - numberProto.b = undefined; - - try { - var matches = matchesProperty('b', undefined); - assert.strictEqual(matches(1), true); - } catch (e) { - assert.ok(false, e.message); - } - numberProto.a = { 'b': 1, 'c': undefined }; - try { - matches = matchesProperty('a', { 'c': undefined }); - assert.strictEqual(matches(1), true); - } catch (e) { - assert.ok(false, e.message); - } - delete numberProto.a; - delete numberProto.b; - }); - - it('should return `true` when comparing a `srcValue` of empty arrays and objects', function() { - var objects = [{ 'a': [1], 'b': { 'c': 1 } }, { 'a': [2, 3], 'b': { 'd': 2 } }], - matches = matchesProperty('a', { 'a': [], 'b': {} }); - - var actual = lodashStable.filter(objects, function(object) { - return matches({ 'a': object }); - }); - - assert.deepStrictEqual(actual, objects); - }); - - it('should not change behavior if `srcValue` is modified', function() { - lodashStable.each([{ 'a': { 'b': 2, 'c': 3 } }, { 'a': 1, 'b': 2 }, { 'a': 1 }], function(source, index) { - var object = lodashStable.cloneDeep(source), - matches = matchesProperty('a', source); - - assert.strictEqual(matches({ 'a': object }), true); - - if (index) { - source.a = 2; - source.b = 1; - source.c = 3; - } else { - source.a.b = 1; - source.a.c = 2; - source.a.d = 3; - } - assert.strictEqual(matches({ 'a': object }), true); - assert.strictEqual(matches({ 'a': source }), false); - }); - }); -}); diff --git a/libs/nanofn/test/math-operator-methods.js b/libs/nanofn/test/math-operator-methods.js deleted file mode 100644 index cd5e88c4e..000000000 --- a/libs/nanofn/test/math-operator-methods.js +++ /dev/null @@ -1,56 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, symbol } from './utils.js'; - -describe('math operator methods', function() { - lodashStable.each(['add', 'divide', 'multiply', 'subtract'], function(methodName) { - var func = _[methodName], - isAddSub = methodName == 'add' || methodName == 'subtract'; - - it('`_.' + methodName + '` should return `' + (isAddSub ? 0 : 1) + '` when no arguments are given', function() { - assert.strictEqual(func(), isAddSub ? 0 : 1); - }); - - it('`_.' + methodName + '` should work with only one defined argument', function() { - assert.strictEqual(func(6), 6); - assert.strictEqual(func(6, undefined), 6); - assert.strictEqual(func(undefined, 4), 4); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var values = [0, '0', -0, '-0'], - expected = [[0, Infinity], ['0', Infinity], [-0, -Infinity], ['-0', -Infinity]]; - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(values, function(value) { - var result = index ? func(undefined, value) : func(value); - return [result, 1 / result]; - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('`_.' + methodName + '` should convert objects to `NaN`', function() { - assert.deepStrictEqual(func(0, {}), NaN); - assert.deepStrictEqual(func({}, 0), NaN); - }); - - it('`_.' + methodName + '` should convert symbols to `NaN`', function() { - if (Symbol) { - assert.deepStrictEqual(func(0, symbol), NaN); - assert.deepStrictEqual(func(symbol, 0), NaN); - } - }); - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var actual = _(1)[methodName](2); - assert.notOk(actual instanceof _); - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() { - var actual = _(1).chain()[methodName](2); - assert.ok(actual instanceof _); - }); - }); -}); diff --git a/libs/nanofn/test/max.js b/libs/nanofn/test/max.js deleted file mode 100644 index 28fca7954..000000000 --- a/libs/nanofn/test/max.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, noop } from './utils.js'; -import max from '../max.js'; - -describe('max', function() { - it('should return the largest value from a collection', function() { - assert.strictEqual(max([1, 2, 3]), 3); - }); - - it('should return `undefined` for empty collections', function() { - var values = falsey.concat([[]]), - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? max(value) : max(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with non-numeric collection values', function() { - assert.strictEqual(max(['a', 'b']), 'b'); - }); -}); diff --git a/libs/nanofn/test/mean.test.js b/libs/nanofn/test/mean.test.js deleted file mode 100644 index f0f09061b..000000000 --- a/libs/nanofn/test/mean.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, stubNaN } from './utils.js'; -import mean from '../mean.js'; - -describe('mean', function() { - it('should return the mean of an array of numbers', function() { - var array = [4, 2, 8, 6]; - assert.strictEqual(mean(array), 5); - }); - - it('should return `NaN` when passing empty `array` values', function() { - var expected = lodashStable.map(empties, stubNaN), - actual = lodashStable.map(empties, mean); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/meanBy.js b/libs/nanofn/test/meanBy.js deleted file mode 100644 index 987eebdd3..000000000 --- a/libs/nanofn/test/meanBy.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import meanBy from '../meanBy.js'; - -describe('meanBy', function() { - var objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; - - it('should work with an `iteratee`', function() { - var actual = meanBy(objects, function(object) { - return object.a; - }); - - assert.deepStrictEqual(actual, 2); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - meanBy(objects, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [{ 'a': 2 }]); - }); - - it('should work with `_.property` shorthands', function() { - var arrays = [[2], [3], [1]]; - assert.strictEqual(meanBy(arrays, 0), 2); - assert.strictEqual(meanBy(objects, 'a'), 2); - }); -}); diff --git a/libs/nanofn/test/memoize.test.js b/libs/nanofn/test/memoize.test.js deleted file mode 100644 index e3f92cd6d..000000000 --- a/libs/nanofn/test/memoize.test.js +++ /dev/null @@ -1,178 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop, stubTrue, identity } from './utils.js'; -import memoize from '../memoize.js'; -import isFunction from '../isFunction.js'; - -describe('memoize', function() { - function CustomCache() { - this.clear(); - } - - CustomCache.prototype = { - 'clear': function() { - this.__data__ = []; - return this; - }, - 'get': function(key) { - var entry = lodashStable.find(this.__data__, ['key', key]); - return entry && entry.value; - }, - 'has': function(key) { - return lodashStable.some(this.__data__, ['key', key]); - }, - 'set': function(key, value) { - this.__data__.push({ 'key': key, 'value': value }); - return this; - } - }; - - function ImmutableCache() { - this.__data__ = []; - } - - ImmutableCache.prototype = lodashStable.create(CustomCache.prototype, { - 'constructor': ImmutableCache, - 'clear': function() { - return new ImmutableCache; - }, - 'set': function(key, value) { - var result = new ImmutableCache; - result.__data__ = this.__data__.concat({ 'key': key, 'value': value }); - return result; - } - }); - - it('should memoize results based on the first argument given', function() { - var memoized = memoize(function(a, b, c) { - return a + b + c; - }); - - assert.strictEqual(memoized(1, 2, 3), 6); - assert.strictEqual(memoized(1, 3, 5), 6); - }); - - it('should support a `resolver`', function() { - var fn = function(a, b, c) { return a + b + c; }, - memoized = memoize(fn, fn); - - assert.strictEqual(memoized(1, 2, 3), 6); - assert.strictEqual(memoized(1, 3, 5), 9); - }); - - it('should use `this` binding of function for `resolver`', function() { - var fn = function(a, b, c) { return a + this.b + this.c; }, - memoized = memoize(fn, fn); - - var object = { 'memoized': memoized, 'b': 2, 'c': 3 }; - assert.strictEqual(object.memoized(1), 6); - - object.b = 3; - object.c = 5; - assert.strictEqual(object.memoized(1), 9); - }); - - it('should throw a TypeError if `resolve` is truthy and not a function', function() { - assert.throws(function() { memoize(noop, true); }, TypeError); - }); - - it('should not error if `resolver` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(resolver, index) { - try { - return isFunction(index ? memoize(noop, resolver) : memoize(noop)); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should check cache for own properties', function() { - var props = [ - 'constructor', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'toLocaleString', - 'toString', - 'valueOf' - ]; - - var memoized = memoize(identity); - - var actual = lodashStable.map(props, function(value) { - return memoized(value); - }); - - assert.deepStrictEqual(actual, props); - }); - - it('should cache the `__proto__` key', function() { - var array = [], - key = '__proto__'; - - lodashStable.times(2, function(index) { - var count = 0, - resolver = index ? identity : undefined; - - var memoized = memoize(function() { - count++; - return array; - }, resolver); - - var cache = memoized.cache; - - memoized(key); - memoized(key); - - assert.strictEqual(count, 1); - assert.strictEqual(cache.get(key), array); - assert.ok(!(cache.__data__ instanceof Array)); - assert.strictEqual(cache.delete(key), true); - }); - }); - - it('should allow `_.memoize.Cache` to be customized', function() { - var oldCache = memoize.Cache; - memoize.Cache = CustomCache; - - var memoized = memoize(function(object) { - return object.id; - }); - - var cache = memoized.cache, - key1 = { 'id': 'a' }, - key2 = { 'id': 'b' }; - - assert.strictEqual(memoized(key1), 'a'); - assert.strictEqual(cache.has(key1), true); - - assert.strictEqual(memoized(key2), 'b'); - assert.strictEqual(cache.has(key2), true); - - memoize.Cache = oldCache; - }); - - it('should works with an immutable `_.memoize.Cache` ', function() { - var oldCache = memoize.Cache; - memoize.Cache = ImmutableCache; - - var memoized = memoize(function(object) { - return object.id; - }); - - var key1 = { 'id': 'a' }, - key2 = { 'id': 'b' }; - - memoized(key1); - memoized(key2); - - var cache = memoized.cache; - assert.strictEqual(cache.has(key1), true); - assert.strictEqual(cache.has(key2), true); - - memoize.Cache = oldCache; - }); -}); diff --git a/libs/nanofn/test/memoizeCapped.test.js b/libs/nanofn/test/memoizeCapped.test.js deleted file mode 100644 index c87920a2d..000000000 --- a/libs/nanofn/test/memoizeCapped.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, MAX_MEMOIZE_SIZE } from './utils.js'; -import _memoizeCapped from '../.internal/memoizeCapped.js'; - -describe('memoizeCapped', function() { - var func = _memoizeCapped; - - it('should enforce a max cache size of `MAX_MEMOIZE_SIZE`', function() { - if (func) { - var memoized = func(identity), - cache = memoized.cache; - - lodashStable.times(MAX_MEMOIZE_SIZE, memoized); - assert.strictEqual(cache.size, MAX_MEMOIZE_SIZE); - - memoized(MAX_MEMOIZE_SIZE); - assert.strictEqual(cache.size, 1); - } - }); -}); diff --git a/libs/nanofn/test/merge.test.js b/libs/nanofn/test/merge.test.js deleted file mode 100644 index 397a9aafa..000000000 --- a/libs/nanofn/test/merge.test.js +++ /dev/null @@ -1,350 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, typedArrays, stubTrue, defineProperty, document, root } from './utils.js'; -import merge from '../merge.js'; -import isArguments from '../isArguments.js'; - -describe('merge', function() { - it('should merge `source` into `object`', function() { - var names = { - 'characters': [ - { 'name': 'barney' }, - { 'name': 'fred' } - ] - }; - - var ages = { - 'characters': [ - { 'age': 36 }, - { 'age': 40 } - ] - }; - - var heights = { - 'characters': [ - { 'height': '5\'4"' }, - { 'height': '5\'5"' } - ] - }; - - var expected = { - 'characters': [ - { 'name': 'barney', 'age': 36, 'height': '5\'4"' }, - { 'name': 'fred', 'age': 40, 'height': '5\'5"' } - ] - }; - - assert.deepStrictEqual(merge(names, ages, heights), expected); - }); - - it('should merge sources containing circular references', function() { - var object = { - 'foo': { 'a': 1 }, - 'bar': { 'a': 2 } - }; - - var source = { - 'foo': { 'b': { 'c': { 'd': {} } } }, - 'bar': {} - }; - - source.foo.b.c.d = source; - source.bar.b = source.foo.b; - - var actual = merge(object, source); - - assert.notStrictEqual(actual.bar.b, actual.foo.b); - assert.strictEqual(actual.foo.b.c.d, actual.foo.b.c.d.foo.b.c.d); - }); - - it('should work with four arguments', function() { - var expected = { 'a': 4 }, - actual = merge({ 'a': 1 }, { 'a': 2 }, { 'a': 3 }, expected); - - assert.deepStrictEqual(actual, expected); - }); - - it('should merge onto function `object` values', function() { - function Foo() {} - - var source = { 'a': 1 }, - actual = merge(Foo, source); - - assert.strictEqual(actual, Foo); - assert.strictEqual(Foo.a, 1); - }); - - it('should merge first source object properties to function', function() { - var fn = function() {}, - object = { 'prop': {} }, - actual = merge({ 'prop': fn }, object); - - assert.deepStrictEqual(actual, object); - }); - - it('should merge first and second source object properties to function', function() { - var fn = function() {}, - object = { 'prop': {} }, - actual = merge({ 'prop': fn }, { 'prop': fn }, object); - - assert.deepStrictEqual(actual, object); - }); - - it('should not merge onto function values of sources', function() { - var source1 = { 'a': function() {} }, - source2 = { 'a': { 'b': 2 } }, - expected = { 'a': { 'b': 2 } }, - actual = merge({}, source1, source2); - - assert.deepStrictEqual(actual, expected); - assert.ok(!('b' in source1.a)); - - actual = merge(source1, source2); - assert.deepStrictEqual(actual, expected); - }); - - it('should merge onto non-plain `object` values', function() { - function Foo() {} - - var object = new Foo, - actual = merge(object, { 'a': 1 }); - - assert.strictEqual(actual, object); - assert.strictEqual(object.a, 1); - }); - - // TODO: revisit. - it.skip('should treat sparse array sources as dense', function() { - var array = [1]; - array[2] = 3; - - var actual = merge([], array), - expected = array.slice(); - - expected[1] = undefined; - - assert.ok('1' in actual); - assert.deepStrictEqual(actual, expected); - }); - - it('should merge `arguments` objects', function() { - var object1 = { 'value': args }, - object2 = { 'value': { '3': 4 } }, - expected = { '0': 1, '1': 2, '2': 3, '3': 4 }, - actual = merge(object1, object2); - - assert.ok(!('3' in args)); - assert.ok(!isArguments(actual.value)); - assert.deepStrictEqual(actual.value, expected); - object1.value = args; - - actual = merge(object2, object1); - assert.ok(!isArguments(actual.value)); - assert.deepStrictEqual(actual.value, expected); - - expected = { '0': 1, '1': 2, '2': 3 }; - - actual = merge({}, object1); - assert.ok(!isArguments(actual.value)); - assert.deepStrictEqual(actual.value, expected); - }); - - it('should merge typed arrays', function() { - var array1 = [0], - array2 = [0, 0], - array3 = [0, 0, 0, 0], - array4 = [0, 0, 0, 0, 0, 0, 0, 0]; - - var arrays = [array2, array1, array4, array3, array2, array4, array4, array3, array2], - buffer = ArrayBuffer && new ArrayBuffer(8); - - var expected = lodashStable.map(typedArrays, function(type, index) { - var array = arrays[index].slice(); - array[0] = 1; - return root[type] ? { 'value': array } : false; - }); - - var actual = lodashStable.map(typedArrays, function(type) { - var Ctor = root[type]; - return Ctor ? merge({ 'value': new Ctor(buffer) }, { 'value': [1] }) : false; - }); - - assert.ok(lodashStable.isArray(actual)); - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(typedArrays, function(type, index) { - var array = arrays[index].slice(); - array.push(1); - return root[type] ? { 'value': array } : false; - }); - - actual = lodashStable.map(typedArrays, function(type, index) { - var Ctor = root[type], - array = lodashStable.range(arrays[index].length); - - array.push(1); - return Ctor ? merge({ 'value': array }, { 'value': new Ctor(buffer) }) : false; - }); - - assert.ok(lodashStable.isArray(actual)); - assert.deepStrictEqual(actual, expected); - }); - - it('should assign `null` values', function() { - var actual = merge({ 'a': 1 }, { 'a': null }); - assert.strictEqual(actual.a, null); - }); - - it('should assign non array/buffer/typed-array/plain-object source values directly', function() { - function Foo() {} - - var values = [new Foo, new Boolean, new Date, Foo, new Number, new String, new RegExp], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - var object = merge({}, { 'a': value, 'b': { 'c': value } }); - return object.a === value && object.b.c === value; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should clone buffer source values', function() { - if (Buffer) { - var buffer = new Buffer([1]), - actual = merge({}, { 'value': buffer }).value; - - assert.ok(lodashStable.isBuffer(actual)); - assert.strictEqual(actual[0], buffer[0]); - assert.notStrictEqual(actual, buffer); - } - }); - - it('should deep clone array/typed-array/plain-object source values', function() { - var typedArray = Uint8Array - ? new Uint8Array([1]) - : { 'buffer': [1] }; - - var props = ['0', 'buffer', 'a'], - values = [[{ 'a': 1 }], typedArray, { 'a': [1] }], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value, index) { - var key = props[index], - object = merge({}, { 'value': value }), - subValue = value[key], - newValue = object.value, - newSubValue = newValue[key]; - - return ( - newValue !== value && - newSubValue !== subValue && - lodashStable.isEqual(newValue, value) - ); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not augment source objects', function() { - var source1 = { 'a': [{ 'a': 1 }] }, - source2 = { 'a': [{ 'b': 2 }] }, - actual = merge({}, source1, source2); - - assert.deepStrictEqual(source1.a, [{ 'a': 1 }]); - assert.deepStrictEqual(source2.a, [{ 'b': 2 }]); - assert.deepStrictEqual(actual.a, [{ 'a': 1, 'b': 2 }]); - - var source1 = { 'a': [[1, 2, 3]] }, - source2 = { 'a': [[3, 4]] }, - actual = merge({}, source1, source2); - - assert.deepStrictEqual(source1.a, [[1, 2, 3]]); - assert.deepStrictEqual(source2.a, [[3, 4]]); - assert.deepStrictEqual(actual.a, [[3, 4, 3]]); - }); - - it('should merge plain objects onto non-plain objects', function() { - function Foo(object) { - lodashStable.assign(this, object); - } - - var object = { 'a': 1 }, - actual = merge(new Foo, object); - - assert.ok(actual instanceof Foo); - assert.deepStrictEqual(actual, new Foo(object)); - - actual = merge([new Foo], [object]); - assert.ok(actual[0] instanceof Foo); - assert.deepStrictEqual(actual, [new Foo(object)]); - }); - - it('should not overwrite existing values with `undefined` values of object sources', function() { - var actual = merge({ 'a': 1 }, { 'a': undefined, 'b': undefined }); - assert.deepStrictEqual(actual, { 'a': 1, 'b': undefined }); - }); - - it('should not overwrite existing values with `undefined` values of array sources', function() { - var array = [1]; - array[2] = 3; - - var actual = merge([4, 5, 6], array), - expected = [1, 5, 3]; - - assert.deepStrictEqual(actual, expected); - - array = [1, , 3]; - array[1] = undefined; - - actual = merge([4, 5, 6], array); - assert.deepStrictEqual(actual, expected); - }); - - it('should skip merging when `object` and `source` are the same value', function() { - var object = {}, - pass = true; - - defineProperty(object, 'a', { - 'configurable': true, - 'enumerable': true, - 'get': function() { pass = false; }, - 'set': function() { pass = false; } - }); - - merge(object, object); - assert.ok(pass); - }); - - it('should convert values to arrays when merging arrays of `source`', function() { - var object = { 'a': { '1': 'y', 'b': 'z', 'length': 2 } }, - actual = merge(object, { 'a': ['x'] }); - - assert.deepStrictEqual(actual, { 'a': ['x', 'y'] }); - - actual = merge({ 'a': {} }, { 'a': [] }); - assert.deepStrictEqual(actual, { 'a': [] }); - }); - - it('should convert strings to arrays when merging arrays of `source`', function() { - var object = { 'a': 'abcde' }, - actual = merge(object, { 'a': ['x', 'y', 'z'] }); - - assert.deepStrictEqual(actual, { 'a': ['x', 'y', 'z'] }); - }); - - it('should not error on DOM elements', function() { - var object1 = { 'el': document && document.createElement('div') }, - object2 = { 'el': document && document.createElement('div') }, - pairs = [[{}, object1], [object1, object2]], - expected = lodashStable.map(pairs, stubTrue); - - var actual = lodashStable.map(pairs, function(pair) { - try { - return merge(pair[0], pair[1]).el === pair[1].el; - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/mergeWith.js b/libs/nanofn/test/mergeWith.js deleted file mode 100644 index 45f10a907..000000000 --- a/libs/nanofn/test/mergeWith.js +++ /dev/null @@ -1,64 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop, identity, isNpm, mapCaches } from './utils.js'; -import mergeWith from '../mergeWith.js'; -import last from '../last.js'; - -describe('mergeWith', function() { - it('should handle merging when `customizer` returns `undefined`', function() { - var actual = mergeWith({ 'a': { 'b': [1, 1] } }, { 'a': { 'b': [0] } }, noop); - assert.deepStrictEqual(actual, { 'a': { 'b': [0, 1] } }); - - actual = mergeWith([], [undefined], identity); - assert.deepStrictEqual(actual, [undefined]); - }); - - it('should clone sources when `customizer` returns `undefined`', function() { - var source1 = { 'a': { 'b': { 'c': 1 } } }, - source2 = { 'a': { 'b': { 'd': 2 } } }; - - mergeWith({}, source1, source2, noop); - assert.deepStrictEqual(source1.a.b, { 'c': 1 }); - }); - - it('should defer to `customizer` for non `undefined` results', function() { - var actual = mergeWith({ 'a': { 'b': [0, 1] } }, { 'a': { 'b': [2] } }, function(a, b) { - return lodashStable.isArray(a) ? a.concat(b) : undefined; - }); - - assert.deepStrictEqual(actual, { 'a': { 'b': [0, 1, 2] } }); - }); - - it('should provide `stack` to `customizer`', function() { - var actual; - - mergeWith({}, { 'a': { 'b': 2 } }, function() { - actual = last(arguments); - }); - - assert.ok(isNpm - ? actual.constructor.name == 'Stack' - : actual instanceof mapCaches.Stack - ); - }); - - it('should overwrite primitives with source object clones', function() { - var actual = mergeWith({ 'a': 0 }, { 'a': { 'b': ['c'] } }, function(a, b) { - return lodashStable.isArray(a) ? a.concat(b) : undefined; - }); - - assert.deepStrictEqual(actual, { 'a': { 'b': ['c'] } }); - }); - - it('should pop the stack of sources for each sibling property', function() { - var array = ['b', 'c'], - object = { 'a': ['a'] }, - source = { 'a': array, 'b': array }; - - var actual = mergeWith(object, source, function(a, b) { - return lodashStable.isArray(a) ? a.concat(b) : undefined; - }); - - assert.deepStrictEqual(actual, { 'a': ['a', 'b', 'c'], 'b': ['b', 'c'] }); - }); -}); diff --git a/libs/nanofn/test/method.js b/libs/nanofn/test/method.js deleted file mode 100644 index 617c89105..000000000 --- a/libs/nanofn/test/method.js +++ /dev/null @@ -1,132 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubOne, _, stubTwo, stubThree, stubFour, noop, slice } from './utils.js'; -import constant from '../constant.js'; - -describe('method', function() { - it('should create a function that calls a method of a given object', function() { - var object = { 'a': stubOne }; - - lodashStable.each(['a', ['a']], function(path) { - var method = _.method(path); - assert.strictEqual(method.length, 1); - assert.strictEqual(method(object), 1); - }); - }); - - it('should work with deep property values', function() { - var object = { 'a': { 'b': stubTwo } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var method = _.method(path); - assert.strictEqual(method(object), 2); - }); - }); - - it('should work with a non-string `path`', function() { - var array = lodashStable.times(3, constant); - - lodashStable.each([1, [1]], function(path) { - var method = _.method(path); - assert.strictEqual(method(array), 1); - }); - }); - - it('should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var expected = [1, 2, 3, 4], - object = { 'null': stubOne, 'undefined': stubTwo, 'fn': stubThree, '[object Object]': stubFour }, - paths = [null, undefined, fn, {}]; - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - var method = _.method(index ? [path] : path); - return method(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should work with inherited property values', function() { - function Foo() {} - Foo.prototype.a = stubOne; - - lodashStable.each(['a', ['a']], function(path) { - var method = _.method(path); - assert.strictEqual(method(new Foo), 1); - }); - }); - - it('should use a key over a path', function() { - var object = { 'a.b': stubOne, 'a': { 'b': stubTwo } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - var method = _.method(path); - assert.strictEqual(method(object), 1); - }); - }); - - it('should return `undefined` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var method = _.method(path); - - var actual = lodashStable.map(values, function(value, index) { - return index ? method(value) : method(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` for deep paths when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var method = _.method(path); - - var actual = lodashStable.map(values, function(value, index) { - return index ? method(value) : method(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` if parts of `path` are missing', function() { - var object = {}; - - lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) { - var method = _.method(path); - assert.strictEqual(method(object), undefined); - }); - }); - - it('should apply partial arguments to function', function() { - var object = { - 'fn': function() { - return slice.call(arguments); - } - }; - - lodashStable.each(['fn', ['fn']], function(path) { - var method = _.method(path, 1, 2, 3); - assert.deepStrictEqual(method(object), [1, 2, 3]); - }); - }); - - it('should invoke deep property methods with the correct `this` binding', function() { - var object = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var method = _.method(path); - assert.strictEqual(method(object), 1); - }); - }); -}); diff --git a/libs/nanofn/test/methodOf.js b/libs/nanofn/test/methodOf.js deleted file mode 100644 index 29170a29f..000000000 --- a/libs/nanofn/test/methodOf.js +++ /dev/null @@ -1,131 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubOne, _, stubTwo, stubThree, stubFour, noop, slice } from './utils.js'; -import constant from '../constant.js'; - -describe('methodOf', function() { - it('should create a function that calls a method of a given key', function() { - var object = { 'a': stubOne }; - - lodashStable.each(['a', ['a']], function(path) { - var methodOf = _.methodOf(object); - assert.strictEqual(methodOf.length, 1); - assert.strictEqual(methodOf(path), 1); - }); - }); - - it('should work with deep property values', function() { - var object = { 'a': { 'b': stubTwo } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var methodOf = _.methodOf(object); - assert.strictEqual(methodOf(path), 2); - }); - }); - - it('should work with a non-string `path`', function() { - var array = lodashStable.times(3, constant); - - lodashStable.each([1, [1]], function(path) { - var methodOf = _.methodOf(array); - assert.strictEqual(methodOf(path), 1); - }); - }); - - it('should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var expected = [1, 2, 3, 4], - object = { 'null': stubOne, 'undefined': stubTwo, 'fn': stubThree, '[object Object]': stubFour }, - paths = [null, undefined, fn, {}]; - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - var methodOf = _.methodOf(object); - return methodOf(index ? [path] : path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should work with inherited property values', function() { - function Foo() {} - Foo.prototype.a = stubOne; - - lodashStable.each(['a', ['a']], function(path) { - var methodOf = _.methodOf(new Foo); - assert.strictEqual(methodOf(path), 1); - }); - }); - - it('should use a key over a path', function() { - var object = { 'a.b': stubOne, 'a': { 'b': stubTwo } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - var methodOf = _.methodOf(object); - assert.strictEqual(methodOf(path), 1); - }); - }); - - it('should return `undefined` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var actual = lodashStable.map(values, function(value, index) { - var methodOf = index ? _.methodOf() : _.methodOf(value); - return methodOf(path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` for deep paths when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var actual = lodashStable.map(values, function(value, index) { - var methodOf = index ? _.methodOf() : _.methodOf(value); - return methodOf(path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` if parts of `path` are missing', function() { - var object = {}, - methodOf = _.methodOf(object); - - lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) { - assert.strictEqual(methodOf(path), undefined); - }); - }); - - it('should apply partial arguments to function', function() { - var object = { - 'fn': function() { - return slice.call(arguments); - } - }; - - var methodOf = _.methodOf(object, 1, 2, 3); - - lodashStable.each(['fn', ['fn']], function(path) { - assert.deepStrictEqual(methodOf(path), [1, 2, 3]); - }); - }); - - it('should invoke deep property methods with the correct `this` binding', function() { - var object = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }, - methodOf = _.methodOf(object); - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(methodOf(path), 1); - }); - }); -}); diff --git a/libs/nanofn/test/methods-using-createWrapper.js b/libs/nanofn/test/methods-using-createWrapper.js deleted file mode 100644 index df44aa770..000000000 --- a/libs/nanofn/test/methods-using-createWrapper.js +++ /dev/null @@ -1,198 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, _, push, HOT_COUNT } from './utils.js'; -import bind from '../bind.js'; -import bindKey from '../bindKey.js'; -import partial from '../partial.js'; -import partialRight from '../partialRight.js'; -import last from '../last.js'; - -describe('methods using `createWrapper`', function() { - function fn() { - return slice.call(arguments); - } - - var ph1 = bind.placeholder, - ph2 = bindKey.placeholder, - ph3 = partial.placeholder, - ph4 = partialRight.placeholder; - - it('should work with combinations of partial functions', function() { - var a = partial(fn), - b = partialRight(a, 3), - c = partial(b, 1); - - assert.deepStrictEqual(c(2), [1, 2, 3]); - }); - - it('should work with combinations of bound and partial functions', function() { - var fn = function() { - var result = [this.a]; - push.apply(result, arguments); - return result; - }; - - var expected = [1, 2, 3, 4], - object = { 'a': 1, 'fn': fn }; - - var a = bindKey(object, 'fn'), - b = partialRight(a, 4), - c = partial(b, 2); - - assert.deepStrictEqual(c(3), expected); - - a = bind(fn, object); - b = partialRight(a, 4); - c = partial(b, 2); - - assert.deepStrictEqual(c(3), expected); - - a = partial(fn, 2); - b = bind(a, object); - c = partialRight(b, 4); - - assert.deepStrictEqual(c(3), expected); - }); - - it('should ensure `new combo` is an instance of `func`', function() { - function Foo(a, b, c) { - return b === 0 && object; - } - - var combo = partial(partialRight(Foo, 3), 1), - object = {}; - - assert.ok(new combo(2) instanceof Foo); - assert.strictEqual(new combo(0), object); - }); - - it('should work with combinations of functions with placeholders', function() { - var expected = [1, 2, 3, 4, 5, 6], - object = { 'fn': fn }; - - var a = bindKey(object, 'fn', ph2, 2), - b = partialRight(a, ph4, 6), - c = partial(b, 1, ph3, 4); - - assert.deepStrictEqual(c(3, 5), expected); - - a = bind(fn, object, ph1, 2); - b = partialRight(a, ph4, 6); - c = partial(b, 1, ph3, 4); - - assert.deepStrictEqual(c(3, 5), expected); - - a = partial(fn, ph3, 2); - b = bind(a, object, 1, ph1, 4); - c = partialRight(b, ph4, 6); - - assert.deepStrictEqual(c(3, 5), expected); - }); - - it('should work with combinations of functions with overlapping placeholders', function() { - var expected = [1, 2, 3, 4], - object = { 'fn': fn }; - - var a = bindKey(object, 'fn', ph2, 2), - b = partialRight(a, ph4, 4), - c = partial(b, ph3, 3); - - assert.deepStrictEqual(c(1), expected); - - a = bind(fn, object, ph1, 2); - b = partialRight(a, ph4, 4); - c = partial(b, ph3, 3); - - assert.deepStrictEqual(c(1), expected); - - a = partial(fn, ph3, 2); - b = bind(a, object, ph1, 3); - c = partialRight(b, ph4, 4); - - assert.deepStrictEqual(c(1), expected); - }); - - it('should work with recursively bound functions', function() { - var fn = function() { - return this.a; - }; - - var a = bind(fn, { 'a': 1 }), - b = bind(a, { 'a': 2 }), - c = bind(b, { 'a': 3 }); - - assert.strictEqual(c(), 1); - }); - - it('should work when hot', function() { - lodashStable.times(2, function(index) { - var fn = function() { - var result = [this]; - push.apply(result, arguments); - return result; - }; - - var object = {}, - bound1 = index ? bind(fn, object, 1) : bind(fn, object), - expected = [object, 1, 2, 3]; - - var actual = last(lodashStable.times(HOT_COUNT, function() { - var bound2 = index ? bind(bound1, null, 2) : bind(bound1); - return index ? bound2(3) : bound2(1, 2, 3); - })); - - assert.deepStrictEqual(actual, expected); - - actual = last(lodashStable.times(HOT_COUNT, function() { - var bound1 = index ? bind(fn, object, 1) : bind(fn, object), - bound2 = index ? bind(bound1, null, 2) : bind(bound1); - - return index ? bound2(3) : bound2(1, 2, 3); - })); - - assert.deepStrictEqual(actual, expected); - }); - - lodashStable.each(['curry', 'curryRight'], function(methodName, index) { - var fn = function(a, b, c) { return [a, b, c]; }, - curried = _[methodName](fn), - expected = index ? [3, 2, 1] : [1, 2, 3]; - - var actual = last(lodashStable.times(HOT_COUNT, function() { - return curried(1)(2)(3); - })); - - assert.deepStrictEqual(actual, expected); - - actual = last(lodashStable.times(HOT_COUNT, function() { - var curried = _[methodName](fn); - return curried(1)(2)(3); - })); - - assert.deepStrictEqual(actual, expected); - }); - - lodashStable.each(['partial', 'partialRight'], function(methodName, index) { - var func = _[methodName], - fn = function() { return slice.call(arguments); }, - par1 = func(fn, 1), - expected = index ? [3, 2, 1] : [1, 2, 3]; - - var actual = last(lodashStable.times(HOT_COUNT, function() { - var par2 = func(par1, 2); - return par2(3); - })); - - assert.deepStrictEqual(actual, expected); - - actual = last(lodashStable.times(HOT_COUNT, function() { - var par1 = func(fn, 1), - par2 = func(par1, 2); - - return par2(3); - })); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/min.js b/libs/nanofn/test/min.js deleted file mode 100644 index 271d44431..000000000 --- a/libs/nanofn/test/min.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, noop } from './utils.js'; -import min from '../min.js'; - -describe('min', function() { - it('should return the smallest value from a collection', function() { - assert.strictEqual(min([1, 2, 3]), 1); - }); - - it('should return `undefined` for empty collections', function() { - var values = falsey.concat([[]]), - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? min(value) : min(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with non-numeric collection values', function() { - assert.strictEqual(min(['a', 'b']), 'a'); - }); -}); diff --git a/libs/nanofn/test/mixin.js b/libs/nanofn/test/mixin.js deleted file mode 100644 index 4b78cf848..000000000 --- a/libs/nanofn/test/mixin.js +++ /dev/null @@ -1,189 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, getUnwrappedValue, noop } from './utils.js'; -import has from '../has.js'; -import mixin from '../mixin.js'; -import prototype from '../prototype.js'; -import countBy from '../countBy.js'; -import filter from '../filter.js'; - -describe('mixin', function() { - function reset(wrapper) { - delete wrapper.a; - delete wrapper.prototype.a; - delete wrapper.b; - delete wrapper.prototype.b; - } - - function Wrapper(value) { - if (!(this instanceof Wrapper)) { - return new Wrapper(value); - } - if (has(value, '__wrapped__')) { - var actions = slice.call(value.__actions__), - chain = value.__chain__; - - value = value.__wrapped__; - } - this.__wrapped__ = value; - this.__actions__ = actions || []; - this.__chain__ = chain || false; - } - - Wrapper.prototype.value = function() { - return getUnwrappedValue(this); - }; - - var array = ['a'], - source = { 'a': function(array) { return array[0]; }, 'b': 'B' }; - - it('should mixin `source` methods into lodash', function() { - mixin(source); - - assert.strictEqual(_.a(array), 'a'); - assert.strictEqual(_(array).a().value(), 'a'); - assert.notOk('b' in _); - assert.notOk('b' in prototype); - - reset(_); - }); - - it('should mixin chaining methods by reference', function() { - mixin(source); - _.a = stubB; - - assert.strictEqual(_.a(array), 'b'); - assert.strictEqual(_(array).a().value(), 'a'); - - reset(_); - }); - - it('should use a default `object` of `this`', function() { - var object = lodashStable.create(_); - object.mixin(source); - - assert.strictEqual(object.a(array), 'a'); - assert.ok(!('a' in _)); - assert.ok(!('a' in prototype)); - - reset(_); - }); - - it('should accept an `object`', function() { - var object = {}; - mixin(object, source); - assert.strictEqual(object.a(array), 'a'); - }); - - it('should accept a function `object`', function() { - mixin(Wrapper, source); - - var wrapped = Wrapper(array), - actual = wrapped.a(); - - assert.strictEqual(actual.value(), 'a'); - assert.ok(actual instanceof Wrapper); - - reset(Wrapper); - }); - - it('should return `object`', function() { - var object = {}; - assert.strictEqual(mixin(object, source), object); - assert.strictEqual(mixin(Wrapper, source), Wrapper); - assert.strictEqual(mixin(), _); - - reset(Wrapper); - }); - - it('should not assign inherited `source` methods', function() { - function Foo() {} - Foo.prototype.a = noop; - - var object = {}; - assert.strictEqual(mixin(object, new Foo), object); - }); - - it('should accept an `options`', function() { - function message(func, chain) { - return (func === _ ? 'lodash' : 'given') + ' function should ' + (chain ? '' : 'not ') + 'chain'; - } - - lodashStable.each([_, Wrapper], function(func) { - lodashStable.each([{ 'chain': false }, { 'chain': true }], function(options) { - if (func === _) { - mixin(source, options); - } else { - mixin(func, source, options); - } - var wrapped = func(array), - actual = wrapped.a(); - - if (options.chain) { - assert.strictEqual(actual.value(), 'a', message(func, true)); - assert.ok(actual instanceof func, message(func, true)); - } else { - assert.strictEqual(actual, 'a', message(func, false)); - assert.notOk(actual instanceof func, message(func, false)); - } - reset(func); - }); - }); - }); - - it('should not extend lodash when an `object` is given with an empty `options` object', function() { - mixin({ 'a': noop }, {}); - assert.ok(!('a' in _)); - reset(_); - }); - - it('should not error for non-object `options` values', function() { - var pass = true; - - try { - mixin({}, source, 1); - } catch (e) { - pass = false; - } - assert.ok(pass); - - pass = true; - - try { - mixin(source, 1); - } catch (e) { - pass = false; - } - assert.ok(pass); - - reset(_); - }); - - it('should not return the existing wrapped value when chaining', function() { - lodashStable.each([_, Wrapper], function(func) { - if (func === _) { - var wrapped = _(source), - actual = wrapped.mixin(); - - assert.strictEqual(actual.value(), _); - } - else { - wrapped = _(func); - actual = wrapped.mixin(source); - assert.notStrictEqual(actual, wrapped); - } - reset(func); - }); - }); - - it('should produce methods that work in a lazy sequence', function() { - mixin({ 'a': countBy, 'b': filter }); - - var array = lodashStable.range(LARGE_ARRAY_SIZE), - actual = _(array).a().map(square).b(isEven).take().value(); - - assert.deepEqual(actual, _.take(_.b(_.map(_.a(array), square), isEven))); - - reset(_); - }); -}); diff --git a/libs/nanofn/test/multiply.test.js b/libs/nanofn/test/multiply.test.js deleted file mode 100644 index 23e966fb9..000000000 --- a/libs/nanofn/test/multiply.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import multiply from '../multiply.js'; - -describe('multiply', function() { - it('should multiply two numbers', function() { - assert.strictEqual(multiply(6, 4), 24); - assert.strictEqual(multiply(-6, 4), -24); - assert.strictEqual(multiply(-6, -4), 24); - }); - - it('should coerce arguments to numbers', function() { - assert.strictEqual(multiply('6', '4'), 24); - assert.deepStrictEqual(multiply('x', 'y'), NaN); - }); -}); diff --git a/libs/nanofn/test/negate.js b/libs/nanofn/test/negate.js deleted file mode 100644 index 3f7725592..000000000 --- a/libs/nanofn/test/negate.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, isEven, stubTrue } from './utils.js'; - -describe('negate', function() { - it('should create a function that negates the result of `func`', function() { - var negate = _.negate(isEven); - - assert.strictEqual(negate(1), true); - assert.strictEqual(negate(2), false); - }); - - it('should create a function that negates the result of `func`', function() { - var negate = _.negate(isEven); - - assert.strictEqual(negate(1), true); - assert.strictEqual(negate(2), false); - }); - - it('should create a function that accepts multiple arguments', function() { - var argCount, - count = 5, - negate = _.negate(function() { argCount = arguments.length; }), - expected = lodashStable.times(count, stubTrue); - - var actual = lodashStable.times(count, function(index) { - switch (index) { - case 0: negate(); break; - case 1: negate(1); break; - case 2: negate(1, 2); break; - case 3: negate(1, 2, 3); break; - case 4: negate(1, 2, 3, 4); - } - return argCount == index; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/noConflict.js b/libs/nanofn/test/noConflict.js deleted file mode 100644 index 419130d5b..000000000 --- a/libs/nanofn/test/noConflict.js +++ /dev/null @@ -1,33 +0,0 @@ -import assert from 'assert'; -import { oldDash, coverage, document, isModularize, realm, filePath } from './utils.js'; -import noConflict from '../noConflict.js'; - -describe('noConflict', function() { - it('should return the `lodash` function', function() { - assert.strictEqual(noConflict(), oldDash); - assert.notStrictEqual(root._, oldDash); - root._ = oldDash; - }); - - it('should restore `_` only if `lodash` is the current `_` value', function() { - var object = root._ = {}; - assert.strictEqual(noConflict(), oldDash); - assert.strictEqual(root._, object); - root._ = oldDash; - }); - - it('should work with a `root` of `this`', function() { - if (!coverage && !document && !isModularize && realm.object) { - var fs = require('fs'), - vm = require('vm'), - expected = {}, - context = vm.createContext({ '_': expected, 'console': console }), - source = fs.readFileSync(filePath, 'utf8'); - - vm.runInContext(source + '\nthis.lodash = this._.noConflict()', context); - - assert.strictEqual(context._, expected); - assert.ok(context.lodash); - } - }); -}); diff --git a/libs/nanofn/test/now.js b/libs/nanofn/test/now.js deleted file mode 100644 index 6b2febb24..000000000 --- a/libs/nanofn/test/now.js +++ /dev/null @@ -1,26 +0,0 @@ -import assert from 'assert'; -import { _, stubA } from './utils.js'; - -describe('now', function() { - it('should return the number of milliseconds that have elapsed since the Unix epoch', function(done) { - var stamp = +new Date, - actual = _.now(); - - assert.ok(actual >= stamp); - - setTimeout(function() { - assert.ok(_.now() > actual); - done(); - }, 32); - }); - - it('should work with mocked `Date.now`', function() { - var now = Date.now; - Date.now = stubA; - - var actual = _.now(); - Date.now = now; - - assert.strictEqual(actual, 'a'); - }); -}); diff --git a/libs/nanofn/test/nth.js b/libs/nanofn/test/nth.js deleted file mode 100644 index 49c0fcf2e..000000000 --- a/libs/nanofn/test/nth.js +++ /dev/null @@ -1,69 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubA, stubB, noop } from './utils.js'; -import nth from '../nth.js'; - -describe('nth', function() { - var array = ['a', 'b', 'c', 'd']; - - it('should get the nth element of `array`', function() { - var actual = lodashStable.map(array, function(value, index) { - return nth(array, index); - }); - - assert.deepStrictEqual(actual, array); - }); - - it('should work with a negative `n`', function() { - var actual = lodashStable.map(lodashStable.range(1, array.length + 1), function(n) { - return nth(array, -n); - }); - - assert.deepStrictEqual(actual, ['d', 'c', 'b', 'a']); - }); - - it('should coerce `n` to an integer', function() { - var values = falsey, - expected = lodashStable.map(values, stubA); - - var actual = lodashStable.map(values, function(n) { - return n ? nth(array, n) : nth(array); - }); - - assert.deepStrictEqual(actual, expected); - - values = ['1', 1.6]; - expected = lodashStable.map(values, stubB); - - actual = lodashStable.map(values, function(n) { - return nth(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `undefined` for empty arrays', function() { - var values = [null, undefined, []], - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(array) { - return nth(array, 1); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `undefined` for non-indexes', function() { - var array = [1, 2], - values = [Infinity, array.length], - expected = lodashStable.map(values, noop); - - array[-1] = 3; - - var actual = lodashStable.map(values, function(n) { - return nth(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/nthArg.js b/libs/nanofn/test/nthArg.js deleted file mode 100644 index 387e15f7d..000000000 --- a/libs/nanofn/test/nthArg.js +++ /dev/null @@ -1,65 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, falsey, stubA, stubB, noop } from './utils.js'; -import nthArg from '../nthArg.js'; - -describe('nthArg', function() { - var args = ['a', 'b', 'c', 'd']; - - it('should create a function that returns its nth argument', function() { - var actual = lodashStable.map(args, function(value, index) { - var func = nthArg(index); - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, args); - }); - - it('should work with a negative `n`', function() { - var actual = lodashStable.map(lodashStable.range(1, args.length + 1), function(n) { - var func = nthArg(-n); - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, ['d', 'c', 'b', 'a']); - }); - - it('should coerce `n` to an integer', function() { - var values = falsey, - expected = lodashStable.map(values, stubA); - - var actual = lodashStable.map(values, function(n) { - var func = n ? nthArg(n) : nthArg(); - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - - values = ['1', 1.6]; - expected = lodashStable.map(values, stubB); - - actual = lodashStable.map(values, function(n) { - var func = nthArg(n); - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `undefined` for empty arrays', function() { - var func = nthArg(1); - assert.strictEqual(func(), undefined); - }); - - it('should return `undefined` for non-indexes', function() { - var values = [Infinity, args.length], - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(n) { - var func = nthArg(n); - return func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/number-coercion-methods.js b/libs/nanofn/test/number-coercion-methods.js deleted file mode 100644 index edf982d62..000000000 --- a/libs/nanofn/test/number-coercion-methods.js +++ /dev/null @@ -1,248 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - _, - identity, - whitespace, - MAX_SAFE_INTEGER, - MAX_INTEGER, - MAX_ARRAY_LENGTH, - symbol, - falsey, -} from './utils.js'; - -describe('number coercion methods', function() { - lodashStable.each(['toFinite', 'toInteger', 'toNumber', 'toSafeInteger'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var values = [0, '0', -0, '-0'], - expected = [[0, Infinity], [0, Infinity], [-0, -Infinity], [-0, -Infinity]]; - - lodashStable.times(2, function(index) { - var others = lodashStable.map(values, index ? Object : identity); - - var actual = lodashStable.map(others, function(value) { - var result = func(value); - return [result, 1 / result]; - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - }); - - lodashStable.each(['toFinite', 'toInteger', 'toLength', 'toNumber', 'toSafeInteger'], function(methodName) { - var func = _[methodName], - isToFinite = methodName == 'toFinite', - isToLength = methodName == 'toLength', - isToNumber = methodName == 'toNumber', - isToSafeInteger = methodName == 'toSafeInteger'; - - function negative(string) { - return '-' + string; - } - - function pad(string) { - return whitespace + string + whitespace; - } - - function positive(string) { - return '+' + string; - } - - it('`_.' + methodName + '` should pass thru primitive number values', function() { - var values = [0, 1, NaN]; - - var expected = lodashStable.map(values, function(value) { - return (!isToNumber && value !== value) ? 0 : value; - }); - - var actual = lodashStable.map(values, func); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert number primitives and objects to numbers', function() { - var values = [2, 1.2, MAX_SAFE_INTEGER, MAX_INTEGER, Infinity, NaN]; - - var expected = lodashStable.map(values, function(value) { - if (!isToNumber) { - if (!isToFinite && value == 1.2) { - value = 1; - } - else if (value == Infinity) { - value = MAX_INTEGER; - } - else if (value !== value) { - value = 0; - } - if (isToLength || isToSafeInteger) { - value = Math.min(value, isToLength ? MAX_ARRAY_LENGTH : MAX_SAFE_INTEGER); - } - } - var neg = isToLength ? 0 : -value; - return [value, value, neg, neg]; - }); - - var actual = lodashStable.map(values, function(value) { - return [func(value), func(Object(value)), func(-value), func(Object(-value))]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert string primitives and objects to numbers', function() { - var transforms = [identity, pad, positive, negative]; - - var values = [ - '10', '1.234567890', (MAX_SAFE_INTEGER + ''), - '1e+308', '1e308', '1E+308', '1E308', - '5e-324', '5E-324', - 'Infinity', 'NaN' - ]; - - var expected = lodashStable.map(values, function(value) { - var n = +value; - if (!isToNumber) { - if (!isToFinite && n == 1.234567890) { - n = 1; - } - else if (n == Infinity) { - n = MAX_INTEGER; - } - else if ((!isToFinite && n == Number.MIN_VALUE) || n !== n) { - n = 0; - } - if (isToLength || isToSafeInteger) { - n = Math.min(n, isToLength ? MAX_ARRAY_LENGTH : MAX_SAFE_INTEGER); - } - } - var neg = isToLength ? 0 : -n; - return [n, n, n, n, n, n, neg, neg]; - }); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.flatMap(transforms, function(mod) { - return [func(mod(value)), func(Object(mod(value)))]; - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert binary/octal strings to numbers', function() { - var numbers = [42, 5349, 1715004], - transforms = [identity, pad], - values = ['0b101010', '0o12345', '0x1a2b3c']; - - var expected = lodashStable.map(numbers, function(n) { - return lodashStable.times(8, lodashStable.constant(n)); - }); - - var actual = lodashStable.map(values, function(value) { - var upper = value.toUpperCase(); - return lodashStable.flatMap(transforms, function(mod) { - return [func(mod(value)), func(Object(mod(value))), func(mod(upper)), func(Object(mod(upper)))]; - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert invalid binary/octal strings to `' + (isToNumber ? 'NaN' : '0') + '`', function() { - var transforms = [identity, pad, positive, negative], - values = ['0b', '0o', '0x', '0b1010102', '0o123458', '0x1a2b3x']; - - var expected = lodashStable.map(values, function(n) { - return lodashStable.times(8, lodashStable.constant(isToNumber ? NaN : 0)); - }); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.flatMap(transforms, function(mod) { - return [func(mod(value)), func(Object(mod(value)))]; - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert symbols to `' + (isToNumber ? 'NaN' : '0') + '`', function() { - if (Symbol) { - var object1 = Object(symbol), - object2 = Object(symbol), - values = [symbol, object1, object2], - expected = lodashStable.map(values, lodashStable.constant(isToNumber ? NaN : 0)); - - object2.valueOf = undefined; - var actual = lodashStable.map(values, func); - - assert.deepStrictEqual(actual, expected); - } - }); - - it('`_.' + methodName + '` should convert empty values to `0` or `NaN`', function() { - var values = falsey.concat(whitespace); - - var expected = lodashStable.map(values, function(value) { - return (isToNumber && value !== whitespace) ? Number(value) : 0; - }); - - var actual = lodashStable.map(values, function(value, index) { - return index ? func(value) : func(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should coerce objects to numbers', function() { - var values = [ - {}, - [], - [1], - [1, 2], - { 'valueOf': '1.1' }, - { 'valueOf': '1.1', 'toString': lodashStable.constant('2.2') }, - { 'valueOf': lodashStable.constant('1.1'), 'toString': '2.2' }, - { 'valueOf': lodashStable.constant('1.1'), 'toString': lodashStable.constant('2.2') }, - { 'valueOf': lodashStable.constant('-0x1a2b3c') }, - { 'toString': lodashStable.constant('-0x1a2b3c') }, - { 'valueOf': lodashStable.constant('0o12345') }, - { 'toString': lodashStable.constant('0o12345') }, - { 'valueOf': lodashStable.constant('0b101010') }, - { 'toString': lodashStable.constant('0b101010') } - ]; - - var expected = [ - NaN, 0, 1, NaN, - NaN, 2.2, 1.1, 1.1, - NaN, NaN, - 5349, 5349, - 42, 42 - ]; - - if (isToFinite) { - expected = [ - 0, 0, 1, 0, - 0, 2.2, 1.1, 1.1, - 0, 0, - 5349, 5349, - 42, 42 - ]; - } - else if (!isToNumber) { - expected = [ - 0, 0, 1, 0, - 0, 2, 1, 1, - 0, 0, - 5349, 5349, - 42, 42 - ]; - } - var actual = lodashStable.map(values, func); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/object-assignments.js b/libs/nanofn/test/object-assignments.js deleted file mode 100644 index a9cb8b0cb..000000000 --- a/libs/nanofn/test/object-assignments.js +++ /dev/null @@ -1,180 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, primitives, stubTrue, defineProperty, slice } from './utils.js'; -import has from '../has.js'; - -describe('object assignments', function() { - lodashStable.each(['assign', 'assignIn', 'defaults', 'defaultsDeep', 'merge'], function(methodName) { - var func = _[methodName], - isAssign = methodName == 'assign', - isDefaults = /^defaults/.test(methodName); - - it('`_.' + methodName + '` should coerce primitives to objects', function() { - var expected = lodashStable.map(primitives, function(value) { - var object = Object(value); - object.a = 1; - return object; - }); - - var actual = lodashStable.map(primitives, function(value) { - return func(value, { 'a': 1 }); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should assign own ' + (isAssign ? '' : 'and inherited ') + 'string keyed source properties', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var expected = isAssign ? { 'a': 1 } : { 'a': 1, 'b': 2 }; - assert.deepStrictEqual(func({}, new Foo), expected); - }); - - it('`_.' + methodName + '` should not skip a trailing function source', function() { - function fn() {} - fn.b = 2; - - assert.deepStrictEqual(func({}, { 'a': 1 }, fn), { 'a': 1, 'b': 2 }); - }); - - it('`_.' + methodName + '` should not error on nullish sources', function() { - try { - assert.deepStrictEqual(func({ 'a': 1 }, undefined, { 'b': 2 }, null), { 'a': 1, 'b': 2 }); - } catch (e) { - assert.ok(false, e.message); - } - }); - - it('`_.' + methodName + '` should create an object when `object` is nullish', function() { - var source = { 'a': 1 }, - values = [null, undefined], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - var object = func(value, source); - return object !== source && lodashStable.isEqual(object, source); - }); - - assert.deepStrictEqual(actual, expected); - - actual = lodashStable.map(values, function(value) { - return lodashStable.isEqual(func(value), {}); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', function() { - var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }], - expected = { 'a': isDefaults ? 0 : 1, 'b': 2, 'c': 3 }; - - function fn() {} - fn.a = array[0]; - fn.b = array[1]; - fn.c = array[2]; - - assert.deepStrictEqual(lodashStable.reduce(array, func, { 'a': 0 }), expected); - assert.deepStrictEqual(lodashStable.reduce(fn, func, { 'a': 0 }), expected); - }); - - it('`_.' + methodName + '` should not return the existing wrapped value when chaining', function() { - var wrapped = _({ 'a': 1 }), - actual = wrapped[methodName]({ 'b': 2 }); - - assert.notStrictEqual(actual, wrapped); - }); - }); - - lodashStable.each(['assign', 'assignIn', 'merge'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should not treat `object` as `source`', function() { - function Foo() {} - Foo.prototype.a = 1; - - var actual = func(new Foo, { 'b': 2 }); - assert.ok(!has(actual, 'a')); - }); - }); - - lodashStable.each(['assign', 'assignIn', 'assignInWith', 'assignWith', 'defaults', 'defaultsDeep', 'merge', 'mergeWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should not assign values that are the same as their destinations', function() { - lodashStable.each(['a', ['a'], { 'a': 1 }, NaN], function(value) { - var object = {}, - pass = true; - - defineProperty(object, 'a', { - 'configurable': true, - 'enumerable': true, - 'get': lodashStable.constant(value), - 'set': function() { pass = false; } - }); - - func(object, { 'a': value }); - assert.ok(pass); - }); - }); - }); - - lodashStable.each(['assignWith', 'assignInWith', 'mergeWith'], function(methodName) { - var func = _[methodName], - isMergeWith = methodName == 'mergeWith'; - - it('`_.' + methodName + '` should provide correct `customizer` arguments', function() { - var args, - object = { 'a': 1 }, - source = { 'a': 2 }, - expected = lodashStable.map([1, 2, 'a', object, source], lodashStable.cloneDeep); - - func(object, source, function() { - args || (args = lodashStable.map(slice.call(arguments, 0, 5), lodashStable.cloneDeep)); - }); - - assert.deepStrictEqual(args, expected, 'primitive values'); - - var argsList = [], - objectValue = [1, 2], - sourceValue = { 'b': 2 }; - - object = { 'a': objectValue }; - source = { 'a': sourceValue }; - expected = [lodashStable.map([objectValue, sourceValue, 'a', object, source], lodashStable.cloneDeep)]; - - if (isMergeWith) { - expected.push(lodashStable.map([undefined, 2, 'b', objectValue, sourceValue], lodashStable.cloneDeep)); - } - func(object, source, function() { - argsList.push(lodashStable.map(slice.call(arguments, 0, 5), lodashStable.cloneDeep)); - }); - - assert.deepStrictEqual(argsList, expected, 'object values'); - - args = undefined; - object = { 'a': 1 }; - source = { 'b': 2 }; - expected = lodashStable.map([undefined, 2, 'b', object, source], lodashStable.cloneDeep); - - func(object, source, function() { - args || (args = lodashStable.map(slice.call(arguments, 0, 5), lodashStable.cloneDeep)); - }); - - assert.deepStrictEqual(args, expected, 'undefined properties'); - }); - - it('`_.' + methodName + '` should not treat the second argument as a `customizer` callback', function() { - function callback() {} - callback.b = 2; - - var actual = func({ 'a': 1 }, callback); - assert.deepStrictEqual(actual, { 'a': 1, 'b': 2 }); - - actual = func({ 'a': 1 }, callback, { 'c': 3 }); - assert.deepStrictEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); - }); - }); -}); diff --git a/libs/nanofn/test/omit-methods.js b/libs/nanofn/test/omit-methods.js deleted file mode 100644 index 750cb9f34..000000000 --- a/libs/nanofn/test/omit-methods.js +++ /dev/null @@ -1,114 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, symbol, defineProperty } from './utils.js'; - -describe('omit methods', function() { - lodashStable.each(['omit', 'omitBy'], function(methodName) { - var expected = { 'b': 2, 'd': 4 }, - func = _[methodName], - object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - resolve = lodashStable.nthArg(1); - - if (methodName == 'omitBy') { - resolve = function(object, props) { - props = lodashStable.castArray(props); - return function(value) { - return lodashStable.some(props, function(key) { - key = lodashStable.isSymbol(key) ? key : lodashStable.toString(key); - return object[key] === value; - }); - }; - }; - } - it('`_.' + methodName + '` should create an object with omitted string keyed properties', function() { - assert.deepStrictEqual(func(object, resolve(object, 'a')), { 'b': 2, 'c': 3, 'd': 4 }); - assert.deepStrictEqual(func(object, resolve(object, ['a', 'c'])), expected); - }); - - it('`_.' + methodName + '` should include inherited string keyed properties', function() { - function Foo() {} - Foo.prototype = object; - - assert.deepStrictEqual(func(new Foo, resolve(object, ['a', 'c'])), expected); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)], - expected = [{ '0': 'b' }, { '0': 'b' }, { '-0': 'a' }, { '-0': 'a' }]; - - var actual = lodashStable.map(props, function(key) { - return func(object, resolve(object, key)); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should include symbols', function() { - function Foo() { - this.a = 0; - this[symbol] = 1; - } - - if (Symbol) { - var symbol2 = Symbol('b'); - Foo.prototype[symbol2] = 2; - - var symbol3 = Symbol('c'); - defineProperty(Foo.prototype, symbol3, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 3 - }); - - var foo = new Foo, - actual = func(foo, resolve(foo, 'a')); - - assert.strictEqual(actual[symbol], 1); - assert.strictEqual(actual[symbol2], 2); - assert.ok(!(symbol3 in actual)); - } - }); - - it('`_.' + methodName + '` should create an object with omitted symbols', function() { - function Foo() { - this.a = 0; - this[symbol] = 1; - } - - if (Symbol) { - var symbol2 = Symbol('b'); - Foo.prototype[symbol2] = 2; - - var symbol3 = Symbol('c'); - defineProperty(Foo.prototype, symbol3, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 3 - }); - - var foo = new Foo, - actual = func(foo, resolve(foo, symbol)); - - assert.strictEqual(actual.a, 0); - assert.ok(!(symbol in actual)); - assert.strictEqual(actual[symbol2], 2); - assert.ok(!(symbol3 in actual)); - - actual = func(foo, resolve(foo, symbol2)); - - assert.strictEqual(actual.a, 0); - assert.strictEqual(actual[symbol], 1); - assert.ok(!(symbol2 in actual)); - assert.ok(!(symbol3 in actual)); - } - }); - - it('`_.' + methodName + '` should work with an array `object`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(func(array, resolve(array, ['0', '2'])), { '1': 2 }); - }); - }); -}); diff --git a/libs/nanofn/test/omit.js b/libs/nanofn/test/omit.js deleted file mode 100644 index 7bde8dc8d..000000000 --- a/libs/nanofn/test/omit.js +++ /dev/null @@ -1,69 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, toArgs, objectProto, stringProto } from './utils.js'; -import omit from '../omit.js'; - -describe('omit', function() { - var args = toArgs(['a', 'c']), - object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - nested = { 'a': 1, 'b': { 'c': 2, 'd': 3 } }; - - it('should flatten `paths`', function() { - assert.deepStrictEqual(omit(object, 'a', 'c'), { 'b': 2, 'd': 4 }); - assert.deepStrictEqual(omit(object, ['a', 'd'], 'c'), { 'b': 2 }); - }); - - it('should support deep paths', function() { - assert.deepStrictEqual(omit(nested, 'b.c'), { 'a': 1, 'b': { 'd': 3} }); - }); - - it('should support path arrays', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }, - actual = omit(object, [['a.b']]); - - assert.deepStrictEqual(actual, { 'a': { 'b': 2 } }); - }); - - it('should omit a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - assert.deepStrictEqual(omit(object, path), { 'a': { 'b': 2 } }); - }); - }); - - it('should coerce `paths` to strings', function() { - assert.deepStrictEqual(omit({ '0': 'a' }, 0), {}); - }); - - it('should return an empty object when `object` is nullish', function() { - lodashStable.each([null, undefined], function(value) { - objectProto.a = 1; - var actual = omit(value, 'valueOf'); - delete objectProto.a; - assert.deepStrictEqual(actual, {}); - }); - }); - - it('should work with a primitive `object`', function() { - stringProto.a = 1; - stringProto.b = 2; - - assert.deepStrictEqual(omit('', 'b'), { 'a': 1 }); - - delete stringProto.a; - delete stringProto.b; - }); - - it('should work with `arguments` object `paths`', function() { - assert.deepStrictEqual(omit(object, args), { 'b': 2, 'd': 4 }); - }); - - it('should not mutate `object`', function() { - lodashStable.each(['a', ['a'], 'a.b', ['a.b']], function(path) { - var object = { 'a': { 'b': 2 } }; - omit(object, path); - assert.deepStrictEqual(object, { 'a': { 'b': 2 } }); - }); - }); -}); diff --git a/libs/nanofn/test/omitBy.js b/libs/nanofn/test/omitBy.js deleted file mode 100644 index 28c6a9aff..000000000 --- a/libs/nanofn/test/omitBy.js +++ /dev/null @@ -1,14 +0,0 @@ -import assert from 'assert'; -import omitBy from '../omitBy.js'; - -describe('omitBy', function() { - it('should work with a predicate argument', function() { - var object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }; - - var actual = omitBy(object, function(n) { - return n != 2 && n != 4; - }); - - assert.deepStrictEqual(actual, { 'b': 2, 'd': 4 }); - }); -}); diff --git a/libs/nanofn/test/once.test.js b/libs/nanofn/test/once.test.js deleted file mode 100644 index 7279125e8..000000000 --- a/libs/nanofn/test/once.test.js +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'assert'; -import { _ } from './utils.js'; - -describe('once', function() { - it('should invoke `func` once', function() { - var count = 0, - once = _.once(function() { return ++count; }); - - once(); - assert.strictEqual(once(), 1); - assert.strictEqual(count, 1); - }); - - it('should ignore recursive calls', function() { - var count = 0; - - var once = _.once(function() { - once(); - return ++count; - }); - - assert.strictEqual(once(), 1); - assert.strictEqual(count, 1); - }); - - it('should not throw more than once', function() { - var once = _.once(function() { - throw new Error; - }); - - assert.throws(once); - - once(); - assert.ok(true); - }); -}); diff --git a/libs/nanofn/test/orderBy.js b/libs/nanofn/test/orderBy.js deleted file mode 100644 index 7aba5fe48..000000000 --- a/libs/nanofn/test/orderBy.js +++ /dev/null @@ -1,61 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey } from './utils.js'; -import orderBy from '../orderBy.js'; - -describe('orderBy', function() { - var objects = [ - { 'a': 'x', 'b': 3 }, - { 'a': 'y', 'b': 4 }, - { 'a': 'x', 'b': 1 }, - { 'a': 'y', 'b': 2 } - ]; - - var nestedObj = [ - { id: '4', address: { zipCode: 4, streetName: 'Beta' } }, - { id: '3', address: { zipCode: 3, streetName: 'Alpha' } }, - { id: '1', address: { zipCode: 1, streetName: 'Alpha' } }, - { id: '2', address: { zipCode: 2, streetName: 'Alpha' } }, - { id: '5', address: { zipCode: 4, streetName: 'Alpha' } }, - ]; - - - it('should sort by a single property by a specified order', function() { - var actual = orderBy(objects, 'a', 'desc'); - assert.deepStrictEqual(actual, [objects[1], objects[3], objects[0], objects[2]]); - }); - - it('should sort by nested key in array format', () => { - var actual = orderBy( - nestedObj, - [['address', 'zipCode'], ['address.streetName']], - ['asc', 'desc'], - ); - assert.deepStrictEqual(actual, [nestedObj[2], nestedObj[3], nestedObj[1], nestedObj[0], nestedObj[4]]); - }); - - it('should sort by multiple properties by specified orders', function() { - var actual = orderBy(objects, ['a', 'b'], ['desc', 'asc']); - assert.deepStrictEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); - }); - - it('should sort by a property in ascending order when its order is not specified', function() { - var expected = [objects[2], objects[0], objects[3], objects[1]], - actual = orderBy(objects, ['a', 'b']); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(falsey, lodashStable.constant([objects[3], objects[1], objects[2], objects[0]])); - - actual = lodashStable.map(falsey, function(order, index) { - return orderBy(objects, ['a', 'b'], index ? ['desc', order] : ['desc']); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `orders` specified as string objects', function() { - var actual = orderBy(objects, ['a'], [Object('desc')]); - assert.deepStrictEqual(actual, [objects[1], objects[3], objects[0], objects[2]]); - }); -}); diff --git a/libs/nanofn/test/over.js b/libs/nanofn/test/over.js deleted file mode 100644 index 93ce95186..000000000 --- a/libs/nanofn/test/over.js +++ /dev/null @@ -1,58 +0,0 @@ -import assert from 'assert'; -import { _, slice } from './utils.js'; - -describe('over', function() { - it('should create a function that invokes `iteratees`', function() { - var over = _.over(Math.max, Math.min); - assert.deepStrictEqual(over(1, 2, 3, 4), [4, 1]); - }); - - it('should use `_.identity` when a predicate is nullish', function() { - var over = _.over(undefined, null); - assert.deepStrictEqual(over('a', 'b', 'c'), ['a', 'a']); - }); - - it('should work with `_.property` shorthands', function() { - var over = _.over('b', 'a'); - assert.deepStrictEqual(over({ 'a': 1, 'b': 2 }), [2, 1]); - }); - - it('should work with `_.matches` shorthands', function() { - var over = _.over({ 'b': 1 }, { 'a': 1 }); - assert.deepStrictEqual(over({ 'a': 1, 'b': 2 }), [false, true]); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - var over = _.over([['b', 2], ['a', 2]]); - - assert.deepStrictEqual(over({ 'a': 1, 'b': 2 }), [true, false]); - assert.deepStrictEqual(over({ 'a': 2, 'b': 1 }), [false, true]); - }); - - it('should differentiate between `_.property` and `_.matchesProperty` shorthands', function() { - var over = _.over(['a', 1]); - - assert.deepStrictEqual(over({ 'a': 1, '1': 2 }), [1, 2]); - assert.deepStrictEqual(over({ 'a': 2, '1': 1 }), [2, 1]); - - over = _.over([['a', 1]]); - - assert.deepStrictEqual(over({ 'a': 1 }), [true]); - assert.deepStrictEqual(over({ 'a': 2 }), [false]); - }); - - it('should provide arguments to predicates', function() { - var over = _.over(function() { - return slice.call(arguments); - }); - - assert.deepStrictEqual(over('a', 'b', 'c'), [['a', 'b', 'c']]); - }); - - it('should use `this` binding of function for `iteratees`', function() { - var over = _.over(function() { return this.b; }, function() { return this.a; }), - object = { 'over': over, 'a': 1, 'b': 2 }; - - assert.deepStrictEqual(object.over(), [2, 1]); - }); -}); diff --git a/libs/nanofn/test/overArgs.js b/libs/nanofn/test/overArgs.js deleted file mode 100644 index f6e20db59..000000000 --- a/libs/nanofn/test/overArgs.js +++ /dev/null @@ -1,82 +0,0 @@ -import assert from 'assert'; -import { slice, doubled, square, identity, noop } from './utils.js'; -import overArgs from '../overArgs.js'; - -describe('overArgs', function() { - function fn() { - return slice.call(arguments); - } - - it('should transform each argument', function() { - var over = overArgs(fn, doubled, square); - assert.deepStrictEqual(over(5, 10), [10, 100]); - }); - - it('should use `_.identity` when a predicate is nullish', function() { - var over = overArgs(fn, undefined, null); - assert.deepStrictEqual(over('a', 'b'), ['a', 'b']); - }); - - it('should work with `_.property` shorthands', function() { - var over = overArgs(fn, 'b', 'a'); - assert.deepStrictEqual(over({ 'b': 2 }, { 'a': 1 }), [2, 1]); - }); - - it('should work with `_.matches` shorthands', function() { - var over = overArgs(fn, { 'b': 1 }, { 'a': 1 }); - assert.deepStrictEqual(over({ 'b': 2 }, { 'a': 1 }), [false, true]); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - var over = overArgs(fn, [['b', 1], ['a', 1]]); - assert.deepStrictEqual(over({ 'b': 2 }, { 'a': 1 }), [false, true]); - }); - - it('should differentiate between `_.property` and `_.matchesProperty` shorthands', function() { - var over = overArgs(fn, ['a', 1]); - assert.deepStrictEqual(over({ 'a': 1 }, { '1': 2 }), [1, 2]); - - over = overArgs(fn, [['a', 1]]); - assert.deepStrictEqual(over({ 'a': 1 }), [true]); - }); - - it('should flatten `transforms`', function() { - var over = overArgs(fn, [doubled, square], String); - assert.deepStrictEqual(over(5, 10, 15), [10, 100, '15']); - }); - - it('should not transform any argument greater than the number of transforms', function() { - var over = overArgs(fn, doubled, square); - assert.deepStrictEqual(over(5, 10, 18), [10, 100, 18]); - }); - - it('should not transform any arguments if no transforms are given', function() { - var over = overArgs(fn); - assert.deepStrictEqual(over(5, 10, 18), [5, 10, 18]); - }); - - it('should not pass `undefined` if there are more transforms than arguments', function() { - var over = overArgs(fn, doubled, identity); - assert.deepStrictEqual(over(5), [10]); - }); - - it('should provide the correct argument to each transform', function() { - var argsList = [], - transform = function() { argsList.push(slice.call(arguments)); }, - over = overArgs(noop, transform, transform, transform); - - over('a', 'b'); - assert.deepStrictEqual(argsList, [['a'], ['b']]); - }); - - it('should use `this` binding of function for `transforms`', function() { - var over = overArgs(function(x) { - return this[x]; - }, function(x) { - return this === x; - }); - - var object = { 'over': over, 'true': 1 }; - assert.strictEqual(object.over(object), 1); - }); -}); diff --git a/libs/nanofn/test/overEvery.js b/libs/nanofn/test/overEvery.js deleted file mode 100644 index 7ce135cf9..000000000 --- a/libs/nanofn/test/overEvery.js +++ /dev/null @@ -1,87 +0,0 @@ -import assert from 'assert'; -import { stubTrue, stubOne, stubA, stubFalse, slice } from './utils.js'; -import overEvery from '../overEvery.js'; - -describe('overEvery', function() { - it('should create a function that returns `true` if all predicates return truthy', function() { - var over = overEvery(stubTrue, stubOne, stubA); - assert.strictEqual(over(), true); - }); - - it('should return `false` as soon as a predicate returns falsey', function() { - var count = 0, - countFalse = function() { count++; return false; }, - countTrue = function() { count++; return true; }, - over = overEvery(countTrue, countFalse, countTrue); - - assert.strictEqual(over(), false); - assert.strictEqual(count, 2); - }); - - it('should use `_.identity` when a predicate is nullish', function() { - var over = overEvery(undefined, null); - - assert.strictEqual(over(true), true); - assert.strictEqual(over(false), false); - }); - - it('should work with `_.property` shorthands', function() { - var over = overEvery('b', 'a'); - - assert.strictEqual(over({ 'a': 1, 'b': 1 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 1 }), false); - }); - - it('should work with `_.matches` shorthands', function() { - var over = overEvery({ 'b': 2 }, { 'a': 1 }); - - assert.strictEqual(over({ 'a': 1, 'b': 2 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 2 }), false); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - var over = overEvery([['b', 2], ['a', 1]]); - - assert.strictEqual(over({ 'a': 1, 'b': 2 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 2 }), false); - }); - - it('should differentiate between `_.property` and `_.matchesProperty` shorthands', function() { - var over = overEvery(['a', 1]); - - assert.strictEqual(over({ 'a': 1, '1': 1 }), true); - assert.strictEqual(over({ 'a': 1, '1': 0 }), false); - assert.strictEqual(over({ 'a': 0, '1': 1 }), false); - - over = overEvery([['a', 1]]); - - assert.strictEqual(over({ 'a': 1 }), true); - assert.strictEqual(over({ 'a': 2 }), false); - }); - - it('should flatten `predicates`', function() { - var over = overEvery(stubTrue, [stubFalse]); - assert.strictEqual(over(), false); - }); - - it('should provide arguments to predicates', function() { - var args; - - var over = overEvery(function() { - args = slice.call(arguments); - }); - - over('a', 'b', 'c'); - assert.deepStrictEqual(args, ['a', 'b', 'c']); - }); - - it('should use `this` binding of function for `predicates`', function() { - var over = overEvery(function() { return this.b; }, function() { return this.a; }), - object = { 'over': over, 'a': 1, 'b': 2 }; - - assert.strictEqual(object.over(), true); - - object.a = 0; - assert.strictEqual(object.over(), false); - }); -}); diff --git a/libs/nanofn/test/overSome.js b/libs/nanofn/test/overSome.js deleted file mode 100644 index 07ecaa22c..000000000 --- a/libs/nanofn/test/overSome.js +++ /dev/null @@ -1,98 +0,0 @@ -import assert from 'assert'; -import { stubFalse, stubOne, stubString, stubNull, stubA, stubZero, stubTrue, slice } from './utils.js'; -import overSome from '../overSome.js'; - -describe('overSome', function() { - it('should create a function that returns `true` if any predicates return truthy', function() { - var over = overSome(stubFalse, stubOne, stubString); - assert.strictEqual(over(), true); - - over = overSome(stubNull, stubA, stubZero); - assert.strictEqual(over(), true); - }); - - it('should return `true` as soon as `predicate` returns truthy', function() { - var count = 0, - countFalse = function() { count++; return false; }, - countTrue = function() { count++; return true; }, - over = overSome(countFalse, countTrue, countFalse); - - assert.strictEqual(over(), true); - assert.strictEqual(count, 2); - }); - - it('should return `false` if all predicates return falsey', function() { - var over = overSome(stubFalse, stubFalse, stubFalse); - assert.strictEqual(over(), false); - - over = overSome(stubNull, stubZero, stubString); - assert.strictEqual(over(), false); - }); - - it('should use `_.identity` when a predicate is nullish', function() { - var over = overSome(undefined, null); - - assert.strictEqual(over(true), true); - assert.strictEqual(over(false), false); - }); - - it('should work with `_.property` shorthands', function() { - var over = overSome('b', 'a'); - - assert.strictEqual(over({ 'a': 1, 'b': 0 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 0 }), false); - }); - - it('should work with `_.matches` shorthands', function() { - var over = overSome({ 'b': 2 }, { 'a': 1 }); - - assert.strictEqual(over({ 'a': 0, 'b': 2 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 0 }), false); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - var over = overSome([['b', 2], ['a', 1]]); - - assert.strictEqual(over({ 'a': 0, 'b': 2 }), true); - assert.strictEqual(over({ 'a': 0, 'b': 0 }), false); - }); - - it('should differentiate between `_.property` and `_.matchesProperty` shorthands', function() { - var over = overSome(['a', 1]); - - assert.strictEqual(over({ 'a': 0, '1': 0 }), false); - assert.strictEqual(over({ 'a': 1, '1': 0 }), true); - assert.strictEqual(over({ 'a': 0, '1': 1 }), true); - - over = overSome([['a', 1]]); - - assert.strictEqual(over({ 'a': 1 }), true); - assert.strictEqual(over({ 'a': 2 }), false); - }); - - it('should flatten `predicates`', function() { - var over = overSome(stubFalse, [stubTrue]); - assert.strictEqual(over(), true); - }); - - it('should provide arguments to predicates', function() { - var args; - - var over = overSome(function() { - args = slice.call(arguments); - }); - - over('a', 'b', 'c'); - assert.deepStrictEqual(args, ['a', 'b', 'c']); - }); - - it('should use `this` binding of function for `predicates`', function() { - var over = overSome(function() { return this.b; }, function() { return this.a; }), - object = { 'over': over, 'a': 1, 'b': 2 }; - - assert.strictEqual(object.over(), true); - - object.a = object.b = 0; - assert.strictEqual(object.over(), false); - }); -}); diff --git a/libs/nanofn/test/pad-methods.js b/libs/nanofn/test/pad-methods.js deleted file mode 100644 index 8d2e61a04..000000000 --- a/libs/nanofn/test/pad-methods.js +++ /dev/null @@ -1,51 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; -import pad from '../pad.js'; - -describe('pad methods', function() { - lodashStable.each(['pad', 'padStart', 'padEnd'], function(methodName) { - var func = _[methodName], - isPad = methodName == 'pad', - isStart = methodName == 'padStart', - string = 'abc'; - - it('`_.' + methodName + '` should not pad if string is >= `length`', function() { - assert.strictEqual(func(string, 2), string); - assert.strictEqual(func(string, 3), string); - }); - - it('`_.' + methodName + '` should treat negative `length` as `0`', function() { - lodashStable.each([0, -2], function(length) { - assert.strictEqual(func(string, length), string); - }); - }); - - it('`_.' + methodName + '` should coerce `length` to a number', function() { - lodashStable.each(['', '4'], function(length) { - var actual = length ? (isStart ? ' abc' : 'abc ') : string; - assert.strictEqual(func(string, length), actual); - }); - }); - - it('`_.' + methodName + '` should treat nullish values as empty strings', function() { - lodashStable.each([undefined, '_-'], function(chars) { - var expected = chars ? (isPad ? '__' : chars) : ' '; - assert.strictEqual(func(null, 2, chars), expected); - assert.strictEqual(func(undefined, 2, chars), expected); - assert.strictEqual(func('', 2, chars), expected); - }); - }); - - it('`_.' + methodName + '` should return `string` when `chars` coerces to an empty string', function() { - var values = ['', Object('')], - expected = lodashStable.map(values, lodashStable.constant(string)); - - var actual = lodashStable.map(values, function(value) { - return pad(string, 6, value); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/pad.js b/libs/nanofn/test/pad.js deleted file mode 100644 index 8a62fe036..000000000 --- a/libs/nanofn/test/pad.js +++ /dev/null @@ -1,35 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue } from './utils.js'; -import pad from '../pad.js'; - -describe('pad', function() { - var string = 'abc'; - - it('should pad a string to a given length', function() { - var values = [, undefined], - expected = lodashStable.map(values, lodashStable.constant(' abc ')); - - var actual = lodashStable.map(values, function(value, index) { - return index ? pad(string, 6, value) : pad(string, 6); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should truncate pad characters to fit the pad length', function() { - assert.strictEqual(pad(string, 8), ' abc '); - assert.strictEqual(pad(string, 8, '_-'), '_-abc_-_'); - }); - - it('should coerce `string` to a string', function() { - var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return pad(value, 6) === ' abc '; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/padEnd.js b/libs/nanofn/test/padEnd.js deleted file mode 100644 index 6edb5232c..000000000 --- a/libs/nanofn/test/padEnd.js +++ /dev/null @@ -1,34 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue } from './utils.js'; -import padEnd from '../padEnd.js'; - -describe('padEnd', function() { - var string = 'abc'; - - it('should pad a string to a given length', function() { - var values = [, undefined], - expected = lodashStable.map(values, lodashStable.constant('abc ')); - - var actual = lodashStable.map(values, function(value, index) { - return index ? padEnd(string, 6, value) : padEnd(string, 6); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should truncate pad characters to fit the pad length', function() { - assert.strictEqual(padEnd(string, 6, '_-'), 'abc_-_'); - }); - - it('should coerce `string` to a string', function() { - var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return padEnd(value, 6) === 'abc '; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/padStart.js b/libs/nanofn/test/padStart.js deleted file mode 100644 index 9ec998858..000000000 --- a/libs/nanofn/test/padStart.js +++ /dev/null @@ -1,34 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubTrue } from './utils.js'; -import padStart from '../padStart.js'; - -describe('padStart', function() { - var string = 'abc'; - - it('should pad a string to a given length', function() { - var values = [, undefined], - expected = lodashStable.map(values, lodashStable.constant(' abc')); - - var actual = lodashStable.map(values, function(value, index) { - return index ? padStart(string, 6, value) : padStart(string, 6); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should truncate pad characters to fit the pad length', function() { - assert.strictEqual(padStart(string, 6, '_-'), '_-_abc'); - }); - - it('should coerce `string` to a string', function() { - var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return padStart(value, 6) === ' abc'; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/parseInt.js b/libs/nanofn/test/parseInt.js deleted file mode 100644 index d068cbfe4..000000000 --- a/libs/nanofn/test/parseInt.js +++ /dev/null @@ -1,81 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { lodashBizarro, whitespace, stubZero } from './utils.js'; -import parseInt from '../parseInt.js'; - -describe('parseInt', function() { - it('should accept a `radix`', function() { - var expected = lodashStable.range(2, 37); - - var actual = lodashStable.map(expected, function(radix) { - return parseInt('10', radix); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should use a radix of `10`, for non-hexadecimals, if `radix` is `undefined` or `0`', function() { - assert.strictEqual(parseInt('10'), 10); - assert.strictEqual(parseInt('10', 0), 10); - assert.strictEqual(parseInt('10', 10), 10); - assert.strictEqual(parseInt('10', undefined), 10); - }); - - it('should use a radix of `16`, for hexadecimals, if `radix` is `undefined` or `0`', function() { - lodashStable.each(['0x20', '0X20'], function(string) { - assert.strictEqual(parseInt(string), 32); - assert.strictEqual(parseInt(string, 0), 32); - assert.strictEqual(parseInt(string, 16), 32); - assert.strictEqual(parseInt(string, undefined), 32); - }); - }); - - it('should use a radix of `10` for string with leading zeros', function() { - assert.strictEqual(parseInt('08'), 8); - assert.strictEqual(parseInt('08', 10), 8); - }); - - it('should parse strings with leading whitespace', function() { - var expected = [8, 8, 10, 10, 32, 32, 32, 32]; - - lodashStable.times(2, function(index) { - var actual = [], - func = (index ? (lodashBizarro || {}) : _).parseInt; - - if (func) { - lodashStable.times(2, function(otherIndex) { - var string = otherIndex ? '10' : '08'; - actual.push( - func(whitespace + string, 10), - func(whitespace + string) - ); - }); - - lodashStable.each(['0x20', '0X20'], function(string) { - actual.push( - func(whitespace + string), - func(whitespace + string, 16) - ); - }); - - assert.deepStrictEqual(actual, expected); - } - }); - }); - - it('should coerce `radix` to a number', function() { - var object = { 'valueOf': stubZero }; - assert.strictEqual(parseInt('08', object), 8); - assert.strictEqual(parseInt('0x20', object), 32); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var strings = lodashStable.map(['6', '08', '10'], Object), - actual = lodashStable.map(strings, parseInt); - - assert.deepStrictEqual(actual, [6, 8, 10]); - - actual = lodashStable.map('123', parseInt); - assert.deepStrictEqual(actual, [1, 2, 3]); - }); -}); diff --git a/libs/nanofn/test/partial-methods.js b/libs/nanofn/test/partial-methods.js deleted file mode 100644 index 4509c9916..000000000 --- a/libs/nanofn/test/partial-methods.js +++ /dev/null @@ -1,113 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, identity, slice } from './utils.js'; -import placeholder from '../placeholder.js'; -import curry from '../curry.js'; - -describe('partial methods', function() { - lodashStable.each(['partial', 'partialRight'], function(methodName) { - var func = _[methodName], - isPartial = methodName == 'partial', - ph = func.placeholder; - - it('`_.' + methodName + '` partially applies arguments', function() { - var par = func(identity, 'a'); - assert.strictEqual(par(), 'a'); - }); - - it('`_.' + methodName + '` creates a function that can be invoked with additional arguments', function() { - var fn = function(a, b) { return [a, b]; }, - par = func(fn, 'a'), - expected = isPartial ? ['a', 'b'] : ['b', 'a']; - - assert.deepStrictEqual(par('b'), expected); - }); - - it('`_.' + methodName + '` works when there are no partially applied arguments and the created function is invoked without additional arguments', function() { - var fn = function() { return arguments.length; }, - par = func(fn); - - assert.strictEqual(par(), 0); - }); - - it('`_.' + methodName + '` works when there are no partially applied arguments and the created function is invoked with additional arguments', function() { - var par = func(identity); - assert.strictEqual(par('a'), 'a'); - }); - - it('`_.' + methodName + '` should support placeholders', function() { - var fn = function() { return slice.call(arguments); }, - par = func(fn, ph, 'b', ph); - - assert.deepStrictEqual(par('a', 'c'), ['a', 'b', 'c']); - assert.deepStrictEqual(par('a'), ['a', 'b', undefined]); - assert.deepStrictEqual(par(), [undefined, 'b', undefined]); - - if (isPartial) { - assert.deepStrictEqual(par('a', 'c', 'd'), ['a', 'b', 'c', 'd']); - } else { - par = func(fn, ph, 'c', ph); - assert.deepStrictEqual(par('a', 'b', 'd'), ['a', 'b', 'c', 'd']); - } - }); - - it('`_.' + methodName + '` should use `_.placeholder` when set', function() { - var _ph = placeholder = {}, - fn = function() { return slice.call(arguments); }, - par = func(fn, _ph, 'b', ph), - expected = isPartial ? ['a', 'b', ph, 'c'] : ['a', 'c', 'b', ph]; - - assert.deepEqual(par('a', 'c'), expected); - delete placeholder; - }); - - it('`_.' + methodName + '` creates a function with a `length` of `0`', function() { - var fn = function(a, b, c) {}, - par = func(fn, 'a'); - - assert.strictEqual(par.length, 0); - }); - - it('`_.' + methodName + '` should ensure `new par` is an instance of `func`', function() { - function Foo(value) { - return value && object; - } - - var object = {}, - par = func(Foo); - - assert.ok(new par instanceof Foo); - assert.strictEqual(new par(true), object); - }); - - it('`_.' + methodName + '` should clone metadata for created functions', function() { - function greet(greeting, name) { - return greeting + ' ' + name; - } - - var par1 = func(greet, 'hi'), - par2 = func(par1, 'barney'), - par3 = func(par1, 'pebbles'); - - assert.strictEqual(par1('fred'), isPartial ? 'hi fred' : 'fred hi'); - assert.strictEqual(par2(), isPartial ? 'hi barney' : 'barney hi'); - assert.strictEqual(par3(), isPartial ? 'hi pebbles' : 'pebbles hi'); - }); - - it('`_.' + methodName + '` should work with curried functions', function() { - var fn = function(a, b, c) { return a + b + c; }, - curried = curry(func(fn, 1), 2); - - assert.strictEqual(curried(2, 3), 6); - assert.strictEqual(curried(2)(3), 6); - }); - - it('should work with placeholders and curried functions', function() { - var fn = function() { return slice.call(arguments); }, - curried = curry(fn), - par = func(curried, ph, 'b', ph, 'd'); - - assert.deepStrictEqual(par('a', 'c'), ['a', 'b', 'c', 'd']); - }); - }); -}); diff --git a/libs/nanofn/test/partialRight.js b/libs/nanofn/test/partialRight.js deleted file mode 100644 index 87d48e4cc..000000000 --- a/libs/nanofn/test/partialRight.js +++ /dev/null @@ -1,18 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import partialRight from '../partialRight.js'; -import mergeWith from '../mergeWith.js'; - -describe('partialRight', function() { - it('should work as a deep `_.defaults`', function() { - var object = { 'a': { 'b': 2 } }, - source = { 'a': { 'b': 3, 'c': 3 } }, - expected = { 'a': { 'b': 2, 'c': 3 } }; - - var defaultsDeep = partialRight(mergeWith, function deep(value, other) { - return lodashStable.isObject(value) ? mergeWith(value, other, deep) : value; - }); - - assert.deepStrictEqual(defaultsDeep(object, source), expected); - }); -}); diff --git a/libs/nanofn/test/partition.js b/libs/nanofn/test/partition.js deleted file mode 100644 index 1767548a1..000000000 --- a/libs/nanofn/test/partition.js +++ /dev/null @@ -1,48 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, stubTrue, stubFalse } from './utils.js'; -import partition from '../partition.js'; - -describe('partition', function() { - var array = [1, 0, 1]; - - it('should split elements into two groups by `predicate`', function() { - assert.deepStrictEqual(partition([], identity), [[], []]); - assert.deepStrictEqual(partition(array, stubTrue), [array, []]); - assert.deepStrictEqual(partition(array, stubFalse), [[], array]); - }); - - it('should use `_.identity` when `predicate` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([[1, 1], [0]])); - - var actual = lodashStable.map(values, function(value, index) { - return index ? partition(array, value) : partition(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 1 }, { 'a': 1 }, { 'b': 2 }], - actual = partition(objects, 'a'); - - assert.deepStrictEqual(actual, [objects.slice(0, 2), objects.slice(2)]); - }); - - it('should work with a number for `predicate`', function() { - var array = [ - [1, 0], - [0, 1], - [1, 0] - ]; - - assert.deepStrictEqual(partition(array, 0), [[array[0], array[2]], [array[1]]]); - assert.deepStrictEqual(partition(array, 1), [[array[1]], [array[0], array[2]]]); - }); - - it('should work with an object for `collection`', function() { - var actual = partition({ 'a': 1.1, 'b': 0.2, 'c': 1.3 }, Math.floor); - assert.deepStrictEqual(actual, [[1.1, 1.3], [0.2]]); - }); -}); diff --git a/libs/nanofn/test/pick-methods.js b/libs/nanofn/test/pick-methods.js deleted file mode 100644 index 50eb1188d..000000000 --- a/libs/nanofn/test/pick-methods.js +++ /dev/null @@ -1,85 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, symbol, defineProperty } from './utils.js'; - -describe('pick methods', function() { - lodashStable.each(['pick', 'pickBy'], function(methodName) { - var expected = { 'a': 1, 'c': 3 }, - func = _[methodName], - isPick = methodName == 'pick', - object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - resolve = lodashStable.nthArg(1); - - if (methodName == 'pickBy') { - resolve = function(object, props) { - props = lodashStable.castArray(props); - return function(value) { - return lodashStable.some(props, function(key) { - key = lodashStable.isSymbol(key) ? key : lodashStable.toString(key); - return object[key] === value; - }); - }; - }; - } - it('`_.' + methodName + '` should create an object of picked string keyed properties', function() { - assert.deepStrictEqual(func(object, resolve(object, 'a')), { 'a': 1 }); - assert.deepStrictEqual(func(object, resolve(object, ['a', 'c'])), expected); - }); - - it('`_.' + methodName + '` should pick inherited string keyed properties', function() { - function Foo() {} - Foo.prototype = object; - - var foo = new Foo; - assert.deepStrictEqual(func(foo, resolve(foo, ['a', 'c'])), expected); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)], - expected = [{ '-0': 'a' }, { '-0': 'a' }, { '0': 'b' }, { '0': 'b' }]; - - var actual = lodashStable.map(props, function(key) { - return func(object, resolve(object, key)); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should pick symbols', function() { - function Foo() { - this[symbol] = 1; - } - - if (Symbol) { - var symbol2 = Symbol('b'); - Foo.prototype[symbol2] = 2; - - var symbol3 = Symbol('c'); - defineProperty(Foo.prototype, symbol3, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': 3 - }); - - var foo = new Foo, - actual = func(foo, resolve(foo, [symbol, symbol2, symbol3])); - - assert.strictEqual(actual[symbol], 1); - assert.strictEqual(actual[symbol2], 2); - - if (isPick) { - assert.strictEqual(actual[symbol3], 3); - } else { - assert.ok(!(symbol3 in actual)); - } - } - }); - - it('`_.' + methodName + '` should work with an array `object`', function() { - var array = [1, 2, 3]; - assert.deepStrictEqual(func(array, resolve(array, '1')), { '1': 2 }); - }); - }); -}); diff --git a/libs/nanofn/test/pick.js b/libs/nanofn/test/pick.js deleted file mode 100644 index 08d62911d..000000000 --- a/libs/nanofn/test/pick.js +++ /dev/null @@ -1,52 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args, toArgs } from './utils.js'; -import pick from '../pick.js'; - -describe('pick', function() { - var args = toArgs(['a', 'c']), - object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - nested = { 'a': 1, 'b': { 'c': 2, 'd': 3 } }; - - it('should flatten `paths`', function() { - assert.deepStrictEqual(pick(object, 'a', 'c'), { 'a': 1, 'c': 3 }); - assert.deepStrictEqual(pick(object, ['a', 'd'], 'c'), { 'a': 1, 'c': 3, 'd': 4 }); - }); - - it('should support deep paths', function() { - assert.deepStrictEqual(pick(nested, 'b.c'), { 'b': { 'c': 2 } }); - }); - - it('should support path arrays', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }, - actual = pick(object, [['a.b']]); - - assert.deepStrictEqual(actual, { 'a.b': 1 }); - }); - - it('should pick a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - assert.deepStrictEqual(pick(object, path), { 'a.b': 1 }); - }); - }); - - it('should coerce `paths` to strings', function() { - assert.deepStrictEqual(pick({ '0': 'a', '1': 'b' }, 0), { '0': 'a' }); - }); - - it('should return an empty object when `object` is nullish', function() { - lodashStable.each([null, undefined], function(value) { - assert.deepStrictEqual(pick(value, 'valueOf'), {}); - }); - }); - - it('should work with a primitive `object`', function() { - assert.deepStrictEqual(pick('', 'slice'), { 'slice': ''.slice }); - }); - - it('should work with `arguments` object `paths`', function() { - assert.deepStrictEqual(pick(object, args), { 'a': 1, 'c': 3 }); - }); -}); diff --git a/libs/nanofn/test/pickBy.test.js b/libs/nanofn/test/pickBy.test.js deleted file mode 100644 index aa074daee..000000000 --- a/libs/nanofn/test/pickBy.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import { stubTrue } from './utils.js'; -import pickBy from '../pickBy.js'; - -describe('pickBy', function() { - it('should work with a predicate argument', function() { - var object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }; - - var actual = pickBy(object, function(n) { - return n == 1 || n == 3; - }); - - assert.deepStrictEqual(actual, { 'a': 1, 'c': 3 }); - }); - - it('should not treat keys with dots as deep paths', function() { - var object = { 'a.b.c': 1 }, - actual = pickBy(object, stubTrue); - - assert.deepStrictEqual(actual, { 'a.b.c': 1 }); - }); -}); diff --git a/libs/nanofn/test/property.test.js b/libs/nanofn/test/property.test.js deleted file mode 100644 index a846e1e10..000000000 --- a/libs/nanofn/test/property.test.js +++ /dev/null @@ -1,122 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop } from './utils.js'; -import property from '../property.js'; - -describe('property', function() { - it('should create a function that plucks a property value of a given object', function() { - var object = { 'a': 1 }; - - lodashStable.each(['a', ['a']], function(path) { - var prop = property(path); - assert.strictEqual(prop.length, 1); - assert.strictEqual(prop(object), 1); - }); - }); - - it('should pluck deep property values', function() { - var object = { 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var prop = property(path); - assert.strictEqual(prop(object), 2); - }); - }); - - it('should pluck inherited property values', function() { - function Foo() {} - Foo.prototype.a = 1; - - lodashStable.each(['a', ['a']], function(path) { - var prop = property(path); - assert.strictEqual(prop(new Foo), 1); - }); - }); - - it('should work with a non-string `path`', function() { - var array = [1, 2, 3]; - - lodashStable.each([1, [1]], function(path) { - var prop = property(path); - assert.strictEqual(prop(array), 2); - }); - }); - - it('should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - var prop = property(key); - return prop(object); - }); - - assert.deepStrictEqual(actual, ['a', 'a', 'b', 'b']); - }); - - it('should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var expected = [1, 2, 3, 4], - object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, - paths = [null, undefined, fn, {}]; - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - var prop = property(index ? [path] : path); - return prop(object); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should pluck a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }; - - lodashStable.each(['a.b', ['a.b']], function(path) { - var prop = property(path); - assert.strictEqual(prop(object), 1); - }); - }); - - it('should return `undefined` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var prop = property(path); - - var actual = lodashStable.map(values, function(value, index) { - return index ? prop(value) : prop(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` for deep paths when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var prop = property(path); - - var actual = lodashStable.map(values, function(value, index) { - return index ? prop(value) : prop(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` if parts of `path` are missing', function() { - var object = {}; - - lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) { - var prop = property(path); - assert.strictEqual(prop(object), undefined); - }); - }); -}); diff --git a/libs/nanofn/test/propertyOf.test.js b/libs/nanofn/test/propertyOf.test.js deleted file mode 100644 index 0fe43b7b3..000000000 --- a/libs/nanofn/test/propertyOf.test.js +++ /dev/null @@ -1,122 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop } from './utils.js'; -import propertyOf from '../propertyOf.js'; - -describe('propertyOf', function() { - it('should create a function that plucks a property value of a given key', function() { - var object = { 'a': 1 }, - propOf = propertyOf(object); - - assert.strictEqual(propOf.length, 1); - lodashStable.each(['a', ['a']], function(path) { - assert.strictEqual(propOf(path), 1); - }); - }); - - it('should pluck deep property values', function() { - var object = { 'a': { 'b': 2 } }, - propOf = propertyOf(object); - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(propOf(path), 2); - }); - }); - - it('should pluck inherited property values', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var propOf = propertyOf(new Foo); - - lodashStable.each(['b', ['b']], function(path) { - assert.strictEqual(propOf(path), 2); - }); - }); - - it('should work with a non-string `path`', function() { - var array = [1, 2, 3], - propOf = propertyOf(array); - - lodashStable.each([1, [1]], function(path) { - assert.strictEqual(propOf(path), 2); - }); - }); - - it('should preserve the sign of `0`', function() { - var object = { '-0': 'a', '0': 'b' }, - props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - var propOf = propertyOf(object); - return propOf(key); - }); - - assert.deepStrictEqual(actual, ['a', 'a', 'b', 'b']); - }); - - it('should coerce `path` to a string', function() { - function fn() {} - fn.toString = lodashStable.constant('fn'); - - var expected = [1, 2, 3, 4], - object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, - paths = [null, undefined, fn, {}]; - - lodashStable.times(2, function(index) { - var actual = lodashStable.map(paths, function(path) { - var propOf = propertyOf(object); - return propOf(index ? [path] : path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should pluck a key over a path', function() { - var object = { 'a.b': 1, 'a': { 'b': 2 } }, - propOf = propertyOf(object); - - lodashStable.each(['a.b', ['a.b']], function(path) { - assert.strictEqual(propOf(path), 1); - }); - }); - - it('should return `undefined` when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var actual = lodashStable.map(values, function(value, index) { - var propOf = index ? propertyOf(value) : propertyOf(); - return propOf(path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` for deep paths when `object` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, noop); - - lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { - var actual = lodashStable.map(values, function(value, index) { - var propOf = index ? propertyOf(value) : propertyOf(); - return propOf(path); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should return `undefined` if parts of `path` are missing', function() { - var propOf = propertyOf({}); - - lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) { - assert.strictEqual(propOf(path), undefined); - }); - }); -}); diff --git a/libs/nanofn/test/pull-methods.js b/libs/nanofn/test/pull-methods.js deleted file mode 100644 index 4336b48e8..000000000 --- a/libs/nanofn/test/pull-methods.js +++ /dev/null @@ -1,49 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('pull methods', function() { - lodashStable.each(['pull', 'pullAll', 'pullAllWith'], function(methodName) { - var func = _[methodName], - isPull = methodName == 'pull'; - - function pull(array, values) { - return isPull - ? func.apply(undefined, [array].concat(values)) - : func(array, values); - } - - it('`_.' + methodName + '` should modify and return the array', function() { - var array = [1, 2, 3], - actual = pull(array, [1, 3]); - - assert.strictEqual(actual, array); - assert.deepStrictEqual(array, [2]); - }); - - it('`_.' + methodName + '` should preserve holes in arrays', function() { - var array = [1, 2, 3, 4]; - delete array[1]; - delete array[3]; - - pull(array, [1]); - assert.ok(!('0' in array)); - assert.ok(!('2' in array)); - }); - - it('`_.' + methodName + '` should treat holes as `undefined`', function() { - var array = [1, 2, 3]; - delete array[1]; - - pull(array, [undefined]); - assert.deepStrictEqual(array, [1, 3]); - }); - - it('`_.' + methodName + '` should match `NaN`', function() { - var array = [1, NaN, 3, NaN]; - - pull(array, [NaN]); - assert.deepStrictEqual(array, [1, 3]); - }); - }); -}); diff --git a/libs/nanofn/test/pullAll.test.js b/libs/nanofn/test/pullAll.test.js deleted file mode 100644 index 7579e6a0f..000000000 --- a/libs/nanofn/test/pullAll.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import assert from 'assert'; -import pullAll from '../pullAll.js'; - -describe('pullAll', function() { - it('should work with the same value for `array` and `values`', function() { - var array = [{ 'a': 1 }, { 'b': 2 }], - actual = pullAll(array, array); - - assert.deepStrictEqual(actual, []); - }); -}); diff --git a/libs/nanofn/test/pullAllBy.test.js b/libs/nanofn/test/pullAllBy.test.js deleted file mode 100644 index a7fb64f61..000000000 --- a/libs/nanofn/test/pullAllBy.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import pullAllBy from '../pullAllBy.js'; - -describe('pullAllBy', function() { - it('should accept an `iteratee`', function() { - var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; - - var actual = pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], function(object) { - return object.x; - }); - - assert.deepStrictEqual(actual, [{ 'x': 2 }]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args, - array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; - - pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [{ 'x': 1 }]); - }); -}); diff --git a/libs/nanofn/test/pullAllWith.test.js b/libs/nanofn/test/pullAllWith.test.js deleted file mode 100644 index 3a47ebaae..000000000 --- a/libs/nanofn/test/pullAllWith.test.js +++ /dev/null @@ -1,13 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import pullAllWith from '../pullAllWith.js'; - -describe('pullAllWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 1 }, { 'x': 2, 'y': 2 }, { 'x': 3, 'y': 3 }], - expected = [objects[0], objects[2]], - actual = pullAllWith(objects, [{ 'x': 2, 'y': 2 }], lodashStable.isEqual); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/pullAt.js b/libs/nanofn/test/pullAt.js deleted file mode 100644 index c70020eb2..000000000 --- a/libs/nanofn/test/pullAt.js +++ /dev/null @@ -1,122 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, stubOne, noop, falsey } from './utils.js'; -import pullAt from '../pullAt.js'; - -describe('pullAt', function() { - it('should modify the array and return removed elements', function() { - var array = [1, 2, 3], - actual = pullAt(array, [0, 1]); - - assert.deepStrictEqual(array, [3]); - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('should work with unsorted indexes', function() { - var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], - actual = pullAt(array, [1, 3, 11, 7, 5, 9]); - - assert.deepStrictEqual(array, [1, 3, 5, 7, 9, 11]); - assert.deepStrictEqual(actual, [2, 4, 12, 8, 6, 10]); - }); - - it('should work with repeated indexes', function() { - var array = [1, 2, 3, 4], - actual = pullAt(array, [0, 2, 0, 1, 0, 2]); - - assert.deepStrictEqual(array, [4]); - assert.deepStrictEqual(actual, [1, 3, 1, 2, 1, 3]); - }); - - it('should use `undefined` for nonexistent indexes', function() { - var array = ['a', 'b', 'c'], - actual = pullAt(array, [2, 4, 0]); - - assert.deepStrictEqual(array, ['b']); - assert.deepStrictEqual(actual, ['c', undefined, 'a']); - }); - - it('should flatten `indexes`', function() { - var array = ['a', 'b', 'c']; - assert.deepStrictEqual(pullAt(array, 2, 0), ['c', 'a']); - assert.deepStrictEqual(array, ['b']); - - array = ['a', 'b', 'c', 'd']; - assert.deepStrictEqual(pullAt(array, [3, 0], 2), ['d', 'a', 'c']); - assert.deepStrictEqual(array, ['b']); - }); - - it('should return an empty array when no indexes are given', function() { - var array = ['a', 'b', 'c'], - actual = pullAt(array); - - assert.deepStrictEqual(array, ['a', 'b', 'c']); - assert.deepStrictEqual(actual, []); - - actual = pullAt(array, [], []); - - assert.deepStrictEqual(array, ['a', 'b', 'c']); - assert.deepStrictEqual(actual, []); - }); - - it('should work with non-index paths', function() { - var values = lodashStable.reject(empties, function(value) { - return (value === 0) || lodashStable.isArray(value); - }).concat(-1, 1.1); - - var array = lodashStable.transform(values, function(result, value) { - result[value] = 1; - }, []); - - var expected = lodashStable.map(values, stubOne), - actual = pullAt(array, values); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(values, noop); - actual = lodashStable.at(array, values); - - assert.deepStrictEqual(actual, expected); - }); - - it('should preserve the sign of `0`', function() { - var props = [-0, Object(-0), 0, Object(0)]; - - var actual = lodashStable.map(props, function(key) { - var array = [-1]; - array['-0'] = -2; - return pullAt(array, key); - }); - - assert.deepStrictEqual(actual, [[-2], [-2], [-1], [-1]]); - }); - - it('should support deep paths', function() { - var array = []; - array.a = { 'b': 2 }; - - var actual = pullAt(array, 'a.b'); - - assert.deepStrictEqual(actual, [2]); - assert.deepStrictEqual(array.a, {}); - - try { - actual = pullAt(array, 'a.b.c'); - } catch (e) {} - - assert.deepStrictEqual(actual, [undefined]); - }); - - it('should work with a falsey `array` when keys are given', function() { - var values = falsey.slice(), - expected = lodashStable.map(values, lodashStable.constant(Array(4))); - - var actual = lodashStable.map(values, function(array) { - try { - return pullAt(array, 0, 1, 'pop', 'push'); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/random.js b/libs/nanofn/test/random.js deleted file mode 100644 index a111dc84f..000000000 --- a/libs/nanofn/test/random.js +++ /dev/null @@ -1,104 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { MAX_INTEGER, stubTrue } from './utils.js'; -import random from '../random.js'; - -describe('random', function() { - var array = Array(1000); - - it('should return `0` or `1` when no arguments are given', function() { - var actual = lodashStable.uniq(lodashStable.map(array, function() { - return random(); - })).sort(); - - assert.deepStrictEqual(actual, [0, 1]); - }); - - it('should support a `min` and `max`', function() { - var min = 5, - max = 10; - - assert.ok(lodashStable.some(array, function() { - var result = random(min, max); - return result >= min && result <= max; - })); - }); - - it('should support not providing a `max`', function() { - var min = 0, - max = 5; - - assert.ok(lodashStable.some(array, function() { - var result = random(max); - return result >= min && result <= max; - })); - }); - - it('should swap `min` and `max` when `min` > `max`', function() { - var min = 4, - max = 2, - expected = [2, 3, 4]; - - var actual = lodashStable.uniq(lodashStable.map(array, function() { - return random(min, max); - })).sort(); - - assert.deepStrictEqual(actual, expected); - }); - - it('should support large integer values', function() { - var min = Math.pow(2, 31), - max = Math.pow(2, 62); - - assert.ok(lodashStable.every(array, function() { - var result = random(min, max); - return result >= min && result <= max; - })); - - assert.ok(lodashStable.some(array, function() { - return random(MAX_INTEGER); - })); - }); - - it('should coerce arguments to finite numbers', function() { - var actual = [ - random(NaN, NaN), - random('1', '1'), - random(Infinity, Infinity) - ]; - - assert.deepStrictEqual(actual, [0, 1, MAX_INTEGER]); - }); - - it('should support floats', function() { - var min = 1.5, - max = 1.6, - actual = random(min, max); - - assert.ok(actual % 1); - assert.ok(actual >= min && actual <= max); - }); - - it('should support providing a `floating`', function() { - var actual = random(true); - assert.ok(actual % 1 && actual >= 0 && actual <= 1); - - actual = random(2, true); - assert.ok(actual % 1 && actual >= 0 && actual <= 2); - - actual = random(2, 4, true); - assert.ok(actual % 1 && actual >= 2 && actual <= 4); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [1, 2, 3], - expected = lodashStable.map(array, stubTrue), - randoms = lodashStable.map(array, random); - - var actual = lodashStable.map(randoms, function(result, index) { - return result >= 0 && result <= array[index] && (result % 1) == 0; - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/range-methods.js b/libs/nanofn/test/range-methods.js deleted file mode 100644 index 7f011e9d0..000000000 --- a/libs/nanofn/test/range-methods.js +++ /dev/null @@ -1,82 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, falsey } from './utils.js'; - -describe('range methods', function() { - lodashStable.each(['range', 'rangeRight'], function(methodName) { - var func = _[methodName], - isRange = methodName == 'range'; - - function resolve(range) { - return isRange ? range : range.reverse(); - } - - it('`_.' + methodName + '` should infer the sign of `step` when only `end` is given', function() { - assert.deepStrictEqual(func(4), resolve([0, 1, 2, 3])); - assert.deepStrictEqual(func(-4), resolve([0, -1, -2, -3])); - }); - - it('`_.' + methodName + '` should infer the sign of `step` when only `start` and `end` are given', function() { - assert.deepStrictEqual(func(1, 5), resolve([1, 2, 3, 4])); - assert.deepStrictEqual(func(5, 1), resolve([5, 4, 3, 2])); - }); - - it('`_.' + methodName + '` should work with a `start`, `end`, and `step`', function() { - assert.deepStrictEqual(func(0, -4, -1), resolve([0, -1, -2, -3])); - assert.deepStrictEqual(func(5, 1, -1), resolve([5, 4, 3, 2])); - assert.deepStrictEqual(func(0, 20, 5), resolve([0, 5, 10, 15])); - }); - - it('`_.' + methodName + '` should support a `step` of `0`', function() { - assert.deepStrictEqual(func(1, 4, 0), [1, 1, 1]); - }); - - it('`_.' + methodName + '` should work with a `step` larger than `end`', function() { - assert.deepStrictEqual(func(1, 5, 20), [1]); - }); - - it('`_.' + methodName + '` should work with a negative `step`', function() { - assert.deepStrictEqual(func(0, -4, -1), resolve([0, -1, -2, -3])); - assert.deepStrictEqual(func(21, 10, -3), resolve([21, 18, 15, 12])); - }); - - it('`_.' + methodName + '` should support `start` of `-0`', function() { - var actual = func(-0, 1); - assert.strictEqual(1 / actual[0], -Infinity); - }); - - it('`_.' + methodName + '` should treat falsey `start` as `0`', function() { - lodashStable.each(falsey, function(value, index) { - if (index) { - assert.deepStrictEqual(func(value), []); - assert.deepStrictEqual(func(value, 1), [0]); - } else { - assert.deepStrictEqual(func(), []); - } - }); - }); - - it('`_.' + methodName + '` should coerce arguments to finite numbers', function() { - var actual = [ - func('1'), - func('0', 1), - func(0, 1, '1'), - func(NaN), - func(NaN, NaN) - ]; - - assert.deepStrictEqual(actual, [[0], [0], [0], [], []]); - }); - - it('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', function() { - var array = [1, 2, 3], - object = { 'a': 1, 'b': 2, 'c': 3 }, - expected = lodashStable.map([[0], [0, 1], [0, 1, 2]], resolve); - - lodashStable.each([array, object], function(collection) { - var actual = lodashStable.map(collection, func); - assert.deepStrictEqual(actual, expected); - }); - }); - }); -}); diff --git a/libs/nanofn/test/rearg.js b/libs/nanofn/test/rearg.js deleted file mode 100644 index 1e76fdb51..000000000 --- a/libs/nanofn/test/rearg.js +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, empties } from './utils.js'; -import rearg from '../rearg.js'; - -describe('rearg', function() { - function fn() { - return slice.call(arguments); - } - - it('should reorder arguments provided to `func`', function() { - var rearged = rearg(fn, [2, 0, 1]); - assert.deepStrictEqual(rearged('b', 'c', 'a'), ['a', 'b', 'c']); - }); - - it('should work with repeated indexes', function() { - var rearged = rearg(fn, [1, 1, 1]); - assert.deepStrictEqual(rearged('c', 'a', 'b'), ['a', 'a', 'a']); - }); - - it('should use `undefined` for nonexistent indexes', function() { - var rearged = rearg(fn, [1, 4]); - assert.deepStrictEqual(rearged('b', 'a', 'c'), ['a', undefined, 'c']); - }); - - it('should use `undefined` for non-index values', function() { - var values = lodashStable.reject(empties, function(value) { - return (value === 0) || lodashStable.isArray(value); - }).concat(-1, 1.1); - - var expected = lodashStable.map(values, lodashStable.constant([undefined, 'b', 'c'])); - - var actual = lodashStable.map(values, function(value) { - var rearged = rearg(fn, [value]); - return rearged('a', 'b', 'c'); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not rearrange arguments when no indexes are given', function() { - var rearged = rearg(fn); - assert.deepStrictEqual(rearged('a', 'b', 'c'), ['a', 'b', 'c']); - - rearged = rearg(fn, [], []); - assert.deepStrictEqual(rearged('a', 'b', 'c'), ['a', 'b', 'c']); - }); - - it('should accept multiple index arguments', function() { - var rearged = rearg(fn, 2, 0, 1); - assert.deepStrictEqual(rearged('b', 'c', 'a'), ['a', 'b', 'c']); - }); - - it('should accept multiple arrays of indexes', function() { - var rearged = rearg(fn, [2], [0, 1]); - assert.deepStrictEqual(rearged('b', 'c', 'a'), ['a', 'b', 'c']); - }); - - it('should work with fewer indexes than arguments', function() { - var rearged = rearg(fn, [1, 0]); - assert.deepStrictEqual(rearged('b', 'a', 'c'), ['a', 'b', 'c']); - }); - - it('should work on functions that have been rearged', function() { - var rearged1 = rearg(fn, 2, 1, 0), - rearged2 = rearg(rearged1, 1, 0, 2); - - assert.deepStrictEqual(rearged2('b', 'c', 'a'), ['a', 'b', 'c']); - }); -}); diff --git a/libs/nanofn/test/reduce-methods.js b/libs/nanofn/test/reduce-methods.js deleted file mode 100644 index 34f4b34c3..000000000 --- a/libs/nanofn/test/reduce-methods.js +++ /dev/null @@ -1,68 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, empties, noop, add } from './utils.js'; - -describe('reduce methods', function() { - lodashStable.each(['reduce', 'reduceRight'], function(methodName) { - var func = _[methodName], - array = [1, 2, 3], - isReduce = methodName == 'reduce'; - - it('`_.' + methodName + '` should reduce a collection to a single value', function() { - var actual = func(['a', 'b', 'c'], function(accumulator, value) { - return accumulator + value; - }, ''); - - assert.strictEqual(actual, isReduce ? 'abc' : 'cba'); - }); - - it('`_.' + methodName + '` should support empty collections without an initial `accumulator` value', function() { - var actual = [], - expected = lodashStable.map(empties, noop); - - lodashStable.each(empties, function(value) { - try { - actual.push(func(value, noop)); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should support empty collections with an initial `accumulator` value', function() { - var expected = lodashStable.map(empties, lodashStable.constant('x')); - - var actual = lodashStable.map(empties, function(value) { - try { - return func(value, noop, 'x'); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should handle an initial `accumulator` value of `undefined`', function() { - var actual = func([], noop, undefined); - assert.strictEqual(actual, undefined); - }); - - it('`_.' + methodName + '` should return `undefined` for empty collections when no `accumulator` is given (test in IE > 9 and modern browsers)', function() { - var array = [], - object = { '0': 1, 'length': 0 }; - - if ('__proto__' in array) { - array.__proto__ = object; - assert.strictEqual(func(array, noop), undefined); - } - assert.strictEqual(func(object, noop), undefined); - }); - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - assert.strictEqual(_(array)[methodName](add), 6); - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() { - assert.ok(_(array).chain()[methodName](add) instanceof _); - }); - }); -}); diff --git a/libs/nanofn/test/reduce.js b/libs/nanofn/test/reduce.js deleted file mode 100644 index bae164750..000000000 --- a/libs/nanofn/test/reduce.js +++ /dev/null @@ -1,57 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import reduce from '../reduce.js'; -import head from '../head.js'; -import keys from '../keys.js'; - -describe('reduce', function() { - var array = [1, 2, 3]; - - it('should use the first element of a collection as the default `accumulator`', function() { - assert.strictEqual(reduce(array), 1); - }); - - it('should provide correct `iteratee` arguments when iterating an array', function() { - var args; - - reduce(array, function() { - args || (args = slice.call(arguments)); - }, 0); - - assert.deepStrictEqual(args, [0, 1, 0, array]); - - args = undefined; - reduce(array, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [1, 2, 1, array]); - }); - - it('should provide correct `iteratee` arguments when iterating an object', function() { - var args, - object = { 'a': 1, 'b': 2 }, - firstKey = head(keys(object)); - - var expected = firstKey == 'a' - ? [0, 1, 'a', object] - : [0, 2, 'b', object]; - - reduce(object, function() { - args || (args = slice.call(arguments)); - }, 0); - - assert.deepStrictEqual(args, expected); - - args = undefined; - expected = firstKey == 'a' - ? [1, 2, 'b', object] - : [2, 1, 'a', object]; - - reduce(object, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, expected); - }); -}); diff --git a/libs/nanofn/test/reduceRight.js b/libs/nanofn/test/reduceRight.js deleted file mode 100644 index ea2beae02..000000000 --- a/libs/nanofn/test/reduceRight.js +++ /dev/null @@ -1,56 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice } from './utils.js'; -import reduceRight from '../reduceRight.js'; - -describe('reduceRight', function() { - var array = [1, 2, 3]; - - it('should use the last element of a collection as the default `accumulator`', function() { - assert.strictEqual(reduceRight(array), 3); - }); - - it('should provide correct `iteratee` arguments when iterating an array', function() { - var args; - - reduceRight(array, function() { - args || (args = slice.call(arguments)); - }, 0); - - assert.deepStrictEqual(args, [0, 3, 2, array]); - - args = undefined; - reduceRight(array, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [3, 2, 1, array]); - }); - - it('should provide correct `iteratee` arguments when iterating an object', function() { - var args, - object = { 'a': 1, 'b': 2 }, - isFIFO = lodashStable.keys(object)[0] == 'a'; - - var expected = isFIFO - ? [0, 2, 'b', object] - : [0, 1, 'a', object]; - - reduceRight(object, function() { - args || (args = slice.call(arguments)); - }, 0); - - assert.deepStrictEqual(args, expected); - - args = undefined; - expected = isFIFO - ? [2, 1, 'a', object] - : [1, 2, 'b', object]; - - reduceRight(object, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, expected); - }); -}); diff --git a/libs/nanofn/test/reject.test.js b/libs/nanofn/test/reject.test.js deleted file mode 100644 index fcf305041..000000000 --- a/libs/nanofn/test/reject.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import assert from 'assert'; -import { isEven } from './utils.js'; -import reject from '../reject.js'; - -describe('reject', function() { - var array = [1, 2, 3]; - - it('should return elements the `predicate` returns falsey for', function() { - assert.deepStrictEqual(reject(array, isEven), [1, 3]); - }); -}); diff --git a/libs/nanofn/test/remove.js b/libs/nanofn/test/remove.js deleted file mode 100644 index 92b025151..000000000 --- a/libs/nanofn/test/remove.js +++ /dev/null @@ -1,80 +0,0 @@ -import assert from 'assert'; -import { isEven, slice } from './utils.js'; -import remove from '../remove.js'; - -describe('remove', function() { - it('should modify the array and return removed elements', function() { - var array = [1, 2, 3, 4], - actual = remove(array, isEven); - - assert.deepStrictEqual(array, [1, 3]); - assert.deepStrictEqual(actual, [2, 4]); - }); - - it('should provide correct `predicate` arguments', function() { - var argsList = [], - array = [1, 2, 3], - clone = array.slice(); - - remove(array, function(n, index) { - var args = slice.call(arguments); - args[2] = args[2].slice(); - argsList.push(args); - return isEven(index); - }); - - assert.deepStrictEqual(argsList, [[1, 0, clone], [2, 1, clone], [3, 2, clone]]); - }); - - it('should work with `_.matches` shorthands', function() { - var objects = [{ 'a': 0, 'b': 1 }, { 'a': 1, 'b': 2 }]; - remove(objects, { 'a': 1 }); - assert.deepStrictEqual(objects, [{ 'a': 0, 'b': 1 }]); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - var objects = [{ 'a': 0, 'b': 1 }, { 'a': 1, 'b': 2 }]; - remove(objects, ['a', 1]); - assert.deepStrictEqual(objects, [{ 'a': 0, 'b': 1 }]); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - remove(objects, 'a'); - assert.deepStrictEqual(objects, [{ 'a': 0 }]); - }); - - it('should preserve holes in arrays', function() { - var array = [1, 2, 3, 4]; - delete array[1]; - delete array[3]; - - remove(array, function(n) { - return n === 1; - }); - - assert.ok(!('0' in array)); - assert.ok(!('2' in array)); - }); - - it('should treat holes as `undefined`', function() { - var array = [1, 2, 3]; - delete array[1]; - - remove(array, function(n) { - return n == null; - }); - - assert.deepStrictEqual(array, [1, 3]); - }); - - it('should not mutate the array until all elements to remove are determined', function() { - var array = [1, 2, 3]; - - remove(array, function(n, index) { - return isEven(index); - }); - - assert.deepStrictEqual(array, [2]); - }); -}); diff --git a/libs/nanofn/test/repeat.js b/libs/nanofn/test/repeat.js deleted file mode 100644 index caa4e2e60..000000000 --- a/libs/nanofn/test/repeat.js +++ /dev/null @@ -1,46 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubThree } from './utils.js'; -import repeat from '../repeat.js'; - -describe('repeat', function() { - var string = 'abc'; - - it('should repeat a string `n` times', function() { - assert.strictEqual(repeat('*', 3), '***'); - assert.strictEqual(repeat(string, 2), 'abcabc'); - }); - - it('should treat falsey `n` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? string : ''; - }); - - var actual = lodashStable.map(falsey, function(n, index) { - return index ? repeat(string, n) : repeat(string); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an empty string if `n` is <= `0`', function() { - assert.strictEqual(repeat(string, 0), ''); - assert.strictEqual(repeat(string, -2), ''); - }); - - it('should coerce `n` to an integer', function() { - assert.strictEqual(repeat(string, '2'), 'abcabc'); - assert.strictEqual(repeat(string, 2.6), 'abcabc'); - assert.strictEqual(repeat('*', { 'valueOf': stubThree }), '***'); - }); - - it('should coerce `string` to a string', function() { - assert.strictEqual(repeat(Object(string), 2), 'abcabc'); - assert.strictEqual(repeat({ 'toString': lodashStable.constant('*') }, 3), '***'); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map(['a', 'b', 'c'], repeat); - assert.deepStrictEqual(actual, ['a', 'b', 'c']); - }); -}); diff --git a/libs/nanofn/test/replace.test.js b/libs/nanofn/test/replace.test.js deleted file mode 100644 index f28a9f03c..000000000 --- a/libs/nanofn/test/replace.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import replace from '../replace.js'; - -describe('replace', function() { - it('should replace the matched pattern', function() { - var string = 'abcde'; - assert.strictEqual(replace(string, 'de', '123'), 'abc123'); - assert.strictEqual(replace(string, /[bd]/g, '-'), 'a-c-e'); - }); -}); diff --git a/libs/nanofn/test/rest.js b/libs/nanofn/test/rest.js deleted file mode 100644 index d7b98de46..000000000 --- a/libs/nanofn/test/rest.js +++ /dev/null @@ -1,49 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, _ } from './utils.js'; - -describe('rest', function() { - function fn(a, b, c) { - return slice.call(arguments); - } - - it('should apply a rest parameter to `func`', function() { - var rest = _.rest(fn); - assert.deepStrictEqual(rest(1, 2, 3, 4), [1, 2, [3, 4]]); - }); - - it('should work with `start`', function() { - var rest = _.rest(fn, 1); - assert.deepStrictEqual(rest(1, 2, 3, 4), [1, [2, 3, 4]]); - }); - - it('should treat `start` as `0` for `NaN` or negative values', function() { - var values = [-1, NaN, 'a'], - expected = lodashStable.map(values, lodashStable.constant([[1, 2, 3, 4]])); - - var actual = lodashStable.map(values, function(value) { - var rest = _.rest(fn, value); - return rest(1, 2, 3, 4); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should coerce `start` to an integer', function() { - var rest = _.rest(fn, 1.6); - assert.deepStrictEqual(rest(1, 2, 3), [1, [2, 3]]); - }); - - it('should use an empty array when `start` is not reached', function() { - var rest = _.rest(fn); - assert.deepStrictEqual(rest(1), [1, undefined, []]); - }); - - it('should work on functions with more than three parameters', function() { - var rest = _.rest(function(a, b, c, d) { - return slice.call(arguments); - }); - - assert.deepStrictEqual(rest(1, 2, 3, 4, 5), [1, 2, 3, [4, 5]]); - }); -}); diff --git a/libs/nanofn/test/result.test.js b/libs/nanofn/test/result.test.js deleted file mode 100644 index 3087ac0c6..000000000 --- a/libs/nanofn/test/result.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubB } from './utils.js'; -import result from '../result.js'; - -describe('result', function() { - var object = { 'a': 1, 'b': stubB }; - - it('should invoke function values', function() { - assert.strictEqual(result(object, 'b'), 'b'); - }); - - it('should invoke default function values', function() { - var actual = result(object, 'c', object.b); - assert.strictEqual(actual, 'b'); - }); - - it('should invoke nested function values', function() { - var value = { 'a': lodashStable.constant({ 'b': stubB }) }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(result(value, path), 'b'); - }); - }); - - it('should invoke deep property methods with the correct `this` binding', function() { - var value = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }; - - lodashStable.each(['a.b', ['a', 'b']], function(path) { - assert.strictEqual(result(value, path), 1); - }); - }); -}); diff --git a/libs/nanofn/test/reverse.js b/libs/nanofn/test/reverse.js deleted file mode 100644 index f6c80ca59..000000000 --- a/libs/nanofn/test/reverse.js +++ /dev/null @@ -1,94 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, identity } from './utils.js'; -import reverse from '../reverse.js'; -import compact from '../compact.js'; -import head from '../head.js'; - -describe('reverse', function() { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE).concat(null), - smallArray = [0, 1, 2, null]; - - it('should reverse `array`', function() { - var array = [1, 2, 3], - actual = reverse(array); - - assert.strictEqual(actual, array); - assert.deepStrictEqual(array, [3, 2, 1]); - }); - - it('should return the wrapped reversed `array`', function() { - lodashStable.times(2, function(index) { - var array = (index ? largeArray : smallArray).slice(), - clone = array.slice(), - wrapped = _(array).reverse(), - actual = wrapped.value(); - - assert.ok(wrapped instanceof _); - assert.strictEqual(actual, array); - assert.deepStrictEqual(actual, clone.slice().reverse()); - }); - }); - - it('should work in a lazy sequence', function() { - lodashStable.times(2, function(index) { - var array = (index ? largeArray : smallArray).slice(), - expected = array.slice(), - actual = _(array).slice(1).reverse().value(); - - assert.deepStrictEqual(actual, expected.slice(1).reverse()); - assert.deepStrictEqual(array, expected); - }); - }); - - it('should be lazy when in a lazy sequence', function() { - var spy = { - 'toString': function() { - throw new Error('spy was revealed'); - } - }; - - var array = largeArray.concat(spy), - expected = array.slice(); - - try { - var wrapped = _(array).slice(1).map(String).reverse(), - actual = wrapped.last(); - } catch (e) {} - - assert.ok(wrapped instanceof _); - assert.strictEqual(actual, '1'); - assert.deepEqual(array, expected); - }); - - it('should work in a hybrid sequence', function() { - lodashStable.times(2, function(index) { - var clone = (index ? largeArray : smallArray).slice(); - - lodashStable.each(['map', 'filter'], function(methodName) { - var array = clone.slice(), - expected = clone.slice(1, -1).reverse(), - actual = _(array)[methodName](identity).thru(compact).reverse().value(); - - assert.deepStrictEqual(actual, expected); - - array = clone.slice(); - actual = _(array).thru(compact)[methodName](identity).pull(1).push(3).reverse().value(); - - assert.deepStrictEqual(actual, [3].concat(expected.slice(0, -1))); - }); - }); - }); - - it('should track the `__chain__` value of a wrapper', function() { - lodashStable.times(2, function(index) { - var array = (index ? largeArray : smallArray).slice(), - expected = array.slice().reverse(), - wrapped = _(array).chain().reverse().head(); - - assert.ok(wrapped instanceof _); - assert.strictEqual(wrapped.value(), head(expected)); - assert.deepStrictEqual(array, expected); - }); - }); -}); diff --git a/libs/nanofn/test/round-methods.js b/libs/nanofn/test/round-methods.js deleted file mode 100644 index be0a92498..000000000 --- a/libs/nanofn/test/round-methods.js +++ /dev/null @@ -1,82 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, MAX_SAFE_INTEGER, stubFalse } from './utils.js'; -import round from '../round.js'; - -describe('round methods', function() { - lodashStable.each(['ceil', 'floor', 'round'], function(methodName) { - var func = _[methodName], - isCeil = methodName == 'ceil', - isFloor = methodName == 'floor'; - - it('`_.' + methodName + '` should return a rounded number without a precision', function() { - var actual = func(4.006); - assert.strictEqual(actual, isCeil ? 5 : 4); - }); - - it('`_.' + methodName + '` should work with a precision of `0`', function() { - var actual = func(4.006, 0); - assert.strictEqual(actual, isCeil ? 5 : 4); - }); - - it('`_.' + methodName + '` should work with a positive precision', function() { - var actual = func(4.016, 2); - assert.strictEqual(actual, isFloor ? 4.01 : 4.02); - - actual = func(4.1, 2); - assert.strictEqual(actual, 4.1); - }); - - it('`_.' + methodName + '` should work with a negative precision', function() { - var actual = func(4160, -2); - assert.strictEqual(actual, isFloor ? 4100 : 4200); - }); - - it('`_.' + methodName + '` should coerce `precision` to an integer', function() { - var actual = func(4.006, NaN); - assert.strictEqual(actual, isCeil ? 5 : 4); - - var expected = isFloor ? 4.01 : 4.02; - - actual = func(4.016, 2.6); - assert.strictEqual(actual, expected); - - actual = func(4.016, '+2'); - assert.strictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with exponential notation and `precision`', function() { - var actual = func(5e1, 2); - assert.deepStrictEqual(actual, 50); - - actual = func('5e', 1); - assert.deepStrictEqual(actual, NaN); - - actual = func('5e1e1', 1); - assert.deepStrictEqual(actual, NaN); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var values = [[0], [-0], ['0'], ['-0'], [0, 1], [-0, 1], ['0', 1], ['-0', 1]], - expected = [Infinity, -Infinity, Infinity, -Infinity, Infinity, -Infinity, Infinity, -Infinity]; - - var actual = lodashStable.map(values, function(args) { - return 1 / func.apply(undefined, args); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should not return `NaN` for large `precision` values', function() { - var results = [ - round(10.0000001, 1000), - round(MAX_SAFE_INTEGER, 293) - ]; - - var expected = lodashStable.map(results, stubFalse), - actual = lodashStable.map(results, lodashStable.isNaN); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/runInContext.js b/libs/nanofn/test/runInContext.js deleted file mode 100644 index 402ddac66..000000000 --- a/libs/nanofn/test/runInContext.js +++ /dev/null @@ -1,29 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import runInContext from '../runInContext.js'; -import uniqueId from '../uniqueId.js'; - -describe('runInContext', function() { - it('should not require a fully populated `context` object', function() { - var lodash = runInContext({ - 'setTimeout': function(func) { func(); } - }); - - var pass = false; - lodash.delay(function() { pass = true; }, 32); - assert.ok(pass); - }); - - it('should use a zeroed `_.uniqueId` counter', function() { - lodashStable.times(2, uniqueId); - - var oldId = Number(uniqueId()), - lodash = runInContext(); - - assert.ok(uniqueId() > oldId); - - var id = lodash.uniqueId(); - assert.strictEqual(id, '1'); - assert.ok(id < oldId); - }); -}); diff --git a/libs/nanofn/test/sample.js b/libs/nanofn/test/sample.js deleted file mode 100644 index b29634a42..000000000 --- a/libs/nanofn/test/sample.js +++ /dev/null @@ -1,32 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { empties, noop } from './utils.js'; -import sample from '../sample.js'; - -describe('sample', function() { - var array = [1, 2, 3]; - - it('should return a random element', function() { - var actual = sample(array); - assert.ok(lodashStable.includes(array, actual)); - }); - - it('should return `undefined` when sampling empty collections', function() { - var expected = lodashStable.map(empties, noop); - - var actual = lodashStable.transform(empties, function(result, value) { - try { - result.push(sample(value)); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should sample an object', function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - actual = sample(object); - - assert.ok(lodashStable.includes(array, actual)); - }); -}); diff --git a/libs/nanofn/test/sampleSize.js b/libs/nanofn/test/sampleSize.js deleted file mode 100644 index e394c00c5..000000000 --- a/libs/nanofn/test/sampleSize.js +++ /dev/null @@ -1,76 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, empties, stubArray } from './utils.js'; -import sampleSize from '../sampleSize.js'; - -describe('sampleSize', function() { - var array = [1, 2, 3]; - - it('should return an array of random elements', function() { - var actual = sampleSize(array, 2); - - assert.strictEqual(actual.length, 2); - assert.deepStrictEqual(lodashStable.difference(actual, array), []); - }); - - it('should contain elements of the collection', function() { - var actual = sampleSize(array, array.length).sort(); - - assert.deepStrictEqual(actual, array); - }); - - it('should treat falsey `size` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? ['a'] : []; - }); - - var actual = lodashStable.map(falsey, function(size, index) { - return index ? sampleSize(['a'], size) : sampleSize(['a']); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an empty array when `n` < `1` or `NaN`', function() { - lodashStable.each([0, -1, -Infinity], function(n) { - assert.deepStrictEqual(sampleSize(array, n), []); - }); - }); - - it('should return all elements when `n` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - var actual = sampleSize(array, n).sort(); - assert.deepStrictEqual(actual, array); - }); - }); - - it('should coerce `n` to an integer', function() { - var actual = sampleSize(array, 1.6); - assert.strictEqual(actual.length, 1); - }); - - it('should return an empty array for empty collections', function() { - var expected = lodashStable.map(empties, stubArray); - - var actual = lodashStable.transform(empties, function(result, value) { - try { - result.push(sampleSize(value, 1)); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should sample an object', function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - actual = sampleSize(object, 2); - - assert.strictEqual(actual.length, 2); - assert.deepStrictEqual(lodashStable.difference(actual, lodashStable.values(object)), []); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map([['a']], sampleSize); - assert.deepStrictEqual(actual, [['a']]); - }); -}); diff --git a/libs/nanofn/test/set-methods.js b/libs/nanofn/test/set-methods.js deleted file mode 100644 index c7c69a349..000000000 --- a/libs/nanofn/test/set-methods.js +++ /dev/null @@ -1,172 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, symbol, defineProperty } from './utils.js'; -import unset from '../unset.js'; - -describe('set methods', function() { - lodashStable.each(['update', 'updateWith', 'set', 'setWith'], function(methodName) { - var func = _[methodName], - isUpdate = /^update/.test(methodName); - - var oldValue = 1, - value = 2, - updater = isUpdate ? lodashStable.constant(value) : value; - - it('`_.' + methodName + '` should set property values', function() { - lodashStable.each(['a', ['a']], function(path) { - var object = { 'a': oldValue }, - actual = func(object, path, updater); - - assert.strictEqual(actual, object); - assert.strictEqual(object.a, value); - }); - }); - - it('`_.' + methodName + '` should preserve the sign of `0`', function() { - var props = [-0, Object(-0), 0, Object(0)], - expected = lodashStable.map(props, lodashStable.constant(value)); - - var actual = lodashStable.map(props, function(key) { - var object = { '-0': 'a', '0': 'b' }; - func(object, key, updater); - return object[lodashStable.toString(key)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should unset symbol keyed property values', function() { - if (Symbol) { - var object = {}; - object[symbol] = 1; - - assert.strictEqual(unset(object, symbol), true); - assert.ok(!(symbol in object)); - } - }); - - it('`_.' + methodName + '` should set deep property values', function() { - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var object = { 'a': { 'b': oldValue } }, - actual = func(object, path, updater); - - assert.strictEqual(actual, object); - assert.strictEqual(object.a.b, value); - }); - }); - - it('`_.' + methodName + '` should set a key over a path', function() { - lodashStable.each(['a.b', ['a.b']], function(path) { - var object = { 'a.b': oldValue }, - actual = func(object, path, updater); - - assert.strictEqual(actual, object); - assert.deepStrictEqual(object, { 'a.b': value }); - }); - }); - - it('`_.' + methodName + '` should not coerce array paths to strings', function() { - var object = { 'a,b,c': 1, 'a': { 'b': { 'c': 1 } } }; - - func(object, ['a', 'b', 'c'], updater); - assert.strictEqual(object.a.b.c, value); - }); - - it('`_.' + methodName + '` should not ignore empty brackets', function() { - var object = {}; - - func(object, 'a[]', updater); - assert.deepStrictEqual(object, { 'a': { '': value } }); - }); - - it('`_.' + methodName + '` should handle empty paths', function() { - lodashStable.each([['', ''], [[], ['']]], function(pair, index) { - var object = {}; - - func(object, pair[0], updater); - assert.deepStrictEqual(object, index ? {} : { '': value }); - - func(object, pair[1], updater); - assert.deepStrictEqual(object, { '': value }); - }); - }); - - it('`_.' + methodName + '` should handle complex paths', function() { - var object = { 'a': { '1.23': { '["b"]': { 'c': { "['d']": { '\ne\n': { 'f': { 'g': oldValue } } } } } } } }; - - var paths = [ - 'a[-1.23]["[\\"b\\"]"].c[\'[\\\'d\\\']\'][\ne\n][f].g', - ['a', '-1.23', '["b"]', 'c', "['d']", '\ne\n', 'f', 'g'] - ]; - - lodashStable.each(paths, function(path) { - func(object, path, updater); - assert.strictEqual(object.a[-1.23]['["b"]'].c["['d']"]['\ne\n'].f.g, value); - object.a[-1.23]['["b"]'].c["['d']"]['\ne\n'].f.g = oldValue; - }); - }); - - it('`_.' + methodName + '` should create parts of `path` that are missing', function() { - var object = {}; - - lodashStable.each(['a[1].b.c', ['a', '1', 'b', 'c']], function(path) { - var actual = func(object, path, updater); - - assert.strictEqual(actual, object); - assert.deepStrictEqual(actual, { 'a': [undefined, { 'b': { 'c': value } }] }); - assert.ok(!('0' in object.a)); - - delete object.a; - }); - }); - - it('`_.' + methodName + '` should not error when `object` is nullish', function() { - var values = [null, undefined], - expected = [[null, null], [undefined, undefined]]; - - var actual = lodashStable.map(values, function(value) { - try { - return [func(value, 'a.b', updater), func(value, ['a', 'b'], updater)]; - } catch (e) { - return e.message; - } - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should overwrite primitives in the path', function() { - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var object = { 'a': '' }; - - func(object, path, updater); - assert.deepStrictEqual(object, { 'a': { 'b': 2 } }); - }); - }); - - it('`_.' + methodName + '` should not create an array for missing non-index property names that start with numbers', function() { - var object = {}; - - func(object, ['1a', '2b', '3c'], updater); - assert.deepStrictEqual(object, { '1a': { '2b': { '3c': value } } }); - }); - - it('`_.' + methodName + '` should not assign values that are the same as their destinations', function() { - lodashStable.each(['a', ['a'], { 'a': 1 }, NaN], function(value) { - var object = {}, - pass = true, - updater = isUpdate ? lodashStable.constant(value) : value; - - defineProperty(object, 'a', { - 'configurable': true, - 'enumerable': true, - 'get': lodashStable.constant(value), - 'set': function() { pass = false; } - }); - - func(object, 'a', updater); - assert.ok(pass); - }); - }); - }); -}); diff --git a/libs/nanofn/test/setWith.js b/libs/nanofn/test/setWith.js deleted file mode 100644 index 87cc2a2a1..000000000 --- a/libs/nanofn/test/setWith.js +++ /dev/null @@ -1,19 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop } from './utils.js'; -import setWith from '../setWith.js'; - -describe('setWith', function() { - it('should work with a `customizer` callback', function() { - var actual = setWith({ '0': {} }, '[0][1][2]', 3, function(value) { - return lodashStable.isObject(value) ? undefined : {}; - }); - - assert.deepStrictEqual(actual, { '0': { '1': { '2': 3 } } }); - }); - - it('should work with a `customizer` that returns `undefined`', function() { - var actual = setWith({}, 'a[0].b.c', 4, noop); - assert.deepStrictEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); - }); -}); diff --git a/libs/nanofn/test/shuffle.js b/libs/nanofn/test/shuffle.js deleted file mode 100644 index fb86b89fd..000000000 --- a/libs/nanofn/test/shuffle.js +++ /dev/null @@ -1,29 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import shuffle from '../shuffle.js'; - -describe('shuffle', function() { - var array = [1, 2, 3], - object = { 'a': 1, 'b': 2, 'c': 3 }; - - it('should return a new array', function() { - assert.notStrictEqual(shuffle(array), array); - }); - - it('should contain the same elements after a collection is shuffled', function() { - assert.deepStrictEqual(shuffle(array).sort(), array); - assert.deepStrictEqual(shuffle(object).sort(), array); - }); - - it('should shuffle small collections', function() { - var actual = lodashStable.times(1000, function() { - return shuffle([1, 2]); - }); - - assert.deepStrictEqual(lodashStable.sortBy(lodashStable.uniqBy(actual, String), '0'), [[1, 2], [2, 1]]); - }); - - it('should treat number values for `collection` as empty', function() { - assert.deepStrictEqual(shuffle(1), []); - }); -}); diff --git a/libs/nanofn/test/size.test.js b/libs/nanofn/test/size.test.js deleted file mode 100644 index 286173453..000000000 --- a/libs/nanofn/test/size.test.js +++ /dev/null @@ -1,75 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubZero, args, push, arrayProto, realm, MAX_SAFE_INTEGER } from './utils.js'; -import size from '../size.js'; - -describe('size', function() { - var array = [1, 2, 3]; - - it('should return the number of own enumerable string keyed properties of an object', function() { - assert.strictEqual(size({ 'one': 1, 'two': 2, 'three': 3 }), 3); - }); - - it('should return the length of an array', function() { - assert.strictEqual(size(array), 3); - }); - - it('should accept a falsey `object`', function() { - var expected = lodashStable.map(falsey, stubZero); - - var actual = lodashStable.map(falsey, function(object, index) { - try { - return index ? size(object) : size(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `arguments` objects', function() { - assert.strictEqual(size(args), 3); - }); - - it('should work with jQuery/MooTools DOM query collections', function() { - function Foo(elements) { - push.apply(this, elements); - } - Foo.prototype = { 'length': 0, 'splice': arrayProto.splice }; - - assert.strictEqual(size(new Foo(array)), 3); - }); - - it('should work with maps', function() { - if (Map) { - lodashStable.each([new Map, realm.map], function(map) { - map.set('a', 1); - map.set('b', 2); - assert.strictEqual(size(map), 2); - map.clear(); - }); - } - }); - - it('should work with sets', function() { - if (Set) { - lodashStable.each([new Set, realm.set], function(set) { - set.add(1); - set.add(2); - assert.strictEqual(size(set), 2); - set.clear(); - }); - } - }); - - it('should not treat objects with negative lengths as array-like', function() { - assert.strictEqual(size({ 'length': -1 }), 1); - }); - - it('should not treat objects with lengths larger than `MAX_SAFE_INTEGER` as array-like', function() { - assert.strictEqual(size({ 'length': MAX_SAFE_INTEGER + 1 }), 1); - }); - - it('should not treat objects with non-number lengths as array-like', function() { - assert.strictEqual(size({ 'length': '0' }), 1); - }); -}); diff --git a/libs/nanofn/test/slice-and-toArray.js b/libs/nanofn/test/slice-and-toArray.js deleted file mode 100644 index 7c8607015..000000000 --- a/libs/nanofn/test/slice-and-toArray.js +++ /dev/null @@ -1,43 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, args, document, body } from './utils.js'; - -describe('slice and toArray', function() { - lodashStable.each(['slice', 'toArray'], function(methodName) { - var array = [1, 2, 3], - func = _[methodName]; - - it('`_.' + methodName + '` should return a dense array', function() { - var sparse = Array(3); - sparse[1] = 2; - - var actual = func(sparse); - - assert.ok('0' in actual); - assert.ok('2' in actual); - assert.deepStrictEqual(actual, sparse); - }); - - it('`_.' + methodName + '` should treat array-like objects like arrays', function() { - var object = { '0': 'a', 'length': 1 }; - assert.deepStrictEqual(func(object), ['a']); - assert.deepStrictEqual(func(args), array); - }); - - it('`_.' + methodName + '` should return a shallow clone of arrays', function() { - var actual = func(array); - assert.deepStrictEqual(actual, array); - assert.notStrictEqual(actual, array); - }); - - it('`_.' + methodName + '` should work with a node list for `collection`', function() { - if (document) { - try { - var actual = func(document.getElementsByTagName('body')); - } catch (e) {} - - assert.deepStrictEqual(actual, [body]); - } - }); - }); -}); diff --git a/libs/nanofn/test/slice.js b/libs/nanofn/test/slice.js deleted file mode 100644 index 1e47e1283..000000000 --- a/libs/nanofn/test/slice.js +++ /dev/null @@ -1,133 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, LARGE_ARRAY_SIZE } from './utils.js'; -import slice from '../slice.js'; - -describe('slice', function() { - var array = [1, 2, 3]; - - it('should use a default `start` of `0` and a default `end` of `length`', function() { - var actual = slice(array); - assert.deepStrictEqual(actual, array); - assert.notStrictEqual(actual, array); - }); - - it('should work with a positive `start`', function() { - assert.deepStrictEqual(slice(array, 1), [2, 3]); - assert.deepStrictEqual(slice(array, 1, 3), [2, 3]); - }); - - it('should work with a `start` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(start) { - assert.deepStrictEqual(slice(array, start), []); - }); - }); - - it('should treat falsey `start` values as `0`', function() { - var expected = lodashStable.map(falsey, lodashStable.constant(array)); - - var actual = lodashStable.map(falsey, function(start) { - return slice(array, start); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with a negative `start`', function() { - assert.deepStrictEqual(slice(array, -1), [3]); - }); - - it('should work with a negative `start` <= negative `length`', function() { - lodashStable.each([-3, -4, -Infinity], function(start) { - assert.deepStrictEqual(slice(array, start), array); - }); - }); - - it('should work with `start` >= `end`', function() { - lodashStable.each([2, 3], function(start) { - assert.deepStrictEqual(slice(array, start, 2), []); - }); - }); - - it('should work with a positive `end`', function() { - assert.deepStrictEqual(slice(array, 0, 1), [1]); - }); - - it('should work with a `end` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(end) { - assert.deepStrictEqual(slice(array, 0, end), array); - }); - }); - - it('should treat falsey `end` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? array : []; - }); - - var actual = lodashStable.map(falsey, function(end, index) { - return index ? slice(array, 0, end) : slice(array, 0); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with a negative `end`', function() { - assert.deepStrictEqual(slice(array, 0, -1), [1, 2]); - }); - - it('should work with a negative `end` <= negative `length`', function() { - lodashStable.each([-3, -4, -Infinity], function(end) { - assert.deepStrictEqual(slice(array, 0, end), []); - }); - }); - - it('should coerce `start` and `end` to integers', function() { - var positions = [[0.1, 1.6], ['0', 1], [0, '1'], ['1'], [NaN, 1], [1, NaN]]; - - var actual = lodashStable.map(positions, function(pos) { - return slice.apply(_, [array].concat(pos)); - }); - - assert.deepStrictEqual(actual, [[1], [1], [1], [2, 3], [1], []]); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1], [2, 3]], - actual = lodashStable.map(array, slice); - - assert.deepStrictEqual(actual, array); - assert.notStrictEqual(actual, array); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - length = array.length, - wrapped = _(array); - - lodashStable.each(['map', 'filter'], function(methodName) { - assert.deepEqual(wrapped[methodName]().slice(0, -1).value(), array.slice(0, -1)); - assert.deepEqual(wrapped[methodName]().slice(1).value(), array.slice(1)); - assert.deepEqual(wrapped[methodName]().slice(1, 3).value(), array.slice(1, 3)); - assert.deepEqual(wrapped[methodName]().slice(-1).value(), array.slice(-1)); - - assert.deepEqual(wrapped[methodName]().slice(length).value(), array.slice(length)); - assert.deepEqual(wrapped[methodName]().slice(3, 2).value(), array.slice(3, 2)); - assert.deepEqual(wrapped[methodName]().slice(0, -length).value(), array.slice(0, -length)); - assert.deepEqual(wrapped[methodName]().slice(0, null).value(), array.slice(0, null)); - - assert.deepEqual(wrapped[methodName]().slice(0, length).value(), array.slice(0, length)); - assert.deepEqual(wrapped[methodName]().slice(-length).value(), array.slice(-length)); - assert.deepEqual(wrapped[methodName]().slice(null).value(), array.slice(null)); - - assert.deepEqual(wrapped[methodName]().slice(0, 1).value(), array.slice(0, 1)); - assert.deepEqual(wrapped[methodName]().slice(NaN, '1').value(), array.slice(NaN, '1')); - - assert.deepEqual(wrapped[methodName]().slice(0.1, 1.1).value(), array.slice(0.1, 1.1)); - assert.deepEqual(wrapped[methodName]().slice('0', 1).value(), array.slice('0', 1)); - assert.deepEqual(wrapped[methodName]().slice(0, '1').value(), array.slice(0, '1')); - assert.deepEqual(wrapped[methodName]().slice('1').value(), array.slice('1')); - assert.deepEqual(wrapped[methodName]().slice(NaN, 1).value(), array.slice(NaN, 1)); - assert.deepEqual(wrapped[methodName]().slice(1, NaN).value(), array.slice(1, NaN)); - }); - }); -}); diff --git a/libs/nanofn/test/some.js b/libs/nanofn/test/some.js deleted file mode 100644 index 5f93f4145..000000000 --- a/libs/nanofn/test/some.js +++ /dev/null @@ -1,76 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, empties, stubFalse, stubTrue } from './utils.js'; -import some from '../some.js'; - -describe('some', function() { - it('should return `true` if `predicate` returns truthy for any element', function() { - assert.strictEqual(some([false, 1, ''], identity), true); - assert.strictEqual(some([null, 'a', 0], identity), true); - }); - - it('should return `false` for empty collections', function() { - var expected = lodashStable.map(empties, stubFalse); - - var actual = lodashStable.map(empties, function(value) { - try { - return some(value, identity); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return `true` as soon as `predicate` returns truthy', function() { - var count = 0; - - assert.strictEqual(some([null, true, null], function(value) { - count++; - return value; - }), true); - - assert.strictEqual(count, 2); - }); - - it('should return `false` if `predicate` returns falsey for all elements', function() { - assert.strictEqual(some([false, false, false], identity), false); - assert.strictEqual(some([null, 0, ''], identity), false); - }); - - it('should use `_.identity` when `predicate` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value, index) { - var array = [0, 0]; - return index ? some(array, value) : some(array); - }); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(values, stubTrue); - actual = lodashStable.map(values, function(value, index) { - var array = [0, 1]; - return index ? some(array, value) : some(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var objects = [{ 'a': 0, 'b': 0 }, { 'a': 0, 'b': 1 }]; - assert.strictEqual(some(objects, 'a'), false); - assert.strictEqual(some(objects, 'b'), true); - }); - - it('should work with `_.matches` shorthands', function() { - var objects = [{ 'a': 0, 'b': 0 }, { 'a': 1, 'b': 1}]; - assert.strictEqual(some(objects, { 'a': 0 }), true); - assert.strictEqual(some(objects, { 'b': 2 }), false); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map([[1]], some); - assert.deepStrictEqual(actual, [true]); - }); -}); diff --git a/libs/nanofn/test/sortBy-methods.js b/libs/nanofn/test/sortBy-methods.js deleted file mode 100644 index fb4748d0f..000000000 --- a/libs/nanofn/test/sortBy-methods.js +++ /dev/null @@ -1,87 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('sortBy methods', function() { - lodashStable.each(['orderBy', 'sortBy'], function(methodName) { - var func = _[methodName]; - - function Pair(a, b, c) { - this.a = a; - this.b = b; - this.c = c; - } - - var objects = [ - { 'a': 'x', 'b': 3 }, - { 'a': 'y', 'b': 4 }, - { 'a': 'x', 'b': 1 }, - { 'a': 'y', 'b': 2 } - ]; - - var stableArray = [ - new Pair(1, 1, 1), new Pair(1, 2, 1), - new Pair(1, 1, 1), new Pair(1, 2, 1), - new Pair(1, 3, 1), new Pair(1, 4, 1), - new Pair(1, 5, 1), new Pair(1, 6, 1), - new Pair(2, 1, 2), new Pair(2, 2, 2), - new Pair(2, 3, 2), new Pair(2, 4, 2), - new Pair(2, 5, 2), new Pair(2, 6, 2), - new Pair(undefined, 1, 1), new Pair(undefined, 2, 1), - new Pair(undefined, 3, 1), new Pair(undefined, 4, 1), - new Pair(undefined, 5, 1), new Pair(undefined, 6, 1) - ]; - - var stableObject = lodashStable.zipObject('abcdefghijklmnopqrst'.split(''), stableArray); - - it('`_.' + methodName + '` should sort multiple properties in ascending order', function() { - var actual = func(objects, ['a', 'b']); - assert.deepStrictEqual(actual, [objects[2], objects[0], objects[3], objects[1]]); - }); - - it('`_.' + methodName + '` should support iteratees', function() { - var actual = func(objects, ['a', function(object) { return object.b; }]); - assert.deepStrictEqual(actual, [objects[2], objects[0], objects[3], objects[1]]); - }); - - it('`_.' + methodName + '` should perform a stable sort (test in IE > 8 and V8)', function() { - lodashStable.each([stableArray, stableObject], function(value, index) { - var actual = func(value, ['a', 'c']); - assert.deepStrictEqual(actual, stableArray, index ? 'object' : 'array'); - }); - }); - - it('`_.' + methodName + '` should not error on nullish elements', function() { - try { - var actual = func(objects.concat(null, undefined), ['a', 'b']); - } catch (e) {} - - assert.deepStrictEqual(actual, [objects[2], objects[0], objects[3], objects[1], null, undefined]); - }); - - it('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', function() { - var objects = [ - { 'a': 'x', '0': 3 }, - { 'a': 'y', '0': 4 }, - { 'a': 'x', '0': 1 }, - { 'a': 'y', '0': 2 } - ]; - - var funcs = [func, lodashStable.partialRight(func, 'bogus')]; - - lodashStable.each(['a', 0, [0]], function(props, index) { - var expected = lodashStable.map(funcs, lodashStable.constant( - index - ? [objects[2], objects[3], objects[0], objects[1]] - : [objects[0], objects[2], objects[1], objects[3]] - )); - - var actual = lodashStable.map(funcs, function(func) { - return lodashStable.reduce([props], func, objects); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - }); -}); diff --git a/libs/nanofn/test/sortBy.js b/libs/nanofn/test/sortBy.js deleted file mode 100644 index 6cf7acc4f..000000000 --- a/libs/nanofn/test/sortBy.js +++ /dev/null @@ -1,75 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import sortBy from '../sortBy.js'; - -describe('sortBy', function() { - var objects = [ - { 'a': 'x', 'b': 3 }, - { 'a': 'y', 'b': 4 }, - { 'a': 'x', 'b': 1 }, - { 'a': 'y', 'b': 2 } - ]; - - it('should sort in ascending order by `iteratee`', function() { - var actual = lodashStable.map(sortBy(objects, function(object) { - return object.b; - }), 'b'); - - assert.deepStrictEqual(actual, [1, 2, 3, 4]); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var array = [3, 2, 1], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([1, 2, 3])); - - var actual = lodashStable.map(values, function(value, index) { - return index ? sortBy(array, value) : sortBy(array); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `_.property` shorthands', function() { - var actual = lodashStable.map(sortBy(objects.concat(undefined), 'b'), 'b'); - assert.deepStrictEqual(actual, [1, 2, 3, 4, undefined]); - }); - - it('should work with an object for `collection`', function() { - var actual = sortBy({ 'a': 1, 'b': 2, 'c': 3 }, Math.sin); - assert.deepStrictEqual(actual, [3, 1, 2]); - }); - - it('should move `NaN`, nullish, and symbol values to the end', function() { - var symbol1 = Symbol ? Symbol('a') : null, - symbol2 = Symbol ? Symbol('b') : null, - array = [NaN, undefined, null, 4, symbol1, null, 1, symbol2, undefined, 3, NaN, 2], - expected = [1, 2, 3, 4, symbol1, symbol2, null, null, undefined, undefined, NaN, NaN]; - - assert.deepStrictEqual(sortBy(array), expected); - - array = [NaN, undefined, symbol1, null, 'd', null, 'a', symbol2, undefined, 'c', NaN, 'b']; - expected = ['a', 'b', 'c', 'd', symbol1, symbol2, null, null, undefined, undefined, NaN, NaN]; - - assert.deepStrictEqual(sortBy(array), expected); - }); - - it('should treat number values for `collection` as empty', function() { - assert.deepStrictEqual(sortBy(1), []); - }); - - it('should coerce arrays returned from `iteratee`', function() { - var actual = sortBy(objects, function(object) { - var result = [object.a, object.b]; - result.toString = function() { return String(this[0]); }; - return result; - }); - - assert.deepStrictEqual(actual, [objects[0], objects[2], objects[1], objects[3]]); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map([[2, 1, 3], [3, 2, 1]], sortBy); - assert.deepStrictEqual(actual, [[1, 2, 3], [1, 2, 3]]); - }); -}); diff --git a/libs/nanofn/test/sortedIndex-methods.js b/libs/nanofn/test/sortedIndex-methods.js deleted file mode 100644 index 056918bc7..000000000 --- a/libs/nanofn/test/sortedIndex-methods.js +++ /dev/null @@ -1,84 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; -import sortBy from '../sortBy.js'; - -describe('sortedIndex methods', function() { - lodashStable.each(['sortedIndex', 'sortedLastIndex'], function(methodName) { - var func = _[methodName], - isSortedIndex = methodName == 'sortedIndex'; - - it('`_.' + methodName + '` should return the insert index', function() { - var array = [30, 50], - values = [30, 40, 50], - expected = isSortedIndex ? [0, 1, 1] : [1, 1, 2]; - - var actual = lodashStable.map(values, function(value) { - return func(array, value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with an array of strings', function() { - var array = ['a', 'c'], - values = ['a', 'b', 'c'], - expected = isSortedIndex ? [0, 1, 1] : [1, 1, 2]; - - var actual = lodashStable.map(values, function(value) { - return func(array, value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should accept a nullish `array` and a `value`', function() { - var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant([0, 0, 0])); - - var actual = lodashStable.map(values, function(array) { - return [func(array, 1), func(array, undefined), func(array, NaN)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should align with `_.sortBy`', function() { - var symbol1 = Symbol ? Symbol('a') : null, - symbol2 = Symbol ? Symbol('b') : null, - symbol3 = Symbol ? Symbol('c') : null, - expected = [1, '2', {}, symbol1, symbol2, null, undefined, NaN, NaN]; - - lodashStable.each([ - [NaN, symbol1, null, 1, '2', {}, symbol2, NaN, undefined], - ['2', null, 1, symbol1, NaN, {}, NaN, symbol2, undefined] - ], function(array) { - assert.deepStrictEqual(sortBy(array), expected); - assert.strictEqual(func(expected, 3), 2); - assert.strictEqual(func(expected, symbol3), isSortedIndex ? 3 : (Symbol ? 5 : 6)); - assert.strictEqual(func(expected, null), isSortedIndex ? (Symbol ? 5 : 3) : 6); - assert.strictEqual(func(expected, undefined), isSortedIndex ? 6 : 7); - assert.strictEqual(func(expected, NaN), isSortedIndex ? 7 : 9); - }); - }); - - it('`_.' + methodName + '` should align with `_.sortBy` for nulls', function() { - var array = [null, null]; - - assert.strictEqual(func(array, null), isSortedIndex ? 0 : 2); - assert.strictEqual(func(array, 1), 0); - assert.strictEqual(func(array, 'a'), 0); - }); - - it('`_.' + methodName + '` should align with `_.sortBy` for symbols', function() { - var symbol1 = Symbol ? Symbol('a') : null, - symbol2 = Symbol ? Symbol('b') : null, - symbol3 = Symbol ? Symbol('c') : null, - array = [symbol1, symbol2]; - - assert.strictEqual(func(array, symbol3), isSortedIndex ? 0 : 2); - assert.strictEqual(func(array, 1), 0); - assert.strictEqual(func(array, 'a'), 0); - }); - }); -}); diff --git a/libs/nanofn/test/sortedIndexBy-methods.js b/libs/nanofn/test/sortedIndexBy-methods.js deleted file mode 100644 index ae3b5feaa..000000000 --- a/libs/nanofn/test/sortedIndexBy-methods.js +++ /dev/null @@ -1,59 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, slice, MAX_ARRAY_LENGTH, MAX_ARRAY_INDEX } from './utils.js'; - -describe('sortedIndexBy methods', function() { - lodashStable.each(['sortedIndexBy', 'sortedLastIndexBy'], function(methodName) { - var func = _[methodName], - isSortedIndexBy = methodName == 'sortedIndexBy'; - - it('`_.' + methodName + '` should provide correct `iteratee` arguments', function() { - var args; - - func([30, 50], 40, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [40]); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - var objects = [{ 'x': 30 }, { 'x': 50 }], - actual = func(objects, { 'x': 40 }, 'x'); - - assert.strictEqual(actual, 1); - }); - - it('`_.' + methodName + '` should avoid calling iteratee when length is 0', function() { - var objects = [], - actual = func(objects, { 'x': 50 }, assert.fail); - - assert.strictEqual(actual, 0); - }); - - it('`_.' + methodName + '` should support arrays larger than `MAX_ARRAY_LENGTH / 2`', function() { - lodashStable.each([Math.ceil(MAX_ARRAY_LENGTH / 2), MAX_ARRAY_LENGTH], function(length) { - var array = [], - values = [MAX_ARRAY_LENGTH, NaN, undefined]; - - array.length = length; - - lodashStable.each(values, function(value) { - var steps = 0; - - var actual = func(array, value, function(value) { - steps++; - return value; - }); - - var expected = (isSortedIndexBy ? !lodashStable.isNaN(value) : lodashStable.isFinite(value)) - ? 0 - : Math.min(length, MAX_ARRAY_INDEX); - - assert.ok(steps == 32 || steps == 33); - assert.strictEqual(actual, expected); - }); - }); - }); - }); -}); diff --git a/libs/nanofn/test/sortedIndexOf-methods.js b/libs/nanofn/test/sortedIndexOf-methods.js deleted file mode 100644 index 14550c564..000000000 --- a/libs/nanofn/test/sortedIndexOf-methods.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('sortedIndexOf methods', function() { - lodashStable.each(['sortedIndexOf', 'sortedLastIndexOf'], function(methodName) { - var func = _[methodName], - isSortedIndexOf = methodName == 'sortedIndexOf'; - - it('`_.' + methodName + '` should perform a binary search', function() { - var sorted = [4, 4, 5, 5, 6, 6]; - assert.deepStrictEqual(func(sorted, 5), isSortedIndexOf ? 2 : 3); - }); - }); -}); diff --git a/libs/nanofn/test/sortedUniq.test.js b/libs/nanofn/test/sortedUniq.test.js deleted file mode 100644 index fec499a66..000000000 --- a/libs/nanofn/test/sortedUniq.test.js +++ /dev/null @@ -1,13 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import sortedUniq from '../sortedUniq.js'; - -describe('sortedUniq', function() { - it('should return unique values of a sorted array', function() { - var expected = [1, 2, 3]; - - lodashStable.each([[1, 2, 3], [1, 1, 2, 2, 3], [1, 2, 3, 3, 3, 3, 3]], function(array) { - assert.deepStrictEqual(sortedUniq(array), expected); - }); - }); -}); diff --git a/libs/nanofn/test/split.js b/libs/nanofn/test/split.js deleted file mode 100644 index cc8e05b7f..000000000 --- a/libs/nanofn/test/split.js +++ /dev/null @@ -1,35 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import split from '../split.js'; - -describe('split', function() { - it('should split a string by `separator`', function() { - var string = 'abcde'; - assert.deepStrictEqual(split(string, 'c'), ['ab', 'de']); - assert.deepStrictEqual(split(string, /[bd]/), ['a', 'c', 'e']); - assert.deepStrictEqual(split(string, '', 2), ['a', 'b']); - }); - - it('should return an array containing an empty string for empty values', function() { - var values = [, null, undefined, ''], - expected = lodashStable.map(values, lodashStable.constant([''])); - - var actual = lodashStable.map(values, function(value, index) { - return index ? split(value) : split(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var strings = ['abc', 'def', 'ghi'], - actual = lodashStable.map(strings, split); - - assert.deepStrictEqual(actual, [['abc'], ['def'], ['ghi']]); - }); - - it('should allow mixed string and array prototype methods', function() { - var wrapped = _('abc'); - assert.strictEqual(wrapped.split('b').join(','), 'a,c'); - }); -}); diff --git a/libs/nanofn/test/spread.js b/libs/nanofn/test/spread.js deleted file mode 100644 index 862221b93..000000000 --- a/libs/nanofn/test/spread.js +++ /dev/null @@ -1,58 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, _, stubTrue, falsey } from './utils.js'; - -describe('spread', function() { - function fn(a, b, c) { - return slice.call(arguments); - } - - it('should spread arguments to `func`', function() { - var spread = _.spread(fn), - expected = [1, 2]; - - assert.deepStrictEqual(spread([1, 2]), expected); - assert.deepStrictEqual(spread([1, 2], 3), expected); - }); - - it('should accept a falsey `array`', function() { - var spread = _.spread(stubTrue), - expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(array, index) { - try { - return index ? spread(array) : spread(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with `start`', function() { - var spread = _.spread(fn, 1), - expected = [1, 2, 3]; - - assert.deepStrictEqual(spread(1, [2, 3]), expected); - assert.deepStrictEqual(spread(1, [2, 3], 4), expected); - }); - - it('should treat `start` as `0` for negative or `NaN` values', function() { - var values = [-1, NaN, 'a'], - expected = lodashStable.map(values, lodashStable.constant([1, 2])); - - var actual = lodashStable.map(values, function(value) { - var spread = _.spread(fn, value); - return spread([1, 2]); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should coerce `start` to an integer', function() { - var spread = _.spread(fn, 1.6), - expected = [1, 2, 3]; - - assert.deepStrictEqual(spread(1, [2, 3]), expected); - assert.deepStrictEqual(spread(1, [2, 3], 4), expected); - }); -}); diff --git a/libs/nanofn/test/startCase.test.js b/libs/nanofn/test/startCase.test.js deleted file mode 100644 index f61d329d0..000000000 --- a/libs/nanofn/test/startCase.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import startCase from '../startCase.js'; - -describe('startCase', function() { - it('should uppercase only the first character of each word', function() { - assert.strictEqual(startCase('--foo-bar--'), 'Foo Bar'); - assert.strictEqual(startCase('fooBar'), 'Foo Bar'); - assert.strictEqual(startCase('__FOO_BAR__'), 'FOO BAR'); - }); -}); diff --git a/libs/nanofn/test/startsWith-and-endsWith.js b/libs/nanofn/test/startsWith-and-endsWith.js deleted file mode 100644 index 58dabfe94..000000000 --- a/libs/nanofn/test/startsWith-and-endsWith.js +++ /dev/null @@ -1,38 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, MAX_SAFE_INTEGER } from './utils.js'; - -describe('startsWith and endsWith', function() { - lodashStable.each(['startsWith', 'endsWith'], function(methodName) { - var func = _[methodName], - isStartsWith = methodName == 'startsWith'; - - var string = 'abc', - chr = isStartsWith ? 'a' : 'c'; - - it('`_.' + methodName + '` should coerce `string` to a string', function() { - assert.strictEqual(func(Object(string), chr), true); - assert.strictEqual(func({ 'toString': lodashStable.constant(string) }, chr), true); - }); - - it('`_.' + methodName + '` should coerce `target` to a string', function() { - assert.strictEqual(func(string, Object(chr)), true); - assert.strictEqual(func(string, { 'toString': lodashStable.constant(chr) }), true); - }); - - it('`_.' + methodName + '` should coerce `position` to a number', function() { - var position = isStartsWith ? 1 : 2; - - assert.strictEqual(func(string, 'b', Object(position)), true); - assert.strictEqual(func(string, 'b', { 'toString': lodashStable.constant(String(position)) }), true); - }); - - it('should return `true` when `target` is an empty string regardless of `position`', function() { - var positions = [-Infinity, NaN, -3, -1, 0, 1, 2, 3, 5, MAX_SAFE_INTEGER, Infinity]; - - assert.ok(lodashStable.every(positions, function(position) { - return func(string, '', position); - })); - }); - }); -}); diff --git a/libs/nanofn/test/startsWith.js b/libs/nanofn/test/startsWith.js deleted file mode 100644 index d58905032..000000000 --- a/libs/nanofn/test/startsWith.js +++ /dev/null @@ -1,47 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { MAX_SAFE_INTEGER, falsey, stubTrue } from './utils.js'; -import startsWith from '../startsWith.js'; - -describe('startsWith', function() { - var string = 'abc'; - - it('should return `true` if a string starts with `target`', function() { - assert.strictEqual(startsWith(string, 'a'), true); - }); - - it('should return `false` if a string does not start with `target`', function() { - assert.strictEqual(startsWith(string, 'b'), false); - }); - - it('should work with a `position`', function() { - assert.strictEqual(startsWith(string, 'b', 1), true); - }); - - it('should work with `position` >= `length`', function() { - lodashStable.each([3, 5, MAX_SAFE_INTEGER, Infinity], function(position) { - assert.strictEqual(startsWith(string, 'a', position), false); - }); - }); - - it('should treat falsey `position` values as `0`', function() { - var expected = lodashStable.map(falsey, stubTrue); - - var actual = lodashStable.map(falsey, function(position) { - return startsWith(string, 'a', position); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should treat a negative `position` as `0`', function() { - lodashStable.each([-1, -3, -Infinity], function(position) { - assert.strictEqual(startsWith(string, 'a', position), true); - assert.strictEqual(startsWith(string, 'b', position), false); - }); - }); - - it('should coerce `position` to an integer', function() { - assert.strictEqual(startsWith(string, 'bc', 1.2), true); - }); -}); diff --git a/libs/nanofn/test/strict-mode-checks.js b/libs/nanofn/test/strict-mode-checks.js deleted file mode 100644 index 3423fe1b8..000000000 --- a/libs/nanofn/test/strict-mode-checks.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, isStrict, freeze } from './utils.js'; - -describe('strict mode checks', function() { - lodashStable.each(['assign', 'assignIn', 'bindAll', 'defaults', 'defaultsDeep', 'merge'], function(methodName) { - var func = _[methodName], - isBindAll = methodName == 'bindAll'; - - it('`_.' + methodName + '` should ' + (isStrict ? '' : 'not ') + 'throw strict mode errors', function() { - var object = freeze({ 'a': undefined, 'b': function() {} }), - pass = !isStrict; - - try { - func(object, isBindAll ? 'b' : { 'a': 1 }); - } catch (e) { - pass = !pass; - } - assert.ok(pass); - }); - }); -}); diff --git a/libs/nanofn/test/stub-methods.js b/libs/nanofn/test/stub-methods.js deleted file mode 100644 index 1fb0e61b6..000000000 --- a/libs/nanofn/test/stub-methods.js +++ /dev/null @@ -1,32 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, empties } from './utils.js'; - -describe('stub methods', function() { - lodashStable.each(['noop', 'stubTrue', 'stubFalse', 'stubArray', 'stubObject', 'stubString'], function(methodName) { - var func = _[methodName]; - - var pair = ({ - 'stubArray': [[], 'an empty array'], - 'stubFalse': [false, '`false`'], - 'stubObject': [{}, 'an empty object'], - 'stubString': ['', 'an empty string'], - 'stubTrue': [true, '`true`'], - 'noop': [undefined, '`undefined`'] - })[methodName]; - - var values = Array(2).concat(empties, true, 1, 'a'), - expected = lodashStable.map(values, lodashStable.constant(pair[0])); - - it('`_.' + methodName + '` should return ' + pair[1], function() { - var actual = lodashStable.map(values, function(value, index) { - if (index < 2) { - return index ? func.call({}) : func(); - } - return func(value); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/subtract.test.js b/libs/nanofn/test/subtract.test.js deleted file mode 100644 index b148411ad..000000000 --- a/libs/nanofn/test/subtract.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from 'assert'; -import subtract from '../subtract.js'; - -describe('subtract', function() { - it('should subtract two numbers', function() { - assert.strictEqual(subtract(6, 4), 2); - assert.strictEqual(subtract(-6, 4), -10); - assert.strictEqual(subtract(-6, -4), -2); - }); - - it('should coerce arguments to numbers', function() { - assert.strictEqual(subtract('6', '4'), 2); - assert.deepStrictEqual(subtract('x', 'y'), NaN); - }); -}); diff --git a/libs/nanofn/test/sum-methods.js b/libs/nanofn/test/sum-methods.js deleted file mode 100644 index d536b9c50..000000000 --- a/libs/nanofn/test/sum-methods.js +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, empties, stubZero } from './utils.js'; - -describe('sum methods', function() { - lodashStable.each(['sum', 'sumBy'], function(methodName) { - var array = [6, 4, 2], - func = _[methodName]; - - it('`_.' + methodName + '` should return the sum of an array of numbers', function() { - assert.strictEqual(func(array), 12); - }); - - it('`_.' + methodName + '` should return `0` when passing empty `array` values', function() { - var expected = lodashStable.map(empties, stubZero); - - var actual = lodashStable.map(empties, function(value) { - return func(value); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should skip `undefined` values', function() { - assert.strictEqual(func([1, undefined]), 1); - }); - - it('`_.' + methodName + '` should not skip `NaN` values', function() { - assert.deepStrictEqual(func([1, NaN]), NaN); - }); - - it('`_.' + methodName + '` should not coerce values to numbers', function() { - assert.strictEqual(func(['1', '2']), '12'); - }); - }); -}); diff --git a/libs/nanofn/test/sumBy.js b/libs/nanofn/test/sumBy.js deleted file mode 100644 index 62c780e58..000000000 --- a/libs/nanofn/test/sumBy.js +++ /dev/null @@ -1,32 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import sumBy from '../sumBy.js'; - -describe('sumBy', function() { - var array = [6, 4, 2], - objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; - - it('should work with an `iteratee`', function() { - var actual = sumBy(objects, function(object) { - return object.a; - }); - - assert.deepStrictEqual(actual, 6); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - sumBy(array, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [6]); - }); - - it('should work with `_.property` shorthands', function() { - var arrays = [[2], [3], [1]]; - assert.strictEqual(sumBy(arrays, 0), 6); - assert.strictEqual(sumBy(objects, 'a'), 6); - }); -}); diff --git a/libs/nanofn/test/tail.js b/libs/nanofn/test/tail.js deleted file mode 100644 index 6fd325796..000000000 --- a/libs/nanofn/test/tail.js +++ /dev/null @@ -1,77 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, stubArray, LARGE_ARRAY_SIZE } from './utils.js'; -import tail from '../tail.js'; - -describe('tail', function() { - var array = [1, 2, 3]; - - it('should accept a falsey `array`', function() { - var expected = lodashStable.map(falsey, stubArray); - - var actual = lodashStable.map(falsey, function(array, index) { - try { - return index ? tail(array) : tail(); - } catch (e) {} - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should exclude the first element', function() { - assert.deepStrictEqual(tail(array), [2, 3]); - }); - - it('should return an empty when querying empty arrays', function() { - assert.deepStrictEqual(tail([]), []); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, tail); - - assert.deepStrictEqual(actual, [[2, 3], [5, 6], [8, 9]]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - values = []; - - var actual = _(array).tail().filter(function(value) { - values.push(value); - return false; - }) - .value(); - - assert.deepEqual(actual, []); - assert.deepEqual(values, array.slice(1)); - - values = []; - - actual = _(array).filter(function(value) { - values.push(value); - return isEven(value); - }) - .tail() - .value(); - - assert.deepEqual(actual, tail(_.filter(array, isEven))); - assert.deepEqual(values, array); - }); - - it('should not execute subsequent iteratees on an empty array in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - iteratee = function() { pass = false; }, - pass = true, - actual = _(array).slice(0, 1).tail().map(iteratee).value(); - - assert.ok(pass); - assert.deepEqual(actual, []); - - pass = true; - actual = _(array).filter().slice(0, 1).tail().map(iteratee).value(); - - assert.ok(pass); - assert.deepEqual(actual, []); - }); -}); diff --git a/libs/nanofn/test/take.js b/libs/nanofn/test/take.js deleted file mode 100644 index 76690a58b..000000000 --- a/libs/nanofn/test/take.js +++ /dev/null @@ -1,65 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import take from '../take.js'; - -describe('take', function() { - var array = [1, 2, 3]; - - it('should take the first two elements', function() { - assert.deepStrictEqual(take(array, 2), [1, 2]); - }); - - it('should treat falsey `n` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? [1] : []; - }); - - var actual = lodashStable.map(falsey, function(n) { - return take(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an empty array when `n` < `1`', function() { - lodashStable.each([0, -1, -Infinity], function(n) { - assert.deepStrictEqual(take(array, n), []); - }); - }); - - it('should return all elements when `n` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - assert.deepStrictEqual(take(array, n), array); - }); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, take); - - assert.deepStrictEqual(actual, [[1], [4], [7]]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1), - predicate = function(value) { values.push(value); return isEven(value); }, - values = [], - actual = _(array).take(2).take().value(); - - assert.deepEqual(actual, take(take(array, 2))); - - actual = _(array).filter(predicate).take(2).take().value(); - assert.deepEqual(values, [1, 2]); - assert.deepEqual(actual, take(take(_.filter(array, predicate), 2))); - - actual = _(array).take(6).takeRight(4).take(2).takeRight().value(); - assert.deepEqual(actual, _.takeRight(take(_.takeRight(take(array, 6), 4), 2))); - - values = []; - - actual = _(array).take(array.length - 1).filter(predicate).take(6).takeRight(4).take(2).takeRight().value(); - assert.deepEqual(values, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); - assert.deepEqual(actual, _.takeRight(take(_.takeRight(take(_.filter(take(array, array.length - 1), predicate), 6), 4), 2))); - }); -}); diff --git a/libs/nanofn/test/takeRight.js b/libs/nanofn/test/takeRight.js deleted file mode 100644 index ee48abc80..000000000 --- a/libs/nanofn/test/takeRight.js +++ /dev/null @@ -1,65 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { falsey, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import takeRight from '../takeRight.js'; - -describe('takeRight', function() { - var array = [1, 2, 3]; - - it('should take the last two elements', function() { - assert.deepStrictEqual(takeRight(array, 2), [2, 3]); - }); - - it('should treat falsey `n` values, except `undefined`, as `0`', function() { - var expected = lodashStable.map(falsey, function(value) { - return value === undefined ? [3] : []; - }); - - var actual = lodashStable.map(falsey, function(n) { - return takeRight(array, n); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an empty array when `n` < `1`', function() { - lodashStable.each([0, -1, -Infinity], function(n) { - assert.deepStrictEqual(takeRight(array, n), []); - }); - }); - - it('should return all elements when `n` >= `length`', function() { - lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - assert.deepStrictEqual(takeRight(array, n), array); - }); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], - actual = lodashStable.map(array, takeRight); - - assert.deepStrictEqual(actual, [[3], [6], [9]]); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - predicate = function(value) { values.push(value); return isEven(value); }, - values = [], - actual = _(array).takeRight(2).takeRight().value(); - - assert.deepEqual(actual, takeRight(takeRight(array))); - - actual = _(array).filter(predicate).takeRight(2).takeRight().value(); - assert.deepEqual(values, array); - assert.deepEqual(actual, takeRight(takeRight(_.filter(array, predicate), 2))); - - actual = _(array).takeRight(6).take(4).takeRight(2).take().value(); - assert.deepEqual(actual, _.take(takeRight(_.take(takeRight(array, 6), 4), 2))); - - values = []; - - actual = _(array).filter(predicate).takeRight(6).take(4).takeRight(2).take().value(); - assert.deepEqual(values, array); - assert.deepEqual(actual, _.take(takeRight(_.take(takeRight(_.filter(array, predicate), 6), 4), 2))); - }); -}); diff --git a/libs/nanofn/test/takeRightWhile.js b/libs/nanofn/test/takeRightWhile.js deleted file mode 100644 index d080e0c60..000000000 --- a/libs/nanofn/test/takeRightWhile.js +++ /dev/null @@ -1,96 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, LARGE_ARRAY_SIZE } from './utils.js'; -import takeRightWhile from '../takeRightWhile.js'; - -describe('takeRightWhile', function() { - var array = [1, 2, 3, 4]; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 1 }, - { 'a': 2, 'b': 2 } - ]; - - it('should take elements while `predicate` returns truthy', function() { - var actual = takeRightWhile(array, function(n) { - return n > 2; - }); - - assert.deepStrictEqual(actual, [3, 4]); - }); - - it('should provide correct `predicate` arguments', function() { - var args; - - takeRightWhile(array, function() { - args = slice.call(arguments); - }); - - assert.deepStrictEqual(args, [4, 3, array]); - }); - - it('should work with `_.matches` shorthands', function() { - assert.deepStrictEqual(takeRightWhile(objects, { 'b': 2 }), objects.slice(2)); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - assert.deepStrictEqual(takeRightWhile(objects, ['b', 2]), objects.slice(2)); - }); - - it('should work with `_.property` shorthands', function() { - assert.deepStrictEqual(takeRightWhile(objects, 'b'), objects.slice(1)); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - predicate = function(n) { return n > 2; }, - expected = takeRightWhile(array, predicate), - wrapped = _(array).takeRightWhile(predicate); - - assert.deepEqual(wrapped.value(), expected); - assert.deepEqual(wrapped.reverse().value(), expected.slice().reverse()); - assert.strictEqual(wrapped.last(), _.last(expected)); - }); - - it('should provide correct `predicate` arguments in a lazy sequence', function() { - var args, - array = lodashStable.range(LARGE_ARRAY_SIZE + 1); - - var expected = [ - square(LARGE_ARRAY_SIZE), - LARGE_ARRAY_SIZE - 1, - lodashStable.map(array.slice(1), square) - ]; - - _(array).slice(1).takeRightWhile(function(value, index, array) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, [LARGE_ARRAY_SIZE, LARGE_ARRAY_SIZE - 1, array.slice(1)]); - - _(array).slice(1).map(square).takeRightWhile(function(value, index, array) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - - _(array).slice(1).map(square).takeRightWhile(function(value, index) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - - _(array).slice(1).map(square).takeRightWhile(function(index) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, [square(LARGE_ARRAY_SIZE)]); - - _(array).slice(1).map(square).takeRightWhile(function() { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - }); -}); diff --git a/libs/nanofn/test/takeWhile.js b/libs/nanofn/test/takeWhile.js deleted file mode 100644 index 43d1b10d9..000000000 --- a/libs/nanofn/test/takeWhile.js +++ /dev/null @@ -1,102 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, LARGE_ARRAY_SIZE, square } from './utils.js'; -import takeWhile from '../takeWhile.js'; - -describe('takeWhile', function() { - var array = [1, 2, 3, 4]; - - var objects = [ - { 'a': 2, 'b': 2 }, - { 'a': 1, 'b': 1 }, - { 'a': 0, 'b': 0 } - ]; - - it('should take elements while `predicate` returns truthy', function() { - var actual = takeWhile(array, function(n) { - return n < 3; - }); - - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('should provide correct `predicate` arguments', function() { - var args; - - takeWhile(array, function() { - args = slice.call(arguments); - }); - - assert.deepStrictEqual(args, [1, 0, array]); - }); - - it('should work with `_.matches` shorthands', function() { - assert.deepStrictEqual(takeWhile(objects, { 'b': 2 }), objects.slice(0, 1)); - }); - - it('should work with `_.matchesProperty` shorthands', function() { - assert.deepStrictEqual(takeWhile(objects, ['b', 2]), objects.slice(0, 1)); - }); - it('should work with `_.property` shorthands', function() { - assert.deepStrictEqual(takeWhile(objects, 'b'), objects.slice(0, 2)); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE), - predicate = function(n) { return n < 3; }, - expected = takeWhile(array, predicate), - wrapped = _(array).takeWhile(predicate); - - assert.deepEqual(wrapped.value(), expected); - assert.deepEqual(wrapped.reverse().value(), expected.slice().reverse()); - assert.strictEqual(wrapped.last(), _.last(expected)); - }); - - it('should work in a lazy sequence with `take`', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE); - - var actual = _(array) - .takeWhile(function(n) { return n < 4; }) - .take(2) - .takeWhile(function(n) { return n == 0; }) - .value(); - - assert.deepEqual(actual, [0]); - }); - - it('should provide correct `predicate` arguments in a lazy sequence', function() { - var args, - array = lodashStable.range(LARGE_ARRAY_SIZE + 1), - expected = [1, 0, lodashStable.map(array.slice(1), square)]; - - _(array).slice(1).takeWhile(function(value, index, array) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, [1, 0, array.slice(1)]); - - _(array).slice(1).map(square).takeWhile(function(value, index, array) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - - _(array).slice(1).map(square).takeWhile(function(value, index) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - - _(array).slice(1).map(square).takeWhile(function(value) { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, [1]); - - _(array).slice(1).map(square).takeWhile(function() { - args = slice.call(arguments); - }).value(); - - assert.deepEqual(args, expected); - }); -}); diff --git a/libs/nanofn/test/tap.js b/libs/nanofn/test/tap.js deleted file mode 100644 index d50fa573c..000000000 --- a/libs/nanofn/test/tap.js +++ /dev/null @@ -1,30 +0,0 @@ -import assert from 'assert'; - -describe('tap', function() { - it('should intercept and return the given value', function() { - var intercepted, - array = [1, 2, 3]; - - var actual = _.tap(array, function(value) { - intercepted = value; - }); - - assert.strictEqual(actual, array); - assert.strictEqual(intercepted, array); - }); - - it('should intercept unwrapped values and return wrapped values when chaining', function() { - var intercepted, - array = [1, 2, 3]; - - var wrapped = _(array).tap(function(value) { - intercepted = value; - value.pop(); - }); - - assert.ok(wrapped instanceof _); - - wrapped.value(); - assert.strictEqual(intercepted, array); - }); -}); diff --git a/libs/nanofn/test/template.js b/libs/nanofn/test/template.js deleted file mode 100644 index 01308dbce..000000000 --- a/libs/nanofn/test/template.js +++ /dev/null @@ -1,451 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { numberTag, stubString, stubTrue, stubFalse } from './utils.js'; -import template from '../template.js'; -import templateSettings from '../templateSettings.js'; - -describe('template', function() { - it('should escape values in "escape" delimiters', function() { - var strings = ['

<%- value %>

', '

<%-value%>

', '

<%-\nvalue\n%>

'], - expected = lodashStable.map(strings, lodashStable.constant('

&<>"'/

')), - data = { 'value': '&<>"\'/' }; - - var actual = lodashStable.map(strings, function(string) { - return template(string)(data); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not reference `_.escape` when "escape" delimiters are not used', function() { - var compiled = template('<%= typeof __e %>'); - assert.strictEqual(compiled({}), 'undefined'); - }); - - it('should evaluate JavaScript in "evaluate" delimiters', function() { - var compiled = template( - '
    <%\ - for (var key in collection) {\ - %>
  • <%= collection[key] %>
  • <%\ - } %>
' - ); - - var data = { 'collection': { 'a': 'A', 'b': 'B' } }, - actual = compiled(data); - - assert.strictEqual(actual, '
  • A
  • B
'); - }); - - it('should support "evaluate" delimiters with single line comments (test production builds)', function() { - var compiled = template('<% // A code comment. %><% if (value) { %>yap<% } else { %>nope<% } %>'), - data = { 'value': true }; - - assert.strictEqual(compiled(data), 'yap'); - }); - - it('should support referencing variables declared in "evaluate" delimiters from other delimiters', function() { - var compiled = template('<% var b = a; %><%= b.value %>'), - data = { 'a': { 'value': 1 } }; - - assert.strictEqual(compiled(data), '1'); - }); - - it('should interpolate data properties in "interpolate" delimiters', function() { - var strings = ['<%= a %>BC', '<%=a%>BC', '<%=\na\n%>BC'], - expected = lodashStable.map(strings, lodashStable.constant('ABC')), - data = { 'a': 'A' }; - - var actual = lodashStable.map(strings, function(string) { - return template(string)(data); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should support "interpolate" delimiters with escaped values', function() { - var compiled = template('<%= a ? "a=\\"A\\"" : "" %>'), - data = { 'a': true }; - - assert.strictEqual(compiled(data), 'a="A"'); - }); - - it('should support "interpolate" delimiters containing ternary operators', function() { - var compiled = template('<%= value ? value : "b" %>'), - data = { 'value': 'a' }; - - assert.strictEqual(compiled(data), 'a'); - }); - - it('should support "interpolate" delimiters containing global values', function() { - var compiled = template('<%= typeof Math.abs %>'); - - try { - var actual = compiled(); - } catch (e) {} - - assert.strictEqual(actual, 'function'); - }); - - it('should support complex "interpolate" delimiters', function() { - lodashStable.forOwn({ - '<%= a + b %>': '3', - '<%= b - a %>': '1', - '<%= a = b %>': '2', - '<%= !a %>': 'false', - '<%= ~a %>': '-2', - '<%= a * b %>': '2', - '<%= a / b %>': '0.5', - '<%= a % b %>': '1', - '<%= a >> b %>': '0', - '<%= a << b %>': '4', - '<%= a & b %>': '0', - '<%= a ^ b %>': '3', - '<%= a | b %>': '3', - '<%= {}.toString.call(0) %>': numberTag, - '<%= a.toFixed(2) %>': '1.00', - '<%= obj["a"] %>': '1', - '<%= delete a %>': 'true', - '<%= "a" in obj %>': 'true', - '<%= obj instanceof Object %>': 'true', - '<%= new Boolean %>': 'false', - '<%= typeof a %>': 'number', - '<%= void a %>': '' - }, - function(value, key) { - var compiled = template(key), - data = { 'a': 1, 'b': 2 }; - - assert.strictEqual(compiled(data), value, key); - }); - }); - - it('should support ES6 template delimiters', function() { - var data = { 'value': 2 }; - assert.strictEqual(template('1${value}3')(data), '123'); - assert.strictEqual(template('${"{" + value + "\\}"}')(data), '{2}'); - }); - - it('should support the "imports" option', function() { - var compiled = template('<%= a %>', { 'imports': { 'a': 1 } }); - assert.strictEqual(compiled({}), '1'); - }); - - it('should support the "variable" options', function() { - var compiled = template( - '<% _.each( data.a, function( value ) { %>' + - '<%= value.valueOf() %>' + - '<% }) %>', { 'variable': 'data' } - ); - - var data = { 'a': [1, 2, 3] }; - - try { - assert.strictEqual(compiled(data), '123'); - } catch (e) { - assert.ok(false, e.message); - } - }); - - it('should support custom delimiters', function() { - lodashStable.times(2, function(index) { - var settingsClone = lodashStable.clone(templateSettings); - - var settings = lodashStable.assign(index ? templateSettings : {}, { - 'escape': /\{\{-([\s\S]+?)\}\}/g, - 'evaluate': /\{\{([\s\S]+?)\}\}/g, - 'interpolate': /\{\{=([\s\S]+?)\}\}/g - }); - - var expected = '
  • 0: a & A
  • 1: b & B
', - compiled = template('
    {{ _.each(collection, function(value, index) {}}
  • {{= index }}: {{- value }}
  • {{}); }}
', index ? null : settings), - data = { 'collection': ['a & A', 'b & B'] }; - - assert.strictEqual(compiled(data), expected); - lodashStable.assign(templateSettings, settingsClone); - }); - }); - - it('should support custom delimiters containing special characters', function() { - lodashStable.times(2, function(index) { - var settingsClone = lodashStable.clone(templateSettings); - - var settings = lodashStable.assign(index ? templateSettings : {}, { - 'escape': /<\?-([\s\S]+?)\?>/g, - 'evaluate': /<\?([\s\S]+?)\?>/g, - 'interpolate': /<\?=([\s\S]+?)\?>/g - }); - - var expected = '
  • 0: a & A
  • 1: b & B
', - compiled = template('
  • :
', index ? null : settings), - data = { 'collection': ['a & A', 'b & B'] }; - - assert.strictEqual(compiled(data), expected); - lodashStable.assign(templateSettings, settingsClone); - }); - }); - - it('should use a `with` statement by default', function() { - var compiled = template('<%= index %><%= collection[index] %><% _.each(collection, function(value, index) { %><%= index %><% }); %>'), - actual = compiled({ 'index': 1, 'collection': ['a', 'b', 'c'] }); - - assert.strictEqual(actual, '1b012'); - }); - - it('should use `_.templateSettings.imports._.templateSettings`', function() { - var lodash = templateSettings.imports._, - settingsClone = lodashStable.clone(lodash.templateSettings); - - lodash.templateSettings = lodashStable.assign(lodash.templateSettings, { - 'interpolate': /\{\{=([\s\S]+?)\}\}/g - }); - - var compiled = template('{{= a }}'); - assert.strictEqual(compiled({ 'a': 1 }), '1'); - - if (settingsClone) { - lodashStable.assign(lodash.templateSettings, settingsClone); - } else { - delete lodash.templateSettings; - } - }); - - it('should fallback to `_.templateSettings`', function() { - var lodash = templateSettings.imports._, - delimiter = templateSettings.interpolate; - - templateSettings.imports._ = { 'escape': lodashStable.escape }; - templateSettings.interpolate = /\{\{=([\s\S]+?)\}\}/g; - - var compiled = template('{{= a }}'); - assert.strictEqual(compiled({ 'a': 1 }), '1'); - - templateSettings.imports._ = lodash; - templateSettings.interpolate = delimiter; - }); - - it('should ignore `null` delimiters', function() { - var delimiter = { - 'escape': /\{\{-([\s\S]+?)\}\}/g, - 'evaluate': /\{\{([\s\S]+?)\}\}/g, - 'interpolate': /\{\{=([\s\S]+?)\}\}/g - }; - - lodashStable.forOwn({ - 'escape': '{{- a }}', - 'evaluate': '{{ print(a) }}', - 'interpolate': '{{= a }}' - }, - function(value, key) { - var settings = { 'escape': null, 'evaluate': null, 'interpolate': null }; - settings[key] = delimiter[key]; - - var expected = '1 <%- a %> <% print(a) %> <%= a %>', - compiled = template(value + ' <%- a %> <% print(a) %> <%= a %>', settings), - data = { 'a': 1 }; - - assert.strictEqual(compiled(data), expected); - }); - }); - - it('should work without delimiters', function() { - var expected = 'abc'; - assert.strictEqual(template(expected)({}), expected); - }); - - it('should work with `this` references', function() { - var compiled = template('a<%= this.String("b") %>c'); - assert.strictEqual(compiled(), 'abc'); - - var object = { 'b': 'B' }; - object.compiled = template('A<%= this.b %>C', { 'variable': 'obj' }); - assert.strictEqual(object.compiled(), 'ABC'); - }); - - it('should work with backslashes', function() { - var compiled = template('<%= a %> \\b'), - data = { 'a': 'A' }; - - assert.strictEqual(compiled(data), 'A \\b'); - }); - - it('should work with escaped characters in string literals', function() { - var compiled = template('<% print("\'\\n\\r\\t\\u2028\\u2029\\\\") %>'); - assert.strictEqual(compiled(), "'\n\r\t\u2028\u2029\\"); - - var data = { 'a': 'A' }; - compiled = template('\'\n\r\t<%= a %>\u2028\u2029\\"'); - assert.strictEqual(compiled(data), '\'\n\r\tA\u2028\u2029\\"'); - }); - - it('should handle \\u2028 & \\u2029 characters', function() { - var compiled = template('\u2028<%= "\\u2028\\u2029" %>\u2029'); - assert.strictEqual(compiled(), '\u2028\u2028\u2029\u2029'); - }); - - it('should work with statements containing quotes', function() { - var compiled = template("<%\ - if (a == 'A' || a == \"a\") {\ - %>'a',\"A\"<%\ - } %>" - ); - - var data = { 'a': 'A' }; - assert.strictEqual(compiled(data), "'a',\"A\""); - }); - - it('should work with templates containing newlines and comments', function() { - var compiled = template('<%\n\ - // A code comment.\n\ - if (value) { value += 3; }\n\ - %>

<%= value %>

' - ); - - assert.strictEqual(compiled({ 'value': 3 }), '

6

'); - }); - - it('should tokenize delimiters', function() { - var compiled = template(''), - data = { 'type': 1 }; - - assert.strictEqual(compiled(data), ''); - }); - - it('should evaluate delimiters once', function() { - var actual = [], - compiled = template('<%= func("a") %><%- func("b") %><% func("c") %>'), - data = { 'func': function(value) { actual.push(value); } }; - - compiled(data); - assert.deepStrictEqual(actual, ['a', 'b', 'c']); - }); - - it('should match delimiters before escaping text', function() { - var compiled = template('<<\n a \n>>', { 'evaluate': /<<(.*?)>>/g }); - assert.strictEqual(compiled(), '<<\n a \n>>'); - }); - - it('should resolve nullish values to an empty string', function() { - var compiled = template('<%= a %><%- a %>'), - data = { 'a': null }; - - assert.strictEqual(compiled(data), ''); - - data = { 'a': undefined }; - assert.strictEqual(compiled(data), ''); - - data = { 'a': {} }; - compiled = template('<%= a.b %><%- a.b %>'); - assert.strictEqual(compiled(data), ''); - }); - - it('should return an empty string for empty values', function() { - var values = [, null, undefined, ''], - expected = lodashStable.map(values, stubString), - data = { 'a': 1 }; - - var actual = lodashStable.map(values, function(value, index) { - var compiled = index ? template(value) : template(); - return compiled(data); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should parse delimiters without newlines', function() { - var expected = '<<\nprint("

" + (value ? "yes" : "no") + "

")\n>>', - compiled = template(expected, { 'evaluate': /<<(.+?)>>/g }), - data = { 'value': true }; - - assert.strictEqual(compiled(data), expected); - }); - - it('should support recursive calls', function() { - var compiled = template('<%= a %><% a = _.template(c)(obj) %><%= a %>'), - data = { 'a': 'A', 'b': 'B', 'c': '<%= b %>' }; - - assert.strictEqual(compiled(data), 'AB'); - }); - - it('should coerce `text` to a string', function() { - var object = { 'toString': lodashStable.constant('<%= a %>') }, - data = { 'a': 1 }; - - assert.strictEqual(template(object)(data), '1'); - }); - - it('should not modify the `options` object', function() { - var options = {}; - template('', options); - assert.deepStrictEqual(options, {}); - }); - - it('should not modify `_.templateSettings` when `options` are given', function() { - var data = { 'a': 1 }; - - assert.ok(!('a' in templateSettings)); - template('', {}, data); - assert.ok(!('a' in templateSettings)); - - delete templateSettings.a; - }); - - it('should not error for non-object `data` and `options` values', function() { - template('')(1); - assert.ok(true, '`data` value'); - - template('', 1)(1); - assert.ok(true, '`options` value'); - }); - - it('should expose the source on compiled templates', function() { - var compiled = template('x'), - values = [String(compiled), compiled.source], - expected = lodashStable.map(values, stubTrue); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.includes(value, '__p'); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should expose the source on SyntaxErrors', function() { - try { - template('<% if x %>'); - } catch (e) { - var source = e.source; - } - assert.ok(lodashStable.includes(source, '__p')); - }); - - it('should not include sourceURLs in the source', function() { - var options = { 'sourceURL': '/a/b/c' }, - compiled = template('x', options), - values = [compiled.source, undefined]; - - try { - template('<% if x %>', options); - } catch (e) { - values[1] = e.source; - } - var expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - return lodashStable.includes(value, 'sourceURL'); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var array = ['<%= a %>', '<%- b %>', '<% print(c) %>'], - compiles = lodashStable.map(array, template), - data = { 'a': 'one', 'b': '"two"', 'c': 'three' }; - - var actual = lodashStable.map(compiles, function(compiled) { - return compiled(data); - }); - - assert.deepStrictEqual(actual, ['one', '"two"', 'three']); - }); -}); diff --git a/libs/nanofn/test/throttle.js b/libs/nanofn/test/throttle.js deleted file mode 100644 index c495b00eb..000000000 --- a/libs/nanofn/test/throttle.js +++ /dev/null @@ -1,227 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { identity, isModularize, argv, isPhantom } from './utils.js'; -import throttle from '../throttle.js'; -import runInContext from '../runInContext.js'; - -describe('throttle', function() { - it('should throttle a function', function(done) { - var callCount = 0, - throttled = throttle(function() { callCount++; }, 32); - - throttled(); - throttled(); - throttled(); - - var lastCount = callCount; - assert.ok(callCount); - - setTimeout(function() { - assert.ok(callCount > lastCount); - done(); - }, 64); - }); - - it('subsequent calls should return the result of the first call', function(done) { - var throttled = throttle(identity, 32), - results = [throttled('a'), throttled('b')]; - - assert.deepStrictEqual(results, ['a', 'a']); - - setTimeout(function() { - var results = [throttled('c'), throttled('d')]; - assert.notStrictEqual(results[0], 'a'); - assert.notStrictEqual(results[0], undefined); - - assert.notStrictEqual(results[1], 'd'); - assert.notStrictEqual(results[1], undefined); - done(); - }, 64); - }); - - it('should clear timeout when `func` is called', function(done) { - if (!isModularize) { - var callCount = 0, - dateCount = 0; - - var lodash = runInContext({ - 'Date': { - 'now': function() { - return ++dateCount == 5 ? Infinity : +new Date; - } - } - }); - - var throttled = lodash.throttle(function() { callCount++; }, 32); - - throttled(); - throttled(); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 64); - } - else { - done(); - } - }); - - it('should not trigger a trailing call when invoked once', function(done) { - var callCount = 0, - throttled = throttle(function() { callCount++; }, 32); - - throttled(); - assert.strictEqual(callCount, 1); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - done(); - }, 64); - }); - - lodashStable.times(2, function(index) { - it('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), function(done) { - var callCount = 0, - limit = (argv || isPhantom) ? 1000 : 320, - options = index ? { 'leading': false } : {}, - throttled = throttle(function() { callCount++; }, 32, options); - - var start = +new Date; - while ((new Date - start) < limit) { - throttled(); - } - var actual = callCount > 1; - setTimeout(function() { - assert.ok(actual); - done(); - }, 1); - }); - }); - - it('should trigger a second throttled call as soon as possible', function(done) { - var callCount = 0; - - var throttled = throttle(function() { - callCount++; - }, 128, { 'leading': false }); - - throttled(); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - throttled(); - }, 192); - - setTimeout(function() { - assert.strictEqual(callCount, 1); - }, 254); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 384); - }); - - it('should apply default options', function(done) { - var callCount = 0, - throttled = throttle(function() { callCount++; }, 32, {}); - - throttled(); - throttled(); - assert.strictEqual(callCount, 1); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 128); - }); - - it('should support a `leading` option', function() { - var withLeading = throttle(identity, 32, { 'leading': true }); - assert.strictEqual(withLeading('a'), 'a'); - - var withoutLeading = throttle(identity, 32, { 'leading': false }); - assert.strictEqual(withoutLeading('a'), undefined); - }); - - it('should support a `trailing` option', function(done) { - var withCount = 0, - withoutCount = 0; - - var withTrailing = throttle(function(value) { - withCount++; - return value; - }, 64, { 'trailing': true }); - - var withoutTrailing = throttle(function(value) { - withoutCount++; - return value; - }, 64, { 'trailing': false }); - - assert.strictEqual(withTrailing('a'), 'a'); - assert.strictEqual(withTrailing('b'), 'a'); - - assert.strictEqual(withoutTrailing('a'), 'a'); - assert.strictEqual(withoutTrailing('b'), 'a'); - - setTimeout(function() { - assert.strictEqual(withCount, 2); - assert.strictEqual(withoutCount, 1); - done(); - }, 256); - }); - - it('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function(done) { - var callCount = 0; - - var throttled = throttle(function() { - callCount++; - }, 64, { 'trailing': false }); - - throttled(); - throttled(); - - setTimeout(function() { - throttled(); - throttled(); - }, 96); - - setTimeout(function() { - assert.ok(callCount > 1); - done(); - }, 192); - }); - - it('should work with a system time of `0`', function(done) { - if (!isModularize) { - var callCount = 0, - dateCount = 0; - - var lodash = runInContext({ - 'Date': { - 'now': function() { - return ++dateCount < 4 ? 0 : +new Date; - } - } - }); - - var throttled = lodash.throttle(function(value) { - callCount++; - return value; - }, 32); - - var results = [throttled('a'), throttled('b'), throttled('c')]; - assert.deepStrictEqual(results, ['a', 'a', 'a']); - assert.strictEqual(callCount, 1); - - setTimeout(function() { - assert.strictEqual(callCount, 2); - done(); - }, 64); - } - else { - done(); - } - }); -}); diff --git a/libs/nanofn/test/times.js b/libs/nanofn/test/times.js deleted file mode 100644 index b9873f204..000000000 --- a/libs/nanofn/test/times.js +++ /dev/null @@ -1,62 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice, doubled, falsey, stubArray } from './utils.js'; -import times from '../times.js'; -import identity from '../identity.js'; - -describe('times', function() { - it('should coerce non-finite `n` values to `0`', function() { - lodashStable.each([-Infinity, NaN, Infinity], function(n) { - assert.deepStrictEqual(times(n), []); - }); - }); - - it('should coerce `n` to an integer', function() { - var actual = times(2.6, identity); - assert.deepStrictEqual(actual, [0, 1]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - times(1, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [0]); - }); - - it('should use `_.identity` when `iteratee` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant([0, 1, 2])); - - var actual = lodashStable.map(values, function(value, index) { - return index ? times(3, value) : times(3); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an array of the results of each `iteratee` execution', function() { - assert.deepStrictEqual(times(3, doubled), [0, 2, 4]); - }); - - it('should return an empty array for falsey and negative `n` values', function() { - var values = falsey.concat(-1, -Infinity), - expected = lodashStable.map(values, stubArray); - - var actual = lodashStable.map(values, function(value, index) { - return index ? times(value) : times(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should return an unwrapped value when implicitly chaining', function() { - assert.deepStrictEqual(_(3).times(), [0, 1, 2]); - }); - - it('should return a wrapped value when explicitly chaining', function() { - assert.ok(_(3).chain().times() instanceof _); - }); -}); diff --git a/libs/nanofn/test/toArray.test.js b/libs/nanofn/test/toArray.test.js deleted file mode 100644 index 7baaf3c41..000000000 --- a/libs/nanofn/test/toArray.test.js +++ /dev/null @@ -1,48 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { arrayProto, LARGE_ARRAY_SIZE } from './utils.js'; -import toArray from '../toArray.js'; - -describe('toArray', function() { - it('should convert objects to arrays', function() { - assert.deepStrictEqual(toArray({ 'a': 1, 'b': 2 }), [1, 2]); - }); - - it('should convert iterables to arrays', function() { - if (Symbol && Symbol.iterator) { - var object = { '0': 'a', 'length': 1 }; - object[Symbol.iterator] = arrayProto[Symbol.iterator]; - - assert.deepStrictEqual(toArray(object), ['a']); - } - }); - - it('should convert maps to arrays', function() { - if (Map) { - var map = new Map; - map.set('a', 1); - map.set('b', 2); - assert.deepStrictEqual(toArray(map), [['a', 1], ['b', 2]]); - } - }); - - it('should convert strings to arrays', function() { - assert.deepStrictEqual(toArray(''), []); - assert.deepStrictEqual(toArray('ab'), ['a', 'b']); - assert.deepStrictEqual(toArray(Object('ab')), ['a', 'b']); - }); - - it('should work in a lazy sequence', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE + 1); - - var object = lodashStable.zipObject(lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return ['key' + index, index]; - })); - - var actual = _(array).slice(1).map(String).toArray().value(); - assert.deepEqual(actual, lodashStable.map(array.slice(1), String)); - - actual = _(object).toArray().slice(1).map(String).value(); - assert.deepEqual(actual, _.map(toArray(object).slice(1), String)); - }); -}); diff --git a/libs/nanofn/test/toInteger-methods.js b/libs/nanofn/test/toInteger-methods.js deleted file mode 100644 index c9d0c0349..000000000 --- a/libs/nanofn/test/toInteger-methods.js +++ /dev/null @@ -1,25 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, MAX_SAFE_INTEGER, MAX_INTEGER } from './utils.js'; - -describe('toInteger methods', function() { - lodashStable.each(['toInteger', 'toSafeInteger'], function(methodName) { - var func = _[methodName], - isSafe = methodName == 'toSafeInteger'; - - it('`_.' + methodName + '` should convert values to integers', function() { - assert.strictEqual(func(-5.6), -5); - assert.strictEqual(func('5.6'), 5); - assert.strictEqual(func(), 0); - assert.strictEqual(func(NaN), 0); - - var expected = isSafe ? MAX_SAFE_INTEGER : MAX_INTEGER; - assert.strictEqual(func(Infinity), expected); - assert.strictEqual(func(-Infinity), -expected); - }); - - it('`_.' + methodName + '` should support `value` of `-0`', function() { - assert.strictEqual(1 / func(-0), -Infinity); - }); - }); -}); diff --git a/libs/nanofn/test/toLength.test.js b/libs/nanofn/test/toLength.test.js deleted file mode 100644 index 3abbdd227..000000000 --- a/libs/nanofn/test/toLength.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import { MAX_INTEGER, MAX_ARRAY_LENGTH } from './utils.js'; -import toLength from '../toLength.js'; - -describe('toLength', function() { - it('should return a valid length', function() { - assert.strictEqual(toLength(-1), 0); - assert.strictEqual(toLength('1'), 1); - assert.strictEqual(toLength(1.1), 1); - assert.strictEqual(toLength(MAX_INTEGER), MAX_ARRAY_LENGTH); - }); - - it('should return `value` if a valid length', function() { - assert.strictEqual(toLength(0), 0); - assert.strictEqual(toLength(3), 3); - assert.strictEqual(toLength(MAX_ARRAY_LENGTH), MAX_ARRAY_LENGTH); - }); - - it('should convert `-0` to `0`', function() { - assert.strictEqual(1 / toLength(-0), Infinity); - }); -}); diff --git a/libs/nanofn/test/toLower.js b/libs/nanofn/test/toLower.js deleted file mode 100644 index 03e7117d9..000000000 --- a/libs/nanofn/test/toLower.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import toLower from '../toLower.js'; - -describe('toLower', function() { - it('should convert whole string to lower case', function() { - assert.deepStrictEqual(toLower('--Foo-Bar--'), '--foo-bar--'); - assert.deepStrictEqual(toLower('fooBar'), 'foobar'); - assert.deepStrictEqual(toLower('__FOO_BAR__'), '__foo_bar__'); - }); -}); diff --git a/libs/nanofn/test/toPairs-methods.js b/libs/nanofn/test/toPairs-methods.js deleted file mode 100644 index 34f0ddba2..000000000 --- a/libs/nanofn/test/toPairs-methods.js +++ /dev/null @@ -1,61 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('toPairs methods', function() { - lodashStable.each(['toPairs', 'toPairsIn'], function(methodName) { - var func = _[methodName], - isToPairs = methodName == 'toPairs'; - - it('`_.' + methodName + '` should create an array of string keyed-value pairs', function() { - var object = { 'a': 1, 'b': 2 }, - actual = lodashStable.sortBy(func(object), 0); - - assert.deepStrictEqual(actual, [['a', 1], ['b', 2]]); - }); - - it('`_.' + methodName + '` should ' + (isToPairs ? 'not ' : '') + 'include inherited string keyed property values', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var expected = isToPairs ? [['a', 1]] : [['a', 1], ['b', 2]], - actual = lodashStable.sortBy(func(new Foo), 0); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should convert objects with a `length` property', function() { - var object = { '0': 'a', '1': 'b', 'length': 2 }, - actual = lodashStable.sortBy(func(object), 0); - - assert.deepStrictEqual(actual, [['0', 'a'], ['1', 'b'], ['length', 2]]); - }); - - it('`_.' + methodName + '` should convert maps', function() { - if (Map) { - var map = new Map; - map.set('a', 1); - map.set('b', 2); - assert.deepStrictEqual(func(map), [['a', 1], ['b', 2]]); - } - }); - - it('`_.' + methodName + '` should convert sets', function() { - if (Set) { - var set = new Set; - set.add(1); - set.add(2); - assert.deepStrictEqual(func(set), [[1, 1], [2, 2]]); - } - }); - - it('`_.' + methodName + '` should convert strings', function() { - lodashStable.each(['xo', Object('xo')], function(string) { - var actual = lodashStable.sortBy(func(string), 0); - assert.deepStrictEqual(actual, [['0', 'x'], ['1', 'o']]); - }); - }); - }); -}); diff --git a/libs/nanofn/test/toPairs.js b/libs/nanofn/test/toPairs.js deleted file mode 100644 index 8605aa7bb..000000000 --- a/libs/nanofn/test/toPairs.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import entries from '../entries.js'; -import toPairs from '../toPairs.js'; - -describe('toPairs', function() { - it('should be aliased', function() { - assert.strictEqual(entries, toPairs); - }); -}); diff --git a/libs/nanofn/test/toPairsIn.js b/libs/nanofn/test/toPairsIn.js deleted file mode 100644 index f35de06d9..000000000 --- a/libs/nanofn/test/toPairsIn.js +++ /dev/null @@ -1,9 +0,0 @@ -import assert from 'assert'; -import entriesIn from '../entriesIn.js'; -import toPairsIn from '../toPairsIn.js'; - -describe('toPairsIn', function() { - it('should be aliased', function() { - assert.strictEqual(entriesIn, toPairsIn); - }); -}); diff --git a/libs/nanofn/test/toPath.js b/libs/nanofn/test/toPath.js deleted file mode 100644 index 361de4657..000000000 --- a/libs/nanofn/test/toPath.js +++ /dev/null @@ -1,66 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { symbol } from './utils.js'; -import toPath from '../toPath.js'; - -describe('toPath', function() { - it('should convert a string to a path', function() { - assert.deepStrictEqual(toPath('a.b.c'), ['a', 'b', 'c']); - assert.deepStrictEqual(toPath('a[0].b.c'), ['a', '0', 'b', 'c']); - }); - - it('should coerce array elements to strings', function() { - var array = ['a', 'b', 'c']; - - lodashStable.each([array, lodashStable.map(array, Object)], function(value) { - var actual = toPath(value); - assert.deepStrictEqual(actual, array); - assert.notStrictEqual(actual, array); - }); - }); - - it('should return new path array', function() { - assert.notStrictEqual(toPath('a.b.c'), toPath('a.b.c')); - }); - - it('should not coerce symbols to strings', function() { - if (Symbol) { - var object = Object(symbol); - lodashStable.each([symbol, object, [symbol], [object]], function(value) { - var actual = toPath(value); - assert.ok(lodashStable.isSymbol(actual[0])); - }); - } - }); - - it('should handle complex paths', function() { - var actual = toPath('a[-1.23]["[\\"b\\"]"].c[\'[\\\'d\\\']\'][\ne\n][f].g'); - assert.deepStrictEqual(actual, ['a', '-1.23', '["b"]', 'c', "['d']", '\ne\n', 'f', 'g']); - }); - - it('should handle consecutive empty brackets and dots', function() { - var expected = ['', 'a']; - assert.deepStrictEqual(toPath('.a'), expected); - assert.deepStrictEqual(toPath('[].a'), expected); - - expected = ['', '', 'a']; - assert.deepStrictEqual(toPath('..a'), expected); - assert.deepStrictEqual(toPath('[][].a'), expected); - - expected = ['a', '', 'b']; - assert.deepStrictEqual(toPath('a..b'), expected); - assert.deepStrictEqual(toPath('a[].b'), expected); - - expected = ['a', '', '', 'b']; - assert.deepStrictEqual(toPath('a...b'), expected); - assert.deepStrictEqual(toPath('a[][].b'), expected); - - expected = ['a', '']; - assert.deepStrictEqual(toPath('a.'), expected); - assert.deepStrictEqual(toPath('a[]'), expected); - - expected = ['a', '', '']; - assert.deepStrictEqual(toPath('a..'), expected); - assert.deepStrictEqual(toPath('a[][]'), expected); - }); -}); diff --git a/libs/nanofn/test/toPlainObject.js b/libs/nanofn/test/toPlainObject.js deleted file mode 100644 index 78046d28f..000000000 --- a/libs/nanofn/test/toPlainObject.js +++ /dev/null @@ -1,30 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { args } from './utils.js'; -import toPlainObject from '../toPlainObject.js'; - -describe('toPlainObject', function() { - it('should flatten inherited string keyed properties', function() { - function Foo() { - this.b = 2; - } - Foo.prototype.c = 3; - - var actual = lodashStable.assign({ 'a': 1 }, toPlainObject(new Foo)); - assert.deepStrictEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); - }); - - it('should convert `arguments` objects to plain objects', function() { - var actual = toPlainObject(args), - expected = { '0': 1, '1': 2, '2': 3 }; - - assert.deepStrictEqual(actual, expected); - }); - - it('should convert arrays to plain objects', function() { - var actual = toPlainObject(['a', 'b', 'c']), - expected = { '0': 'a', '1': 'b', '2': 'c' }; - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/toString.test.js b/libs/nanofn/test/toString.test.js deleted file mode 100644 index 16e08ab57..000000000 --- a/libs/nanofn/test/toString.test.js +++ /dev/null @@ -1,43 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubString, symbol } from './utils.js'; -import toString from '../toString.js'; - -describe('toString', function() { - it('should treat nullish values as empty strings', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubString); - - var actual = lodashStable.map(values, function(value, index) { - return index ? toString(value) : toString(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should preserve the sign of `0`', function() { - var values = [-0, Object(-0), 0, Object(0)], - expected = ['-0', '-0', '0', '0'], - actual = lodashStable.map(values, toString); - - assert.deepStrictEqual(actual, expected); - }); - - it('should preserve the sign of `0` in an array', function() { - var values = [-0, Object(-0), 0, Object(0)]; - assert.deepStrictEqual(toString(values), '-0,-0,0,0'); - }); - - it('should handle symbols', function() { - assert.strictEqual(toString(symbol), 'Symbol(a)'); - }); - - it('should handle an array of symbols', function() { - assert.strictEqual(toString([symbol]), 'Symbol(a)'); - }); - - it('should return the `toString` result of the wrapped value', function() { - var wrapped = _([1, 2, 3]); - assert.strictEqual(wrapped.toString(), '1,2,3'); - }); -}); diff --git a/libs/nanofn/test/toUpper.js b/libs/nanofn/test/toUpper.js deleted file mode 100644 index bb6b83729..000000000 --- a/libs/nanofn/test/toUpper.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import toUpper from '../toUpper.js'; - -describe('toUpper', function() { - it('should convert whole string to upper case', function() { - assert.deepStrictEqual(toUpper('--Foo-Bar'), '--FOO-BAR'); - assert.deepStrictEqual(toUpper('fooBar'), 'FOOBAR'); - assert.deepStrictEqual(toUpper('__FOO_BAR__'), '__FOO_BAR__'); - }); -}); diff --git a/libs/nanofn/test/transform.js b/libs/nanofn/test/transform.js deleted file mode 100644 index c8121183a..000000000 --- a/libs/nanofn/test/transform.js +++ /dev/null @@ -1,205 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -import { - stubTrue, - square, - typedArrays, - noop, - stubObject, - stubFalse, - falsey, - slice, - realm, -} from './utils.js'; - -import transform from '../transform.js'; - -describe('transform', function() { - function Foo() { - this.a = 1; - this.b = 2; - this.c = 3; - } - - it('should create an object with the same `[[Prototype]]` as `object` when `accumulator` is nullish', function() { - var accumulators = [, null, undefined], - object = new Foo, - expected = lodashStable.map(accumulators, stubTrue); - - var iteratee = function(result, value, key) { - result[key] = square(value); - }; - - var mapper = function(accumulator, index) { - return index ? transform(object, iteratee, accumulator) : transform(object, iteratee); - }; - - var results = lodashStable.map(accumulators, mapper); - - var actual = lodashStable.map(results, function(result) { - return result instanceof Foo; - }); - - assert.deepStrictEqual(actual, expected); - - expected = lodashStable.map(accumulators, lodashStable.constant({ 'a': 1, 'b': 4, 'c': 9 })); - actual = lodashStable.map(results, lodashStable.toPlainObject); - - assert.deepStrictEqual(actual, expected); - - object = { 'a': 1, 'b': 2, 'c': 3 }; - actual = lodashStable.map(accumulators, mapper); - - assert.deepStrictEqual(actual, expected); - - object = [1, 2, 3]; - expected = lodashStable.map(accumulators, lodashStable.constant([1, 4, 9])); - actual = lodashStable.map(accumulators, mapper); - - assert.deepStrictEqual(actual, expected); - }); - - it('should create regular arrays from typed arrays', function() { - var expected = lodashStable.map(typedArrays, stubTrue); - - var actual = lodashStable.map(typedArrays, function(type) { - var Ctor = root[type], - array = Ctor ? new Ctor(new ArrayBuffer(24)) : []; - - return lodashStable.isArray(transform(array, noop)); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should support an `accumulator` value', function() { - var values = [new Foo, [1, 2, 3], { 'a': 1, 'b': 2, 'c': 3 }], - expected = lodashStable.map(values, lodashStable.constant([1, 4, 9])); - - var actual = lodashStable.map(values, function(value) { - return transform(value, function(result, value) { - result.push(square(value)); - }, []); - }); - - assert.deepStrictEqual(actual, expected); - - var object = { 'a': 1, 'b': 4, 'c': 9 }, - expected = [object, { '0': 1, '1': 4, '2': 9 }, object]; - - actual = lodashStable.map(values, function(value) { - return transform(value, function(result, value, key) { - result[key] = square(value); - }, {}); - }); - - assert.deepStrictEqual(actual, expected); - - lodashStable.each([[], {}], function(accumulator) { - var actual = lodashStable.map(values, function(value) { - return transform(value, noop, accumulator); - }); - - assert.ok(lodashStable.every(actual, function(result) { - return result === accumulator; - })); - - assert.strictEqual(transform(null, null, accumulator), accumulator); - }); - }); - - it('should treat sparse arrays as dense', function() { - var actual = transform(Array(1), function(result, value, index) { - result[index] = String(value); - }); - - assert.deepStrictEqual(actual, ['undefined']); - }); - - it('should work without an `iteratee`', function() { - assert.ok(transform(new Foo) instanceof Foo); - }); - - it('should ensure `object` is an object before using its `[[Prototype]]`', function() { - var Ctors = [Boolean, Boolean, Number, Number, Number, String, String], - values = [false, true, 0, 1, NaN, '', 'a'], - expected = lodashStable.map(values, stubObject); - - var results = lodashStable.map(values, function(value) { - return transform(value); - }); - - assert.deepStrictEqual(results, expected); - - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(results, function(value, index) { - return value instanceof Ctors[index]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should ensure `object` constructor is a function before using its `[[Prototype]]`', function() { - Foo.prototype.constructor = null; - assert.ok(!(transform(new Foo) instanceof Foo)); - Foo.prototype.constructor = Foo; - }); - - it('should create an empty object when given a falsey `object`', function() { - var expected = lodashStable.map(falsey, stubObject); - - var actual = lodashStable.map(falsey, function(object, index) { - return index ? transform(object) : transform(); - }); - - assert.deepStrictEqual(actual, expected); - }); - - lodashStable.each({ - 'array': [1, 2, 3], - 'object': { 'a': 1, 'b': 2, 'c': 3 } - }, - function(object, key) { - it('should provide correct `iteratee` arguments when transforming an ' + key, function() { - var args; - - transform(object, function() { - args || (args = slice.call(arguments)); - }); - - var first = args[0]; - if (key == 'array') { - assert.ok(first !== object && lodashStable.isArray(first)); - assert.deepStrictEqual(args, [first, 1, 0, object]); - } else { - assert.ok(first !== object && lodashStable.isPlainObject(first)); - assert.deepStrictEqual(args, [first, 1, 'a', object]); - } - }); - }); - - it('should create an object from the same realm as `object`', function() { - var objects = lodashStable.filter(realm, function(value) { - return lodashStable.isObject(value) && !lodashStable.isElement(value); - }); - - var expected = lodashStable.map(objects, stubTrue); - - var actual = lodashStable.map(objects, function(object) { - var Ctor = object.constructor, - result = transform(object); - - if (result === object) { - return false; - } - if (lodashStable.isTypedArray(object)) { - return result instanceof Array; - } - return result instanceof Ctor || !(new Ctor instanceof Ctor); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/trim-methods.js b/libs/nanofn/test/trim-methods.js deleted file mode 100644 index c3f8a845c..000000000 --- a/libs/nanofn/test/trim-methods.js +++ /dev/null @@ -1,83 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, whitespace } from './utils.js'; - -describe('trim methods', function() { - lodashStable.each(['trim', 'trimStart', 'trimEnd'], function(methodName, index) { - var func = _[methodName], - parts = []; - - if (index != 2) { - parts.push('leading'); - } - if (index != 1) { - parts.push('trailing'); - } - parts = parts.join(' and '); - - it('`_.' + methodName + '` should remove ' + parts + ' whitespace', function() { - var string = whitespace + 'a b c' + whitespace, - expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); - - assert.strictEqual(func(string), expected); - }); - - it('`_.' + methodName + '` should coerce `string` to a string', function() { - var object = { 'toString': lodashStable.constant(whitespace + 'a b c' + whitespace) }, - expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); - - assert.strictEqual(func(object), expected); - }); - - it('`_.' + methodName + '` should remove ' + parts + ' `chars`', function() { - var string = '-_-a-b-c-_-', - expected = (index == 2 ? '-_-' : '') + 'a-b-c' + (index == 1 ? '-_-' : ''); - - assert.strictEqual(func(string, '_-'), expected); - }); - - it('`_.' + methodName + '` should coerce `chars` to a string', function() { - var object = { 'toString': lodashStable.constant('_-') }, - string = '-_-a-b-c-_-', - expected = (index == 2 ? '-_-' : '') + 'a-b-c' + (index == 1 ? '-_-' : ''); - - assert.strictEqual(func(string, object), expected); - }); - - it('`_.' + methodName + '` should return an empty string for empty values and `chars`', function() { - lodashStable.each([null, '_-'], function(chars) { - assert.strictEqual(func(null, chars), ''); - assert.strictEqual(func(undefined, chars), ''); - assert.strictEqual(func('', chars), ''); - }); - }); - - it('`_.' + methodName + '` should work with `undefined` or empty string values for `chars`', function() { - var string = whitespace + 'a b c' + whitespace, - expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); - - assert.strictEqual(func(string, undefined), expected); - assert.strictEqual(func(string, ''), string); - }); - - it('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', function() { - var string = Object(whitespace + 'a b c' + whitespace), - trimmed = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''), - actual = lodashStable.map([string, string, string], func); - - assert.deepStrictEqual(actual, [trimmed, trimmed, trimmed]); - }); - - it('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function() { - var string = whitespace + 'a b c' + whitespace, - expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); - - assert.strictEqual(_(string)[methodName](), expected); - }); - - it('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function() { - var string = whitespace + 'a b c' + whitespace; - assert.ok(_(string).chain()[methodName]() instanceof _); - }); - }); -}); diff --git a/libs/nanofn/test/truncate.js b/libs/nanofn/test/truncate.js deleted file mode 100644 index 240eae0b9..000000000 --- a/libs/nanofn/test/truncate.js +++ /dev/null @@ -1,64 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import truncate from '../truncate.js'; - -describe('truncate', function() { - var string = 'hi-diddly-ho there, neighborino'; - - it('should use a default `length` of `30`', function() { - assert.strictEqual(truncate(string), 'hi-diddly-ho there, neighbo...'); - }); - - it('should not truncate if `string` is <= `length`', function() { - assert.strictEqual(truncate(string, { 'length': string.length }), string); - assert.strictEqual(truncate(string, { 'length': string.length + 2 }), string); - }); - - it('should truncate string the given length', function() { - assert.strictEqual(truncate(string, { 'length': 24 }), 'hi-diddly-ho there, n...'); - }); - - it('should support a `omission` option', function() { - assert.strictEqual(truncate(string, { 'omission': ' [...]' }), 'hi-diddly-ho there, neig [...]'); - }); - - it('should coerce nullish `omission` values to strings', function() { - assert.strictEqual(truncate(string, { 'omission': null }), 'hi-diddly-ho there, neighbnull'); - assert.strictEqual(truncate(string, { 'omission': undefined }), 'hi-diddly-ho there, nundefined'); - }); - - it('should support a `length` option', function() { - assert.strictEqual(truncate(string, { 'length': 4 }), 'h...'); - }); - - it('should support a `separator` option', function() { - assert.strictEqual(truncate(string, { 'length': 24, 'separator': ' ' }), 'hi-diddly-ho there,...'); - assert.strictEqual(truncate(string, { 'length': 24, 'separator': /,? +/ }), 'hi-diddly-ho there...'); - assert.strictEqual(truncate(string, { 'length': 24, 'separator': /,? +/g }), 'hi-diddly-ho there...'); - }); - - it('should treat negative `length` as `0`', function() { - lodashStable.each([0, -2], function(length) { - assert.strictEqual(truncate(string, { 'length': length }), '...'); - }); - }); - - it('should coerce `length` to an integer', function() { - lodashStable.each(['', NaN, 4.6, '4'], function(length, index) { - var actual = index > 1 ? 'h...' : '...'; - assert.strictEqual(truncate(string, { 'length': { 'valueOf': lodashStable.constant(length) } }), actual); - }); - }); - - it('should coerce `string` to a string', function() { - assert.strictEqual(truncate(Object(string), { 'length': 4 }), 'h...'); - assert.strictEqual(truncate({ 'toString': lodashStable.constant(string) }, { 'length': 5 }), 'hi...'); - }); - - it('should work as an iteratee for methods like `_.map`', function() { - var actual = lodashStable.map([string, string, string], truncate), - truncated = 'hi-diddly-ho there, neighbo...'; - - assert.deepStrictEqual(actual, [truncated, truncated, truncated]); - }); -}); diff --git a/libs/nanofn/test/unary.js b/libs/nanofn/test/unary.js deleted file mode 100644 index 333c89091..000000000 --- a/libs/nanofn/test/unary.js +++ /dev/null @@ -1,27 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice } from './utils.js'; -import unary from '../unary.js'; - -describe('unary', function() { - function fn() { - return slice.call(arguments); - } - - it('should cap the number of arguments provided to `func`', function() { - var actual = lodashStable.map(['6', '8', '10'], unary(parseInt)); - assert.deepStrictEqual(actual, [6, 8, 10]); - }); - - it('should not force a minimum argument count', function() { - var capped = unary(fn); - assert.deepStrictEqual(capped(), []); - }); - - it('should use `this` binding of function', function() { - var capped = unary(function(a, b) { return this; }), - object = { 'capped': capped }; - - assert.strictEqual(object.capped(), object); - }); -}); diff --git a/libs/nanofn/test/uncommon-symbols.js b/libs/nanofn/test/uncommon-symbols.js deleted file mode 100644 index f108be793..000000000 --- a/libs/nanofn/test/uncommon-symbols.js +++ /dev/null @@ -1,170 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { emojiVar, comboMarks, fitzModifiers } from './utils.js'; -import repeat from '../repeat.js'; -import camelCase from '../camelCase.js'; -import capitalize from '../capitalize.js'; -import pad from '../pad.js'; -import padStart from '../padStart.js'; -import padEnd from '../padEnd.js'; -import size from '../size.js'; -import split from '../split.js'; -import toArray from '../toArray.js'; -import trim from '../trim.js'; -import trimStart from '../trimStart.js'; -import trimEnd from '../trimEnd.js'; -import truncate from '../truncate.js'; -import words from '../words.js'; - -describe('uncommon symbols', function() { - var flag = '\ud83c\uddfa\ud83c\uddf8', - heart = '\u2764' + emojiVar, - hearts = '\ud83d\udc95', - comboGlyph = '\ud83d\udc68\u200d' + heart + '\u200d\ud83d\udc8B\u200d\ud83d\udc68', - hashKeycap = '#' + emojiVar + '\u20e3', - leafs = '\ud83c\udf42', - mic = '\ud83c\udf99', - noMic = mic + '\u20e0', - raisedHand = '\u270B' + emojiVar, - rocket = '\ud83d\ude80', - thumbsUp = '\ud83d\udc4d'; - - it('should account for astral symbols', function() { - var allHearts = repeat(hearts, 10), - chars = hearts + comboGlyph, - string = 'A ' + leafs + ', ' + comboGlyph + ', and ' + rocket, - trimChars = comboGlyph + hearts, - trimString = trimChars + string + trimChars; - - assert.strictEqual(camelCase(hearts + ' the ' + leafs), hearts + 'The' + leafs); - assert.strictEqual(camelCase(string), 'a' + leafs + comboGlyph + 'And' + rocket); - assert.strictEqual(capitalize(rocket), rocket); - - assert.strictEqual(pad(string, 16), ' ' + string + ' '); - assert.strictEqual(padStart(string, 16), ' ' + string); - assert.strictEqual(padEnd(string, 16), string + ' '); - - assert.strictEqual(pad(string, 16, chars), hearts + string + chars); - assert.strictEqual(padStart(string, 16, chars), chars + hearts + string); - assert.strictEqual(padEnd(string, 16, chars), string + chars + hearts); - - assert.strictEqual(size(string), 13); - assert.deepStrictEqual(split(string, ' '), ['A', leafs + ',', comboGlyph + ',', 'and', rocket]); - assert.deepStrictEqual(split(string, ' ', 3), ['A', leafs + ',', comboGlyph + ',']); - assert.deepStrictEqual(split(string, undefined), [string]); - assert.deepStrictEqual(split(string, undefined, -1), [string]); - assert.deepStrictEqual(split(string, undefined, 0), []); - - var expected = ['A', ' ', leafs, ',', ' ', comboGlyph, ',', ' ', 'a', 'n', 'd', ' ', rocket]; - - assert.deepStrictEqual(split(string, ''), expected); - assert.deepStrictEqual(split(string, '', 6), expected.slice(0, 6)); - assert.deepStrictEqual(toArray(string), expected); - - assert.strictEqual(trim(trimString, chars), string); - assert.strictEqual(trimStart(trimString, chars), string + trimChars); - assert.strictEqual(trimEnd(trimString, chars), trimChars + string); - - assert.strictEqual(truncate(string, { 'length': 13 }), string); - assert.strictEqual(truncate(string, { 'length': 6 }), 'A ' + leafs + '...'); - - assert.deepStrictEqual(words(string), ['A', leafs, comboGlyph, 'and', rocket]); - assert.deepStrictEqual(toArray(hashKeycap), [hashKeycap]); - assert.deepStrictEqual(toArray(noMic), [noMic]); - - lodashStable.times(2, function(index) { - var separator = index ? RegExp(hearts) : hearts, - options = { 'length': 4, 'separator': separator }, - actual = truncate(string, options); - - assert.strictEqual(actual, 'A...'); - assert.strictEqual(actual.length, 4); - - actual = truncate(allHearts, options); - assert.strictEqual(actual, hearts + '...'); - assert.strictEqual(actual.length, 5); - }); - }); - - it('should account for combining diacritical marks', function() { - var values = lodashStable.map(comboMarks, function(mark) { - return 'o' + mark; - }); - - var expected = lodashStable.map(values, function(value) { - return [1, [value], [value]]; - }); - - var actual = lodashStable.map(values, function(value) { - return [size(value), toArray(value), words(value)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should account for fitzpatrick modifiers', function() { - var values = lodashStable.map(fitzModifiers, function(modifier) { - return thumbsUp + modifier; - }); - - var expected = lodashStable.map(values, function(value) { - return [1, [value], [value]]; - }); - - var actual = lodashStable.map(values, function(value) { - return [size(value), toArray(value), words(value)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should account for regional symbols', function() { - var pair = flag.match(/\ud83c[\udde6-\uddff]/g), - regionals = pair.join(' '); - - assert.strictEqual(size(flag), 1); - assert.strictEqual(size(regionals), 3); - - assert.deepStrictEqual(toArray(flag), [flag]); - assert.deepStrictEqual(toArray(regionals), [pair[0], ' ', pair[1]]); - - assert.deepStrictEqual(words(flag), [flag]); - assert.deepStrictEqual(words(regionals), [pair[0], pair[1]]); - }); - - it('should account for variation selectors', function() { - assert.strictEqual(size(heart), 1); - assert.deepStrictEqual(toArray(heart), [heart]); - assert.deepStrictEqual(words(heart), [heart]); - }); - - it('should account for variation selectors with fitzpatrick modifiers', function() { - var values = lodashStable.map(fitzModifiers, function(modifier) { - return raisedHand + modifier; - }); - - var expected = lodashStable.map(values, function(value) { - return [1, [value], [value]]; - }); - - var actual = lodashStable.map(values, function(value) { - return [size(value), toArray(value), words(value)]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should match lone surrogates', function() { - var pair = hearts.split(''), - surrogates = pair[0] + ' ' + pair[1]; - - assert.strictEqual(size(surrogates), 3); - assert.deepStrictEqual(toArray(surrogates), [pair[0], ' ', pair[1]]); - assert.deepStrictEqual(words(surrogates), []); - }); - - it('should match side by side fitzpatrick modifiers separately ', function() { - var string = fitzModifiers[0] + fitzModifiers[0]; - assert.deepStrictEqual(toArray(string), [fitzModifiers[0], fitzModifiers[0]]); - }); -}); diff --git a/libs/nanofn/test/unescape.js b/libs/nanofn/test/unescape.js deleted file mode 100644 index 7bd56137f..000000000 --- a/libs/nanofn/test/unescape.js +++ /dev/null @@ -1,40 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import unescape from '../unescape.js'; -import escape from '../escape.js'; - -describe('unescape', function() { - var escaped = '&<>"'/', - unescaped = '&<>"\'/'; - - escaped += escaped; - unescaped += unescaped; - - it('should unescape entities in order', function() { - assert.strictEqual(unescape('&lt;'), '<'); - }); - - it('should unescape the proper entities', function() { - assert.strictEqual(unescape(escaped), unescaped); - }); - - it('should handle strings with nothing to unescape', function() { - assert.strictEqual(unescape('abc'), 'abc'); - }); - - it('should unescape the same characters escaped by `_.escape`', function() { - assert.strictEqual(unescape(escape(unescaped)), unescaped); - }); - - it('should handle leading zeros in html entities', function() { - assert.strictEqual(unescape('''), "'"); - assert.strictEqual(unescape('''), "'"); - assert.strictEqual(unescape('''), "'"); - }); - - lodashStable.each(['`', '/'], function(entity) { - it('should not unescape the "' + entity + '" entity', function() { - assert.strictEqual(unescape(entity), entity); - }); - }); -}); diff --git a/libs/nanofn/test/union-methods.js b/libs/nanofn/test/union-methods.js deleted file mode 100644 index fc872e278..000000000 --- a/libs/nanofn/test/union-methods.js +++ /dev/null @@ -1,31 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, args } from './utils.js'; - -describe('union methods', function() { - lodashStable.each(['union', 'unionBy', 'unionWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should return the union of two arrays', function() { - var actual = func([2], [1, 2]); - assert.deepStrictEqual(actual, [2, 1]); - }); - - it('`_.' + methodName + '` should return the union of multiple arrays', function() { - var actual = func([2], [1, 2], [2, 3]); - assert.deepStrictEqual(actual, [2, 1, 3]); - }); - - it('`_.' + methodName + '` should not flatten nested arrays', function() { - var actual = func([1, 3, 2], [1, [5]], [2, [4]]); - assert.deepStrictEqual(actual, [1, 3, 2, [5], [4]]); - }); - - it('`_.' + methodName + '` should ignore values that are not arrays or `arguments` objects', function() { - var array = [0]; - assert.deepStrictEqual(func(array, 3, { '0': 1 }, null), array); - assert.deepStrictEqual(func(null, array, null, [2, 1]), [0, 2, 1]); - assert.deepStrictEqual(func(array, null, args, null), [0, 1, 2, 3]); - }); - }); -}); diff --git a/libs/nanofn/test/unionBy.js b/libs/nanofn/test/unionBy.js deleted file mode 100644 index 9dd5f8e55..000000000 --- a/libs/nanofn/test/unionBy.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import unionBy from '../unionBy.js'; - -describe('unionBy', function() { - it('should accept an `iteratee`', function() { - var actual = unionBy([2.1], [1.2, 2.3], Math.floor); - assert.deepStrictEqual(actual, [2.1, 1.2]); - - actual = unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - assert.deepStrictEqual(actual, [{ 'x': 1 }, { 'x': 2 }]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - unionBy([2.1], [1.2, 2.3], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [2.1]); - }); - - it('should output values from the first possible array', function() { - var actual = unionBy([{ 'x': 1, 'y': 1 }], [{ 'x': 1, 'y': 2 }], 'x'); - assert.deepStrictEqual(actual, [{ 'x': 1, 'y': 1 }]); - }); -}); diff --git a/libs/nanofn/test/unionWith.test.js b/libs/nanofn/test/unionWith.test.js deleted file mode 100644 index e5f4d9664..000000000 --- a/libs/nanofn/test/unionWith.test.js +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import unionWith from '../unionWith.js'; - -describe('unionWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], - others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }], - actual = unionWith(objects, others, lodashStable.isEqual); - - assert.deepStrictEqual(actual, [objects[0], objects[1], others[0]]); - }); - - it('should output values from the first possible array', function() { - var objects = [{ 'x': 1, 'y': 1 }], - others = [{ 'x': 1, 'y': 2 }]; - - var actual = unionWith(objects, others, function(a, b) { - return a.x == b.x; - }); - - assert.deepStrictEqual(actual, [{ 'x': 1, 'y': 1 }]); - }); -}); diff --git a/libs/nanofn/test/uniq-methods.js b/libs/nanofn/test/uniq-methods.js deleted file mode 100644 index 6949a311f..000000000 --- a/libs/nanofn/test/uniq-methods.js +++ /dev/null @@ -1,123 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import sortBy from '../sortBy.js'; - -describe('uniq methods', function() { - lodashStable.each(['uniq', 'uniqBy', 'uniqWith', 'sortedUniq', 'sortedUniqBy'], function(methodName) { - var func = _[methodName], - isSorted = /^sorted/.test(methodName), - objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }, { 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; - - if (isSorted) { - objects = sortBy(objects, 'a'); - } - else { - it('`_.' + methodName + '` should return unique values of an unsorted array', function() { - var array = [2, 1, 2]; - assert.deepStrictEqual(func(array), [2, 1]); - }); - } - it('`_.' + methodName + '` should return unique values of a sorted array', function() { - var array = [1, 2, 2]; - assert.deepStrictEqual(func(array), [1, 2]); - }); - - it('`_.' + methodName + '` should treat object instances as unique', function() { - assert.deepStrictEqual(func(objects), objects); - }); - - it('`_.' + methodName + '` should treat `-0` as `0`', function() { - var actual = lodashStable.map(func([-0, 0]), lodashStable.toString); - assert.deepStrictEqual(actual, ['0']); - }); - - it('`_.' + methodName + '` should match `NaN`', function() { - assert.deepStrictEqual(func([NaN, NaN]), [NaN]); - }); - - it('`_.' + methodName + '` should work with large arrays', function() { - var largeArray = [], - expected = [0, {}, 'a'], - count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); - - lodashStable.each(expected, function(value) { - lodashStable.times(count, function() { - largeArray.push(value); - }); - }); - - assert.deepStrictEqual(func(largeArray), expected); - }); - - it('`_.' + methodName + '` should work with large arrays of `-0` as `0`', function() { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return isEven(index) ? -0 : 0; - }); - - var actual = lodashStable.map(func(largeArray), lodashStable.toString); - assert.deepStrictEqual(actual, ['0']); - }); - - it('`_.' + methodName + '` should work with large arrays of boolean, `NaN`, and nullish values', function() { - var largeArray = [], - expected = [null, undefined, false, true, NaN], - count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); - - lodashStable.each(expected, function(value) { - lodashStable.times(count, function() { - largeArray.push(value); - }); - }); - - assert.deepStrictEqual(func(largeArray), expected); - }); - - it('`_.' + methodName + '` should work with large arrays of symbols', function() { - if (Symbol) { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, Symbol); - assert.deepStrictEqual(func(largeArray), largeArray); - } - }); - - it('`_.' + methodName + '` should work with large arrays of well-known symbols', function() { - // See http://www.ecma-international.org/ecma-262/6.0/#sec-well-known-symbols. - if (Symbol) { - var expected = [ - Symbol.hasInstance, Symbol.isConcatSpreadable, Symbol.iterator, - Symbol.match, Symbol.replace, Symbol.search, Symbol.species, - Symbol.split, Symbol.toPrimitive, Symbol.toStringTag, Symbol.unscopables - ]; - - var largeArray = [], - count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); - - expected = lodashStable.map(expected, function(symbol) { - return symbol || {}; - }); - - lodashStable.each(expected, function(value) { - lodashStable.times(count, function() { - largeArray.push(value); - }); - }); - - assert.deepStrictEqual(func(largeArray), expected); - } - }); - - it('`_.' + methodName + '` should distinguish between numbers and numeric strings', function() { - var largeArray = [], - expected = ['2', 2, Object('2'), Object(2)], - count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); - - lodashStable.each(expected, function(value) { - lodashStable.times(count, function() { - largeArray.push(value); - }); - }); - - assert.deepStrictEqual(func(largeArray), expected); - }); - }); -}); diff --git a/libs/nanofn/test/uniq.js b/libs/nanofn/test/uniq.js deleted file mode 100644 index 5eaf74c41..000000000 --- a/libs/nanofn/test/uniq.js +++ /dev/null @@ -1,11 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; - -describe('uniq', function() { - it('should perform an unsorted uniq when used as an iteratee for methods like `_.map`', function() { - var array = [[2, 1, 2], [1, 2, 1]], - actual = lodashStable.map(array, lodashStable.uniq); - - assert.deepStrictEqual(actual, [[2, 1], [1, 2]]); - }); -}); diff --git a/libs/nanofn/test/uniqBy-methods.js b/libs/nanofn/test/uniqBy-methods.js deleted file mode 100644 index 046ae644d..000000000 --- a/libs/nanofn/test/uniqBy-methods.js +++ /dev/null @@ -1,74 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, LARGE_ARRAY_SIZE, slice } from './utils.js'; -import sortBy from '../sortBy.js'; - -describe('uniqBy methods', function() { - lodashStable.each(['uniqBy', 'sortedUniqBy'], function(methodName) { - var func = _[methodName], - isSorted = methodName == 'sortedUniqBy', - objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }, { 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; - - if (isSorted) { - objects = sortBy(objects, 'a'); - } - it('`_.' + methodName + '` should work with an `iteratee`', function() { - var expected = isSorted ? [{ 'a': 1 }, { 'a': 2 }, { 'a': 3 }] : objects.slice(0, 3); - - var actual = func(objects, function(object) { - return object.a; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should work with large arrays', function() { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, function() { - return [1, 2]; - }); - - var actual = func(largeArray, String); - assert.strictEqual(actual[0], largeArray[0]); - assert.deepStrictEqual(actual, [[1, 2]]); - }); - - it('`_.' + methodName + '` should provide correct `iteratee` arguments', function() { - var args; - - func(objects, function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [objects[0]]); - }); - - it('`_.' + methodName + '` should work with `_.property` shorthands', function() { - var expected = isSorted ? [{ 'a': 1 }, { 'a': 2 }, { 'a': 3 }] : objects.slice(0, 3), - actual = func(objects, 'a'); - - assert.deepStrictEqual(actual, expected); - - var arrays = [[2], [3], [1], [2], [3], [1]]; - if (isSorted) { - arrays = lodashStable.sortBy(arrays, 0); - } - expected = isSorted ? [[1], [2], [3]] : arrays.slice(0, 3); - actual = func(arrays, 0); - - assert.deepStrictEqual(actual, expected); - }); - - lodashStable.each({ - 'an array': [0, 'a'], - 'an object': { '0': 'a' }, - 'a number': 0, - 'a string': '0' - }, - function(iteratee, key) { - it('`_.' + methodName + '` should work with ' + key + ' for `iteratee`', function() { - var actual = func([['a'], ['a'], ['b']], iteratee); - assert.deepStrictEqual(actual, [['a'], ['b']]); - }); - }); - }); -}); diff --git a/libs/nanofn/test/uniqWith.test.js b/libs/nanofn/test/uniqWith.test.js deleted file mode 100644 index bb9e79873..000000000 --- a/libs/nanofn/test/uniqWith.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { LARGE_ARRAY_SIZE, isEven } from './utils.js'; -import uniqWith from '../uniqWith.js'; - -describe('uniqWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }], - actual = uniqWith(objects, lodashStable.isEqual); - - assert.deepStrictEqual(actual, [objects[0], objects[1]]); - }); - - it('should preserve the sign of `0`', function() { - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, function(index) { - return isEven(index) ? -0 : 0; - }); - - var arrays = [[-0, 0], largeArray], - expected = lodashStable.map(arrays, lodashStable.constant(['-0'])); - - var actual = lodashStable.map(arrays, function(array) { - return lodashStable.map(uniqWith(array, lodashStable.eq), lodashStable.toString); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/uniqueId.test.js b/libs/nanofn/test/uniqueId.test.js deleted file mode 100644 index 4b0485b82..000000000 --- a/libs/nanofn/test/uniqueId.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import uniqueId from '../uniqueId.js'; - -describe('uniqueId', function() { - it('should generate unique ids', function() { - var actual = lodashStable.times(1000, function() { - return uniqueId(); - }); - - assert.strictEqual(lodashStable.uniq(actual).length, actual.length); - }); - - it('should return a string value when not providing a `prefix`', function() { - assert.strictEqual(typeof uniqueId(), 'string'); - }); - - it('should coerce the prefix argument to a string', function() { - var actual = [uniqueId(3), uniqueId(2), uniqueId(1)]; - assert.ok(/3\d+,2\d+,1\d+/.test(actual)); - }); -}); diff --git a/libs/nanofn/test/unset.js b/libs/nanofn/test/unset.js deleted file mode 100644 index 0aa2f5bd7..000000000 --- a/libs/nanofn/test/unset.js +++ /dev/null @@ -1,119 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { symbol, numberProto, stringProto, defineProperty } from './utils.js'; -import unset from '../unset.js'; - -describe('unset', function() { - it('should unset property values', function() { - lodashStable.each(['a', ['a']], function(path) { - var object = { 'a': 1, 'c': 2 }; - assert.strictEqual(unset(object, path), true); - assert.deepStrictEqual(object, { 'c': 2 }); - }); - }); - - it('should preserve the sign of `0`', function() { - var props = [-0, Object(-0), 0, Object(0)], - expected = lodashStable.map(props, lodashStable.constant([true, false])); - - var actual = lodashStable.map(props, function(key) { - var object = { '-0': 'a', '0': 'b' }; - return [unset(object, key), lodashStable.toString(key) in object]; - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should unset symbol keyed property values', function() { - if (Symbol) { - var object = {}; - object[symbol] = 1; - - assert.strictEqual(unset(object, symbol), true); - assert.ok(!(symbol in object)); - } - }); - - it('should unset deep property values', function() { - lodashStable.each(['a.b', ['a', 'b']], function(path) { - var object = { 'a': { 'b': null } }; - assert.strictEqual(unset(object, path), true); - assert.deepStrictEqual(object, { 'a': {} }); - }); - }); - - it('should handle complex paths', function() { - var paths = [ - 'a[-1.23]["[\\"b\\"]"].c[\'[\\\'d\\\']\'][\ne\n][f].g', - ['a', '-1.23', '["b"]', 'c', "['d']", '\ne\n', 'f', 'g'] - ]; - - lodashStable.each(paths, function(path) { - var object = { 'a': { '-1.23': { '["b"]': { 'c': { "['d']": { '\ne\n': { 'f': { 'g': 8 } } } } } } } }; - assert.strictEqual(unset(object, path), true); - assert.ok(!('g' in object.a[-1.23]['["b"]'].c["['d']"]['\ne\n'].f)); - }); - }); - - it('should return `true` for nonexistent paths', function() { - var object = { 'a': { 'b': { 'c': null } } }; - - lodashStable.each(['z', 'a.z', 'a.b.z', 'a.b.c.z'], function(path) { - assert.strictEqual(unset(object, path), true); - }); - - assert.deepStrictEqual(object, { 'a': { 'b': { 'c': null } } }); - }); - - it('should not error when `object` is nullish', function() { - var values = [null, undefined], - expected = [[true, true], [true, true]]; - - var actual = lodashStable.map(values, function(value) { - try { - return [unset(value, 'a.b'), unset(value, ['a', 'b'])]; - } catch (e) { - return e.message; - } - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should follow `path` over non-plain objects', function() { - var object = { 'a': '' }, - paths = ['constructor.prototype.a', ['constructor', 'prototype', 'a']]; - - lodashStable.each(paths, function(path) { - numberProto.a = 1; - - var actual = unset(0, path); - assert.strictEqual(actual, true); - assert.ok(!('a' in numberProto)); - - delete numberProto.a; - }); - - lodashStable.each(['a.replace.b', ['a', 'replace', 'b']], function(path) { - stringProto.replace.b = 1; - - var actual = unset(object, path); - assert.strictEqual(actual, true); - assert.ok(!('a' in stringProto.replace)); - - delete stringProto.replace.b; - }); - }); - - it('should return `false` for non-configurable properties', function() { - var object = {}; - - defineProperty(object, 'a', { - 'configurable': false, - 'enumerable': true, - 'writable': true, - 'value': 1, - }); - assert.strictEqual(unset(object, 'a'), false); - }); -}); diff --git a/libs/nanofn/test/unzip-and-zip.js b/libs/nanofn/test/unzip-and-zip.js deleted file mode 100644 index 57cdfd6ef..000000000 --- a/libs/nanofn/test/unzip-and-zip.js +++ /dev/null @@ -1,72 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, falsey, stubArray } from './utils.js'; - -describe('unzip and zip', function() { - lodashStable.each(['unzip', 'zip'], function(methodName, index) { - var func = _[methodName]; - func = lodashStable.bind(index ? func.apply : func.call, func, null); - - var object = { - 'an empty array': [ - [], - [] - ], - '0-tuples': [ - [[], []], - [] - ], - '2-tuples': [ - [['barney', 'fred'], [36, 40]], - [['barney', 36], ['fred', 40]] - ], - '3-tuples': [ - [['barney', 'fred'], [36, 40], [false, true]], - [['barney', 36, false], ['fred', 40, true]] - ] - }; - - lodashStable.forOwn(object, function(pair, key) { - it('`_.' + methodName + '` should work with ' + key, function() { - var actual = func(pair[0]); - assert.deepStrictEqual(actual, pair[1]); - assert.deepStrictEqual(func(actual), actual.length ? pair[0] : []); - }); - }); - - it('`_.' + methodName + '` should work with tuples of different lengths', function() { - var pair = [ - [['barney', 36], ['fred', 40, false]], - [['barney', 'fred'], [36, 40], [undefined, false]] - ]; - - var actual = func(pair[0]); - assert.ok('0' in actual[2]); - assert.deepStrictEqual(actual, pair[1]); - - actual = func(actual); - assert.ok('2' in actual[0]); - assert.deepStrictEqual(actual, [['barney', 36, undefined], ['fred', 40, false]]); - }); - - it('`_.' + methodName + '` should treat falsey values as empty arrays', function() { - var expected = lodashStable.map(falsey, stubArray); - - var actual = lodashStable.map(falsey, function(value) { - return func([value, value, value]); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should ignore values that are not arrays or `arguments` objects', function() { - var array = [[1, 2], [3, 4], null, undefined, { '0': 1 }]; - assert.deepStrictEqual(func(array), [[1, 3], [2, 4]]); - }); - - it('`_.' + methodName + '` should support consuming its return value', function() { - var expected = [['barney', 'fred'], [36, 40]]; - assert.deepStrictEqual(func(func(func(func(expected)))), expected); - }); - }); -}); diff --git a/libs/nanofn/test/unzipWith.js b/libs/nanofn/test/unzipWith.js deleted file mode 100644 index d02d1a76a..000000000 --- a/libs/nanofn/test/unzipWith.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice } from './utils.js'; -import unzipWith from '../unzipWith.js'; -import unzip from '../unzip.js'; - -describe('unzipWith', function() { - it('should unzip arrays combining regrouped elements with `iteratee`', function() { - var array = [[1, 4], [2, 5], [3, 6]]; - - var actual = unzipWith(array, function(a, b, c) { - return a + b + c; - }); - - assert.deepStrictEqual(actual, [6, 15]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - unzipWith([[1, 3, 5], [2, 4, 6]], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [1, 2]); - }); - - it('should perform a basic unzip when `iteratee` is nullish', function() { - var array = [[1, 3], [2, 4]], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(unzip(array))); - - var actual = lodashStable.map(values, function(value, index) { - return index ? unzipWith(array, value) : unzipWith(array); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/test/update-methods.js b/libs/nanofn/test/update-methods.js deleted file mode 100644 index 159f4008a..000000000 --- a/libs/nanofn/test/update-methods.js +++ /dev/null @@ -1,25 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _ } from './utils.js'; - -describe('update methods', function() { - lodashStable.each(['update', 'updateWith'], function(methodName) { - var func = _[methodName], - oldValue = 1; - - it('`_.' + methodName + '` should invoke `updater` with the value on `path` of `object`', function() { - var object = { 'a': [{ 'b': { 'c': oldValue } }] }, - expected = oldValue + 1; - - lodashStable.each(['a[0].b.c', ['a', '0', 'b', 'c']], function(path) { - func(object, path, function(n) { - assert.strictEqual(n, oldValue); - return ++n; - }); - - assert.strictEqual(object.a[0].b.c, expected); - object.a[0].b.c = oldValue; - }); - }); - }); -}); diff --git a/libs/nanofn/test/updateWith.js b/libs/nanofn/test/updateWith.js deleted file mode 100644 index 7c709f91d..000000000 --- a/libs/nanofn/test/updateWith.js +++ /dev/null @@ -1,19 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { stubThree, stubFour, noop } from './utils.js'; -import updateWith from '../updateWith.js'; - -describe('updateWith', function() { - it('should work with a `customizer` callback', function() { - var actual = updateWith({ '0': {} }, '[0][1][2]', stubThree, function(value) { - return lodashStable.isObject(value) ? undefined : {}; - }); - - assert.deepStrictEqual(actual, { '0': { '1': { '2': 3 } } }); - }); - - it('should work with a `customizer` that returns `undefined`', function() { - var actual = updateWith({}, 'a[0].b.c', stubFour, noop); - assert.deepStrictEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); - }); -}); diff --git a/libs/nanofn/test/upperCase.test.js b/libs/nanofn/test/upperCase.test.js deleted file mode 100644 index 08c362a0a..000000000 --- a/libs/nanofn/test/upperCase.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import upperCase from '../upperCase.js'; - -describe('upperCase', function() { - it('should uppercase as space-separated words', function() { - assert.strictEqual(upperCase('--foo-bar--'), 'FOO BAR'); - assert.strictEqual(upperCase('fooBar'), 'FOO BAR'); - assert.strictEqual(upperCase('__foo_bar__'), 'FOO BAR'); - }); -}); diff --git a/libs/nanofn/test/upperFirst.test.js b/libs/nanofn/test/upperFirst.test.js deleted file mode 100644 index b3833310a..000000000 --- a/libs/nanofn/test/upperFirst.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import assert from 'assert'; -import upperFirst from '../upperFirst.js'; - -describe('upperFirst', function() { - it('should uppercase only the first character', function() { - assert.strictEqual(upperFirst('fred'), 'Fred'); - assert.strictEqual(upperFirst('Fred'), 'Fred'); - assert.strictEqual(upperFirst('FRED'), 'FRED'); - }); -}); diff --git a/libs/nanofn/test/utils.js b/libs/nanofn/test/utils.js deleted file mode 100644 index 19d327a03..000000000 --- a/libs/nanofn/test/utils.js +++ /dev/null @@ -1,799 +0,0 @@ -/** Used to detect when a function becomes hot. */ -var HOT_COUNT = 150; - -/** Used as the size to cover large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** Used as the maximum memoize cache size. */ -var MAX_MEMOIZE_SIZE = 500; - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991, - MAX_INTEGER = 1.7976931348623157e+308; - -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH = 4294967295, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - -/** `Object#toString` result references. */ -var funcTag = '[object Function]', - numberTag = '[object Number]', - objectTag = '[object Object]'; - -/** Used as a reference to the global object. */ -var root = (typeof global === 'object' && global) || this; - -/** Used to store lodash to test for bad extensions/shims. */ -var lodashBizarro = root.lodashBizarro; - -/** Used for native method references. */ -var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype, - numberProto = Number.prototype, - stringProto = String.prototype; - -/** Method and object shortcuts. */ -var phantom = root.phantom, - process = root.process, - amd = root.define ? define.amd : undefined, - args = toArgs([1, 2, 3]), - argv = process ? process.argv : undefined, - defineProperty = Object.defineProperty, - document = phantom ? undefined : root.document, - body = root.document ? root.document.body : undefined, - create = Object.create, - fnToString = funcProto.toString, - freeze = Object.freeze, - getSymbols = Object.getOwnPropertySymbols, - identity = function(value) { return value; }, - noop = function() {}, - objToString = objectProto.toString, - params = argv, - push = arrayProto.push, - realm = {}, - slice = arrayProto.slice, - strictArgs = (function() { 'use strict'; return arguments; }(1, 2, 3)); - -var ArrayBuffer = root.ArrayBuffer, - Buffer = root.Buffer, - Map = root.Map, - Promise = root.Promise, - Proxy = root.Proxy, - Set = root.Set, - Symbol = root.Symbol, - Uint8Array = root.Uint8Array, - WeakMap = root.WeakMap, - WeakSet = root.WeakSet; - -var arrayBuffer = ArrayBuffer ? new ArrayBuffer(2) : undefined, - map = Map ? new Map : undefined, - promise = Promise ? Promise.resolve(1) : undefined, - set = Set ? new Set : undefined, - symbol = Symbol ? Symbol('a') : undefined, - weakMap = WeakMap ? new WeakMap : undefined, - weakSet = WeakSet ? new WeakSet : undefined; - -/** Math helpers. */ -var add = function(x, y) { return x + y; }, - doubled = function(n) { return n * 2; }, - isEven = function(n) { return n % 2 == 0; }, - square = function(n) { return n * n; }; - -/** Stub functions. */ -var stubA = function() { return 'a'; }, - stubB = function() { return 'b'; }, - stubC = function() { return 'c'; }; - -var stubTrue = function() { return true; }, - stubFalse = function() { return false; }; - -var stubNaN = function() { return NaN; }, - stubNull = function() { return null; }; - -var stubZero = function() { return 0; }, - stubOne = function() { return 1; }, - stubTwo = function() { return 2; }, - stubThree = function() { return 3; }, - stubFour = function() { return 4; }; - -var stubArray = function() { return []; }, - stubObject = function() { return {}; }, - stubString = function() { return ''; }; - -/** List of Latin Unicode letters. */ -var burredLetters = [ - // Latin-1 Supplement letters. - '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf', - '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf', - '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef', - '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff', - // Latin Extended-A letters. - '\u0100', '\u0101', '\u0102', '\u0103', '\u0104', '\u0105', '\u0106', '\u0107', '\u0108', '\u0109', '\u010a', '\u010b', '\u010c', '\u010d', '\u010e', '\u010f', - '\u0110', '\u0111', '\u0112', '\u0113', '\u0114', '\u0115', '\u0116', '\u0117', '\u0118', '\u0119', '\u011a', '\u011b', '\u011c', '\u011d', '\u011e', '\u011f', - '\u0120', '\u0121', '\u0122', '\u0123', '\u0124', '\u0125', '\u0126', '\u0127', '\u0128', '\u0129', '\u012a', '\u012b', '\u012c', '\u012d', '\u012e', '\u012f', - '\u0130', '\u0131', '\u0132', '\u0133', '\u0134', '\u0135', '\u0136', '\u0137', '\u0138', '\u0139', '\u013a', '\u013b', '\u013c', '\u013d', '\u013e', '\u013f', - '\u0140', '\u0141', '\u0142', '\u0143', '\u0144', '\u0145', '\u0146', '\u0147', '\u0148', '\u0149', '\u014a', '\u014b', '\u014c', '\u014d', '\u014e', '\u014f', - '\u0150', '\u0151', '\u0152', '\u0153', '\u0154', '\u0155', '\u0156', '\u0157', '\u0158', '\u0159', '\u015a', '\u015b', '\u015c', '\u015d', '\u015e', '\u015f', - '\u0160', '\u0161', '\u0162', '\u0163', '\u0164', '\u0165', '\u0166', '\u0167', '\u0168', '\u0169', '\u016a', '\u016b', '\u016c', '\u016d', '\u016e', '\u016f', - '\u0170', '\u0171', '\u0172', '\u0173', '\u0174', '\u0175', '\u0176', '\u0177', '\u0178', '\u0179', '\u017a', '\u017b', '\u017c', '\u017d', '\u017e', '\u017f' -]; - -/** List of combining diacritical marks. */ -var comboMarks = [ - '\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307', '\u0308', '\u0309', '\u030a', '\u030b', '\u030c', '\u030d', '\u030e', '\u030f', - '\u0310', '\u0311', '\u0312', '\u0313', '\u0314', '\u0315', '\u0316', '\u0317', '\u0318', '\u0319', '\u031a', '\u031b', '\u031c', '\u031d', '\u031e', '\u031f', - '\u0320', '\u0321', '\u0322', '\u0323', '\u0324', '\u0325', '\u0326', '\u0327', '\u0328', '\u0329', '\u032a', '\u032b', '\u032c', '\u032d', '\u032e', '\u032f', - '\u0330', '\u0331', '\u0332', '\u0333', '\u0334', '\u0335', '\u0336', '\u0337', '\u0338', '\u0339', '\u033a', '\u033b', '\u033c', '\u033d', '\u033e', '\u033f', - '\u0340', '\u0341', '\u0342', '\u0343', '\u0344', '\u0345', '\u0346', '\u0347', '\u0348', '\u0349', '\u034a', '\u034b', '\u034c', '\u034d', '\u034e', '\u034f', - '\u0350', '\u0351', '\u0352', '\u0353', '\u0354', '\u0355', '\u0356', '\u0357', '\u0358', '\u0359', '\u035a', '\u035b', '\u035c', '\u035d', '\u035e', '\u035f', - '\u0360', '\u0361', '\u0362', '\u0363', '\u0364', '\u0365', '\u0366', '\u0367', '\u0368', '\u0369', '\u036a', '\u036b', '\u036c', '\u036d', '\u036e', '\u036f', - '\ufe20', '\ufe21', '\ufe22', '\ufe23' -]; - -/** List of converted Latin Unicode letters. */ -var deburredLetters = [ - // Converted Latin-1 Supplement letters. - 'A', 'A', 'A', 'A', 'A', 'A', 'Ae', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', - 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', - 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', - 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y', - // Converted Latin Extended-A letters. - 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', - 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', - 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', - 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', - 'K', 'k', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', - 'N', 'n', 'N', 'n', 'N', 'n', "'n", 'N', 'n', - 'O', 'o', 'O', 'o', 'O', 'o', 'Oe', 'oe', - 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', - 'T', 't', 'T', 't', 'T', 't', - 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', - 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's' -]; - -/** Used to provide falsey values to methods. */ -var falsey = [, null, undefined, false, 0, NaN, '']; - -/** Used to specify the emoji style glyph variant of characters. */ -var emojiVar = '\ufe0f'; - -/** Used to provide empty values to methods. */ -var empties = [[], {}].concat(falsey.slice(1)); - -/** Used to test error objects. */ -var errors = [ - new Error, - new EvalError, - new RangeError, - new ReferenceError, - new SyntaxError, - new TypeError, - new URIError -]; - -/** List of fitzpatrick modifiers. */ -var fitzModifiers = [ - '\ud83c\udffb', - '\ud83c\udffc', - '\ud83c\udffd', - '\ud83c\udffe', - '\ud83c\udfff' -]; - -/** Used to provide primitive values to methods. */ -var primitives = [null, undefined, false, true, 1, NaN, 'a']; - -/** Used to check whether methods support typed arrays. */ -var typedArrays = [ - 'Float32Array', - 'Float64Array', - 'Int8Array', - 'Int16Array', - 'Int32Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Uint16Array', - 'Uint32Array' -]; - -/** Used to check whether methods support array views. */ -var arrayViews = typedArrays.concat('DataView'); - -/** The file path of the lodash file to test. */ -var filePath = (function() { - var min = 2, - result = params || []; - - if (phantom) { - min = 0; - result = params = phantom.args || require('system').args; - } - var last = result[result.length - 1]; - result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../node_modules/lodash/lodash.js'; - - if (!amd) { - try { - result = require('fs').realpathSync(result); - } catch (e) {} - - try { - result = require.resolve(result); - } catch (e) {} - } - return result; -}()); - -/** The `ui` object. */ -var ui = root.ui || (root.ui = { - 'buildPath': filePath, - 'loaderPath': '', - 'isModularize': /\b(?:amd|commonjs|es|node|npm|(index|main)\.js)\b/.test(filePath), - 'isStrict': /\bes\b/.test(filePath) || 'default' in require(filePath), - 'urlParams': {} -}); - -/** The basename of the lodash file to test. */ -var basename = /[\w.-]+$/.exec(filePath)[0]; - -/** Used to indicate testing a modularized build. */ -var isModularize = ui.isModularize; - -/** Detect if testing `npm` modules. */ -var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); - -/** Detect if running in PhantomJS. */ -var isPhantom = phantom || (typeof callPhantom === 'function'); - -/** Detect if lodash is in strict mode. */ -var isStrict = ui.isStrict; - -/*--------------------------------------------------------------------------*/ - -// Leak to avoid sporadic `noglobals` fails on Edge in Sauce Labs. -root.msWDfn = undefined; - -// Assign `setTimeout` to itself to avoid being flagged as a leak. -setProperty(root, 'setTimeout', setTimeout); - -/*--------------------------------------------------------------------------*/ - -/** Used to test Web Workers. */ -var Worker = !(ui.isForeign || ui.isSauceLabs || isModularize) && - (document && document.origin != 'null') && root.Worker; - -/** Poison the free variable `root` in Node.js */ -try { - defineProperty(global.root, 'root', { - 'configurable': false, - 'enumerable': false, - 'get': function() { throw new ReferenceError; } - }); -} catch (e) {} - -/** Load stable Lodash. */ -var lodashStable = root.lodashStable; -if (!lodashStable) { - try { - lodashStable = interopRequire('../node_modules/lodash/lodash.js'); - } catch (e) { - console.log('Error: The stable lodash dev dependency should be at least a version behind master branch.'); - } - lodashStable = lodashStable.noConflict(); -} - -/** The `lodash` function to test. */ -var _ = root._ || (root._ = interopRequire(filePath)); - -/** Used to test pseudo private map caches. */ -var mapCaches = (function() { - var MapCache = _.memoize.Cache; - var result = { - 'Hash': new MapCache().__data__.hash.constructor, - 'MapCache': MapCache - }; - _.isMatchWith({ 'a': 1 }, { 'a': 1 }, function() { - var stack = lodashStable.last(arguments); - result.ListCache = stack.__data__.constructor; - result.Stack = stack.constructor; - }); - return result; -}()); - -/** Used to detect instrumented istanbul code coverage runs. */ -var coverage = root.__coverage__ || root[lodashStable.find(lodashStable.keys(root), function(key) { - return /^(?:\$\$cov_\d+\$\$)$/.test(key); -})]; - -/** Used to test async functions. */ -var asyncFunc = lodashStable.attempt(function() { - return Function('return async () => {}'); -}); - -/** Used to test generator functions. */ -var genFunc = lodashStable.attempt(function() { - return Function('return function*(){}'); -}); - -/** Used to restore the `_` reference. */ -var oldDash = root._; - -/** - * Used to check for problems removing whitespace. For a whitespace reference, - * see [V8's unit test](https://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/whitespaces.js). - */ -var whitespace = lodashStable.filter([ - // Basic whitespace characters. - ' ', '\t', '\x0b', '\f', '\xa0', '\ufeff', - - // Line terminators. - '\n', '\r', '\u2028', '\u2029', - - // Unicode category "Zs" space separators. - '\u1680', '\u180e', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', - '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u202f', '\u205f', '\u3000' -], -function(chr) { return /\s/.exec(chr); }) -.join(''); - -/** - * Creates a custom error object. - * - * @private - * @constructor - * @param {string} message The error message. - */ -function CustomError(message) { - this.name = 'CustomError'; - this.message = message; -} - -CustomError.prototype = lodashStable.create(Error.prototype, { - 'constructor': CustomError -}); - -/** - * Removes all own enumerable string keyed properties from a given object. - * - * @private - * @param {Object} object The object to empty. - */ -function emptyObject(object) { - lodashStable.forOwn(object, function(value, key, object) { - delete object[key]; - }); -} - -/** - * Extracts the unwrapped value from its wrapper. - * - * @private - * @param {Object} wrapper The wrapper to unwrap. - * @returns {*} Returns the unwrapped value. - */ -function getUnwrappedValue(wrapper) { - var index = -1, - actions = wrapper.__actions__, - length = actions.length, - result = wrapper.__wrapped__; - - while (++index < length) { - var args = [result], - action = actions[index]; - - push.apply(args, action.args); - result = action.func.apply(action.thisArg, args); - } - return result; -} - -/** - * Loads the module of `id`. If the module has an `exports.default`, the - * exported default value is returned as the resolved module. - * - * @private - * @param {string} id The identifier of the module to resolve. - * @returns {*} Returns the resolved module. - */ -function interopRequire(id) { - var result = require(id); - return 'default' in result ? result['default'] : result; -} - -/** - * Sets a non-enumerable property value on `object`. - * - * Note: This function is used to avoid a bug in older versions of V8 where - * overwriting non-enumerable built-ins makes them enumerable. - * See https://code.google.com/p/v8/issues/detail?id=1623 - * - * @private - * @param {Object} object The object modify. - * @param {string} key The name of the property to set. - * @param {*} value The property value. - */ -function setProperty(object, key, value) { - try { - defineProperty(object, key, { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': value - }); - } catch (e) { - object[key] = value; - } - return object; -} - -/** - * Skips a given number of tests with a passing result. - * - * @private - * @param {Object} assert The QUnit assert object. - * @param {number} [count=1] The number of tests to skip. - */ -function skipAssert(assert, count) { - count || (count = 1); - while (count--) { - assert.ok(true, 'test skipped'); - } -} - -/** - * Converts `array` to an `arguments` object. - * - * @private - * @param {Array} array The array to convert. - * @returns {Object} Returns the converted `arguments` object. - */ -function toArgs(array) { - return (function() { return arguments; }.apply(undefined, array)); -} - -/*--------------------------------------------------------------------------*/ - -// Add bizarro values. -(function() { - return; // fixme - if (document || (typeof require !== 'function')) { - return; - } - var nativeString = fnToString.call(toString), - reToString = /toString/g; - - function createToString(funcName) { - return lodashStable.constant(nativeString.replace(reToString, funcName)); - } - - // Allow bypassing native checks. - setProperty(funcProto, 'toString', function wrapper() { - setProperty(funcProto, 'toString', fnToString); - var result = lodashStable.has(this, 'toString') ? this.toString() : fnToString.call(this); - setProperty(funcProto, 'toString', wrapper); - return result; - }); - - // Add prototype extensions. - funcProto._method = noop; - - // Set bad shims. - setProperty(Object, 'create', undefined); - setProperty(Object, 'getOwnPropertySymbols', undefined); - - var _propertyIsEnumerable = objectProto.propertyIsEnumerable; - setProperty(objectProto, 'propertyIsEnumerable', function(key) { - return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key); - }); - - if (Buffer) { - defineProperty(root, 'Buffer', { - 'configurable': true, - 'enumerable': true, - 'get': function get() { - var caller = get.caller, - name = caller ? caller.name : ''; - - if (!(name == 'runInContext' || name.length == 1 || /\b_\.isBuffer\b/.test(caller))) { - return Buffer; - } - } - }); - } - if (Map) { - setProperty(root, 'Map', (function() { - var count = 0; - return function() { - if (count++) { - return new Map; - } - setProperty(root, 'Map', Map); - return {}; - }; - }())); - - setProperty(root.Map, 'toString', createToString('Map')); - } - setProperty(root, 'Promise', noop); - setProperty(root, 'Set', noop); - setProperty(root, 'Symbol', undefined); - setProperty(root, 'WeakMap', noop); - - // Fake `WinRTError`. - setProperty(root, 'WinRTError', Error); - - // Clear cache so lodash can be reloaded. - emptyObject(require.cache); - - // Load lodash and expose it to the bad extensions/shims. - lodashBizarro = interopRequire(filePath); - root._ = oldDash; - - // Restore built-in methods. - setProperty(Object, 'create', create); - setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable); - setProperty(root, 'Buffer', Buffer); - - if (getSymbols) { - Object.getOwnPropertySymbols = getSymbols; - } else { - delete Object.getOwnPropertySymbols; - } - if (Map) { - setProperty(root, 'Map', Map); - } else { - delete root.Map; - } - if (Promise) { - setProperty(root, 'Promise', Promise); - } else { - delete root.Promise; - } - if (Set) { - setProperty(root, 'Set', Set); - } else { - delete root.Set; - } - if (Symbol) { - setProperty(root, 'Symbol', Symbol); - } else { - delete root.Symbol; - } - if (WeakMap) { - setProperty(root, 'WeakMap', WeakMap); - } else { - delete root.WeakMap; - } - delete root.WinRTError; - delete funcProto._method; -}()); - -// Add other realm values from the `vm` module. -lodashStable.attempt(function() { - lodashStable.assign(realm, require('vm').runInNewContext([ - '(function() {', - ' var noop = function() {},', - ' root = this;', - '', - ' var object = {', - " 'ArrayBuffer': root.ArrayBuffer,", - " 'arguments': (function() { return arguments; }(1, 2, 3)),", - " 'array': [1],", - " 'arrayBuffer': root.ArrayBuffer ? new root.ArrayBuffer : undefined,", - " 'boolean': Object(false),", - " 'date': new Date,", - " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", - " 'function': noop,", - " 'map': root.Map ? new root.Map : undefined,", - " 'nan': NaN,", - " 'null': null,", - " 'number': Object(0),", - " 'object': { 'a': 1 },", - " 'promise': root.Promise ? Promise.resolve(1) : undefined,", - " 'regexp': /x/,", - " 'set': root.Set ? new root.Set : undefined,", - " 'string': Object('a'),", - " 'symbol': root.Symbol ? root.Symbol() : undefined,", - " 'undefined': undefined,", - " 'weakMap': root.WeakMap ? new root.WeakMap : undefined,", - " 'weakSet': root.WeakSet ? new root.WeakSet : undefined", - ' };', - '', - " ['" + arrayViews.join("', '") + "'].forEach(function(type) {", - ' var Ctor = root[type]', - ' object[type] = Ctor;', - ' object[type.toLowerCase()] = Ctor ? new Ctor(new ArrayBuffer(24)) : undefined;', - ' });', - '', - ' return object;', - '}());' - ].join('\n'))); -}); - -// Add other realm values from an iframe. -lodashStable.attempt(function() { - _._realm = realm; - - var iframe = document.createElement('iframe'); - iframe.frameBorder = iframe.height = iframe.width = 0; - body.appendChild(iframe); - - var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; - idoc.write([ - '', - '', - '', - '', - '' - ].join('\n')); - - idoc.close(); - delete _._realm; -}); - -// Add a web worker. -lodashStable.attempt(function() { - var worker = new Worker('./asset/worker.js?t=' + (+new Date)); - worker.addEventListener('message', function(e) { - _._VERSION = e.data || ''; - }, false); - - worker.postMessage(ui.buildPath); -}); - -// Expose internal modules for better code coverage. -lodashStable.attempt(function() { - var path = require('path'), - basePath = path.dirname(filePath); - - if (isModularize && !(amd || isNpm)) { - lodashStable.each([ - 'baseEach', - 'isIndex', - 'isIterateeCall', - 'memoizeCapped' - ], function(funcName) { - _['_' + funcName] = interopRequire(path.join(basePath, '_' + funcName)); - }); - } -}); - -export { - HOT_COUNT, - LARGE_ARRAY_SIZE, - FUNC_ERROR_TEXT, - MAX_MEMOIZE_SIZE, - MAX_SAFE_INTEGER, - MAX_INTEGER, - MAX_ARRAY_LENGTH, - MAX_ARRAY_INDEX, - funcTag, - numberTag, - objectTag, - lodashBizarro, - arrayProto, - funcProto, - objectProto, - numberProto, - stringProto, - phantom, - amd, - args, - argv, - defineProperty, - document, - body, - create, - fnToString, - freeze, - getSymbols, - identity, - noop, - objToString, - params, - push, - realm, - root, - slice, - strictArgs, - arrayBuffer, - map, - promise, - set, - symbol, - weakMap, - weakSet, - add, - doubled, - isEven, - square, - stubA, - stubB, - stubC, - stubTrue, - stubFalse, - stubNaN, - stubNull, - stubZero, - stubOne, - stubTwo, - stubThree, - stubFour, - stubArray, - stubObject, - stubString, - burredLetters, - comboMarks, - deburredLetters, - falsey, - emojiVar, - empties, - errors, - fitzModifiers, - primitives, - typedArrays, - arrayViews, - filePath, - ui, - basename, - isModularize, - isNpm, - isPhantom, - isStrict, - Worker, - lodashStable, - _, - mapCaches, - coverage, - asyncFunc, - genFunc, - oldDash, - whitespace, - CustomError, - emptyObject, - getUnwrappedValue, - interopRequire, - setProperty, - skipAssert, - toArgs -}; diff --git a/libs/nanofn/test/values-methods.js b/libs/nanofn/test/values-methods.js deleted file mode 100644 index b17f3c48b..000000000 --- a/libs/nanofn/test/values-methods.js +++ /dev/null @@ -1,47 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, args, strictArgs } from './utils.js'; - -describe('values methods', function() { - lodashStable.each(['values', 'valuesIn'], function(methodName) { - var func = _[methodName], - isValues = methodName == 'values'; - - it('`_.' + methodName + '` should get string keyed values of `object`', function() { - var object = { 'a': 1, 'b': 2 }, - actual = func(object).sort(); - - assert.deepStrictEqual(actual, [1, 2]); - }); - - it('`_.' + methodName + '` should work with an object that has a `length` property', function() { - var object = { '0': 'a', '1': 'b', 'length': 2 }, - actual = func(object).sort(); - - assert.deepStrictEqual(actual, [2, 'a', 'b']); - }); - - it('`_.' + methodName + '` should ' + (isValues ? 'not ' : '') + 'include inherited string keyed property values', function() { - function Foo() { - this.a = 1; - } - Foo.prototype.b = 2; - - var expected = isValues ? [1] : [1, 2], - actual = func(new Foo).sort(); - - assert.deepStrictEqual(actual, expected); - }); - - it('`_.' + methodName + '` should work with `arguments` objects', function() { - var values = [args, strictArgs], - expected = lodashStable.map(values, lodashStable.constant([1, 2, 3])); - - var actual = lodashStable.map(values, function(value) { - return func(value).sort(); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); -}); diff --git a/libs/nanofn/test/without.test.js b/libs/nanofn/test/without.test.js deleted file mode 100644 index bad332941..000000000 --- a/libs/nanofn/test/without.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'assert'; -import without from '../without.js'; - -describe('without', function() { - it('should return the difference of values', function() { - var actual = without([2, 1, 2, 3], 1, 2); - assert.deepStrictEqual(actual, [3]); - }); - - it('should use strict equality to determine the values to reject', function() { - var object1 = { 'a': 1 }, - object2 = { 'b': 2 }, - array = [object1, object2]; - - assert.deepStrictEqual(without(array, { 'a': 1 }), array); - assert.deepStrictEqual(without(array, object1), [object2]); - }); - - it('should remove all occurrences of each value from an array', function() { - var array = [1, 2, 3, 1, 2, 3]; - assert.deepStrictEqual(without(array, 1, 2), [3, 3]); - }); -}); diff --git a/libs/nanofn/test/words.test.js b/libs/nanofn/test/words.test.js deleted file mode 100644 index 5eb1043be..000000000 --- a/libs/nanofn/test/words.test.js +++ /dev/null @@ -1,117 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { burredLetters, _, stubArray } from './utils.js'; -import words from '../words.js' - -describe('words', function() { - it('should match words containing Latin Unicode letters', function() { - var expected = lodashStable.map(burredLetters, function(letter) { - return [letter]; - }); - - var actual = lodashStable.map(burredLetters, function(letter) { - return words(letter); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should support a `pattern`', function() { - assert.deepStrictEqual(words('abcd', /ab|cd/g), ['ab', 'cd']); - assert.deepStrictEqual(Array.from(words('abcd', 'ab|cd')), ['ab']); - }); - - it('should work with compound words', function() { - assert.deepStrictEqual(words('12ft'), ['12', 'ft']); - assert.deepStrictEqual(words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']); - assert.deepStrictEqual(words('enable 6h format'), ['enable', '6', 'h', 'format']); - assert.deepStrictEqual(words('enable 24H format'), ['enable', '24', 'H', 'format']); - assert.deepStrictEqual(words('isISO8601'), ['is', 'ISO', '8601']); - assert.deepStrictEqual(words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']); - assert.deepStrictEqual(words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']); - assert.deepStrictEqual(words('walk500Miles'), ['walk', '500', 'Miles']); - assert.deepStrictEqual(words('xhr2Request'), ['xhr', '2', 'Request']); - assert.deepStrictEqual(words('XMLHttp'), ['XML', 'Http']); - assert.deepStrictEqual(words('XmlHTTP'), ['Xml', 'HTTP']); - assert.deepStrictEqual(words('XmlHttp'), ['Xml', 'Http']); - }); - - it('should work with compound words containing diacritical marks', function() { - assert.deepStrictEqual(words('LETTERSÆiouAreVowels'), ['LETTERS', 'Æiou', 'Are', 'Vowels']); - assert.deepStrictEqual(words('æiouAreVowels'), ['æiou', 'Are', 'Vowels']); - assert.deepStrictEqual(words('æiou2Consonants'), ['æiou', '2', 'Consonants']); - }); - - it('should not treat contractions as separate words', function() { - var postfixes = ['d', 'll', 'm', 're', 's', 't', 've']; - - lodashStable.each(["'", '\u2019'], function(apos) { - lodashStable.times(2, function(index) { - var actual = lodashStable.map(postfixes, function(postfix) { - var string = 'a b' + apos + postfix + ' c'; - return words(string[index ? 'toUpperCase' : 'toLowerCase']()); - }); - - var expected = lodashStable.map(postfixes, function(postfix) { - var words = ['a', 'b' + apos + postfix, 'c']; - return lodashStable.map(words, function(word) { - return word[index ? 'toUpperCase' : 'toLowerCase'](); - }); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - }); - - it('should not treat ordinal numbers as separate words', function() { - var ordinals = ['1st', '2nd', '3rd', '4th']; - - lodashStable.times(2, function(index) { - var expected = lodashStable.map(ordinals, function(ordinal) { - return [ordinal[index ? 'toUpperCase' : 'toLowerCase']()]; - }); - - var actual = lodashStable.map(expected, function(expectedWords) { - return words(expectedWords[0]); - }); - - assert.deepStrictEqual(actual, expected); - }); - }); - - it('should not treat mathematical operators as words', function() { - var operators = ['\xac', '\xb1', '\xd7', '\xf7'], - expected = lodashStable.map(operators, stubArray), - actual = lodashStable.map(operators, words); - - assert.deepStrictEqual(actual, expected); - }); - - it('should not treat punctuation as words', function() { - var marks = [ - '\u2012', '\u2013', '\u2014', '\u2015', - '\u2024', '\u2025', '\u2026', - '\u205d', '\u205e' - ]; - - var expected = lodashStable.map(marks, stubArray), - actual = lodashStable.map(marks, words); - - assert.deepStrictEqual(actual, expected); - }); - - it('should prevent ReDoS', function() { - var largeWordLen = 50000, - largeWord = 'A'.repeat(largeWordLen), - maxMs = 1000, - startTime = lodashStable.now(); - - assert.deepStrictEqual(words(largeWord + 'ÆiouAreVowels'), [largeWord, 'Æiou', 'Are', 'Vowels']); - - var endTime = lodashStable.now(), - timeSpent = endTime - startTime; - - assert.ok(timeSpent < maxMs, 'operation took ' + timeSpent + 'ms'); - }); -}); diff --git a/libs/nanofn/test/wrap.js b/libs/nanofn/test/wrap.js deleted file mode 100644 index 7a6bd5a45..000000000 --- a/libs/nanofn/test/wrap.js +++ /dev/null @@ -1,46 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { noop, slice, stubA } from './utils.js'; -import wrap from '../wrap.js'; - -describe('wrap', function() { - it('should create a wrapped function', function() { - var p = wrap(lodashStable.escape, function(func, text) { - return '

' + func(text) + '

'; - }); - - assert.strictEqual(p('fred, barney, & pebbles'), '

fred, barney, & pebbles

'); - }); - - it('should provide correct `wrapper` arguments', function() { - var args; - - var wrapped = wrap(noop, function() { - args || (args = slice.call(arguments)); - }); - - wrapped(1, 2, 3); - assert.deepStrictEqual(args, [noop, 1, 2, 3]); - }); - - it('should use `_.identity` when `wrapper` is nullish', function() { - var values = [, null, undefined], - expected = lodashStable.map(values, stubA); - - var actual = lodashStable.map(values, function(value, index) { - var wrapped = index ? wrap('a', value) : wrap('a'); - return wrapped('b', 'c'); - }); - - assert.deepStrictEqual(actual, expected); - }); - - it('should use `this` binding of function', function() { - var p = wrap(lodashStable.escape, function(func) { - return '

' + func(this.text) + '

'; - }); - - var object = { 'p': p, 'text': 'fred, barney, & pebbles' }; - assert.strictEqual(object.p(), '

fred, barney, & pebbles

'); - }); -}); diff --git a/libs/nanofn/test/xor-methods.js b/libs/nanofn/test/xor-methods.js deleted file mode 100644 index 11c31b07a..000000000 --- a/libs/nanofn/test/xor-methods.js +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, args, LARGE_ARRAY_SIZE } from './utils.js'; - -describe('xor methods', function() { - lodashStable.each(['xor', 'xorBy', 'xorWith'], function(methodName) { - var func = _[methodName]; - - it('`_.' + methodName + '` should return the symmetric difference of two arrays', function() { - var actual = func([2, 1], [2, 3]); - assert.deepStrictEqual(actual, [1, 3]); - }); - - it('`_.' + methodName + '` should return the symmetric difference of multiple arrays', function() { - var actual = func([2, 1], [2, 3], [3, 4]); - assert.deepStrictEqual(actual, [1, 4]); - - actual = func([1, 2], [2, 1], [1, 2]); - assert.deepStrictEqual(actual, []); - }); - - it('`_.' + methodName + '` should return an empty array when comparing the same array', function() { - var array = [1], - actual = func(array, array, array); - - assert.deepStrictEqual(actual, []); - }); - - it('`_.' + methodName + '` should return an array of unique values', function() { - var actual = func([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]); - assert.deepStrictEqual(actual, [1, 4]); - - actual = func([1, 1]); - assert.deepStrictEqual(actual, [1]); - }); - - it('`_.' + methodName + '` should return a new array when a single array is given', function() { - var array = [1]; - assert.notStrictEqual(func(array), array); - }); - - it('`_.' + methodName + '` should ignore individual secondary arguments', function() { - var array = [0]; - assert.deepStrictEqual(func(array, 3, null, { '0': 1 }), array); - }); - - it('`_.' + methodName + '` should ignore values that are not arrays or `arguments` objects', function() { - var array = [1, 2]; - assert.deepStrictEqual(func(array, 3, { '0': 1 }, null), array); - assert.deepStrictEqual(func(null, array, null, [2, 3]), [1, 3]); - assert.deepStrictEqual(func(array, null, args, null), [3]); - }); - - it('`_.' + methodName + '` should return a wrapped value when chaining', function() { - var wrapped = _([1, 2, 3])[methodName]([5, 2, 1, 4]); - assert.ok(wrapped instanceof _); - }); - - it('`_.' + methodName + '` should work when in a lazy sequence before `head` or `last`', function() { - var array = lodashStable.range(LARGE_ARRAY_SIZE + 1), - wrapped = _(array).slice(1)[methodName]([LARGE_ARRAY_SIZE, LARGE_ARRAY_SIZE + 1]); - - var actual = lodashStable.map(['head', 'last'], function(methodName) { - return wrapped[methodName](); - }); - - assert.deepEqual(actual, [1, LARGE_ARRAY_SIZE + 1]); - }); - }); -}); diff --git a/libs/nanofn/test/xorBy.js b/libs/nanofn/test/xorBy.js deleted file mode 100644 index 02b9250c6..000000000 --- a/libs/nanofn/test/xorBy.js +++ /dev/null @@ -1,23 +0,0 @@ -import assert from 'assert'; -import { slice } from './utils.js'; -import xorBy from '../xorBy.js'; - -describe('xorBy', function() { - it('should accept an `iteratee`', function() { - var actual = xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); - assert.deepStrictEqual(actual, [1.2, 3.4]); - - actual = xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - assert.deepStrictEqual(actual, [{ 'x': 2 }]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - xorBy([2.1, 1.2], [2.3, 3.4], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [2.3]); - }); -}); diff --git a/libs/nanofn/test/xorWith.test.js b/libs/nanofn/test/xorWith.test.js deleted file mode 100644 index 83551e2cd..000000000 --- a/libs/nanofn/test/xorWith.test.js +++ /dev/null @@ -1,13 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import xorWith from '../xorWith.js'; - -describe('xorWith', function() { - it('should work with a `comparator`', function() { - var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }], - others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }], - actual = xorWith(objects, others, lodashStable.isEqual); - - assert.deepStrictEqual(actual, [objects[1], others[0]]); - }); -}); diff --git a/libs/nanofn/test/zipObject-methods.js b/libs/nanofn/test/zipObject-methods.js deleted file mode 100644 index 02c4fbaa7..000000000 --- a/libs/nanofn/test/zipObject-methods.js +++ /dev/null @@ -1,39 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { _, LARGE_ARRAY_SIZE, square, isEven } from './utils.js'; - -describe('zipObject methods', function() { - lodashStable.each(['zipObject', 'zipObjectDeep'], function(methodName) { - var func = _[methodName], - object = { 'barney': 36, 'fred': 40 }, - isDeep = methodName == 'zipObjectDeep'; - - it('`_.' + methodName + '` should zip together key/value arrays into an object', function() { - var actual = func(['barney', 'fred'], [36, 40]); - assert.deepStrictEqual(actual, object); - }); - - it('`_.' + methodName + '` should ignore extra `values`', function() { - assert.deepStrictEqual(func(['a'], [1, 2]), { 'a': 1 }); - }); - - it('`_.' + methodName + '` should assign `undefined` values for extra `keys`', function() { - assert.deepStrictEqual(func(['a', 'b'], [1]), { 'a': 1, 'b': undefined }); - }); - - it('`_.' + methodName + '` should ' + (isDeep ? '' : 'not ') + 'support deep paths', function() { - lodashStable.each(['a.b.c', ['a', 'b', 'c']], function(path, index) { - var expected = isDeep ? ({ 'a': { 'b': { 'c': 1 } } }) : (index ? { 'a,b,c': 1 } : { 'a.b.c': 1 }); - assert.deepStrictEqual(func([path], [1]), expected); - }); - }); - - it('`_.' + methodName + '` should work in a lazy sequence', function() { - var values = lodashStable.range(LARGE_ARRAY_SIZE), - props = lodashStable.map(values, function(value) { return 'key' + value; }), - actual = _(props)[methodName](values).map(square).filter(isEven).take().value(); - - assert.deepEqual(actual, _.take(_.filter(_.map(func(props, values), square), isEven))); - }); - }); -}); diff --git a/libs/nanofn/test/zipWith.js b/libs/nanofn/test/zipWith.js deleted file mode 100644 index f6faaa460..000000000 --- a/libs/nanofn/test/zipWith.js +++ /dev/null @@ -1,48 +0,0 @@ -import assert from 'assert'; -import lodashStable from 'lodash'; -import { slice } from './utils.js'; -import zipWith from '../zipWith.js'; -import zip from '../zip.js'; - -describe('zipWith', function() { - it('should zip arrays combining grouped elements with `iteratee`', function() { - var array1 = [1, 2, 3], - array2 = [4, 5, 6], - array3 = [7, 8, 9]; - - var actual = zipWith(array1, array2, array3, function(a, b, c) { - return a + b + c; - }); - - assert.deepStrictEqual(actual, [12, 15, 18]); - - var actual = zipWith(array1, [], function(a, b) { - return a + (b || 0); - }); - - assert.deepStrictEqual(actual, [1, 2, 3]); - }); - - it('should provide correct `iteratee` arguments', function() { - var args; - - zipWith([1, 2], [3, 4], [5, 6], function() { - args || (args = slice.call(arguments)); - }); - - assert.deepStrictEqual(args, [1, 3, 5]); - }); - - it('should perform a basic zip when `iteratee` is nullish', function() { - var array1 = [1, 2], - array2 = [3, 4], - values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(zip(array1, array2))); - - var actual = lodashStable.map(values, function(value, index) { - return index ? zipWith(array1, array2, value) : zipWith(array1, array2); - }); - - assert.deepStrictEqual(actual, expected); - }); -}); diff --git a/libs/nanofn/tsconfig.json b/libs/nanofn/tsconfig.json deleted file mode 100644 index d7a0c7629..000000000 --- a/libs/nanofn/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ], - "compilerOptions": { - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "angularCompilerOptions": { - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/libs/nanofn/tsconfig.lib.json b/libs/nanofn/tsconfig.lib.json deleted file mode 100644 index 5256a92a1..000000000 --- a/libs/nanofn/tsconfig.lib.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "target": "es2015", - "declaration": true, - "declarationMap": true, - "inlineSources": true, - "types": [], - "lib": ["dom", "es2018"] - }, - "exclude": ["src/test-setup.ts", "**/*.spec.ts"], - "include": [ - "**/*.ts" - ] -} diff --git a/libs/nanofn/tsconfig.lib.prod.json b/libs/nanofn/tsconfig.lib.prod.json deleted file mode 100644 index 06de549e1..000000000 --- a/libs/nanofn/tsconfig.lib.prod.json +++ /dev/null @@ -1,10 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.lib.json", - "compilerOptions": { - "declarationMap": false - }, - "angularCompilerOptions": { - "compilationMode": "partial" - } -} diff --git a/libs/nanofn/tsconfig.spec.json b/libs/nanofn/tsconfig.spec.json deleted file mode 100644 index cfff29a54..000000000 --- a/libs/nanofn/tsconfig.spec.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "files": ["src/test-setup.ts"], - "include": ["**/*.spec.ts", "**/*.d.ts"] -} diff --git a/libs/nanofn/tslint.json b/libs/nanofn/tslint.json deleted file mode 100644 index 156f54082..000000000 --- a/libs/nanofn/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tslint.json", - "linterOptions": { - "exclude": ["!**/*"] - }, - "rules": {} -} diff --git a/libs/triangle/accordion/ng-package.json b/libs/triangle/accordion/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/accordion/ng-package.json +++ b/libs/triangle/accordion/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/alert/ng-package.json b/libs/triangle/alert/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/alert/ng-package.json +++ b/libs/triangle/alert/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/anchor/ng-package.json b/libs/triangle/anchor/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/anchor/ng-package.json +++ b/libs/triangle/anchor/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/auth/ng-package.json b/libs/triangle/auth/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/auth/ng-package.json +++ b/libs/triangle/auth/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/autocomplete/ng-package.json b/libs/triangle/autocomplete/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/autocomplete/ng-package.json +++ b/libs/triangle/autocomplete/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/avatar/ng-package.json b/libs/triangle/avatar/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/avatar/ng-package.json +++ b/libs/triangle/avatar/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/back-top/ng-package.json b/libs/triangle/back-top/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/back-top/ng-package.json +++ b/libs/triangle/back-top/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/badge/ng-package.json b/libs/triangle/badge/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/badge/ng-package.json +++ b/libs/triangle/badge/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/breadcrumb/ng-package.json b/libs/triangle/breadcrumb/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/breadcrumb/ng-package.json +++ b/libs/triangle/breadcrumb/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/button-toggle/ng-package.json b/libs/triangle/button-toggle/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/button-toggle/ng-package.json +++ b/libs/triangle/button-toggle/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/button/ng-package.json b/libs/triangle/button/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/button/ng-package.json +++ b/libs/triangle/button/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/button/src/button.component.ts b/libs/triangle/button/src/button.component.ts index 29e09933b..9fe7df0a6 100644 --- a/libs/triangle/button/src/button.component.ts +++ b/libs/triangle/button/src/button.component.ts @@ -6,8 +6,7 @@ import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'; import { - AfterContentInit, ChangeDetectionStrategy, Component, ElementRef, Input, Renderer2, - ViewEncapsulation, ɵmarkDirty + AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Input, ViewEncapsulation } from '@angular/core'; export type ButtonVariant = 'raised' | 'outlined' | 'dashed' | 'default' | 'rounded' | 'text'; @@ -28,7 +27,7 @@ export type ButtonSize = 'xlarge' | 'xl' | 'xsmall' | 'xs'; @Component({ - selector : `[triButton], [tri-button]`, + selector : '[triButton], [tri-button]', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation : ViewEncapsulation.None, template : ` @@ -158,7 +157,7 @@ export class ButtonComponent implements AfterContentInit { */ @Input() set loading(value: boolean) { - ɵmarkDirty(this); + this._cdRef.markForCheck(); this._loading = value; } @@ -187,7 +186,10 @@ export class ButtonComponent implements AfterContentInit { return this._el.querySelector(':scope > .tri-icon') as HTMLElement; } - constructor(private _elementRef: ElementRef) { + constructor( + private _elementRef: ElementRef, + private _cdRef: ChangeDetectorRef + ) { this._el = this._elementRef.nativeElement; } diff --git a/libs/triangle/calendar/ng-package.json b/libs/triangle/calendar/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/calendar/ng-package.json +++ b/libs/triangle/calendar/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/calendar/src/calendar-header.component.html b/libs/triangle/calendar/src/calendar-header.component.html index cf3f92423..7dc97d3a0 100644 --- a/libs/triangle/calendar/src/calendar-header.component.html +++ b/libs/triangle/calendar/src/calendar-header.component.html @@ -1,11 +1,11 @@ + class="tri-fullcalendar-year-select"> {{year.label}} + class="tri-fullcalendar-month-select"> {{month.label}} diff --git a/libs/triangle/card/ng-package.json b/libs/triangle/card/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/card/ng-package.json +++ b/libs/triangle/card/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/cascader/ng-package.json b/libs/triangle/cascader/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/cascader/ng-package.json +++ b/libs/triangle/cascader/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/checkbox/ng-package.json b/libs/triangle/checkbox/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/checkbox/ng-package.json +++ b/libs/triangle/checkbox/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/checkbox/src/checkbox-group.component.ts b/libs/triangle/checkbox/src/checkbox-group.component.ts index 80c677a47..9b4627a7b 100644 --- a/libs/triangle/checkbox/src/checkbox-group.component.ts +++ b/libs/triangle/checkbox/src/checkbox-group.component.ts @@ -8,7 +8,7 @@ import { Component, EventEmitter, forwardRef, Input, OnChanges, Output, SimpleChanges, TemplateRef, ViewEncapsulation } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { isArray, isNumber, isString } from '@gradii/check-type'; +import { isArray, isNumber, isString } from '@gradii/nanofn'; type OptionDisplay = { isChecked: boolean, diff --git a/libs/triangle/combobox/ng-package.json b/libs/triangle/combobox/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/combobox/ng-package.json +++ b/libs/triangle/combobox/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/combobox/src/combobox.component.ts b/libs/triangle/combobox/src/combobox.component.ts index e6d3e6aec..8655c2106 100644 --- a/libs/triangle/combobox/src/combobox.component.ts +++ b/libs/triangle/combobox/src/combobox.component.ts @@ -51,12 +51,12 @@ import { SelectService } from './select.service'; styles : [ ` .tri-select-dropdown { - top : 100%; - left : 0; - position : relative; - width : 100%; - margin-top : 4px; - margin-bottom : 4px; + top: 100%; + left: 0; + position: relative; + width: 100%; + margin-top: 4px; + margin-bottom: 4px; } ` ], @@ -100,7 +100,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie // tslint:disable-next-line:no-any @Input() maxTagPlaceholder: TemplateRef<{ $implicit: any[] }>; private isInit = false; - private destroy$ = new Subject(); + private destroy$: Subject = new Subject(); constructor( private renderer: Renderer2, diff --git a/libs/triangle/combobox/src/option-container.component.ts b/libs/triangle/combobox/src/option-container.component.ts index 69aaef556..7c45dd5c5 100644 --- a/libs/triangle/combobox/src/option-container.component.ts +++ b/libs/triangle/combobox/src/option-container.component.ts @@ -29,10 +29,10 @@ import { ComboboxOptionComponent } from './combobox-option.component'; import { SelectService } from './select.service'; @Component({ - selector : '[tri-option-container]', - changeDetection : ChangeDetectionStrategy.OnPush, - encapsulation : ViewEncapsulation.None, - templateUrl : './option-container.component.html' + selector : '[tri-option-container]', + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation : ViewEncapsulation.None, + templateUrl : './option-container.component.html' }) export class OptionContainerComponent implements OnDestroy, OnInit { @ViewChildren(OptionLiComponent) listOfOptionLiComponent: QueryList; @@ -40,7 +40,7 @@ export class OptionContainerComponent implements OnDestroy, OnInit { @Input() notFoundContent: string; @Input() menuItemSelectedIcon: TemplateRef; @Output() readonly scrollToBottom = new EventEmitter(); - private destroy$ = new Subject(); + private destroy$: Subject = new Subject(); constructor(public selectService: SelectService, private cdr: ChangeDetectorRef, private ngZone: NgZone) { } diff --git a/libs/triangle/combobox/src/option-li.component.ts b/libs/triangle/combobox/src/option-li.component.ts index 3f1887e1e..85880068e 100644 --- a/libs/triangle/combobox/src/option-li.component.ts +++ b/libs/triangle/combobox/src/option-li.component.ts @@ -31,10 +31,10 @@ import { SelectService } from './select.service'; } }) export class OptionLiComponent implements OnInit, OnDestroy { - el: HTMLElement = this.elementRef.nativeElement; - selected = false; - active = false; - destroy$ = new Subject(); + el: HTMLElement = this.elementRef.nativeElement; + selected = false; + active = false; + destroy$: Subject = new Subject(); @Input() option: ComboboxOptionComponent; @Input() menuItemSelectedIcon: TemplateRef; diff --git a/libs/triangle/combobox/src/select-top-control.component.ts b/libs/triangle/combobox/src/select-top-control.component.ts index 53fbb5169..e81c0a81a 100644 --- a/libs/triangle/combobox/src/select-top-control.component.ts +++ b/libs/triangle/combobox/src/select-top-control.component.ts @@ -24,30 +24,30 @@ import { ComboboxOptionComponent } from './combobox-option.component'; import { SelectService } from './select.service'; @Component({ - selector : '[tri-combobox-top-control]', - animations : [ZoomAnimation], - changeDetection : ChangeDetectionStrategy.OnPush, - encapsulation : ViewEncapsulation.None, - templateUrl : './select-top-control.component.html' + selector : '[tri-combobox-top-control]', + animations : [ZoomAnimation], + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation : ViewEncapsulation.None, + templateUrl : './select-top-control.component.html' }) export class SelectTopControlComponent implements OnInit, OnDestroy { inputValue: string; - isComposing = false; + isComposing = false; @ViewChild('inputElement', {static: false}) inputElement: ElementRef; - @Input() showSearch = false; + @Input() showSearch = false; @Input() placeHolder: string; - @Input() open = false; + @Input() open = false; @Input() maxTagCount: number; - @Input() allowClear = false; - @Input() showArrow = true; - @Input() loading = false; + @Input() allowClear = false; + @Input() showArrow = true; + @Input() loading = false; @Input() suffixIcon: TemplateRef; @Input() clearIcon: TemplateRef; @Input() removeIcon: TemplateRef; // tslint:disable-next-line:no-any @Input() maxTagPlaceholder: TemplateRef<{ $implicit: any[] }>; @Input() tokenSeparators: string[] = []; - private destroy$ = new Subject(); + private destroy$: Subject = new Subject(); constructor( private renderer: Renderer2, @@ -62,7 +62,7 @@ export class SelectTopControlComponent implements OnInit, OnDestroy { get selectedValueStyle(): { [key: string]: string } { let showSelectedValue = false; - let opacity = 1; + let opacity = 1; if (!this.showSearch) { showSelectedValue = true; } else { diff --git a/libs/triangle/combobox/src/select.service.ts b/libs/triangle/combobox/src/select.service.ts index 62f65b371..5604afa10 100644 --- a/libs/triangle/combobox/src/select.service.ts +++ b/libs/triangle/combobox/src/select.service.ts @@ -16,43 +16,44 @@ import { defaultFilterOption, FilterOptionPipe, TFilterOption } from './option.p @Injectable() export class SelectService { // Input params - autoClearSearchValue = true; - serverSearch = false; - filterOption: TFilterOption = defaultFilterOption; - mode: 'default' | 'multiple' | 'tags' = 'default'; - maxMultipleCount = Infinity; - disabled = false; - clearInput$ = new Subject(); + autoClearSearchValue = true; + serverSearch = false; + filterOption: TFilterOption = defaultFilterOption; + mode: 'default' | 'multiple' | 'tags' = 'default'; + maxMultipleCount = Infinity; + disabled = false; + clearInput$: Subject = new Subject(); // selectedValueChanged should emit ngModelChange or not - searchValue = ''; - isShowNotFound = false; + searchValue = ''; + isShowNotFound = false; activatedOption: ComboboxOptionComponent | null; - activatedOption$ = new ReplaySubject(1); + activatedOption$ = new ReplaySubject(1); // tslint:disable-next-line:no-any - listOfSelectedValue: any[] = []; + listOfSelectedValue: any[] = []; // flat ViewChildren - listOfTemplateOption: ComboboxOptionComponent[] = []; + listOfTemplateOption: ComboboxOptionComponent[] = []; // tag option - listOfTagOption: ComboboxOptionComponent[] = []; + listOfTagOption: ComboboxOptionComponent[] = []; // tag option concat template option - listOfTagAndTemplateOption: ComboboxOptionComponent[] = []; + listOfTagAndTemplateOption: ComboboxOptionComponent[] = []; // ViewChildren - listOfOptionComponent: ComboboxOptionComponent[] = []; - listOfOptionGroupComponent: OptionGroupComponent[] = []; + listOfOptionComponent: ComboboxOptionComponent[] = []; + listOfOptionGroupComponent: OptionGroupComponent[] = []; // click or enter add tag option addedTagOption: ComboboxOptionComponent | null; // display in top control - listOfCachedSelectedOption: ComboboxOptionComponent[] = []; + listOfCachedSelectedOption: ComboboxOptionComponent[] = []; // tslint:disable-next-line:no-any - private listOfSelectedValueWithEmit$ = new BehaviorSubject<{ value: any[]; emit: boolean }>({ + private listOfSelectedValueWithEmit$ = new BehaviorSubject<{ value: any[]; emit: boolean }>({ value: [], emit : false }); - listOfSelectedValue$: Observable = this.listOfSelectedValueWithEmit$.pipe(map(data => data.value)); - modelChange$: Observable = this.listOfSelectedValueWithEmit$.pipe( + listOfSelectedValue$: Observable = this.listOfSelectedValueWithEmit$.pipe( + map(data => data.value)); + modelChange$: Observable = this.listOfSelectedValueWithEmit$.pipe( filter(item => item.emit), map(data => { - const selectedList = data.value; + const selectedList = data.value; let modelValue: any[] | null = null; // tslint:disable-line:no-any if (this.isSingleMode) { if (selectedList.length) { @@ -65,7 +66,7 @@ export class SelectService { }) ); // ContentChildren Change - private mapOfTemplateOption$ = new BehaviorSubject<{ + private mapOfTemplateOption$ = new BehaviorSubject<{ listOfOptionComponent: ComboboxOptionComponent[]; listOfOptionGroupComponent: OptionGroupComponent[]; }>({ @@ -73,12 +74,13 @@ export class SelectService { listOfOptionGroupComponent: [] }); // selected value or ViewChildren change - valueOrOption$: Observable = combineLatest(this.listOfSelectedValue$, this.mapOfTemplateOption$).pipe( + valueOrOption$: Observable = combineLatest(this.listOfSelectedValue$, + this.mapOfTemplateOption$).pipe( tap(data => { - this.listOfSelectedValue = data[0]; - this.listOfOptionComponent = data[1].listOfOptionComponent; + this.listOfSelectedValue = data[0]; + this.listOfOptionComponent = data[1].listOfOptionComponent; this.listOfOptionGroupComponent = data[1].listOfOptionGroupComponent; - this.listOfTemplateOption = this.listOfOptionComponent.concat( + this.listOfTemplateOption = this.listOfOptionComponent.concat( this.listOfOptionGroupComponent.reduce( (pre, cur) => [...pre, ...cur.listOfOptionComponent.toArray()], [] as ComboboxOptionComponent[] @@ -92,9 +94,9 @@ export class SelectService { share() ); // searchValue Change - private searchValueRaw$ = new BehaviorSubject(''); + private searchValueRaw$ = new BehaviorSubject(''); private listOfFilteredOption: ComboboxOptionComponent[] = []; - searchValue$: Observable = this.searchValueRaw$.pipe( + searchValue$: Observable = this.searchValueRaw$.pipe( distinctUntilChanged(), skip(1), share(), @@ -106,17 +108,17 @@ export class SelectService { this.updateListOfFilteredOption(); }) ); - private openRaw$ = new Subject(); + private openRaw$ = new Subject(); // open - open$: Observable = this.openRaw$.pipe( + open$: Observable = this.openRaw$.pipe( distinctUntilChanged(), share(), tap(() => this.clearInput()) ); - private checkRaw$: Subject = new Subject(); + private checkRaw$: Subject = new Subject(); - check$ = merge( + check$ = merge( this.checkRaw$, this.valueOrOption$, this.searchValue$, @@ -184,7 +186,7 @@ export class SelectService { const listOfCachedSelectedOption: ComboboxOptionComponent[] = []; this.listOfSelectedValue.forEach(v => { const listOfMixedOption = [...this.listOfTagAndTemplateOption, ...this.listOfCachedSelectedOption]; - const option = listOfMixedOption.find(o => this.compareWith(o.value, v)); + const option = listOfMixedOption.find(o => this.compareWith(o.value, v)); if (option) { listOfCachedSelectedOption.push(option); } @@ -195,10 +197,10 @@ export class SelectService { updateListOfTagOption(): void { if (this.isTagsMode) { - const listOfMissValue = this.listOfSelectedValue.filter( + const listOfMissValue = this.listOfSelectedValue.filter( value => !this.listOfTemplateOption.find(o => this.compareWith(o.value, value)) ); - this.listOfTagOption = listOfMissValue.map(value => { + this.listOfTagOption = listOfMissValue.map(value => { const optionComponent = new ComboboxOptionComponent(); optionComponent.value = value; optionComponent.label = value; @@ -213,9 +215,9 @@ export class SelectService { updateAddTagOption(): void { const isMatch = this.listOfTagAndTemplateOption.find(item => item.label === this.searchValue); if (this.isTagsMode && this.searchValue && !isMatch) { - const option = new ComboboxOptionComponent(); - option.value = this.searchValue; - option.label = this.searchValue; + const option = new ComboboxOptionComponent(); + option.value = this.searchValue; + option.label = this.searchValue; this.addedTagOption = option; this.updateActivatedOption(option); } else { @@ -232,12 +234,14 @@ export class SelectService { this.serverSearch ); // @ts-ignore - this.listOfFilteredOption = this.addedTagOption ? [this.addedTagOption, ...listOfFilteredOption] : [...listOfFilteredOption]; - this.isShowNotFound = !this.isTagsMode && !this.listOfFilteredOption.length; + this.listOfFilteredOption = this.addedTagOption ? [ + this.addedTagOption, ...listOfFilteredOption + ] : [...listOfFilteredOption]; + this.isShowNotFound = !this.isTagsMode && !this.listOfFilteredOption.length; } clearInput(): void { - this.clearInput$.next(); + this.clearInput$.next(true); } // tslint:disable-next-line:no-any @@ -276,7 +280,7 @@ export class SelectService { } splitBySeparators(str: string | string[], separators: string[]): string[] { - const reg = new RegExp(`[${separators.join()}]`); + const reg = new RegExp(`[${separators.join()}]`); const array = (str as string).split(reg).filter(token => token); return Array.from(new Set(array)); } @@ -312,7 +316,7 @@ export class SelectService { } updateSelectedValueByLabelList(listOfLabel: string[]): void { - const listOfSelectedValue = [...this.listOfSelectedValue]; + const listOfSelectedValue = [...this.listOfSelectedValue]; const listOfMatchOptionValue = this.listOfTagAndTemplateOption .filter(item => listOfLabel.indexOf(item.label) !== -1) .map(item => item.value) @@ -331,10 +335,11 @@ export class SelectService { } onKeyDown(e: KeyboardEvent): void { - const keyCode = e.keyCode; - const eventTarget = e.target as HTMLInputElement; + const keyCode = e.keyCode; + const eventTarget = e.target as HTMLInputElement; const listOfFilteredOptionWithoutDisabled = this.listOfFilteredOption.filter(item => !item.disabled); - const activatedIndex = listOfFilteredOptionWithoutDisabled.findIndex(item => item === this.activatedOption); + const activatedIndex = listOfFilteredOptionWithoutDisabled.findIndex( + item => item === this.activatedOption); switch (keyCode) { case UP_ARROW: e.preventDefault(); diff --git a/libs/triangle/confirm-popup/ng-package.json b/libs/triangle/confirm-popup/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/confirm-popup/ng-package.json +++ b/libs/triangle/confirm-popup/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/confirm-popup/src/confirm-popup.component.ts b/libs/triangle/confirm-popup/src/confirm-popup.component.ts index ba57deaa1..5b457d4fb 100644 --- a/libs/triangle/confirm-popup/src/confirm-popup.component.ts +++ b/libs/triangle/confirm-popup/src/confirm-popup.component.ts @@ -24,10 +24,10 @@ import { FadeAnimation } from '@gradii/triangle/core'; import { PopoverComponent } from '@gradii/triangle/popover'; @Component({ - selector: 'tri-confirm-popup', + selector : 'tri-confirm-popup', encapsulation: ViewEncapsulation.None, - animations: [FadeAnimation], - template: ` + animations : [FadeAnimation], + template : `
-
{{title}}
+
{{ title }}
- {{content}} + {{ content }}
- - + +
`, - styleUrls: ['../style/confirm-popup.scss'] + styleUrls : ['../style/confirm-popup.scss'] }) export class ConfirmPopupComponent extends PopoverComponent implements OnDestroy { @Input() @@ -64,17 +64,18 @@ export class ConfirmPopupComponent extends PopoverComponent implements OnDestroy okText: string = 'ok'; @Output() - onCancel = new EventEmitter(); + onCancel: EventEmitter = new EventEmitter(); @Output() - onConfirm = new EventEmitter(); + onConfirm: EventEmitter = new EventEmitter(); constructor( protected _elementRef: ElementRef, protected _ngZone: NgZone, protected _focusMonitor: FocusMonitor, protected _breakpointObserver: BreakpointObserver, - protected _viewContainerRef: ViewContainerRef) { + protected _viewContainerRef: ViewContainerRef, + protected _cdRef: ChangeDetectorRef) { super( _elementRef, @@ -82,6 +83,7 @@ export class ConfirmPopupComponent extends PopoverComponent implements OnDestroy _focusMonitor, _breakpointObserver, _viewContainerRef, + _cdRef ); } diff --git a/libs/triangle/core/ng-package.json b/libs/triangle/core/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/core/ng-package.json +++ b/libs/triangle/core/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/data-query/ng-package.json b/libs/triangle/data-query/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/data-query/ng-package.json +++ b/libs/triangle/data-query/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/data-table/ng-package.json b/libs/triangle/data-table/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/data-table/ng-package.json +++ b/libs/triangle/data-table/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/data-table/src/data-table.component.ts b/libs/triangle/data-table/src/data-table.component.ts index f7366778e..937fc6927 100644 --- a/libs/triangle/data-table/src/data-table.component.ts +++ b/libs/triangle/data-table/src/data-table.component.ts @@ -11,7 +11,7 @@ import { Self, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; -import { isIterable } from '@gradii/check-type'; +import { isIterable } from '@gradii/nanofn'; import { CompositeFilterDescriptor, GroupDescriptor, GroupResult, SortDescriptor } from '@gradii/triangle/data-query'; import { TRI_INTERNAL_DATA_TABLE } from './data-table.types'; import { diff --git a/libs/triangle/date-picker/ng-package.json b/libs/triangle/date-picker/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/date-picker/ng-package.json +++ b/libs/triangle/date-picker/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/desc-list/ng-package.json b/libs/triangle/desc-list/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/desc-list/ng-package.json +++ b/libs/triangle/desc-list/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/diagram/ng-package.json b/libs/triangle/diagram/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/diagram/ng-package.json +++ b/libs/triangle/diagram/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/diagram/src/canvas-core/entities/canvas/canvas-widget.ts b/libs/triangle/diagram/src/canvas-core/entities/canvas/canvas-widget.ts index 0bb087e2a..010cb8b80 100644 --- a/libs/triangle/diagram/src/canvas-core/entities/canvas/canvas-widget.ts +++ b/libs/triangle/diagram/src/canvas-core/entities/canvas/canvas-widget.ts @@ -29,9 +29,9 @@ import { CANVAS_WIDGET, ENGINE } from '../../tokens'; ], styles : [ `:host { - position : absolute; - height : 100%; - width : 100%; + position: absolute; + height: 100%; + width: 100%; }` ] }) @@ -47,7 +47,7 @@ export class CanvasWidget implements OnInit, AfterViewInit, OnDestroy { action: null; diagramEngineListener: null; - subject$ = new Subject(); + subject$: Subject = new Subject(); constructor(@Inject(ENGINE) public engine: CanvasEngine, public ngZone: NgZone, diff --git a/libs/triangle/diagram/src/diagram-core/entities/node/node-widget.ts b/libs/triangle/diagram/src/diagram-core/entities/node/node-widget.ts index 7f5f5cb6d..e60761c2f 100644 --- a/libs/triangle/diagram/src/diagram-core/entities/node/node-widget.ts +++ b/libs/triangle/diagram/src/diagram-core/entities/node/node-widget.ts @@ -5,7 +5,7 @@ */ import { CdkPortalOutlet, ComponentPortal } from '@angular/cdk/portal'; -import { CdkPortalOutletAttachedRef } from '@angular/cdk/portal/portal-directives'; +import { CdkPortalOutletAttachedRef } from '@angular/cdk/portal'; import { Component, ComponentRef, ElementRef, Inject, Injector, Input, ViewChild } from '@angular/core'; diff --git a/libs/triangle/diagram/src/diagram-core/x/x-link-point-widget.ts b/libs/triangle/diagram/src/diagram-core/x/x-link-point-widget.ts index 57169ada3..d44bf4b60 100644 --- a/libs/triangle/diagram/src/diagram-core/x/x-link-point-widget.ts +++ b/libs/triangle/diagram/src/diagram-core/x/x-link-point-widget.ts @@ -32,7 +32,7 @@ import { PointModel } from '../entities/link/point-model'; styles : [ ` .pointTop { - pointer-events : all; + pointer-events: all; } ` ] @@ -48,7 +48,7 @@ export class XLinkPointWidget implements AfterViewInit, OnDestroy { @ViewChild('circle', {read: ElementRef}) circleRef: ElementRef; - private destroy$ = new Subject(); + private destroy$: Subject = new Subject(); constructor(private _ngZone: NgZone) { } diff --git a/libs/triangle/diagram/src/diagram.component.ts b/libs/triangle/diagram/src/diagram.component.ts index be4560351..ca34ab34b 100644 --- a/libs/triangle/diagram/src/diagram.component.ts +++ b/libs/triangle/diagram/src/diagram.component.ts @@ -45,17 +45,17 @@ import { DIAGRAM_STATES } from './tokens'; `, styles : [ `:host { - position : relative; - cursor : move; - overflow : hidden; + position: relative; + cursor: move; + overflow: hidden; } :host { - display : flex; - height : 100%; - width : 100%; - background-color : #fafafa; - background-image : linear-gradient( + display: flex; + height: 100%; + width: 100%; + background-color: #fafafa; + background-image: linear-gradient( 0deg, transparent 24%, rgba(128, 128, 128, 0.15) 25%, @@ -79,7 +79,7 @@ import { DIAGRAM_STATES } from './tokens'; transparent 77%, transparent ); - background-size : 30px 30px; + background-size: 30px 30px; } ` @@ -108,7 +108,7 @@ export class DiagramComponent implements OnInit, AfterViewInit, OnDestroy { @Output() stateChange: EventEmitter = new EventEmitter(); - private destroy$ = new Subject(); + private destroy$: Subject = new Subject(); private registerHandle: ListenerHandle; private _positionChanged: Subject = new Subject(); diff --git a/libs/triangle/dialog/ng-package.json b/libs/triangle/dialog/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/dialog/ng-package.json +++ b/libs/triangle/dialog/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/divider/ng-package.json b/libs/triangle/divider/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/divider/ng-package.json +++ b/libs/triangle/divider/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/dnd/ng-package.json b/libs/triangle/dnd/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/dnd/ng-package.json +++ b/libs/triangle/dnd/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/dnd/src/directives/drop-grid-container.ts b/libs/triangle/dnd/src/directives/drop-grid-container.ts index d34e09a28..59748c0f6 100644 --- a/libs/triangle/dnd/src/directives/drop-grid-container.ts +++ b/libs/triangle/dnd/src/directives/drop-grid-container.ts @@ -63,33 +63,33 @@ export const TRI_DROP_GRID_CONTAINER_CONFIG = new InjectionToken('tri drop grid styles : [ ` .tri-drop-grid-container { - position : relative; - box-sizing : border-box; - background : gray; - width : 100%; - height : 100%; - user-select : none; - display : block; - overflow : hidden; + position: relative; + box-sizing: border-box; + background: gray; + width: 100%; + height: 100%; + user-select: none; + display: block; + overflow: hidden; } .tri-drop-grid-container-fit { - overflow-x : hidden; - overflow-y : hidden; + overflow-x: hidden; + overflow-y: hidden; } .tri-drop-grid-container-scrollVertical { - overflow-x : hidden; - overflow-y : auto; + overflow-x: hidden; + overflow-y: auto; } .tri-drop-grid-container-scrollHorizontal { - overflow-x : auto; - overflow-y : hidden; + overflow-x: auto; + overflow-y: hidden; } .tri-drop-grid-container-fixed { - overflow : auto; + overflow: auto; } ` ] @@ -567,7 +567,7 @@ ${JSON.stringify(item, ['cols', 'rows', 'x', 'y'])}`); this._dropContainerRef.withItems(this.getSortedItems().map(item => item._dragRef)); } - private calculateLayout$ = new Subject(); + private calculateLayout$: Subject = new Subject(); calculateLayout() { this.calculateLayout$.next(); diff --git a/libs/triangle/dnd/src/drag-drop-ref/dnd-container-ref.ts b/libs/triangle/dnd/src/drag-drop-ref/dnd-container-ref.ts index ec00a81a7..5a59d4e6e 100644 --- a/libs/triangle/dnd/src/drag-drop-ref/dnd-container-ref.ts +++ b/libs/triangle/dnd/src/drag-drop-ref/dnd-container-ref.ts @@ -111,7 +111,16 @@ export class DndContainerRef { // _parentPositions: ParentPositionTracker; /** Cached `ClientRect` of the drop list. */ - _clientRect: ClientRect | undefined; + _clientRect: { + bottom: number; + height: number; + left: number; + right: number; + top: number; + width: number; + x: number; + y: number; + } | undefined; /** * Draggable items that are currently active inside the container. Includes the items diff --git a/libs/triangle/dnd/src/utils/client-rect.ts b/libs/triangle/dnd/src/utils/client-rect.ts index 62473c462..2f1ba89bb 100644 --- a/libs/triangle/dnd/src/utils/client-rect.ts +++ b/libs/triangle/dnd/src/utils/client-rect.ts @@ -31,7 +31,16 @@ export function getMutableClientRect(element: Element): ClientRect { * @param x Coordinates along the X axis. * @param y Coordinates along the Y axis. */ -export function isInsideClientRect(clientRect: ClientRect, x: number, y: number) { +export function isInsideClientRect(clientRect: { + bottom: number; + height: number; + left: number; + right: number; + top: number; + width: number; + x: number; + y: number; +}, x: number, y: number) { const {top, bottom, left, right} = clientRect; return y >= top && y <= bottom && x >= left && x <= right; } @@ -69,7 +78,16 @@ export function adjustClientRect( * @param pointerY Coordinates along the Y axis. */ export function isPointerNearClientRect( - rect: ClientRect, + rect: { + bottom: number; + height: number; + left: number; + right: number; + top: number; + width: number; + x: number; + y: number; + }, threshold: number, pointerX: number, pointerY: number, diff --git a/libs/triangle/drag-drop/ng-package.json b/libs/triangle/drag-drop/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/drag-drop/ng-package.json +++ b/libs/triangle/drag-drop/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/draggable/ng-package.json b/libs/triangle/draggable/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/draggable/ng-package.json +++ b/libs/triangle/draggable/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/drawer/ng-package.json b/libs/triangle/drawer/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/drawer/ng-package.json +++ b/libs/triangle/drawer/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/dropdown/ng-package.json b/libs/triangle/dropdown/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/dropdown/ng-package.json +++ b/libs/triangle/dropdown/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/empty/ng-package.json b/libs/triangle/empty/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/empty/ng-package.json +++ b/libs/triangle/empty/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/form-field/ng-package.json b/libs/triangle/form-field/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/form-field/ng-package.json +++ b/libs/triangle/form-field/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/form/ng-package.json b/libs/triangle/form/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/form/ng-package.json +++ b/libs/triangle/form/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/grid-list/ng-package.json b/libs/triangle/grid-list/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/grid-list/ng-package.json +++ b/libs/triangle/grid-list/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/grid/ng-package.json b/libs/triangle/grid/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/grid/ng-package.json +++ b/libs/triangle/grid/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/gridster/ng-package.json b/libs/triangle/gridster/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/gridster/ng-package.json +++ b/libs/triangle/gridster/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/gridster/src/gridster.component.ts b/libs/triangle/gridster/src/gridster.component.ts index cc5d41a73..37c4a47b6 100644 --- a/libs/triangle/gridster/src/gridster.component.ts +++ b/libs/triangle/gridster/src/gridster.component.ts @@ -57,7 +57,7 @@ export class GridsterComponent implements OnInit, OnChanges, OnDestroy, Gridster emptyCell: GridsterEmptyCell; compact: GridsterCompact; gridRenderer: GridsterRenderer; - previewStyle$: EventEmitter = new EventEmitter(); + previewStyle$: EventEmitter = new EventEmitter(); constructor(@Inject(ElementRef) el: ElementRef, @Inject(Renderer2) public renderer: Renderer2, @Inject(ChangeDetectorRef) public cdRef: ChangeDetectorRef, @@ -603,7 +603,7 @@ export class GridsterComponent implements OnInit, OnChanges, OnDestroy, Gridster } this.previewStyle$.next(this.movingItem); } else { - this.previewStyle$.next(); + this.previewStyle$.next(null); } } diff --git a/libs/triangle/i18n/ng-package.json b/libs/triangle/i18n/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/i18n/ng-package.json +++ b/libs/triangle/i18n/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/icon/ng-package.json b/libs/triangle/icon/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/icon/ng-package.json +++ b/libs/triangle/icon/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/input-number/ng-package.json b/libs/triangle/input-number/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/input-number/ng-package.json +++ b/libs/triangle/input-number/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/input-number/src/input-number.component.ts b/libs/triangle/input-number/src/input-number.component.ts index 1ef97cff9..4ead4a0f6 100644 --- a/libs/triangle/input-number/src/input-number.component.ts +++ b/libs/triangle/input-number/src/input-number.component.ts @@ -6,7 +6,7 @@ import { FocusMonitor } from '@angular/cdk/a11y'; import { - ChangeDetectionStrategy, + ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, @@ -16,8 +16,7 @@ import { Output, Renderer2, ViewChild, - ViewEncapsulation, - ɵmarkDirty + ViewEncapsulation } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; @@ -221,6 +220,7 @@ export class InputNumberComponent implements OnInit, ControlValueAccessor { constructor(private _elementRef: ElementRef, private _renderer: Renderer2, private focusMonitor: FocusMonitor, + private _cdRef: ChangeDetectorRef ) { this._el = this._elementRef.nativeElement; this._renderer.addClass(this._el, 'tri-input-number'); @@ -332,13 +332,13 @@ export class InputNumberComponent implements OnInit, ControlValueAccessor { setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; - ɵmarkDirty(this); + this._cdRef.markForCheck(); } private _updateValue(value: number, emitChange = true) { value = this._getBoundValue(value); this.displayValue = value; - ɵmarkDirty(this); + this._cdRef.markForCheck(); if (this._value === value) { return; } diff --git a/libs/triangle/input/ng-package.json b/libs/triangle/input/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/input/ng-package.json +++ b/libs/triangle/input/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/layout/ng-package.json b/libs/triangle/layout/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/layout/ng-package.json +++ b/libs/triangle/layout/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/list/ng-package.json b/libs/triangle/list/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/list/ng-package.json +++ b/libs/triangle/list/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/list/src/list.component.ts b/libs/triangle/list/src/list.component.ts index a7fcf3981..2f5bb6f8a 100644 --- a/libs/triangle/list/src/list.component.ts +++ b/libs/triangle/list/src/list.component.ts @@ -57,7 +57,7 @@ export class ListComponent { @Input() itemLayout: 'vertical' | 'horizontal' = 'horizontal'; - @Input() renderItem: TemplateRef; + @Input() renderItem: TemplateRef; @Input() loading = false; diff --git a/libs/triangle/menu/ng-package.json b/libs/triangle/menu/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/menu/ng-package.json +++ b/libs/triangle/menu/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/message/ng-package.json b/libs/triangle/message/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/message/ng-package.json +++ b/libs/triangle/message/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/modal/ng-package.json b/libs/triangle/modal/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/modal/ng-package.json +++ b/libs/triangle/modal/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/navbar/ng-package.json b/libs/triangle/navbar/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/navbar/ng-package.json +++ b/libs/triangle/navbar/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/package.json b/libs/triangle/package.json index 2d4c77dff..580775a28 100644 --- a/libs/triangle/package.json +++ b/libs/triangle/package.json @@ -1,6 +1,6 @@ { "name": "@gradii/triangle", - "version": "2.3.2", + "version": "2.4.0", "description": "Triangle Packages", "repository": { "type": "git", diff --git a/libs/triangle/pagination/ng-package.json b/libs/triangle/pagination/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/pagination/ng-package.json +++ b/libs/triangle/pagination/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/pagination/src/pagination.component.ts b/libs/triangle/pagination/src/pagination.component.ts index 3b5da3f18..b64400390 100644 --- a/libs/triangle/pagination/src/pagination.component.ts +++ b/libs/triangle/pagination/src/pagination.component.ts @@ -107,7 +107,7 @@ import { PageChangeEvent } from './event/page-change.event';
diff --git a/libs/triangle/popover/ng-package.json b/libs/triangle/popover/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/popover/ng-package.json +++ b/libs/triangle/popover/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/popover/src/popover.component.ts b/libs/triangle/popover/src/popover.component.ts index 999e554a1..b0897a698 100644 --- a/libs/triangle/popover/src/popover.component.ts +++ b/libs/triangle/popover/src/popover.component.ts @@ -79,9 +79,11 @@ export class PopoverComponent extends _TriTooltipComponentBase implements OnDest protected _ngZone: NgZone, protected _focusMonitor: FocusMonitor, protected _breakpointObserver: BreakpointObserver, - protected _viewContainerRef: ViewContainerRef) { + protected _viewContainerRef: ViewContainerRef, + protected _cdRef: ChangeDetectorRef + ) { - super(); + super(_cdRef); _ngZone.runOutsideAngular(() => { this._subscriptions.push( diff --git a/libs/triangle/progress/ng-package.json b/libs/triangle/progress/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/progress/ng-package.json +++ b/libs/triangle/progress/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/radio/ng-package.json b/libs/triangle/radio/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/radio/ng-package.json +++ b/libs/triangle/radio/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/rate/ng-package.json b/libs/triangle/rate/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/rate/ng-package.json +++ b/libs/triangle/rate/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/rate/src/rate.component.ts b/libs/triangle/rate/src/rate.component.ts index dd59c6d56..c211c7b56 100644 --- a/libs/triangle/rate/src/rate.component.ts +++ b/libs/triangle/rate/src/rate.component.ts @@ -4,12 +4,13 @@ * Use of this source code is governed by an MIT-style license */ -import { ChangeDetectionStrategy, Component, Directive, ElementRef, EventEmitter, forwardRef, Input, NgZone, OnInit, Output, ViewEncapsulation, ɵmarkDirty } from '@angular/core'; +import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes'; +import { + ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, OnInit, Output, + ViewEncapsulation +} from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { fromEvent, Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; import { clamp } from '@gradii/triangle/util'; -import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes'; @Component({ @@ -41,6 +42,7 @@ export class _RateStarItemComponent { constructor( + private _cdRef: ChangeDetectorRef ) { // const element = this._elementRef.nativeElement; // _ngZone.runOutsideAngular(() => { @@ -177,6 +179,9 @@ export class RateComponent implements OnInit, ControlValueAccessor { // this.setClassMap(); } + constructor(private _cdRef: ChangeDetectorRef) { + } + setChildrenClassMap(): void { let index = 0; while (index < this._count) { @@ -197,7 +202,7 @@ export class RateComponent implements OnInit, ControlValueAccessor { if (oldVal !== this.value) { this.onChange(this.value); - ɵmarkDirty(this); + this._cdRef.markForCheck(); } } @@ -241,7 +246,7 @@ export class RateComponent implements OnInit, ControlValueAccessor { writeValue(value: any): void { this.value = +value; - ɵmarkDirty(this); + this._cdRef.markForCheck() } registerOnChange(fn: (_: any) => {}): void { diff --git a/libs/triangle/select/ng-package.json b/libs/triangle/select/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/select/ng-package.json +++ b/libs/triangle/select/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/select/src/select.ts b/libs/triangle/select/src/select.ts index b285989c8..f935a9a51 100644 --- a/libs/triangle/select/src/select.ts +++ b/libs/triangle/select/src/select.ts @@ -92,7 +92,7 @@ import { take, takeUntil, } from 'rxjs/operators'; -import {matSelectAnimations} from './select-animations'; +import {triSelectAnimations} from './select-animations'; import { getTriSelectDynamicMultipleError, getTriSelectNonArrayValueError, diff --git a/libs/triangle/sidebar/ng-package.json b/libs/triangle/sidebar/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/sidebar/ng-package.json +++ b/libs/triangle/sidebar/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/sidenav/ng-package.json b/libs/triangle/sidenav/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/sidenav/ng-package.json +++ b/libs/triangle/sidenav/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/slider/index.ts b/libs/triangle/slider/index.ts deleted file mode 100644 index 1b19d27b9..000000000 --- a/libs/triangle/slider/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export * from './public-api'; diff --git a/libs/triangle/slider/ng-package.json b/libs/triangle/slider/ng-package.json deleted file mode 100644 index 0a5bd5c3a..000000000 --- a/libs/triangle/slider/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file diff --git a/libs/triangle/slider/public-api.ts b/libs/triangle/slider/public-api.ts deleted file mode 100644 index 324706ad6..000000000 --- a/libs/triangle/slider/public-api.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -export * from './src/slider.component'; -export * from './src/slider.module'; -export * from './src/slider.service'; -export * from './src/slider-handle.component'; -export * from './src/slider-marks.component'; -export * from './src/slider-step.component'; -export * from './src/slider-track.component'; diff --git a/libs/triangle/slider/src/slider-handle.component.ts b/libs/triangle/slider/src/slider-handle.component.ts deleted file mode 100644 index 3b7d3e808..000000000 --- a/libs/triangle/slider/src/slider-handle.component.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { - Component, HostListener, Inject, Input, OnChanges, OnInit, SimpleChanges, ViewChild, ViewEncapsulation -} from '@angular/core'; -import { TRI_INTERNAL_SLIDER } from './slider.types'; -import { TooltipDirective } from '@gradii/triangle/tooltip'; -import type { SliderComponent } from './slider.component'; - -@Component({ - selector : 'tri-slider-handle', - encapsulation: ViewEncapsulation.None, - template : ` -
-
- ` -}) -export class SliderHandleComponent implements OnInit, OnChanges { - // Static properties - @Input() className: string; - @Input() vertical: boolean; - @Input() offset: number; - @Input() value: number; // [For tooltip] - @Input() tipFormatter: Function; // [For tooltip] - // Locals - @ViewChild('tooltip', {static: false}) tooltip: TooltipDirective; // [For tooltip] - tooltipTitle: string; // [For tooltip] - style: any = {}; - - constructor(@Inject(TRI_INTERNAL_SLIDER) private _slider: SliderComponent) { - } - - @Input() - set active(show: boolean) { - // [For tooltip] - if (this.tooltip) { - if (show) { - this.tooltip.show(); - } else { - this.tooltip.hide(); - } - } - } - - ngOnInit() { - } - - ngOnChanges(changes: SimpleChanges) { - if (changes.offset) { - this._updateStyle(); - } - if (changes.value) { - this._updateTooltipTitle(); // [For tooltip] - // this._updateTooltipPosition(); // [For tooltip] - } - } - - // Hover to toggle tooltip when not dragging - @HostListener('mouseenter', ['$event']) - onMouseEnter($event) { - if (!this._slider.isDragging) { - this.active = true; - } - } - - @HostListener('mouseleave', ['$event']) - onMouseLeave($event) { - if (!this._slider.isDragging) { - this.active = false; - } - } - - private _updateTooltipTitle() { - // [For tooltip] - this.tooltipTitle = this.tipFormatter ? this.tipFormatter(this.value) : this.value; - } - - // private _updateTooltipPosition() { - // // [For tooltip] - // if (this.tooltip) { - // window.setTimeout(() => this.tooltip.updatePosition(), 0); // MAY use ngAfterViewChecked? but this will be called so many times. - // } - // } - - private _updateStyle() { - this.style[this.vertical ? 'bottom' : 'left'] = `${this.offset}%`; - } -} diff --git a/libs/triangle/slider/src/slider-marks.component.ts b/libs/triangle/slider/src/slider-marks.component.ts deleted file mode 100644 index d852ce0f8..000000000 --- a/libs/triangle/slider/src/slider-marks.component.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { - Component, - Input, - OnChanges, - OnInit, - SimpleChanges, - ViewEncapsulation -} from '@angular/core'; - -@Component({ - selector : 'tri-slider-marks', - encapsulation: ViewEncapsulation.None, - template : ` -
- -
- ` -}) -export class SliderMarksComponent implements OnInit, OnChanges { - // Dynamic properties - @Input() lowerBound: number = null; - @Input() upperBound: number = null; - - // Static properties - @Input() className: string; - @Input() vertical: boolean; // Required - @Input() marksArray: MarksArray; // Required - @Input() min: number; // Required - @Input() max: number; // Required - @Input() included: boolean; - - attrs; // points for inner use - - ngOnChanges(changes: SimpleChanges) { - if (changes.lowerBound || changes.upperBound) { - this.togglePointActive(); - } - } - - ngOnInit() { - const {vertical, className, marksArray, min, max, lowerBound, upperBound} = this; - const range = max - min; - this.attrs = marksArray.map(mark => { - const {value, offset, config} = mark; - // calc styles - let label = config, - style; - if (vertical) { - style = { - marginBottom: '-50%', - bottom : `${(value - min) / range * 100}%` - }; - } else { - const marksCount = marksArray.length, - unit = 100 / (marksCount - 1), - markWidth = unit * 0.9; - style = { - width : `${markWidth}%`, - marginLeft: `${-markWidth / 2}%`, - left : `${(value - min) / range * 100}%` - }; - } - // custom configuration - if (typeof config === 'object') { - label = config.label; - if (config.style) { - style = {...style, ...config.style}; - } - } - return { - id : value, - value : value, - offset : offset, - classes: { - [`${className}-text`]: true - }, - style : style, - label : label - }; - }); // END - map - this.togglePointActive(); - } - - trackById(index: number, attr) { - return attr.id; - } - - togglePointActive() { - const {className, attrs, lowerBound, upperBound, included} = this; - if (attrs && lowerBound !== null && upperBound !== null) { - attrs.forEach(attr => { - const value = attr.value, - isActive = (!included && value === upperBound) || (included && value <= upperBound && value >= lowerBound); - attr.classes[`${className}-text-active`] = isActive; - }); - } - } -} - -// DEFINITIONS - -export type Mark = - | string - | { - style: Object; - label: string; -}; - -export type Marks = { - [key: number]: Mark; -}; - -export class MarksArray extends Array { - [index: number]: { - value: number; - offset: number; - config: Mark; - }; -} diff --git a/libs/triangle/slider/src/slider-step.component.ts b/libs/triangle/slider/src/slider-step.component.ts deleted file mode 100644 index cef67988d..000000000 --- a/libs/triangle/slider/src/slider-step.component.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { - Component, - Input, - OnChanges, - OnInit, - SimpleChanges, - ViewEncapsulation -} from '@angular/core'; - -@Component({ - selector : 'tri-slider-step', - encapsulation: ViewEncapsulation.None, - template : ` -
- -
- ` -}) -export class SliderStepComponent implements OnInit, OnChanges { - // Dynamic properties - @Input() lowerBound: number = null; - @Input() upperBound: number = null; - - // Static properties - @Input() prefixCls: string; - @Input() vertical: boolean; - @Input() marksArray: any[]; - @Input() included: boolean; - - attrs: any; - - ngOnChanges(changes: SimpleChanges) { - if (changes.lowerBound || changes.upperBound) { - this.togglePointActive(); - } - } - - ngOnInit() { - const orient = this.vertical ? 'bottom' : 'left', - prefixCls = this.prefixCls; - this.attrs = this.marksArray.map(mark => { - const {value, offset} = mark; - return { - id : value, - value : value, - offset : offset, - style : { - [orient]: `${offset}%` - }, - classes: { - [`${prefixCls}-dot`] : true, - [`${prefixCls}-dot-active`]: false - } - }; - }); - this.togglePointActive(); - } - - trackById(index: number, attr) { - return attr.id; - } - - togglePointActive() { - const {prefixCls, attrs, lowerBound, upperBound, included} = this; - if (attrs && lowerBound !== null && upperBound !== null) { - attrs.forEach(attr => { - const value = attr.value, - isActive = (!included && value === upperBound) || (included && value <= upperBound && value >= lowerBound); - attr.classes[`${prefixCls}-dot-active`] = isActive; - }); - } - } -} diff --git a/libs/triangle/slider/src/slider-track.component.ts b/libs/triangle/slider/src/slider-track.component.ts deleted file mode 100644 index 8c0591afe..000000000 --- a/libs/triangle/slider/src/slider-track.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core'; - -@Component({ - selector : 'tri-slider-track', - encapsulation: ViewEncapsulation.None, - template : ` -
- ` -}) -export class SliderTrackComponent implements OnChanges { - // Dynamic properties - @Input() offset; - @Input() length; - - // Static properties - @Input() className; - @Input() vertical; - @Input() included; - - style: any = {}; - - ngOnChanges(changes: SimpleChanges) { - const {offset, length, included, vertical, style} = this; - if (changes.nzIncluded) { - style.visibility = included ? 'visible' : 'hidden'; - } - if (changes.nzVertical || changes.nzOffset || changes.nzLength) { - if (vertical) { - style.bottom = `${offset}%`; - style.height = `${length}%`; - } else { - style.left = `${offset}%`; - style.width = `${length}%`; - } - } - } -} diff --git a/libs/triangle/slider/src/slider.component.ts b/libs/triangle/slider/src/slider.component.ts deleted file mode 100644 index 0150d8f33..000000000 --- a/libs/triangle/slider/src/slider.component.ts +++ /dev/null @@ -1,656 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { - Component, - ElementRef, - EventEmitter, - forwardRef, - Input, - OnChanges, - OnDestroy, - OnInit, - Output, - SimpleChanges, - ViewChild, - ViewEncapsulation -} from '@angular/core'; -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { TRI_INTERNAL_SLIDER } from './slider.types'; -import { fromEvent, merge, Observable, Subscription } from 'rxjs'; -import { distinctUntilChanged, filter, map, pluck, takeUntil, tap } from 'rxjs/operators'; -import { Marks, MarksArray } from './slider-marks.component'; -import { SliderService } from './slider.service'; - -export type SliderValue = number[] | number; - -export class SliderHandle { - offset: number; - value: number; - active: boolean; -} - -@Component({ - selector : 'tri-slider', - encapsulation: ViewEncapsulation.None, - providers : [ - {provide: TRI_INTERNAL_SLIDER, useExisting: forwardRef(() => SliderComponent)}, - { - provide : NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => SliderComponent), - multi : true - } - ], - template : ` -
-
- - - - -
- ` -}) -export class SliderComponent implements ControlValueAccessor, OnInit, OnChanges, OnDestroy { - // Debugging - @Input() debugId: number | string = null; // set this id will print debug informations to console - - // Dynamic property settings - @Input() disabled = false; - - /** - * Static configurations (properties that can only specify once) - * 步长。取值必须大于 0,并且可被 (max - min) 整除。当 `marks` 不为空对象时,可以设置 `step` 为 `null` ,此时 Slider 的可选值仅有 marks 标出来的部分。 - */ - @Input() step = 1; - - /** - * The mark. - * 刻度标记。key 的类型必须为 `number` 且取值在闭区间 [min, max] 内,每个标签可以单独设置样式。 - */ - @Input() marks: Marks = null; - - /** - * Whether only can drag on dot - * 是否只能拖拽到刻度上 - */ - @Input() dots = false; - - /** - * Min value - * 最小值 - * @default 0 - */ - @Input() min = 0; - - /** - * Max value - * 最大值 - * @default 100 - */ - @Input() max = 100; - - /** - * Whether include - * 是否包含。 `marks` 不为空对象时有效,值为 true 时表示值为包含关系,false 表示并列 - */ - @Input() included = true; - /** - * Set default value - * 设置初始取值。当 `range` 为 `false` 时,使用 `number` ,否则用 `[number, number]` - */ - @Input() defaultValue: SliderValue = null; - - /** - * Format the tip - * Slider 会把当前值传给 `nzTipFormatter` ,并在 `Tooltip` 中显示 `nzTipFormatter` 的返回值,若为 `null` ,则隐藏 `Tooltip` 。 - */ - @Input() tipFormatter: Function; - - /** - * The event of on after change - */ - @Output() onAfterChange = new EventEmitter(); - value: SliderValue = null; // CORE value state - sliderDOM: any; - cacheSliderStart: number = null; - cacheSliderLength: number = null; - prefixCls = 'tri-slider'; - classMap: Object; - activeValueIndex: number = null; // Current activated handle's index ONLY for range=true - track = {offset: null, length: null}; // Track's offset and length - handles: SliderHandle[]; // Handles' offset - marksArray: MarksArray; // "marks" in array type with more data & FILTER out the invalid mark - bounds = {lower: null, upper: null}; // now for tri-slider-step - onValueChange: Function; // Used by ngModel. BUG: onValueChange() will not success to effect the "value" variable ( [(ngModel)]="value" ) when the first initializing, except using "nextTick" functionality (MAY angular2's problem ?) - isDragging = false; // Current dragging state - // Events observables & subscriptions - dragstart$: Observable; - dragmove$: Observable; - dragend$: Observable; - dragstart_: Subscription; - dragmove_: Subscription; - dragend_: Subscription; - @ViewChild('slider', {static: false}) private slider: ElementRef; - - constructor(private utils: SliderService) { - } - - // Inside properties - _range = false; - - /** - * Get range - * 获取 range - */ - get range() { - return this._range; - } - - /** - * Set this property, then enable double slider mode - * 当添加该属性时,启动双滑块模式 - * @param value - */ - @Input() - set range(value: boolean | string) { - if (value === '') { - this._range = true; - } else { - this._range = value as boolean; - } - } - - _vertical = false; - - /** - * Get whether vertical - * 获取是否坚直显示 - */ - get vertical(): boolean { - return this._vertical; - } - - // |-------------------------------------------------------------------------------------------- - // | value accessors & ngModel accessors - // |-------------------------------------------------------------------------------------------- - - /** - * Vertical display. when add this property, slider is vertical direction - * 竖直显示。添加该属性时,Slider 为垂直方向。 - * @param value - */ - @Input() - set vertical(value: boolean) { - this._vertical = value; - } - - setValue(val: SliderValue, isWriteValue: boolean = false) { - if (isWriteValue) { - // [ngModel-writeValue]: Formatting before setting value, always update current value, but trigger onValueChange ONLY when the "formatted value" not equals "input value" - this.value = this.formatValue(val); - this.log(`[ngModel:setValue/writeValue]Update track & handles`); - this.updateTrackAndHandles(); - // if (!this.isValueEqual(this.value, val)) { - // this.log(`[ngModel:setValue/writeValue]onValueChange`, val); - // if (this.onValueChange) { // NOTE: onValueChange will be unavailable when writeValue() called at the first time - // this.onValueChange(this.value); - // } - // } - } else { - // [Normal]: setting value, ONLY check changed, then update and trigger onValueChange - if (!this.isValueEqual(this.value, val)) { - this.value = val; - this.log(`[Normal:setValue]Update track & handles`); - this.updateTrackAndHandles(); - this.log(`[Normal:setValue]onValueChange`, val); - if (this.onValueChange) { - // NOTE: onValueChange will be unavailable when writeValue() called at the first time - this.onValueChange(this.value); - } - } - } - } - - getValue(cloneAndSort = false): SliderValue { - if (cloneAndSort && this.range) { - // clone & sort range values - return this.utils.cloneArray(this.value).sort((a, b) => a - b); - } - return this.value; - } - - // clone & sort current value and convert them to offsets, then return the new one - getValueToOffset(value?: SliderValue) { - if (typeof value === 'undefined') { - value = this.getValue(true); - } - return this.range ? (value).map(val => this.valueToOffset(val)) : this.valueToOffset(value); - } - - writeValue(val: SliderValue) { - // NOTE: writeValue will be called twice when initialized (may BUG? see: https://github.com/angular/angular/issues/14988), here we just ignore the first inited(the first the onValueChange will not registered) - if (typeof this.onValueChange !== 'function') { - return; - } // ignore the first initial call - this.log(`[ngModel/writeValue]current writing value = `, val); - this.setValue(val, true); - } - - registerOnChange(fn: Function) { - this.onValueChange = fn; - } - - registerOnTouched(fn) { - } - - // |-------------------------------------------------------------------------------------------- - // | Lifecycle hooks - // |-------------------------------------------------------------------------------------------- - - setDisabledState(isDisabled: boolean): void { - this.disabled = isDisabled; - this.toggleDragDisabled(isDisabled); - this.setClassMap(); - } - - // initialize event binding, class init, etc. (called only once) - ngOnInit() { - // initial checking - this.checkValidValue(this.defaultValue); // check nzDefaultValue - // default handles - this.handles = this._generateHandles(this.range ? 2 : 1); - // initialize - this.sliderDOM = this.slider.nativeElement; - if (this.getValue() === null) { - this.setValue(this.formatValue(null)); - } // init with default value - this.marksArray = this.marks === null ? null : this.toMarksArray(this.marks); - // event bindings - this.createDrag(); - // initialize drag's disabled status - this.toggleDragDisabled(this.disabled); - // the first time to init classes - this.setClassMap(); - } - - ngOnChanges(changes: SimpleChanges) { - const {disabled} = changes; - if (disabled && !disabled.firstChange) { - this.toggleDragDisabled(disabled.currentValue); - this.setClassMap(); - } - } - - ngOnDestroy() { - this.unsubscribeDrag(); - } - - // |-------------------------------------------------------------------------------------------- - // | Basic flow functions - // |-------------------------------------------------------------------------------------------- - - setClassMap() { - const {prefixCls, disabled, vertical, marksArray} = this; - this.classMap = { - [prefixCls] : true, - [`${prefixCls}-disabled`] : disabled, - [`${prefixCls}-vertical`] : vertical, - [`${prefixCls}-with-marks`]: marksArray ? marksArray.length : 0 - }; - } - - // find the cloest value to be activated (only for range = true) - setActiveValueIndex(pointerValue: number): void { - if (this.range) { - let minimal = null, - gap, - activeIndex; - (this.getValue()).forEach((val, index) => { - gap = Math.abs(pointerValue - val); - if (minimal === null || gap < minimal) { - minimal = gap; - activeIndex = index; - } - }); - this.activeValueIndex = activeIndex; - } - } - - setActiveValue(pointerValue: number) { - if (this.range) { - const newValue = this.utils.cloneArray(this.value); - newValue[this.activeValueIndex] = pointerValue; - this.setValue(newValue); - } else { - this.setValue(pointerValue); - } - } - - updateTrackAndHandles() { - const value = this.getValue(); - const offset = this.getValueToOffset(value); - const valueSorted = this.getValue(true); - const offsetSorted = this.getValueToOffset(valueSorted); - const boundParts = this.range ? valueSorted : [0, valueSorted]; - const trackParts = this.range ? [offsetSorted[0], offsetSorted[1] - offsetSorted[0]] : [0, offsetSorted]; - - this.handles.forEach((handle, index) => { - handle.offset = this.range ? offset[index] : offset; - handle.value = this.range ? value[index] : value; - }); - [this.bounds.lower, this.bounds.upper] = boundParts; - [this.track.offset, this.track.length] = trackParts; - } - - toMarksArray(marks) { - const {min, max} = this; - const marksArray = []; - for (const key in marks) { - const mark = marks[key]; - const val = typeof key === 'number' ? key : parseFloat(key); - if (val < min || val > max) { - continue; - } - marksArray.push({value: val, offset: this.valueToOffset(val), config: mark}); - } - return marksArray; - } - - // |-------------------------------------------------------------------------------------------- - // | Event listeners & bindings - // |-------------------------------------------------------------------------------------------- - - onDragStart(value: number) { - this.log('[onDragStart]dragging value = ', value); - this.toggleDragMoving(true); - // cache DOM layout/reflow operations - this.cacheSliderProperty(); - // trigger drag start - this.setActiveValueIndex(value); - this.setActiveValue(value); - // Tooltip visibility of handles - this._showHandleTooltip(this.range ? this.activeValueIndex : 0); - } - - onDragMove(value: number) { - this.log('[onDragMove]dragging value = ', value); - // trigger drag moving - this.setActiveValue(value); - } - - onDragEnd() { - this.log('[onDragEnd]'); - this.toggleDragMoving(false); - this.onAfterChange.emit(this.getValue(true)); - // remove cache DOM layout/reflow operations - this.cacheSliderProperty(true); - // Hide all tooltip - this._hideAllHandleTooltip(); - } - - createDrag() { - const sliderDOM = this.sliderDOM, - orientField = this.vertical ? 'pageY' : 'pageX', - mouse: any = { - start : 'mousedown', - move : 'mousemove', - end : 'mouseup', - pluckKey: [orientField] - }, - touch: any = { - start : 'touchstart', - move : 'touchmove', - end : 'touchend', - pluckKey: ['touches', '0', orientField], - filter : (e: MouseEvent | TouchEvent) => !this.utils.isNotTouchEvent(e) - }; - // make observables - [mouse, touch].forEach(source => { - const {start, move, end, pluckKey, filterFunc = ((value: any, index: number) => true) as any} = source; - // start - source.startPlucked$ = fromEvent(sliderDOM, start).pipe( - filter(filterFunc), - tap(this.utils.pauseEvent), - pluck(...pluckKey), - map((position: number) => this.findClosestValue(position)) - ); - // end - source.end$ = fromEvent(document, end); - // resolve move - source.moveResolved$ = fromEvent(document, move).pipe( - filter(filterFunc), - tap(this.utils.pauseEvent), - pluck(...pluckKey), - distinctUntilChanged(), - map((position: number) => this.findClosestValue(position)), - distinctUntilChanged(), - takeUntil(source.end$) - ); - // merge to become moving - // source.move$ = source.startPlucked$.mergeMapTo(source.moveResolved$); - }); - // merge mouse and touch observables - this.dragstart$ = merge(mouse.startPlucked$, touch.startPlucked$); - // this.dragmove$ = Observable.merge(mouse.move$, touch.move$); - this.dragmove$ = merge(mouse.moveResolved$, touch.moveResolved$); - this.dragend$ = merge(mouse.end$, touch.end$); - } - - subscribeDrag(periods = ['start', 'move', 'end']) { - this.log('[subscribeDrag]this.dragstart$ = ', this.dragstart$); - if (periods.indexOf('start') !== -1 && this.dragstart$ && !this.dragstart_) { - this.dragstart_ = this.dragstart$.subscribe(this.onDragStart.bind(this)); - } - - if (periods.indexOf('move') !== -1 && this.dragmove$ && !this.dragmove_) { - this.dragmove_ = this.dragmove$.subscribe(this.onDragMove.bind(this)); - } - - if (periods.indexOf('end') !== -1 && this.dragend$ && !this.dragend_) { - this.dragend_ = this.dragend$.subscribe(this.onDragEnd.bind(this)); - } - } - - unsubscribeDrag(periods = ['start', 'move', 'end']) { - this.log('[unsubscribeDrag]this.dragstart_ = ', this.dragstart_); - if (periods.indexOf('start') !== -1 && this.dragstart_) { - this.dragstart_.unsubscribe(); - this.dragstart_ = null; - } - - if (periods.indexOf('move') !== -1 && this.dragmove_) { - this.dragmove_.unsubscribe(); - this.dragmove_ = null; - } - - if (periods.indexOf('end') !== -1 && this.dragend_) { - this.dragend_.unsubscribe(); - this.dragend_ = null; - } - } - - toggleDragMoving(movable: boolean) { - const periods = ['move', 'end']; - if (movable) { - this.isDragging = true; - this.subscribeDrag(periods); - } else { - this.isDragging = false; - this.unsubscribeDrag(periods); - } - } - - toggleDragDisabled(disabled: boolean) { - if (disabled) { - this.unsubscribeDrag(); - } else { - this.subscribeDrag(['start']); - } - } - - // |-------------------------------------------------------------------------------------------- - // | Util functions (tools) - // |-------------------------------------------------------------------------------------------- - - // find the closest value depend on pointer's position - findClosestValue(position: number): number { - const {vertical, step, min, max, marks, dots, utils} = this, - sliderStart = this.getSliderStartPosition(), - sliderLength = this.getSliderLength(); - const ratio = utils.correctNumLimit((position - sliderStart) / sliderLength, 0, 1), - val = (max - min) * (vertical ? 1 - ratio : ratio) + min, - points = (marks === null ? [] : Object.keys(marks).map(parseFloat)) as Array; - // push closest step - if (step !== null && !dots) { - const closest = Math.round(val / step) * step; - points.push(closest); - } - // calculate gaps - const gaps = points.map(point => Math.abs(val - point)); - const closest = points[gaps.indexOf(Math.min(...gaps))]; - // return the fixed - return step === null ? closest : parseFloat(closest.toFixed(utils.getPrecision(step))); - } - - valueToOffset(value) { - return this.utils.valueToOffset(this.min, this.max, value); - } - - getSliderStartPosition() { - if (this.cacheSliderStart !== null) { - return this.cacheSliderStart; - } - const offset = this.utils.getElementOffset(this.sliderDOM); - return this.vertical ? offset.top : offset.left; - } - - getSliderLength() { - if (this.cacheSliderLength !== null) { - return this.cacheSliderLength; - } - const sliderDOM = this.sliderDOM; - return this.vertical ? sliderDOM.clientHeight : sliderDOM.clientWidth; - } - - // cache DOM layout/reflow operations for performance (may not necessary?) - cacheSliderProperty(remove: boolean = false) { - this.cacheSliderStart = remove ? null : this.getSliderStartPosition(); - this.cacheSliderLength = remove ? null : this.getSliderLength(); - } - - formatValue(value: SliderValue): SliderValue { - // NOTE: will return new value - if (!this.checkValidValue(value)) { - // if empty, use default value - value = this.defaultValue === null ? (this.range ? [this.min, this.max] : this.min) : this.defaultValue; - } else { - // format - value = this.range - ? (value).map(val => this.utils.correctNumLimit(val, this.min, this.max)) - : this.utils.correctNumLimit(value, this.min, this.max); - } - return value; - } - - // check if value is valid and throw error if value-type/range not match - checkValidValue(value) { - const range = this.range; - if (value === null || value === undefined) { - return false; - } // it's an invalid value, just return - const isArray = Array.isArray(value); - if (!isArray) { - if (typeof value !== 'number') { - value = parseFloat(value); - } - if (isNaN(value)) { - return false; - } // it's an invalid value, just return - } - if (isArray !== !!range) { - // value type not match - throw new Error( - `The "range" can't match the "value"'s type, please check these properties: "range", "value", "defaultValue".` - ); - } - return true; - } - - isValueEqual(value: SliderValue, val: SliderValue) { - if (typeof value !== typeof val) { - return false; - } - if (Array.isArray(value)) { - const len = (value).length; - for (let i = 0; i < len; i++) { - if (value[i] !== val[i]) { - return false; - } - } - return true; - } else { - return value === val; - } - } - - // print debug info - log(...messages: Array) { - if (this.debugId !== null) { - const args = [`[tri-slider][#${this.debugId}] `].concat(Array.prototype.slice.call(arguments)); - console.log(...args); - } - } - - // Show one handle's tooltip and hide others' - private _showHandleTooltip(handleIndex = 0) { - this.handles.forEach((handle, index) => { - this.handles[index].active = index === handleIndex; - }); - } - - private _hideAllHandleTooltip() { - this.handles.forEach(handle => (handle.active = false)); - } - - private _generateHandles(amount: number) { - const handles: SliderHandle[] = []; - for (let i = 0; i < amount; i++) { - handles.push({offset: null, value: null, active: false}); - } - return handles; - } -} diff --git a/libs/triangle/slider/src/slider.module.ts b/libs/triangle/slider/src/slider.module.ts deleted file mode 100644 index bab20e560..000000000 --- a/libs/triangle/slider/src/slider.module.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { TriTooltipModule } from '@gradii/triangle/tooltip'; -import { SliderHandleComponent } from './slider-handle.component'; -import { SliderMarksComponent } from './slider-marks.component'; -import { SliderStepComponent } from './slider-step.component'; -import { SliderTrackComponent } from './slider-track.component'; -import { SliderComponent } from './slider.component'; -import { SliderService } from './slider.service'; - -/** - * - # Slider滑动输入条 - * 滑动型输入器,展示当前值和可选范围。 - * ### 何时使用 - * 当用户需要在数值区间/自定义区间内进行选择时,可为连续或离散值。 - * ### 代码演示 - * 基本滑动条。当 `range` 为 `true` 时,渲染为双滑块。当 `disabled` 为 `true` 时,滑块处于不可用状态。 - * - * 滑块左右可以设置图标来表达业务含义。 - * - * 当 Slider 的值发生改变时,会更新 `ngModel` 所绑定的变量(可通过setter方式或绑定ngModelChange来监测此事件)。在 `onmouseup` 时,会触发 `onAfterChange` 事件,并把当前值作为参数传入。 - * - * 垂直方向的 Slider。 - * - * 和 数字输入框 组件保持同步。 - * - * 使用 `nzTipFormatter` 可以格式化 `Tooltip` 的内容,设置 `[nzTipFormatter]="null"` ,则隐藏 `Tooltip。` - * - * 使用 `marks` 属性标注分段式滑块,使用 `value` / `defaultValue` 指定滑块位置。当 `included=false` 时,表明不同标记间为并列关系。当 `step=null` 时,Slider 的可选值仅有 `marks` 标出来的部分。 - * - */ -@NgModule({ - exports : [ - SliderComponent, SliderTrackComponent, SliderHandleComponent, SliderStepComponent, - SliderMarksComponent - ], - declarations: [ - SliderComponent, - SliderTrackComponent, - SliderHandleComponent, - SliderStepComponent, - SliderMarksComponent - ], - imports : [CommonModule, TriTooltipModule], - providers : [SliderService] -}) -export class TriSliderModule { -} diff --git a/libs/triangle/slider/src/slider.service.ts b/libs/triangle/slider/src/slider.service.ts deleted file mode 100644 index 8aa70b772..000000000 --- a/libs/triangle/slider/src/slider.service.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { Injectable } from '@angular/core'; - -@Injectable() -export class SliderService { - pauseEvent(e) { - e.stopPropagation(); - e.preventDefault(); - } - - getPrecision(num) { - const numStr = num.toString(), - dotIndex = numStr.indexOf('.'); - return dotIndex >= 0 ? numStr.length - dotIndex - 1 : 0; - } - - cloneArray(arr: Array) { - return arr.slice(); - } - - isNotTouchEvent(e: TouchEvent) { - return !e.touches || e.touches.length > 1 || (e.type.toLowerCase() === 'touchend' && e.touches.length > 0); - } - - // convert value to offset in percent - valueToOffset(min, max, value: number) { - return (value - min) / (max - min) * 100; - } - - correctNumLimit(num, min, max) { - if (isNaN((num = +num))) { - return min; - } - if (num < min) { - num = min; - } else if (num > max) { - num = max; - } - return num; - } - - /** - * get the offset of an element relative to the document (Reference from jquery's offset()) - * @param elem HTMLElement ref - */ - getElementOffset(elem: HTMLElement) { - // Return zeros for disconnected and hidden (display: none) elements (gh-2310) - // Support: IE <=11 only - // Running getBoundingClientRect on a - // disconnected node in IE throws an error - if (!elem.getClientRects().length) { - return {top: 0, left: 0}; - } - // Get document-relative position by adding viewport scroll to viewport-relative gBCR - const rect = elem.getBoundingClientRect(), - win = elem.ownerDocument.defaultView; - return { - top : rect.top + win.pageYOffset, - left: rect.left + win.pageXOffset - }; - } -} diff --git a/libs/triangle/slider/src/slider.types.ts b/libs/triangle/slider/src/slider.types.ts deleted file mode 100644 index 887fdb87d..000000000 --- a/libs/triangle/slider/src/slider.types.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * - * Use of this source code is governed by an MIT-style license - */ - -import { InjectionToken } from '@angular/core'; - - -export const TRI_INTERNAL_SLIDER = new InjectionToken('tri slider'); diff --git a/libs/triangle/slider/style/_slider-theme.scss b/libs/triangle/slider/style/_slider-theme.scss deleted file mode 100644 index 9ecd02e28..000000000 --- a/libs/triangle/slider/style/_slider-theme.scss +++ /dev/null @@ -1,102 +0,0 @@ -@use "sass:color"; -@use "sass:map"; -@use "../../core/style/theming"; -@use "../../core/style/mixins"; -@use "../../core/style/variables" as v; - -$slider-prefix-cls : "#{ v.$tri-prefix}-slider"; - -@mixin tri-slider-theme($theme) { - $foreground : map.get($theme, foreground); - $background : map.get($theme, background); - - $primary : map.get($theme, primary); - - // slider color - $slider-disabled-color : theming.tri-color($foreground, disabled-color); - // tooltip - $slider-tooltip-color : #fff; - $slider-tooltip-bg : mixins.tint(theming.tri-color($foreground, text-color), 4%); - $slider-tooltip-arrow-color : $slider-tooltip-bg; - - .#{$slider-prefix-cls} { - @at-root &-rail { - border-radius : 2px; - background-color : theming.tri-color($foreground, border-color-split); - } - - @at-root &-track { - border-radius : v.$border-radius-base; - background-color : mixins.tint(theming.tri-color($primary), 60%); - } - - @at-root &-handle { - border : solid 2px mixins.tint(theming.tri-color($primary), 50%); - background-color : theming.tri-color($background, component-background); - - @at-root &:hover { - border-color : theming.tri-color($primary, 400); - } - - @at-root &:active { - box-shadow : 0 0 0 2px color.adjust(theming.tri-color($primary), $alpha : -0.8); - } - } - - @at-root &:hover { - .#{$slider-prefix-cls}-rail { - background-color : #e1e1e1; - } - - .#{$slider-prefix-cls}-track { - background-color : mixins.tint(theming.tri-color($primary), 40%); - } - - .#{$slider-prefix-cls}-handle { - border-color : theming.tri-color($primary, 400); - } - } - - @at-root &-mark-text { - color : theming.tri-color($foreground, text-color-secondary); - - @at-root &-active { - color : theming.tri-color($foreground, text-color); - } - } - - @at-root &-step { - background : transparent; - } - - @at-root &-dot { - border : 2px solid theming.tri-color($foreground, border-color-split); - background-color : theming.tri-color($background, component-background); - border-radius : 50%; - @at-root &-active { - border-color : mixins.tint(theming.tri-color($primary), 50%); - } - } - - @at-root &-disabled { - cursor : not-allowed; - - .#{$slider-prefix-cls}-track { - background-color : $slider-disabled-color !important; - } - - .#{$slider-prefix-cls}-handle, - .#{$slider-prefix-cls}-dot { - border-color : $slider-disabled-color !important; - background-color : theming.tri-color($background, component-background); - cursor : not-allowed; - box-shadow : none; - } - - .#{$slider-prefix-cls}-mark-text, - .#{$slider-prefix-cls}-dot { - cursor : not-allowed !important; - } - } - } -} diff --git a/libs/triangle/slider/style/slider.scss b/libs/triangle/slider/style/slider.scss deleted file mode 100644 index 7ad1d4dc2..000000000 --- a/libs/triangle/slider/style/slider.scss +++ /dev/null @@ -1,138 +0,0 @@ -@import "../../core/style/mixins"; -@import "../../core/style/variables"; - -$slider-prefix-cls : "#{$tri-prefix}-slider"; -// tooltip -$slider-tooltip-arrow-width : 0.25rem; -$slider-tooltip-distance : $slider-tooltip-arrow-width + 0.25rem; - -@mixin vertical() { - @at-root &-vertical { - width : 12px; - height : 100%; - margin : 6px 10px; - padding : 0 4px; - - .#{$slider-prefix-cls}-rail { - height : 100%; - width : 4px; - } - - .#{$slider-prefix-cls}-track { - width : 4px; - } - - .#{$slider-prefix-cls}-handle { - margin-left : -5px; - margin-bottom : -7px; - } - - .#{$slider-prefix-cls}-mark { - top : 0; - left : 12px; - width : 18px; - height : 100%; - } - - .#{$slider-prefix-cls}-mark-text { - left : 4px; - white-space : nowrap; - } - - .#{$slider-prefix-cls}-step { - width : 4px; - height : 100%; - } - - .#{$slider-prefix-cls}-dot { - top : auto; - left : 2px; - margin-bottom : -4px; - } - } -} - -.#{$slider-prefix-cls} { - position : relative; - margin : 10px 6px; - padding : 4px 0; - height : 12px; - cursor : pointer; - @include vertical(); - - @at-root &-with-marks { - margin-bottom : 28px; - } - - @at-root &-rail { - position : absolute; - width : 100%; - height : 4px; - border-radius : 2px; - transition : background-color 0.3s ease; - } - - @at-root &-track { - position : absolute; - height : 4px; - border-radius : $border-radius-base; - transition : background-color 0.3s ease; - } - - @at-root &-handle { - position : absolute; - margin-left : -7px; - margin-top : -5px; - width : 14px; - height : 14px; - cursor : pointer; - border-radius : 50%; - transition : border-color 0.3s ease, transform .3s cubic-bezier(0.18, 0.89, 0.32, 1.28); - - @at-root &:hover { - transform : scale(1.2); - transform-origin : center center; - } - - } - - @at-root &-mark { - position : absolute; - top : 14px; - left : 0; - width : 100%; - font-size : $font-size-base; - } - - @at-root &-mark-text { - position : absolute; - display : inline-block; - vertical-align : middle; - text-align : center; - cursor : pointer; - } - - @at-root &-step { - position : absolute; - width : 100%; - height : 4px; - background : transparent; - } - - @at-root &-dot { - position : absolute; - top : -2px; - margin-left : -4px; - width : 8px; - height : 8px; - cursor : pointer; - border-radius : 50%; - vertical-align : middle; - @at-root &:first-child { - margin-left : -4px; - } - @at-root &:last-child { - margin-left : -4px; - } - } -} diff --git a/libs/triangle/spin/ng-package.json b/libs/triangle/spin/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/spin/ng-package.json +++ b/libs/triangle/spin/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/splitter/ng-package.json b/libs/triangle/splitter/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/splitter/ng-package.json +++ b/libs/triangle/splitter/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/steps/ng-package.json b/libs/triangle/steps/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/steps/ng-package.json +++ b/libs/triangle/steps/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/switch/ng-package.json b/libs/triangle/switch/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/switch/ng-package.json +++ b/libs/triangle/switch/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tab-nav-bar/ng-package.json b/libs/triangle/tab-nav-bar/ng-package.json deleted file mode 100644 index 0a5bd5c3a..000000000 --- a/libs/triangle/tab-nav-bar/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file diff --git a/libs/triangle/tab-nav-bar/ng-package.json.bak b/libs/triangle/tab-nav-bar/ng-package.json.bak new file mode 100644 index 000000000..98773f3ee --- /dev/null +++ b/libs/triangle/tab-nav-bar/ng-package.json.bak @@ -0,0 +1,5 @@ +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tabs/ng-package.json b/libs/triangle/tabs/ng-package.json deleted file mode 100644 index 0a5bd5c3a..000000000 --- a/libs/triangle/tabs/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file diff --git a/libs/triangle/tabs/ng-package.json.bak b/libs/triangle/tabs/ng-package.json.bak new file mode 100644 index 000000000..98773f3ee --- /dev/null +++ b/libs/triangle/tabs/ng-package.json.bak @@ -0,0 +1,5 @@ +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tabs/src/paginated-tab-header.ts b/libs/triangle/tabs/src/paginated-tab-header.ts index 2b382b51d..340a57e37 100644 --- a/libs/triangle/tabs/src/paginated-tab-header.ts +++ b/libs/triangle/tabs/src/paginated-tab-header.ts @@ -23,8 +23,7 @@ import { NgZone, OnDestroy, Optional, - QueryList, - ɵmarkDirty + QueryList } from '@angular/core'; import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import { fromEvent, merge, of as observableOf, Subject, timer } from 'rxjs'; @@ -78,25 +77,25 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte abstract _nextPaginator: ElementRef; abstract _previousPaginator: ElementRef; /** Whether the controls for pagination should be displayed */ - _showPaginationControls = false; + _showPaginationControls = false; /** Whether the tab list can be scrolled more towards the end of the tab label list. */ - _disableScrollAfter = true; + _disableScrollAfter = true; /** Whether the tab list can be scrolled more towards the beginning of the tab label list. */ - _disableScrollBefore = true; + _disableScrollBefore = true; /** * Whether pagination should be disabled. This can be used to avoid unnecessary * layout recalculations if it's known that pagination won't be required. */ @Input() - disablePagination: boolean = false; + disablePagination: boolean = false; /** Event emitted when the option is selected. */ readonly selectFocusedIndex: EventEmitter = new EventEmitter(); /** Event emitted when a label is focused. */ - readonly indexFocused: EventEmitter = new EventEmitter(); + readonly indexFocused: EventEmitter = new EventEmitter(); /** Emits when the component is destroyed. */ - protected readonly _destroyed = new Subject(); + protected readonly _destroyed = new Subject(); /** Whether the header should scroll to the selected index after the view has been checked. */ - private _selectedIndexChanged = false; + private _selectedIndexChanged = false; /** * The number of tab labels that are displayed on the header. When this changes, the header * should re-evaluate the scroll position. @@ -109,7 +108,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte /** Cached text content of the header. */ private _currentTextContent: string; /** Stream that will stop the automated scrolling. */ - private _stopScrolling = new Subject(); + private _stopScrolling = new Subject(); constructor(protected _elementRef: ElementRef, protected _changeDetectorRef: ChangeDetectorRef, @@ -153,7 +152,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte if (this._selectedIndex != value) { this._selectedIndexChanged = true; - this._selectedIndex = value; + this._selectedIndex = value; if (this._keyManager) { this._keyManager.updateActiveItem(value); @@ -192,8 +191,8 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte ngAfterContentInit() { const dirChange = this._dir ? this._dir.change : observableOf(null); - const resize = this._viewportRuler.change(150); - const realign = () => { + const resize = this._viewportRuler.change(150); + const realign = () => { this.updatePagination(); this._alignInkBarToSelectedTab(); }; @@ -229,7 +228,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte if (this._tabLabelCount != this._items.length) { this.updatePagination(); this._tabLabelCount = this._items.length; - ɵmarkDirty(this); + this._changeDetectorRef.markForCheck(); } // If the selected index has changed, scroll to the label and check if the scrolling controls @@ -239,7 +238,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte this._checkScrollingControls(); this._alignInkBarToSelectedTab(); this._selectedIndexChanged = false; - ɵmarkDirty(this); + this._changeDetectorRef.markForCheck(); } // If the scroll distance has been changed (tab selected, focused, scroll controls activated), @@ -247,7 +246,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte if (this._scrollDistanceChanged) { this._updateTabScrollPosition(); this._scrollDistanceChanged = false; - ɵmarkDirty(this); + this._changeDetectorRef.markForCheck(); } } @@ -300,7 +299,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte this._ngZone.run(() => { this.updatePagination(); this._alignInkBarToSelectedTab(); - ɵmarkDirty(this); + this._changeDetectorRef.markForCheck(); }); } } @@ -347,7 +346,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte // by using translation. In LTR, the scroll left should be 0. In RTL, the scroll width // should be the full width minus the offset width. const containerEl = this._tabListContainer.nativeElement; - const dir = this._getLayoutDirection(); + const dir = this._getLayoutDirection(); if (dir == 'ltr') { containerEl.scrollLeft = 0; @@ -369,8 +368,8 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte } const scrollDistance = this.scrollDistance; - const platform = this._platform; - const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance; + const platform = this._platform; + const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance; // Don't use `translate3d` here because we don't want to create a new layer. A new layer // seems to cause flickering and overflow in Internet Explorer. For example, the ink bar @@ -431,20 +430,20 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte } // The view length is the visible width of the tab labels. - const viewLength = this._tabListContainer.nativeElement.offsetWidth; + const viewLength = this._tabListContainer.nativeElement.offsetWidth; const {offsetLeft, offsetWidth} = selectedLabel.elementRef.nativeElement; let labelBeforePos: number, labelAfterPos: number; if (this._getLayoutDirection() == 'ltr') { labelBeforePos = offsetLeft; - labelAfterPos = labelBeforePos + offsetWidth; + labelAfterPos = labelBeforePos + offsetWidth; } else { - labelAfterPos = this._tabList.nativeElement.offsetWidth - offsetLeft; + labelAfterPos = this._tabList.nativeElement.offsetWidth - offsetLeft; labelBeforePos = labelAfterPos - offsetWidth; } const beforeVisiblePos = this.scrollDistance; - const afterVisiblePos = this.scrollDistance + viewLength; + const afterVisiblePos = this.scrollDistance + viewLength; if (labelBeforePos < beforeVisiblePos) { // Scroll header to move label to the before direction @@ -475,7 +474,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte } if (isEnabled !== this._showPaginationControls) { - ɵmarkDirty(this); + this._changeDetectorRef.markForCheck(); } this._showPaginationControls = isEnabled; @@ -497,8 +496,8 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte } else { // Check if the pagination arrows should be activated. this._disableScrollBefore = this.scrollDistance == 0; - this._disableScrollAfter = this.scrollDistance == this._getMaxScrollDistance(); - ɵmarkDirty(this); + this._disableScrollAfter = this.scrollDistance == this._getMaxScrollDistance(); + this._changeDetectorRef.markForCheck(); } } @@ -511,13 +510,13 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte */ _getMaxScrollDistance(): number { const lengthOfTabList = this._tabList.nativeElement.scrollWidth; - const viewLength = this._tabListContainer.nativeElement.offsetWidth; + const viewLength = this._tabListContainer.nativeElement.offsetWidth; return (lengthOfTabList - viewLength) || 0; } /** Tells the ink-bar to align itself to the current label wrapper */ _alignInkBarToSelectedTab(): void { - const selectedItem = this._items && this._items.length ? + const selectedItem = this._items && this._items.length ? this._items.toArray()[this.selectedIndex] : null; const selectedLabelWrapper = selectedItem ? selectedItem.elementRef.nativeElement : null; @@ -576,7 +575,7 @@ export abstract class TriPaginatedTabHeader implements AfterContentChecked, Afte } const maxScrollDistance = this._getMaxScrollDistance(); - this._scrollDistance = Math.max(0, Math.min(maxScrollDistance, position)); + this._scrollDistance = Math.max(0, Math.min(maxScrollDistance, position)); // Mark that the scroll distance has changed so that after the view is checked, the CSS // transformation can move the header. diff --git a/libs/triangle/tabs/src/tab-group.ts b/libs/triangle/tabs/src/tab-group.ts index fedbce5e6..53fba2001 100644 --- a/libs/triangle/tabs/src/tab-group.ts +++ b/libs/triangle/tabs/src/tab-group.ts @@ -11,11 +11,11 @@ import { import { AfterContentChecked, AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, Optional, Output, - QueryList, ViewChild, ViewEncapsulation, ɵmarkDirty + QueryList, ViewChild, ViewEncapsulation } from '@angular/core'; import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import { - CanColor, CanColorCtor, CanDisableRipple, CanDisableRippleCtor, mixinColor, mixinDisableRipple, + CanColor, CanDisableRipple, mixinColor, mixinDisableRipple, ThemePalette, } from '@gradii/triangle/core'; import { merge, Subscription } from 'rxjs'; @@ -47,7 +47,7 @@ class TriTabGroupMixinBase { } } -const _TriTabGroupMixinBase: CanColorCtor & CanDisableRippleCtor & typeof TriTabGroupMixinBase = +const _TriTabGroupMixinBase: typeof TriTabGroupMixinBase = mixinColor(mixinDisableRipple(TriTabGroupMixinBase), 'primary'); interface TriTabGroupBaseHeader { diff --git a/libs/triangle/tabs/src/tab-label-wrapper.ts b/libs/triangle/tabs/src/tab-label-wrapper.ts index 89560070d..3cf0f8ba5 100644 --- a/libs/triangle/tabs/src/tab-label-wrapper.ts +++ b/libs/triangle/tabs/src/tab-label-wrapper.ts @@ -5,8 +5,8 @@ */ import { BooleanInput } from '@angular/cdk/coercion'; -import { Directive, ElementRef } from '@angular/core'; -import { CanDisable, CanDisableCtor, mixinDisabled } from '@gradii/triangle/core'; +import { booleanAttribute, Directive, ElementRef, Input } from '@angular/core'; +import { CanDisable } from '@gradii/triangle/core'; // Boilerplate for applying mixins to TriTabLabelWrapper. @@ -14,8 +14,8 @@ import { CanDisable, CanDisableCtor, mixinDisabled } from '@gradii/triangle/core class TriTabLabelWrapperBase { } -const _TriTabLabelWrapperMixinBase: CanDisableCtor & typeof TriTabLabelWrapperBase = - mixinDisabled(TriTabLabelWrapperBase); +const _TriTabLabelWrapperMixinBase: typeof TriTabLabelWrapperBase = + TriTabLabelWrapperBase; /** * Used in the `tri-tab-group` view to display tab labels. @@ -23,7 +23,6 @@ const _TriTabLabelWrapperMixinBase: CanDisableCtor & typeof TriTabLabelWrapperBa */ @Directive({ selector: '[triTabLabelWrapper]', - inputs : ['disabled'], host : { '[class.tri-tab-disabled]': 'disabled', '[attr.aria-disabled]' : '!!disabled', @@ -32,6 +31,8 @@ const _TriTabLabelWrapperMixinBase: CanDisableCtor & typeof TriTabLabelWrapperBa export class TriTabLabelWrapper extends _TriTabLabelWrapperMixinBase implements CanDisable { static ngAcceptInputType_disabled: BooleanInput; + @Input({transform: booleanAttribute}) disabled; + constructor(public elementRef: ElementRef) { super(); } diff --git a/libs/triangle/tag/ng-package.json b/libs/triangle/tag/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/tag/ng-package.json +++ b/libs/triangle/tag/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/time-picker/ng-package.json b/libs/triangle/time-picker/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/time-picker/ng-package.json +++ b/libs/triangle/time-picker/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/timeline/ng-package.json b/libs/triangle/timeline/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/timeline/ng-package.json +++ b/libs/triangle/timeline/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tooltip/ng-package.json b/libs/triangle/tooltip/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/tooltip/ng-package.json +++ b/libs/triangle/tooltip/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tooltip/src/tooltip-base.ts b/libs/triangle/tooltip/src/tooltip-base.ts index 5422df756..3ee1ebe5c 100644 --- a/libs/triangle/tooltip/src/tooltip-base.ts +++ b/libs/triangle/tooltip/src/tooltip-base.ts @@ -21,7 +21,7 @@ import { AfterViewInit, Directive, ElementRef, Inject, Input, NgZone, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core'; -import { isString } from '@gradii/check-type'; +import { isString } from '@gradii/nanofn'; import { DEFAULT_4_POSITIONS, POSITION_MAP_LTR, POSITION_MAP_RTL } from '@gradii/triangle/core'; import { Subject } from 'rxjs'; diff --git a/libs/triangle/tooltip/src/tooltip-component-base.ts b/libs/triangle/tooltip/src/tooltip-component-base.ts index dbaf33415..619f4bc8d 100644 --- a/libs/triangle/tooltip/src/tooltip-component-base.ts +++ b/libs/triangle/tooltip/src/tooltip-component-base.ts @@ -6,10 +6,10 @@ import { AnimationEvent } from '@angular/animations'; import { + ChangeDetectorRef, Directive, OnDestroy, - TemplateRef, - ɵmarkDirty + TemplateRef } from '@angular/core'; import { Observable, @@ -50,7 +50,7 @@ export abstract class _TriTooltipComponentBase implements OnDestroy { /** Subject for notifying that the tooltip has been hidden from the view */ protected readonly _onHide: Subject = new Subject(); - protected constructor() { + protected constructor(protected _cdRef: ChangeDetectorRef) { } /** @@ -137,6 +137,6 @@ export abstract class _TriTooltipComponentBase implements OnDestroy { * can be problematic in components with OnPush change detection. */ _markForCheck(): void { - ɵmarkDirty(this); + this._cdRef.markForCheck(); } } diff --git a/libs/triangle/tooltip/src/tooltip.component.ts b/libs/triangle/tooltip/src/tooltip.component.ts index 3600b7a48..f67e909a4 100644 --- a/libs/triangle/tooltip/src/tooltip.component.ts +++ b/libs/triangle/tooltip/src/tooltip.component.ts @@ -55,7 +55,8 @@ export class TooltipComponent extends _TriTooltipComponentBase { _isHandset: Observable = this._breakpointObserver.observe(Breakpoints.Handset); constructor( - private _breakpointObserver: BreakpointObserver) { - super(); + private _breakpointObserver: BreakpointObserver, + protected _cdRef: ChangeDetectorRef) { + super(_cdRef); } } diff --git a/libs/triangle/transfer/ng-package.json b/libs/triangle/transfer/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/transfer/ng-package.json +++ b/libs/triangle/transfer/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/transfer/src/transfer-list.component.ts b/libs/triangle/transfer/src/transfer-list.component.ts index c8f62c429..79e1da2a1 100644 --- a/libs/triangle/transfer/src/transfer-list.component.ts +++ b/libs/triangle/transfer/src/transfer-list.component.ts @@ -77,8 +77,8 @@ export class TransferListComponent implements OnChanges, OnInit, DoCheck { @Input() searchPlaceholder: string; @Input() notFoundContent: string; @Input() filterOption: (inputValue: string, item: TransferItem) => boolean; - @Input() render: TemplateRef; - @Input() footer: TemplateRef; + @Input() render: TemplateRef; + @Input() footer: TemplateRef; // events @Output() handleSelectAll: EventEmitter = new EventEmitter(); @Output() handleSelect: EventEmitter = new EventEmitter(); diff --git a/libs/triangle/tree-view/ng-package.json b/libs/triangle/tree-view/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/tree-view/ng-package.json +++ b/libs/triangle/tree-view/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tree-view/src/check.directive.ts b/libs/triangle/tree-view/src/check.directive.ts index c50ca9661..3014653fb 100644 --- a/libs/triangle/tree-view/src/check.directive.ts +++ b/libs/triangle/tree-view/src/check.directive.ts @@ -16,7 +16,7 @@ import { TreeItemLookup } from './treeitem-lookup.interface'; import { fetchLoadedDescendants, isBoolean, noop } from './utils'; import { filter, switchMap, take, tap } from 'rxjs/operators'; import { isChanged } from './helper/changes'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; export const indexChecked = (keys, index) => keys.filter(k => k === index).length > 0; export const matchKey = index => k => { diff --git a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-editing.directive.ts b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-editing.directive.ts index 330db64f9..cffb67406 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-editing.directive.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-editing.directive.ts @@ -8,7 +8,7 @@ import { Directive, Input, OnDestroy } from '@angular/core'; import { TreeViewComponent } from '../treeview.component'; import { EditService } from './models'; import { Subscription } from 'rxjs'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Directive({ selector: '[triTreeViewDragAndDropEditing]' diff --git a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-utils.ts b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-utils.ts index 334cab551..ce0b6aeb4 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-utils.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop-utils.ts @@ -8,7 +8,7 @@ import { DropAction, DropPosition, ScrollDirection } from './models'; import { closestNode, closestWithMatch, getContentElement, hasParent, isContent, nodeId } from '../utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** * Checks if the browser supports relative stacking context. diff --git a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop.directive.ts b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop.directive.ts index 4feb46ee6..8fcd2211b 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop.directive.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/drag-and-drop.directive.ts @@ -30,7 +30,7 @@ import { import { closestWithMatch, isContent } from '../utils'; import { Draggable } from '@gradii/triangle/draggable'; import { hasObservers } from '../helper/has-observers'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; const DEFAULT_SCROLL_SETTINGS = { enabled : true, diff --git a/libs/triangle/tree-view/src/drag-and-drop/drag-clue/drag-clue.service.ts b/libs/triangle/tree-view/src/drag-and-drop/drag-clue/drag-clue.service.ts index 416b891ea..83c8166f2 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/drag-clue/drag-clue.service.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/drag-clue/drag-clue.service.ts @@ -13,7 +13,7 @@ import { DragAndDropAssetService } from '../editing-services/drag-and-drop-asset import { TreeItemLookup } from '../../treeitem-lookup.interface'; import { dataItemsEqual } from '../../utils'; import { getScrollableContainer, scrollElementBy } from '../drag-and-drop-utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** * @hidden diff --git a/libs/triangle/tree-view/src/drag-and-drop/drop-hint/drop-hint.service.ts b/libs/triangle/tree-view/src/drag-and-drop/drop-hint/drop-hint.service.ts index 9d62311fb..ba5fef7cf 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/drop-hint/drop-hint.service.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/drop-hint/drop-hint.service.ts @@ -10,7 +10,7 @@ import { DragAndDropAssetService } from '../editing-services/drag-and-drop-asset import { DropAction } from '../models'; import { TreeItemLookup } from '../../treeitem-lookup.interface'; import { dataItemsEqual } from '../../utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Injectable() export class DropHintService extends DragAndDropAssetService { diff --git a/libs/triangle/tree-view/src/drag-and-drop/editing-services/drag-and-drop-asset.service.ts b/libs/triangle/tree-view/src/drag-and-drop/editing-services/drag-and-drop-asset.service.ts index f315aeecc..f246dd929 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/editing-services/drag-and-drop-asset.service.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/editing-services/drag-and-drop-asset.service.ts @@ -5,7 +5,7 @@ */ import { ComponentRef, Injectable, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** * @hidden diff --git a/libs/triangle/tree-view/src/drag-and-drop/editing-services/flat-editing.service.ts b/libs/triangle/tree-view/src/drag-and-drop/editing-services/flat-editing.service.ts index 683e519b3..3e89e2504 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/editing-services/flat-editing.service.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/editing-services/flat-editing.service.ts @@ -11,7 +11,7 @@ import { take } from 'rxjs/operators'; import { collapseEmptyParent, expandDropTarget, updateMovedItemIndex } from '../drag-and-drop-utils'; import { copyPageSize, decrementPageSize, incrementPageSize } from '../../load-more/load-more-utils'; import { buildTreeIndex, getDataItem } from '../../utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** * @hidden diff --git a/libs/triangle/tree-view/src/drag-and-drop/editing-services/hierarchy-editing.service.ts b/libs/triangle/tree-view/src/drag-and-drop/editing-services/hierarchy-editing.service.ts index 426905cf3..73cea0eca 100644 --- a/libs/triangle/tree-view/src/drag-and-drop/editing-services/hierarchy-editing.service.ts +++ b/libs/triangle/tree-view/src/drag-and-drop/editing-services/hierarchy-editing.service.ts @@ -4,7 +4,7 @@ * Use of this source code is governed by an MIT-style license */ -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; import { getter, setter } from '@gradii/nanofn'; import { HierarchyBindingDirective } from '../../hierarchy-binding.directive'; import { copyPageSize, decrementPageSize, incrementPageSize } from '../../load-more/load-more-utils'; diff --git a/libs/triangle/tree-view/src/filtering-base.ts b/libs/triangle/tree-view/src/filtering-base.ts index e02e5e9f5..f84988fbf 100644 --- a/libs/triangle/tree-view/src/filtering-base.ts +++ b/libs/triangle/tree-view/src/filtering-base.ts @@ -9,7 +9,7 @@ import { TreeItemFilterState } from './drag-and-drop/models/tree-item-filter-sta import { DEFAULT_FILTER_SETTINGS, TreeViewFilterSettings } from './treeview-filter-settings'; import { Injectable, Input } from '@angular/core'; import { filterTree } from './utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** * @hidden diff --git a/libs/triangle/tree-view/src/flat-binding.directive.ts b/libs/triangle/tree-view/src/flat-binding.directive.ts index 44601fd2b..c2c320758 100644 --- a/libs/triangle/tree-view/src/flat-binding.directive.ts +++ b/libs/triangle/tree-view/src/flat-binding.directive.ts @@ -15,7 +15,7 @@ import { FlatEditingService } from './drag-and-drop/editing-services/flat-editin import { IndexBuilderService } from './index-builder.service'; import { anyChanged, isChanged } from './helper/changes'; import { getter } from '@gradii/triangle/data-query'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; export const findChildren = (prop, nodes, value) => nodes.filter((x) => prop(x) === value); const indexBuilder = new IndexBuilderService(); diff --git a/libs/triangle/tree-view/src/hierarchy-binding.directive.ts b/libs/triangle/tree-view/src/hierarchy-binding.directive.ts index 7e0bac414..cc4dfaaee 100644 --- a/libs/triangle/tree-view/src/hierarchy-binding.directive.ts +++ b/libs/triangle/tree-view/src/hierarchy-binding.directive.ts @@ -18,7 +18,7 @@ import { import { isVisible } from './default-callbacks'; import { IndexBuilderService } from './index-builder.service'; import { anyChanged, isChanged } from './helper/changes'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; const indexBuilder = new IndexBuilderService(); diff --git a/libs/triangle/tree-view/src/load-more/load-more-utils.ts b/libs/triangle/tree-view/src/load-more/load-more-utils.ts index cbcb4ac7d..607de28e1 100644 --- a/libs/triangle/tree-view/src/load-more/load-more-utils.ts +++ b/libs/triangle/tree-view/src/load-more/load-more-utils.ts @@ -4,7 +4,7 @@ * Use of this source code is governed by an MIT-style license */ -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; /** diff --git a/libs/triangle/tree-view/src/load-more/load-more.directive.ts b/libs/triangle/tree-view/src/load-more/load-more.directive.ts index 31af3e7d2..0926bdcc6 100644 --- a/libs/triangle/tree-view/src/load-more/load-more.directive.ts +++ b/libs/triangle/tree-view/src/load-more/load-more.directive.ts @@ -9,7 +9,7 @@ import { TreeViewComponent } from '../treeview.component'; import { LoadMoreRequestArgs } from './load-more-request-args'; import { Directive, Input, isDevMode } from '@angular/core'; import { v4 as uuid } from 'uuid'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Directive({ selector: '[triTreeViewLoadMore]' diff --git a/libs/triangle/tree-view/src/navigation/navigation-model.ts b/libs/triangle/tree-view/src/navigation/navigation-model.ts index 08c8a53ef..9c15b8f45 100644 --- a/libs/triangle/tree-view/src/navigation/navigation-model.ts +++ b/libs/triangle/tree-view/src/navigation/navigation-model.ts @@ -6,7 +6,7 @@ import { NavigationItem } from './navigation-item.interface'; import { IndexBuilderService } from '../index-builder.service'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; export const safe = node => (node || {}); export const safeChildren = node => (safe(node).children || []); diff --git a/libs/triangle/tree-view/src/navigation/navigation.service.ts b/libs/triangle/tree-view/src/navigation/navigation.service.ts index 59aba77e2..058d8ca94 100644 --- a/libs/triangle/tree-view/src/navigation/navigation.service.ts +++ b/libs/triangle/tree-view/src/navigation/navigation.service.ts @@ -11,7 +11,7 @@ import { NavigationModel } from './navigation-model'; import { NavigationState } from './navigation-state.interface'; import { Injectable } from '@angular/core'; import { nodeIndex } from '../utils'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Injectable() export class NavigationService { diff --git a/libs/triangle/tree-view/src/selection/select.directive.ts b/libs/triangle/tree-view/src/selection/select.directive.ts index 055031056..72837273e 100644 --- a/libs/triangle/tree-view/src/selection/select.directive.ts +++ b/libs/triangle/tree-view/src/selection/select.directive.ts @@ -19,7 +19,7 @@ import { Subscription } from 'rxjs'; import { TreeItem } from '../treeitem.interface'; import { isBoolean, noop } from '../utils'; import { isChanged } from '../helper/changes'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Directive({selector: '[triTreeViewSelectable]'}) export class SelectDirective implements OnDestroy, OnChanges { diff --git a/libs/triangle/tree-view/src/shared.module.ts b/libs/triangle/tree-view/src/shared.module.ts index 0f6a3dd67..0d805ddc4 100644 --- a/libs/triangle/tree-view/src/shared.module.ts +++ b/libs/triangle/tree-view/src/shared.module.ts @@ -65,10 +65,6 @@ const COMPONENT_DIRECTIVES = [ TriInputModule, TriCheckboxModule, TriIconModule, - ], - entryComponents: [ - DragClueComponent, - DropHintComponent ] }) export class SharedModule { diff --git a/libs/triangle/tree-view/src/treeview-group.component.ts b/libs/triangle/tree-view/src/treeview-group.component.ts index 518b129a4..fd491842f 100644 --- a/libs/triangle/tree-view/src/treeview-group.component.ts +++ b/libs/triangle/tree-view/src/treeview-group.component.ts @@ -30,7 +30,7 @@ import { animate, style, transition, trigger } from '@angular/animations'; import { getter } from '@gradii/nanofn'; import { isArray } from './utils'; import { catchError, filter, finalize, tap } from 'rxjs/operators'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; @Component({ animations: [ diff --git a/libs/triangle/tree-view/src/treeview-item.directive.ts b/libs/triangle/tree-view/src/treeview-item.directive.ts index 3a86f409e..a7aa46b8c 100644 --- a/libs/triangle/tree-view/src/treeview-item.directive.ts +++ b/libs/triangle/tree-view/src/treeview-item.directive.ts @@ -24,7 +24,7 @@ import { TreeItem } from './treeitem.interface'; import { CheckedState } from './checkbox/checked-state'; import { filter } from 'rxjs/operators'; import { anyChanged } from './helper/changes'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; export const buildItem = (index, dataItem) => ({dataItem, index}); let id = 0; diff --git a/libs/triangle/tree-view/src/treeview.component.ts b/libs/triangle/tree-view/src/treeview.component.ts index e42f954bb..8fdca3f27 100644 --- a/libs/triangle/tree-view/src/treeview.component.ts +++ b/libs/triangle/tree-view/src/treeview.component.ts @@ -72,7 +72,7 @@ import { import { anyChanged } from './helper/changes'; import { hasObservers } from './helper/has-observers'; import { Directionality } from '@angular/cdk/bidi'; -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; const providers = [ ExpandStateService, diff --git a/libs/triangle/tree-view/src/utils.ts b/libs/triangle/tree-view/src/utils.ts index ff974055c..fde317b61 100644 --- a/libs/triangle/tree-view/src/utils.ts +++ b/libs/triangle/tree-view/src/utils.ts @@ -4,7 +4,7 @@ * Use of this source code is governed by an MIT-style license */ -import { isPresent } from '@gradii/check-type'; +import { isPresent } from '@gradii/nanofn'; import { getter } from '@gradii/nanofn'; import { TreeViewFilterSettings } from './treeview-filter-settings'; diff --git a/libs/triangle/tree/ng-package.json b/libs/triangle/tree/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/tree/ng-package.json +++ b/libs/triangle/tree/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/libs/triangle/tsconfig.json b/libs/triangle/tsconfig.json index 260fcee1d..5451dc5ca 100644 --- a/libs/triangle/tsconfig.json +++ b/libs/triangle/tsconfig.json @@ -18,7 +18,8 @@ "strict": true, "noImplicitReturns": false, "noFallthroughCasesInSwitch": true, - "noImplicitAny": false + "noImplicitAny": false, + "useDefineForClassFields": false }, "angularCompilerOptions": { "strictInjectionParameters": true, diff --git a/libs/triangle/util/ng-package.json b/libs/triangle/util/ng-package.json index 0a5bd5c3a..98773f3ee 100644 --- a/libs/triangle/util/ng-package.json +++ b/libs/triangle/util/ng-package.json @@ -1,5 +1,5 @@ - { - "lib": { - "entryFile": "public-api.ts" - } - } \ No newline at end of file +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 2e4e81c47..bb270cccc 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,8 @@ "@angular/platform-server": "~17.3.0", "@angular/router": "~17.3.0", "@angular/ssr": "~17.3.0", + "@gradii/nanofn": "^1.0.6", + "@gradii/vector-math": "^1.0.0", "@nestjs/common": "^8.0.0", "@nestjs/core": "^8.0.0", "@nestjs/platform-express": "^8.0.0", diff --git a/tsconfig.base.json b/tsconfig.base.json index 84a6d0e08..73a9d3fd2 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -40,7 +40,6 @@ "@gradii/diagram/*": ["src/diagram/*/public-api.ts"], "@gradii/fedaco": ["libs/fedaco/index.ts"], "@gradii/injection": ["src/injection/public-api.ts"], - "@gradii/nanofn": ["libs/nanofn/public-api.ts"], "@gradii/stove": ["libs/stove/index.ts"], "@gradii/triangle": ["libs/triangle/index.ts"], "@gradii/triangle-icons": ["libs/triangle-icons/index.ts"], diff --git a/yarn.lock b/yarn.lock index 415fb76e0..8fbba569e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2476,6 +2476,20 @@ p-defer "^3.0.0" protobufjs "^6.8.1" +"@gradii/nanofn@^1.0.6": + version "1.0.6" + resolved "https://registry.npmmirror.com/@gradii/nanofn/-/nanofn-1.0.6.tgz#d3b7dbf9a5e7fc5afdf028c04a8d45eeea1ba9bf" + integrity sha512-W5BWYVQzJw3I10Sthj33CuQt1cmOGsDc8M47EqlM+7hpyxBZrY5CVG0FsY/S5L1VZjmmJ558xMG029wYr2xPxw== + dependencies: + tslib "^2.3.0" + +"@gradii/vector-math@^1.0.0": + version "1.0.0" + resolved "https://registry.npmmirror.com/@gradii/vector-math/-/vector-math-1.0.0.tgz#b1c740b9356ccd6bf7428e08f702dc3df500971d" + integrity sha512-vbpP7cn0StwkHcj0KDyjCN7Kor7IoFkfLB1l8mcLc8g6qy3r/biJ4Xfpbh360Tmu+WJRJkAbwPZ25hK6AmAiAQ== + dependencies: + tslib "^2.3.0" + "@grpc/grpc-js@^0.6.12": version "0.6.18" resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-0.6.18.tgz#ba3b3dfef869533161d192a385412a4abd0db127"