├── .browserlistrc
├── .editorconfig
├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── dictionaries
│ └── Eric.xml
├── encodings.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── micro-dash-platform.iml
├── misc.xml
├── modules.xml
├── runConfigurations
│ ├── Calc_Sizes.xml
│ ├── Docs.xml
│ ├── E2E.xml
│ ├── Lib__Build.xml
│ ├── Lib__Test_server.xml
│ ├── Lib__dtslint.xml
│ └── Tests.xml
├── vcs.xml
└── watcherTasks.xml
├── .prettierignore
├── .travis.yml
├── .vscode
└── settings.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── README.md
├── TODO.md
├── angular.json
├── docs
└── typedoc
│ └── index.html
├── e2e
├── protractor-ci.conf.js
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.json
├── karma.conf.js
├── package.json
├── projects
├── calc-sizes
│ ├── browserslist
│ ├── calc-sizes.ts
│ ├── src
│ │ ├── app
│ │ │ ├── array
│ │ │ │ ├── chunk.lodash.ts
│ │ │ │ ├── chunk.microdash.ts
│ │ │ │ ├── compact.lodash.ts
│ │ │ │ ├── compact.microdash.ts
│ │ │ │ ├── concat.lodash.ts
│ │ │ │ ├── concat.microdash.ts
│ │ │ │ ├── difference.lodash.ts
│ │ │ │ ├── difference.microdash.ts
│ │ │ │ ├── flatten.lodash.ts
│ │ │ │ ├── flatten.microdash.ts
│ │ │ │ ├── initial.lodash.ts
│ │ │ │ ├── initial.microdash.ts
│ │ │ │ ├── last.lodash.ts
│ │ │ │ ├── last.microdash.ts
│ │ │ │ ├── pull-all.lodash.ts
│ │ │ │ ├── pull-all.microdash.ts
│ │ │ │ ├── pull-at.lodash.ts
│ │ │ │ ├── pull-at.microdash.ts
│ │ │ │ ├── pull.lodash.ts
│ │ │ │ ├── pull.microdash.ts
│ │ │ │ ├── remove.lodash.ts
│ │ │ │ ├── remove.microdash.ts
│ │ │ │ ├── sorted-index.lodash.ts
│ │ │ │ ├── sorted-index.microdash.ts
│ │ │ │ ├── union.lodash.ts
│ │ │ │ ├── union.microdash.ts
│ │ │ │ ├── uniq-by.lodash.ts
│ │ │ │ ├── uniq-by.microdash.ts
│ │ │ │ ├── uniq.lodash.ts
│ │ │ │ ├── uniq.microdash.ts
│ │ │ │ ├── without.lodash.ts
│ │ │ │ ├── without.microdash.ts
│ │ │ │ ├── zip-object.lodash.ts
│ │ │ │ ├── zip-object.microdash.ts
│ │ │ │ ├── zip.lodash.ts
│ │ │ │ └── zip.microdash.ts
│ │ │ ├── collection
│ │ │ │ ├── every.lodash.ts
│ │ │ │ ├── every.microdash.ts
│ │ │ │ ├── filter.lodash.ts
│ │ │ │ ├── filter.microdash.ts
│ │ │ │ ├── find.lodash.ts
│ │ │ │ ├── find.microdash.ts
│ │ │ │ ├── flat-map.lodash.ts
│ │ │ │ ├── flat-map.microdash.ts
│ │ │ │ ├── for-each-right.lodash.ts
│ │ │ │ ├── for-each-right.microdash.ts
│ │ │ │ ├── for-each.lodash.ts
│ │ │ │ ├── for-each.microdash.ts
│ │ │ │ ├── group-by.lodash.ts
│ │ │ │ ├── group-by.microdash.ts
│ │ │ │ ├── includes.lodash.ts
│ │ │ │ ├── includes.microdash.ts
│ │ │ │ ├── key-by.lodash.ts
│ │ │ │ ├── key-by.microdash.ts
│ │ │ │ ├── map.lodash.ts
│ │ │ │ ├── map.microdash.ts
│ │ │ │ ├── reduce-right.lodash.ts
│ │ │ │ ├── reduce-right.microdash.ts
│ │ │ │ ├── reduce.lodash.ts
│ │ │ │ ├── reduce.microdash.ts
│ │ │ │ ├── sample.lodash.ts
│ │ │ │ ├── sample.microdash.ts
│ │ │ │ ├── size.lodash.ts
│ │ │ │ ├── size.microdash.ts
│ │ │ │ ├── some.lodash.ts
│ │ │ │ ├── some.microdash.ts
│ │ │ │ ├── sort-by.lodash.ts
│ │ │ │ └── sort-by.microdash.ts
│ │ │ ├── function
│ │ │ │ ├── bind-key.lodash.ts
│ │ │ │ ├── bind-key.microdash.ts
│ │ │ │ ├── curry.lodash.ts
│ │ │ │ ├── curry.microdash.ts
│ │ │ │ ├── debounce.lodash.ts
│ │ │ │ ├── debounce.microdash.ts
│ │ │ │ ├── memoize.lodash.ts
│ │ │ │ ├── memoize.microdash.ts
│ │ │ │ ├── once.lodash.ts
│ │ │ │ ├── once.microdash.ts
│ │ │ │ ├── partial.lodash.ts
│ │ │ │ ├── partial.microdash.ts
│ │ │ │ ├── throttle.lodash.ts
│ │ │ │ └── throttle.microdash.ts
│ │ │ ├── lang
│ │ │ │ ├── cast-array.lodash.ts
│ │ │ │ ├── cast-array.microdash.ts
│ │ │ │ ├── clone-deep.lodash.ts
│ │ │ │ ├── clone-deep.microdash.ts
│ │ │ │ ├── clone.lodash.ts
│ │ │ │ ├── clone.microdash.ts
│ │ │ │ ├── is-boolean.lodash.ts
│ │ │ │ ├── is-boolean.microdash.ts
│ │ │ │ ├── is-empty.lodash.ts
│ │ │ │ ├── is-empty.microdash.ts
│ │ │ │ ├── is-equal.lodash.ts
│ │ │ │ ├── is-equal.microdash.ts
│ │ │ │ ├── is-function.lodash.ts
│ │ │ │ ├── is-function.microdash.ts
│ │ │ │ ├── is-match.lodash.ts
│ │ │ │ ├── is-match.microdash.ts
│ │ │ │ ├── is-nil.lodash.ts
│ │ │ │ ├── is-nil.microdash.ts
│ │ │ │ ├── is-number.lodash.ts
│ │ │ │ ├── is-number.microdash.ts
│ │ │ │ ├── is-reg-exp.lodash.ts
│ │ │ │ ├── is-reg-exp.microdash.ts
│ │ │ │ ├── is-string.lodash.ts
│ │ │ │ ├── is-string.microdash.ts
│ │ │ │ ├── is-undefined.lodash.ts
│ │ │ │ ├── is-undefined.microdash.ts
│ │ │ │ ├── to-array.lodash.ts
│ │ │ │ ├── to-array.microdash.ts
│ │ │ │ ├── to-string.lodash.ts
│ │ │ │ └── to-string.microdash.ts
│ │ │ ├── math
│ │ │ │ ├── max-by.lodash.ts
│ │ │ │ ├── max-by.microdash.ts
│ │ │ │ ├── min-by.lodash.ts
│ │ │ │ ├── min-by.microdash.ts
│ │ │ │ ├── random.lodash.ts
│ │ │ │ ├── random.microdash.ts
│ │ │ │ ├── round.lodash.ts
│ │ │ │ ├── round.microdash.ts
│ │ │ │ ├── sum-by.lodash.ts
│ │ │ │ └── sum-by.microdash.ts
│ │ │ ├── number
│ │ │ │ ├── clamp.lodash.ts
│ │ │ │ ├── clamp.microdash.ts
│ │ │ │ ├── in-range.lodash.ts
│ │ │ │ └── in-range.microdash.ts
│ │ │ ├── object
│ │ │ │ ├── find-key.lodash.ts
│ │ │ │ ├── find-key.microdash.ts
│ │ │ │ ├── for-own-right.lodash.ts
│ │ │ │ ├── for-own-right.microdash.ts
│ │ │ │ ├── for-own.lodash.ts
│ │ │ │ ├── for-own.microdash.ts
│ │ │ │ ├── functions.lodash.ts
│ │ │ │ ├── functions.microdash.ts
│ │ │ │ ├── get.lodash.ts
│ │ │ │ ├── get.microdash.ts
│ │ │ │ ├── invoke.lodash.ts
│ │ │ │ ├── invoke.microdash.ts
│ │ │ │ ├── keys.lodash.ts
│ │ │ │ ├── keys.microdash.ts
│ │ │ │ ├── map-values.lodash.ts
│ │ │ │ ├── map-values.microdash.ts
│ │ │ │ ├── merge.lodash.ts
│ │ │ │ ├── merge.microdash.ts
│ │ │ │ ├── omit-by.lodash.ts
│ │ │ │ ├── omit-by.microdash.ts
│ │ │ │ ├── omit.lodash.ts
│ │ │ │ ├── omit.microdash.ts
│ │ │ │ ├── pick-by.lodash.ts
│ │ │ │ ├── pick-by.microdash.ts
│ │ │ │ ├── pick.lodash.ts
│ │ │ │ ├── pick.microdash.ts
│ │ │ │ ├── set.lodash.ts
│ │ │ │ ├── set.microdash.ts
│ │ │ │ ├── to-pairs.lodash.ts
│ │ │ │ ├── to-pairs.microdash.ts
│ │ │ │ ├── transform.lodash.ts
│ │ │ │ ├── transform.microdash.ts
│ │ │ │ ├── update.lodash.ts
│ │ │ │ ├── update.microdash.ts
│ │ │ │ ├── values.lodash.ts
│ │ │ │ └── values.microdash.ts
│ │ │ ├── string
│ │ │ │ ├── camel-case.lodash.ts
│ │ │ │ ├── camel-case.microdash.ts
│ │ │ │ ├── capitalize.lodash.ts
│ │ │ │ ├── capitalize.microdash.ts
│ │ │ │ ├── kebab-case.lodash.ts
│ │ │ │ ├── kebab-case.microdash.ts
│ │ │ │ ├── lower-first.lodash.ts
│ │ │ │ ├── lower-first.microdash.ts
│ │ │ │ ├── pad-end.lodash.ts
│ │ │ │ ├── pad-end.microdash.ts
│ │ │ │ ├── pad-start.lodash.ts
│ │ │ │ ├── pad-start.microdash.ts
│ │ │ │ ├── pad.lodash.ts
│ │ │ │ ├── pad.microdash.ts
│ │ │ │ ├── repeat.lodash.ts
│ │ │ │ ├── repeat.microdash.ts
│ │ │ │ ├── snake-case.lodash.ts
│ │ │ │ ├── snake-case.microdash.ts
│ │ │ │ ├── to-lower.lodash.ts
│ │ │ │ ├── to-lower.microdash.ts
│ │ │ │ ├── upper-first.lodash.ts
│ │ │ │ ├── upper-first.microdash.ts
│ │ │ │ ├── words.lodash.ts
│ │ │ │ └── words.microdash.ts
│ │ │ └── util
│ │ │ │ ├── constant.lodash.ts
│ │ │ │ ├── constant.microdash.ts
│ │ │ │ ├── flow-right.lodash.ts
│ │ │ │ ├── flow-right.microdash.ts
│ │ │ │ ├── flow.lodash.ts
│ │ │ │ ├── flow.microdash.ts
│ │ │ │ ├── identity.lodash.ts
│ │ │ │ ├── identity.microdash.ts
│ │ │ │ ├── matches.lodash.ts
│ │ │ │ ├── matches.microdash.ts
│ │ │ │ ├── noop.lodash.ts
│ │ │ │ ├── noop.microdash.ts
│ │ │ │ ├── range.lodash.ts
│ │ │ │ ├── range.microdash.ts
│ │ │ │ ├── times.lodash.ts
│ │ │ │ ├── times.microdash.ts
│ │ │ │ ├── unique-id.lodash.ts
│ │ │ │ └── unique-id.microdash.ts
│ │ ├── index.html
│ │ └── main.ts
│ └── tsconfig.app.json
└── micro-dash
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src
│ ├── lib
│ │ ├── array
│ │ │ ├── chunk.spec.ts
│ │ │ ├── chunk.ts
│ │ │ ├── compact.spec.ts
│ │ │ ├── compact.ts
│ │ │ ├── concat.spec.ts
│ │ │ ├── concat.ts
│ │ │ ├── difference.spec.ts
│ │ │ ├── difference.ts
│ │ │ ├── flatten.spec.ts
│ │ │ ├── flatten.ts
│ │ │ ├── index.ts
│ │ │ ├── initial.spec.ts
│ │ │ ├── initial.ts
│ │ │ ├── last.spec.ts
│ │ │ ├── last.ts
│ │ │ ├── pull-all.spec.ts
│ │ │ ├── pull-all.ts
│ │ │ ├── pull-at.spec.ts
│ │ │ ├── pull-at.ts
│ │ │ ├── pull.spec.ts
│ │ │ ├── pull.ts
│ │ │ ├── remove.spec.ts
│ │ │ ├── remove.ts
│ │ │ ├── sorted-index.spec.ts
│ │ │ ├── sorted-index.ts
│ │ │ ├── union.spec.ts
│ │ │ ├── union.ts
│ │ │ ├── uniq-by.spec.ts
│ │ │ ├── uniq-by.ts
│ │ │ ├── uniq.spec.ts
│ │ │ ├── uniq.ts
│ │ │ ├── without.spec.ts
│ │ │ ├── without.ts
│ │ │ ├── zip-object.spec.ts
│ │ │ ├── zip-object.ts
│ │ │ ├── zip.spec.ts
│ │ │ └── zip.ts
│ │ ├── collection
│ │ │ ├── every.spec.ts
│ │ │ ├── every.ts
│ │ │ ├── filter.spec.ts
│ │ │ ├── filter.ts
│ │ │ ├── find.spec.ts
│ │ │ ├── find.ts
│ │ │ ├── flat-map.spec.ts
│ │ │ ├── flat-map.ts
│ │ │ ├── for-each-right.spec.ts
│ │ │ ├── for-each-right.ts
│ │ │ ├── for-each.spec.ts
│ │ │ ├── for-each.ts
│ │ │ ├── group-by.spec.ts
│ │ │ ├── group-by.ts
│ │ │ ├── includes.spec.ts
│ │ │ ├── includes.ts
│ │ │ ├── index.ts
│ │ │ ├── key-by.spec.ts
│ │ │ ├── key-by.ts
│ │ │ ├── map.spec.ts
│ │ │ ├── map.ts
│ │ │ ├── reduce-right.spec.ts
│ │ │ ├── reduce-right.ts
│ │ │ ├── reduce-utils.ts
│ │ │ ├── reduce.spec.ts
│ │ │ ├── reduce.ts
│ │ │ ├── sample.spec.ts
│ │ │ ├── sample.ts
│ │ │ ├── size.spec.ts
│ │ │ ├── size.ts
│ │ │ ├── some.spec.ts
│ │ │ ├── some.ts
│ │ │ ├── sort-by.spec.ts
│ │ │ └── sort-by.ts
│ │ ├── function
│ │ │ ├── bind-key.spec.ts
│ │ │ ├── bind-key.ts
│ │ │ ├── curry.spec.ts
│ │ │ ├── curry.ts
│ │ │ ├── debounce.spec.ts
│ │ │ ├── debounce.ts
│ │ │ ├── index.ts
│ │ │ ├── memoize.spec.ts
│ │ │ ├── memoize.ts
│ │ │ ├── once.spec.ts
│ │ │ ├── once.ts
│ │ │ ├── partial.spec.ts
│ │ │ ├── partial.ts
│ │ │ ├── throttle.spec.ts
│ │ │ └── throttle.ts
│ │ ├── interfaces.ts
│ │ ├── lang
│ │ │ ├── cast-array.spec.ts
│ │ │ ├── cast-array.ts
│ │ │ ├── clone-deep.spec.ts
│ │ │ ├── clone-deep.ts
│ │ │ ├── clone.spec.ts
│ │ │ ├── clone.ts
│ │ │ ├── index.ts
│ │ │ ├── is-boolean.spec.ts
│ │ │ ├── is-boolean.ts
│ │ │ ├── is-empty.spec.ts
│ │ │ ├── is-empty.ts
│ │ │ ├── is-equal.spec.ts
│ │ │ ├── is-equal.ts
│ │ │ ├── is-function.spec.ts
│ │ │ ├── is-function.ts
│ │ │ ├── is-match.spec.ts
│ │ │ ├── is-match.ts
│ │ │ ├── is-nil.spec.ts
│ │ │ ├── is-nil.ts
│ │ │ ├── is-number.spec.ts
│ │ │ ├── is-number.ts
│ │ │ ├── is-reg-exp.spec.ts
│ │ │ ├── is-reg-exp.ts
│ │ │ ├── is-string.spec.ts
│ │ │ ├── is-string.ts
│ │ │ ├── is-undefined.spec.ts
│ │ │ ├── is-undefined.ts
│ │ │ ├── to-array.spec.ts
│ │ │ ├── to-array.ts
│ │ │ ├── to-string.spec.ts
│ │ │ └── to-string.ts
│ │ ├── math
│ │ │ ├── extreme-utils.ts
│ │ │ ├── index.ts
│ │ │ ├── max-by.spec.ts
│ │ │ ├── max-by.ts
│ │ │ ├── min-by.spec.ts
│ │ │ ├── min-by.ts
│ │ │ ├── random.spec.ts
│ │ │ ├── random.ts
│ │ │ ├── round.spec.ts
│ │ │ ├── round.ts
│ │ │ ├── sum-by.spec.ts
│ │ │ └── sum-by.ts
│ │ ├── number
│ │ │ ├── clamp.spec.ts
│ │ │ ├── clamp.ts
│ │ │ ├── in-range.spec.ts
│ │ │ ├── in-range.ts
│ │ │ └── index.ts
│ │ ├── object
│ │ │ ├── find-key.spec.ts
│ │ │ ├── find-key.ts
│ │ │ ├── for-own-right.spec.ts
│ │ │ ├── for-own-right.ts
│ │ │ ├── for-own.spec.ts
│ │ │ ├── for-own.ts
│ │ │ ├── functions.spec.ts
│ │ │ ├── functions.ts
│ │ │ ├── get.spec.ts
│ │ │ ├── get.ts
│ │ │ ├── index.ts
│ │ │ ├── invoke.spec.ts
│ │ │ ├── invoke.ts
│ │ │ ├── keys.spec.ts
│ │ │ ├── keys.ts
│ │ │ ├── map-values.spec.ts
│ │ │ ├── map-values.ts
│ │ │ ├── merge.spec.ts
│ │ │ ├── merge.ts
│ │ │ ├── omit-by.spec.ts
│ │ │ ├── omit-by.ts
│ │ │ ├── omit.spec.ts
│ │ │ ├── omit.ts
│ │ │ ├── pick-by.spec.ts
│ │ │ ├── pick-by.ts
│ │ │ ├── pick.spec.ts
│ │ │ ├── pick.ts
│ │ │ ├── set.spec.ts
│ │ │ ├── set.ts
│ │ │ ├── to-pairs.spec.ts
│ │ │ ├── to-pairs.ts
│ │ │ ├── transform.spec.ts
│ │ │ ├── transform.ts
│ │ │ ├── update.spec.ts
│ │ │ ├── update.ts
│ │ │ ├── values.spec.ts
│ │ │ └── values.ts
│ │ ├── string
│ │ │ ├── camel-case.spec.ts
│ │ │ ├── camel-case.ts
│ │ │ ├── capitalize.spec.ts
│ │ │ ├── capitalize.ts
│ │ │ ├── index.ts
│ │ │ ├── kebab-case.spec.ts
│ │ │ ├── kebab-case.ts
│ │ │ ├── lower-first.spec.ts
│ │ │ ├── lower-first.ts
│ │ │ ├── pad-end.spec.ts
│ │ │ ├── pad-end.ts
│ │ │ ├── pad-start.spec.ts
│ │ │ ├── pad-start.ts
│ │ │ ├── pad.spec.ts
│ │ │ ├── pad.ts
│ │ │ ├── repeat.spec.ts
│ │ │ ├── repeat.ts
│ │ │ ├── snake-case.spec.ts
│ │ │ ├── snake-case.ts
│ │ │ ├── to-lower.spec.ts
│ │ │ ├── to-lower.ts
│ │ │ ├── upper-first.spec.ts
│ │ │ ├── upper-first.ts
│ │ │ ├── words.spec.ts
│ │ │ └── words.ts
│ │ └── util
│ │ │ ├── constant.spec.ts
│ │ │ ├── constant.ts
│ │ │ ├── flow-right.spec.ts
│ │ │ ├── flow-right.ts
│ │ │ ├── flow.spec.ts
│ │ │ ├── flow.ts
│ │ │ ├── identity.spec.ts
│ │ │ ├── identity.ts
│ │ │ ├── index.ts
│ │ │ ├── matches.spec.ts
│ │ │ ├── matches.ts
│ │ │ ├── noop.spec.ts
│ │ │ ├── noop.ts
│ │ │ ├── property.spec.ts
│ │ │ ├── property.ts
│ │ │ ├── range.spec.ts
│ │ │ ├── range.ts
│ │ │ ├── times.spec.ts
│ │ │ ├── times.ts
│ │ │ ├── unique-id.spec.ts
│ │ │ └── unique-id.ts
│ ├── public-api.ts
│ ├── test-helpers
│ │ └── test-utils.ts
│ ├── test.ts
│ └── typing-tests
│ │ ├── array
│ │ ├── concat.dts-spec.ts
│ │ ├── difference.dts-spec.ts
│ │ ├── initial.dts-spec.ts
│ │ ├── union.dts-spec.ts
│ │ ├── zip-object.dts-spec.ts
│ │ └── zip.dts-spec.ts
│ │ ├── collection
│ │ ├── filter.dts-spec.ts
│ │ ├── find.dts-spec.ts
│ │ ├── flat-map.dts-spec.ts
│ │ ├── group-by.dts-spec.ts
│ │ └── key-by.dts-spec.ts
│ │ ├── function
│ │ ├── bind-key.dts-spec.ts
│ │ ├── debounce.dts-spec.ts
│ │ ├── once.dts-spec.ts
│ │ └── partial.dts-spec.ts
│ │ ├── index.d.ts
│ │ ├── lang
│ │ └── to-array.dts-spec.ts
│ │ ├── object
│ │ ├── find-key.dts-spec.ts
│ │ ├── functions.dts-spec.ts
│ │ ├── get.dts-spec.ts
│ │ ├── invoke.dts-spec.ts
│ │ ├── keys.dts-spec.ts
│ │ ├── map-values.dts-spec.ts
│ │ ├── omit-by.dts-spec.ts
│ │ ├── pick-by.dts-spec.ts
│ │ └── to-pairs.dts-spec.ts
│ │ └── tsconfig.json
│ ├── tsconfig.lib.json
│ ├── tsconfig.lib.prod.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── src
├── app
│ ├── app.component.html
│ ├── app.component.ts
│ ├── app.module.ts
│ └── package.json
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
└── test.ts
├── standard-version-postbump.ts
├── tsconfig.app.json
├── tsconfig.base.json
├── tsconfig.json
├── tsconfig.spec.json
├── tslint.json
└── yarn.lock
/.browserlistrc:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # For the full list of supported browsers by the Angular framework, please see:
6 | # https://angular.io/guide/browser-support
7 |
8 | # You can see what browsers were selected by your queries by running:
9 | # npx browserslist
10 |
11 | last 1 Chrome version
12 | last 1 Firefox version
13 | last 2 Edge major versions
14 | last 2 Safari major version
15 | last 2 iOS major versions
16 | Firefox ESR
17 | not IE 9-11 # For IE 9-11 support, remove 'not'.
18 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.ts]
12 | quote_type = single
13 |
14 | [*.md]
15 | max_line_length = off
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events.json
15 | speed-measure-plugin.json
16 |
17 | # IDEs and editors
18 | .project
19 | .classpath
20 | .c9/
21 | *.launch
22 | .settings/
23 | *.sublime-workspace
24 | .idea/workspace.xml
25 | .idea/shelf/
26 |
27 | # IDE - VSCode
28 | .vscode/*
29 | !.vscode/settings.json
30 | !.vscode/tasks.json
31 | !.vscode/launch.json
32 | !.vscode/extensions.json
33 | .history/*
34 |
35 | # misc
36 | /.sass-cache
37 | /connect.lock
38 | /coverage
39 | /libpeerconnection.log
40 | npm-debug.log
41 | yarn-error.log
42 | testem.log
43 | /typings
44 |
45 | # System Files
46 | .DS_Store
47 | Thumbs.db
48 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/dictionaries/Eric.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | buildchain
5 | iteratee
6 | iteratees
7 | lodash
8 | minified
9 | polyfilled
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/micro-dash-platform.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Calc_Sizes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Docs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/E2E.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Lib__Build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Lib__Test_server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Lib__dtslint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Tests.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | coverage/
3 | dist/
4 | node_modules/
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 | sudo: false
3 |
4 | language: node_js
5 | node_js:
6 | - "10"
7 |
8 | addons:
9 | apt:
10 | sources:
11 | - google-chrome
12 | packages:
13 | - google-chrome-stable
14 |
15 | cache:
16 | directories:
17 | - ./node_modules
18 |
19 | before_install:
20 | - npm install -g yarn
21 |
22 | install:
23 | - yarn
24 |
25 | script:
26 | - yarn test micro-dash --code-coverage --watch=false --progress=false --browsers=ChromeHeadlessCI
27 | - yarn dtslint
28 | - yarn build micro-dash
29 | - yarn e2e --protractor-config=./e2e/protractor-ci.conf.js
30 |
31 | after_success:
32 | - cat coverage/micro-dash/lcov.info | node_modules/coveralls/bin/coveralls.js
33 |
34 | notifications:
35 | email: false
36 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules\\typescript\\lib"
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Moved
2 |
3 | This is an old version. The library moved to a new repo [here](https://github.com/simontonsoftware/s-libs/tree/master/projects/micro-dash), as in now published under the name `@s-libs/micro-dash` in NPM.
4 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | - remove sinon
2 |
--------------------------------------------------------------------------------
/docs/typedoc/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Micro-dash
6 |
7 |
8 | Micro-dash
9 |
10 | This is the location for an old version of Micro-dash
.
11 | The library is now published under the name
12 | @s-libs/micro-dash
.
17 |
18 |
19 | It moved to a new repo
20 | here, with API docs
24 | here.
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/e2e/protractor-ci.conf.js:
--------------------------------------------------------------------------------
1 | const config = require("./protractor.conf").config;
2 |
3 | config.capabilities = {
4 | browserName: "chrome",
5 | chromeOptions: {
6 | args: ["--headless", "--no-sandbox", "--disable-gpu"],
7 | },
8 | };
9 |
10 | exports.config = config;
11 |
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 | // Protractor configuration file, see link for more information
3 | // https://github.com/angular/protractor/blob/master/lib/config.ts
4 |
5 | const { SpecReporter, StacktraceOption } = require("jasmine-spec-reporter");
6 |
7 | /**
8 | * @type { import("protractor").Config }
9 | */
10 | exports.config = {
11 | allScriptsTimeout: 11000,
12 | specs: ["./src/**/*.e2e-spec.ts"],
13 | capabilities: {
14 | browserName: "chrome",
15 | },
16 | directConnect: true,
17 | baseUrl: "http://localhost:4200/",
18 | framework: "jasmine",
19 | jasmineNodeOpts: {
20 | showColors: true,
21 | defaultTimeoutInterval: 30000,
22 | print: function () {},
23 | },
24 | onPrepare() {
25 | require("ts-node").register({
26 | project: require("path").join(__dirname, "./tsconfig.json"),
27 | });
28 | jasmine.getEnv().addReporter(
29 | new SpecReporter({
30 | spec: { displayStacktrace: StacktraceOption.PRETTY },
31 | }),
32 | );
33 | },
34 | };
35 |
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { browser, logging } from 'protractor';
2 | import { AppPage } from './app.po';
3 |
4 | describe('workspace-project App', () => {
5 | let page: AppPage;
6 |
7 | beforeEach(() => {
8 | page = new AppPage();
9 | });
10 |
11 | it('should display welcome message', () => {
12 | page.navigateTo();
13 | expect(page.getTitleText()).toEqual('Welcome to micro-dash!');
14 | });
15 |
16 | afterEach(async () => {
17 | // Assert that there are no errors emitted from the browser
18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19 | expect(logs).not.toContain(
20 | jasmine.objectContaining({
21 | level: logging.Level.SEVERE,
22 | } as logging.Entry),
23 | );
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo(): Promise {
5 | return browser.get(browser.baseUrl) as Promise;
6 | }
7 |
8 | getTitleText(): Promise {
9 | return element(by.css('app-root h1')).getText() as Promise;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "../tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "../out-tsc/e2e",
6 | "module": "commonjs",
7 | "target": "es2018",
8 | "types": ["jasmine", "jasminewd2", "node"]
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: "",
7 | frameworks: ["jasmine", "@angular-devkit/build-angular"],
8 | plugins: [
9 | require("karma-jasmine"),
10 | require("karma-chrome-launcher"),
11 | require("karma-jasmine-html-reporter"),
12 | require("karma-coverage-istanbul-reporter"),
13 | require("@angular-devkit/build-angular/plugins/karma"),
14 | ],
15 | client: {
16 | clearContext: false, // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require("path").join(__dirname, "./coverage/micro-dash-platform"),
20 | reports: ["html", "lcovonly", "text-summary"],
21 | fixWebpackSourcePaths: true,
22 | },
23 | reporters: ["progress", "kjhtml"],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ["Chrome"],
29 | singleRun: false,
30 | restartOnFileChange: true,
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/projects/calc-sizes/browserslist:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # For the full list of supported browsers by the Angular framework, please see:
6 | # https://angular.io/guide/browser-support
7 |
8 | # You can see what browsers were selected by your queries by running:
9 | # npx browserslist
10 |
11 | last 1 Chrome version
12 | last 1 Firefox version
13 | last 2 Edge major versions
14 | last 2 Safari major version
15 | last 2 iOS major versions
16 | Firefox ESR
17 | not IE 9-11 # For IE 9-11 support, remove 'not'.
18 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/chunk.lodash.ts:
--------------------------------------------------------------------------------
1 | import chunk from 'lodash-es/chunk';
2 |
3 | console.log(chunk([1, 2]));
4 | console.log(chunk([1, 2], 3));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/chunk.microdash.ts:
--------------------------------------------------------------------------------
1 | import { chunk } from 'micro-dash';
2 |
3 | console.log(chunk([1, 2]));
4 | console.log(chunk([1, 2], 3));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/compact.lodash.ts:
--------------------------------------------------------------------------------
1 | import compact from 'lodash-es/compact';
2 |
3 | compact([]);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/compact.microdash.ts:
--------------------------------------------------------------------------------
1 | import { compact } from 'micro-dash';
2 |
3 | compact([]);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/concat.lodash.ts:
--------------------------------------------------------------------------------
1 | import concat from 'lodash-es/concat';
2 |
3 | console.log(concat([], 1, [2], [3]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/concat.microdash.ts:
--------------------------------------------------------------------------------
1 | import { concat } from 'micro-dash';
2 |
3 | console.log(concat([], 1, [2], [3]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/difference.lodash.ts:
--------------------------------------------------------------------------------
1 | import difference from 'lodash-es/difference';
2 |
3 | console.log(difference([1, 2], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/difference.microdash.ts:
--------------------------------------------------------------------------------
1 | import { difference } from 'micro-dash';
2 |
3 | console.log(difference([1, 2], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/flatten.lodash.ts:
--------------------------------------------------------------------------------
1 | import flatten from 'lodash-es/flatten';
2 |
3 | flatten([]);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/flatten.microdash.ts:
--------------------------------------------------------------------------------
1 | import { flatten } from 'micro-dash';
2 |
3 | flatten([]);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/initial.lodash.ts:
--------------------------------------------------------------------------------
1 | import initial from 'lodash-es/initial';
2 |
3 | console.log(initial([1, 2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/initial.microdash.ts:
--------------------------------------------------------------------------------
1 | import { initial } from 'micro-dash';
2 |
3 | console.log(initial([1, 2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/last.lodash.ts:
--------------------------------------------------------------------------------
1 | import last from 'lodash-es/last';
2 |
3 | console.log(last([1, 2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/last.microdash.ts:
--------------------------------------------------------------------------------
1 | import { last } from 'micro-dash';
2 |
3 | console.log(last([1, 2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull-all.lodash.ts:
--------------------------------------------------------------------------------
1 | import pullAll from 'lodash-es/pullAll';
2 |
3 | console.log(pullAll([1], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull-all.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pullAll } from 'micro-dash';
2 |
3 | console.log(pullAll([1], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull-at.lodash.ts:
--------------------------------------------------------------------------------
1 | import pullAt from 'lodash-es/pullAt';
2 |
3 | console.log(
4 | pullAt([1, 2, 3], 1),
5 | pullAt([1, 2, 3], [1]),
6 | pullAt([1, 2, 3], [1, 2]),
7 | );
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull-at.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pullAt } from 'micro-dash';
2 |
3 | console.log(
4 | pullAt([1, 2, 3], 1),
5 | pullAt([1, 2, 3], [1]),
6 | pullAt([1, 2, 3], [1, 2]),
7 | );
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull.lodash.ts:
--------------------------------------------------------------------------------
1 | import pull from 'lodash-es/pull';
2 |
3 | pull([1], 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/pull.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pull } from 'micro-dash';
2 |
3 | pull([1], 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/remove.lodash.ts:
--------------------------------------------------------------------------------
1 | import remove from 'lodash-es/remove';
2 |
3 | remove([1], () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/remove.microdash.ts:
--------------------------------------------------------------------------------
1 | import { remove } from 'micro-dash';
2 |
3 | remove([1], () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/sorted-index.lodash.ts:
--------------------------------------------------------------------------------
1 | import sortedIndex from 'lodash-es/sortedIndex';
2 |
3 | console.log(sortedIndex([1, 2], 3), sortedIndex(null, NaN));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/sorted-index.microdash.ts:
--------------------------------------------------------------------------------
1 | import { sortedIndex } from 'micro-dash';
2 |
3 | console.log(sortedIndex([1, 2], 3), sortedIndex(null, NaN));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/union.lodash.ts:
--------------------------------------------------------------------------------
1 | import union from 'lodash-es/union';
2 |
3 | console.log(union([1], [2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/union.microdash.ts:
--------------------------------------------------------------------------------
1 | import { union } from 'micro-dash';
2 |
3 | console.log(union([1], [2]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/uniq-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import uniqBy from 'lodash-es/uniqBy';
2 |
3 | console.log(uniqBy([1, 1, 2], (v) => v));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/uniq-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { uniqBy } from 'micro-dash';
2 |
3 | console.log(uniqBy([1, 1, 2], (v) => v));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/uniq.lodash.ts:
--------------------------------------------------------------------------------
1 | import uniq from 'lodash-es/uniq';
2 |
3 | console.log(uniq([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/uniq.microdash.ts:
--------------------------------------------------------------------------------
1 | import { uniq } from 'micro-dash';
2 |
3 | console.log(uniq([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/without.lodash.ts:
--------------------------------------------------------------------------------
1 | import without from 'lodash-es/without';
2 |
3 | without([1, 2, 3], 1, 3);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/without.microdash.ts:
--------------------------------------------------------------------------------
1 | import { without } from 'micro-dash';
2 |
3 | without([1, 2, 3], 1, 3);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/zip-object.lodash.ts:
--------------------------------------------------------------------------------
1 | import zipObject from 'lodash-es/zipObject';
2 |
3 | console.log(zipObject(['a'], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/zip-object.microdash.ts:
--------------------------------------------------------------------------------
1 | import { zipObject } from 'micro-dash';
2 |
3 | console.log(zipObject(['a'], [1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/zip.lodash.ts:
--------------------------------------------------------------------------------
1 | import zip from 'lodash-es/zip';
2 |
3 | console.log(zip([1], null, [2]), zip());
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/array/zip.microdash.ts:
--------------------------------------------------------------------------------
1 | import { zip } from 'micro-dash';
2 |
3 | console.log(zip([1], null, [2]), zip());
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/every.lodash.ts:
--------------------------------------------------------------------------------
1 | import every from 'lodash-es/every';
2 |
3 | console.log(
4 | every([1], () => true),
5 | every({ a: 1 }, () => false),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/every.microdash.ts:
--------------------------------------------------------------------------------
1 | import { every } from 'micro-dash';
2 |
3 | console.log(
4 | every([1], () => true),
5 | every({ a: 1 }, () => false),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/filter.lodash.ts:
--------------------------------------------------------------------------------
1 | import filter from 'lodash-es/filter';
2 |
3 | filter([1], () => true);
4 | filter({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/filter.microdash.ts:
--------------------------------------------------------------------------------
1 | import { filter } from 'micro-dash';
2 |
3 | filter([1], () => true);
4 | filter({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/find.lodash.ts:
--------------------------------------------------------------------------------
1 | import find from 'lodash-es/find';
2 |
3 | find([1, 2, 3], (n) => n === 2, 1);
4 | find({ a: 1, b: 2, c: 3 }, (n) => n === 2);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/find.microdash.ts:
--------------------------------------------------------------------------------
1 | import { find } from 'micro-dash';
2 |
3 | find([1, 2, 3], (n) => n === 2, 1);
4 | find({ a: 1, b: 2, c: 3 }, (n) => n === 2);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/flat-map.lodash.ts:
--------------------------------------------------------------------------------
1 | import flatMap from 'lodash-es/flatMap';
2 |
3 | console.log(
4 | flatMap([1, 2, 3], (n) => [n, n]),
5 | flatMap({ a: 1, b: 2, c: 3 }, (n) => n),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/flat-map.microdash.ts:
--------------------------------------------------------------------------------
1 | import { flatMap } from 'micro-dash';
2 |
3 | console.log(
4 | flatMap([1, 2, 3], (n) => [n, n]),
5 | flatMap({ a: 1, b: 2, c: 3 }, (n) => n),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/for-each-right.lodash.ts:
--------------------------------------------------------------------------------
1 | import forEachRight from 'lodash-es/forEachRight';
2 |
3 | forEachRight([], () => {});
4 | forEachRight({}, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/for-each-right.microdash.ts:
--------------------------------------------------------------------------------
1 | import { forEachRight } from 'micro-dash';
2 |
3 | forEachRight([], () => {});
4 | forEachRight({}, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/for-each.lodash.ts:
--------------------------------------------------------------------------------
1 | import forEach from 'lodash-es/forEach';
2 |
3 | forEach([], () => {});
4 | forEach({}, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/for-each.microdash.ts:
--------------------------------------------------------------------------------
1 | import { forEach } from 'micro-dash';
2 |
3 | forEach([], () => {});
4 | forEach({}, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/group-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import groupBy from 'lodash-es/groupBy';
2 |
3 | console.log(groupBy([1, 2, 3], () => 'a'));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/group-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { groupBy } from 'micro-dash';
2 |
3 | console.log(groupBy([1, 2, 3], () => 'a'));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/includes.lodash.ts:
--------------------------------------------------------------------------------
1 | import includes from 'lodash-es/includes';
2 |
3 | console.log(
4 | includes([1, 2, 3], 2, 1),
5 | includes({ a: 1, b: 2, c: 3 }, 2),
6 | includes('123', 'hi'),
7 | );
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/includes.microdash.ts:
--------------------------------------------------------------------------------
1 | import { includes } from 'micro-dash';
2 |
3 | console.log(
4 | includes([1, 2, 3], 2, 1),
5 | includes({ a: 1, b: 2, c: 3 }, 2),
6 | includes('123', 'hi'),
7 | );
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/key-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import keyBy from 'lodash-es/keyBy';
2 |
3 | keyBy([], () => 'a');
4 | keyBy({}, () => 'a');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/key-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { keyBy } from 'micro-dash';
2 |
3 | keyBy([], () => 'a');
4 | keyBy({}, () => 'a');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/map.lodash.ts:
--------------------------------------------------------------------------------
1 | import map from 'lodash-es/map';
2 |
3 | map([1], () => {});
4 | map({ a: 1 }, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/map.microdash.ts:
--------------------------------------------------------------------------------
1 | import { map } from 'micro-dash';
2 |
3 | map([1], () => {});
4 | map({ a: 1 }, () => {});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/reduce-right.lodash.ts:
--------------------------------------------------------------------------------
1 | import reduceRight from 'lodash-es/reduceRight';
2 |
3 | reduceRight([], () => {});
4 | reduceRight({ a: 1 }, (key) => key);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/reduce-right.microdash.ts:
--------------------------------------------------------------------------------
1 | import { reduceRight } from 'micro-dash';
2 |
3 | reduceRight([], () => {});
4 | reduceRight({ a: 1 }, (key) => key);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/reduce.lodash.ts:
--------------------------------------------------------------------------------
1 | import reduce from 'lodash-es/reduce';
2 |
3 | reduce([], () => {});
4 | reduce({ a: 1 }, (key) => key);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/reduce.microdash.ts:
--------------------------------------------------------------------------------
1 | import { reduce } from 'micro-dash';
2 |
3 | reduce([], () => {});
4 | reduce({ a: 1 }, (key) => key);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/sample.lodash.ts:
--------------------------------------------------------------------------------
1 | import sample from 'lodash-es/sample';
2 | console.log(sample([1, 2]), sample({ a: 1, b: 2 }));
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/sample.microdash.ts:
--------------------------------------------------------------------------------
1 | import { sample } from 'micro-dash';
2 | console.log(sample([1, 2]), sample({ a: 1, b: 2 }));
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/size.lodash.ts:
--------------------------------------------------------------------------------
1 | import size from 'lodash-es/size';
2 | console.log(size([1, 2]), size({ a: 1, b: 2 }), size('hi'));
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/size.microdash.ts:
--------------------------------------------------------------------------------
1 | import { size } from 'micro-dash';
2 | console.log(size([1, 2]), size({ a: 1, b: 2 }), size('hi'));
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/some.lodash.ts:
--------------------------------------------------------------------------------
1 | import some from 'lodash-es/some';
2 |
3 | console.log(
4 | some([1], () => true),
5 | some({ a: 1 }, () => false),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/some.microdash.ts:
--------------------------------------------------------------------------------
1 | import { some } from 'micro-dash';
2 |
3 | console.log(
4 | some([1], () => true),
5 | some({ a: 1 }, () => false),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/sort-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import sortBy from 'lodash-es/sortBy';
2 |
3 | sortBy([1, 2], (i) => i);
4 | sortBy({ a: 1, b: 2 }, [(i: number) => i, (i: number) => -i]);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/collection/sort-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { sortBy } from 'micro-dash';
2 |
3 | sortBy([1, 2], (i) => i);
4 | sortBy({ a: 1, b: 2 }, [(i) => i, (i) => -i]);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/bind-key.lodash.ts:
--------------------------------------------------------------------------------
1 | import bindKey from 'lodash-es/bindKey';
2 |
3 | bindKey({ fn() {} }, 'fn')();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/bind-key.microdash.ts:
--------------------------------------------------------------------------------
1 | import { bindKey } from 'micro-dash';
2 |
3 | bindKey({ fn() {} }, 'fn')();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/curry.lodash.ts:
--------------------------------------------------------------------------------
1 | import curry from 'lodash-es/curry';
2 |
3 | curry(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/curry.microdash.ts:
--------------------------------------------------------------------------------
1 | import { curry } from 'micro-dash';
2 |
3 | curry(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/debounce.lodash.ts:
--------------------------------------------------------------------------------
1 | import debounce from 'lodash-es/debounce';
2 |
3 | debounce(() => {})();
4 | debounce((value: number) => {
5 | console.log(value);
6 | }, 1)(1);
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/debounce.microdash.ts:
--------------------------------------------------------------------------------
1 | import { debounce } from 'micro-dash';
2 |
3 | debounce(() => {})();
4 | debounce((value: number) => {
5 | console.log(value);
6 | }, 1)(1);
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/memoize.lodash.ts:
--------------------------------------------------------------------------------
1 | import memoize from 'lodash-es/memoize';
2 |
3 | memoize((a: any) => a)('a');
4 | memoize(
5 | (a: any) => a,
6 | (b: any) => b,
7 | )('a');
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/memoize.microdash.ts:
--------------------------------------------------------------------------------
1 | import { memoize } from 'micro-dash';
2 |
3 | memoize((a: any) => a)('a');
4 | memoize(
5 | (a: any) => a,
6 | (b: any) => b,
7 | )('a');
8 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/once.lodash.ts:
--------------------------------------------------------------------------------
1 | import once from 'lodash-es/once';
2 |
3 | once(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/once.microdash.ts:
--------------------------------------------------------------------------------
1 | import { once } from 'micro-dash';
2 |
3 | once(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/partial.lodash.ts:
--------------------------------------------------------------------------------
1 | import _partial from 'lodash-es/partial';
2 |
3 | _partial(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/partial.microdash.ts:
--------------------------------------------------------------------------------
1 | import { partial } from 'micro-dash';
2 |
3 | partial(() => 1)();
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/throttle.lodash.ts:
--------------------------------------------------------------------------------
1 | import throttle from 'lodash-es/throttle';
2 |
3 | throttle(() => {})();
4 | throttle(
5 | (value: number) => {
6 | console.log(value);
7 | },
8 | 1,
9 | { leading: false },
10 | )(1);
11 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/function/throttle.microdash.ts:
--------------------------------------------------------------------------------
1 | import { throttle } from 'micro-dash';
2 |
3 | throttle(() => {})();
4 | throttle(
5 | (value: number) => {
6 | console.log(value);
7 | },
8 | 1,
9 | { leading: false },
10 | )(1);
11 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/cast-array.lodash.ts:
--------------------------------------------------------------------------------
1 | import castArray from 'lodash-es/castArray';
2 |
3 | console.log(castArray(1), castArray([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/cast-array.microdash.ts:
--------------------------------------------------------------------------------
1 | import { castArray } from 'micro-dash';
2 |
3 | console.log(castArray(1), castArray([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/clone-deep.lodash.ts:
--------------------------------------------------------------------------------
1 | import cloneDeep from 'lodash-es/cloneDeep';
2 |
3 | cloneDeep('a');
4 | cloneDeep({});
5 | cloneDeep([]);
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/clone-deep.microdash.ts:
--------------------------------------------------------------------------------
1 | import { cloneDeep } from 'micro-dash';
2 |
3 | cloneDeep('a');
4 | cloneDeep({});
5 | cloneDeep([]);
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/clone.lodash.ts:
--------------------------------------------------------------------------------
1 | import clone from 'lodash-es/clone';
2 |
3 | clone('a');
4 | clone({});
5 | clone([]);
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/clone.microdash.ts:
--------------------------------------------------------------------------------
1 | import { clone } from 'micro-dash';
2 |
3 | clone('a');
4 | clone({});
5 | clone([]);
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-boolean.lodash.ts:
--------------------------------------------------------------------------------
1 | import isBoolean from 'lodash-es/isBoolean';
2 |
3 | console.log(isBoolean(true), isBoolean({}));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-boolean.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isBoolean } from 'micro-dash';
2 |
3 | console.log(isBoolean(true), isBoolean({}));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-empty.lodash.ts:
--------------------------------------------------------------------------------
1 | import isEmpty from 'lodash-es/isEmpty';
2 |
3 | isEmpty([]);
4 | isEmpty({});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-empty.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isEmpty } from 'micro-dash';
2 |
3 | isEmpty([]);
4 | isEmpty({});
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-equal.lodash.ts:
--------------------------------------------------------------------------------
1 | import isEqual from 'lodash-es/isEqual';
2 |
3 | isEqual('a', []);
4 | isEqual({}, {});
5 | isEqual([], 'a');
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-equal.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isEqual } from 'micro-dash';
2 |
3 | isEqual('a', []);
4 | isEqual({}, {});
5 | isEqual([], 'a');
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-function.lodash.ts:
--------------------------------------------------------------------------------
1 | import isFunction from 'lodash-es/isFunction';
2 |
3 | console.log(isFunction('a'));
4 | console.log(isFunction(() => {}));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-function.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isFunction } from 'micro-dash';
2 |
3 | console.log(isFunction('a'));
4 | console.log(isFunction(() => {}));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-match.lodash.ts:
--------------------------------------------------------------------------------
1 | import isMatch from 'lodash-es/isMatch';
2 |
3 | isMatch({ a: { b: [3, 4] } }, { a: undefined });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-match.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isMatch } from 'micro-dash';
2 |
3 | isMatch({ a: { b: [3, 4] } }, { a: undefined });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-nil.lodash.ts:
--------------------------------------------------------------------------------
1 | import isNil from 'lodash-es/isNil';
2 |
3 | console.log(isNil(undefined));
4 | console.log(isNil(true));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-nil.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isNil } from 'micro-dash';
2 |
3 | console.log(isNil(undefined));
4 | console.log(isNil(true));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-number.lodash.ts:
--------------------------------------------------------------------------------
1 | import isNumber from 'lodash-es/isNumber';
2 |
3 | console.log(isNumber(1), isNumber({}));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-number.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isNumber } from 'micro-dash';
2 |
3 | console.log(isNumber(1), isNumber({}));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-reg-exp.lodash.ts:
--------------------------------------------------------------------------------
1 | import isRegExp from 'lodash-es/isRegExp';
2 |
3 | console.log(isRegExp('a'));
4 | console.log(isRegExp(/a/));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-reg-exp.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isRegExp } from 'micro-dash';
2 |
3 | console.log(isRegExp('a'));
4 | console.log(isRegExp(/a/));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-string.lodash.ts:
--------------------------------------------------------------------------------
1 | import isString from 'lodash-es/isString';
2 |
3 | console.log(isString('a'));
4 | console.log(isString({}));
5 | console.log(isString([]));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-string.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isString } from 'micro-dash';
2 |
3 | console.log(isString('a'));
4 | console.log(isString({}));
5 | console.log(isString([]));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-undefined.lodash.ts:
--------------------------------------------------------------------------------
1 | import isUndefined from 'lodash-es/isUndefined';
2 |
3 | console.log(isUndefined(undefined));
4 | console.log(isUndefined(true));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/is-undefined.microdash.ts:
--------------------------------------------------------------------------------
1 | import { isUndefined } from 'micro-dash';
2 |
3 | console.log(isUndefined(undefined));
4 | console.log(isUndefined(true));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/to-array.lodash.ts:
--------------------------------------------------------------------------------
1 | import toArray from 'lodash-es/toArray';
2 |
3 | console.log(toArray({ a: 1, b: 2 }));
4 | console.log(toArray([1, 2, 3]));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/to-array.microdash.ts:
--------------------------------------------------------------------------------
1 | import { toArray } from 'micro-dash';
2 |
3 | console.log(toArray({ a: 1, b: 2 }));
4 | console.log(toArray([1, 2, 3]));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/to-string.lodash.ts:
--------------------------------------------------------------------------------
1 | import toString from 'lodash-es/toString';
2 |
3 | console.log(toString(undefined));
4 | console.log(toString([1, 2, 3]));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/lang/to-string.microdash.ts:
--------------------------------------------------------------------------------
1 | import { toString } from 'micro-dash';
2 |
3 | console.log(toString(undefined));
4 | console.log(toString([1, 2, 3]));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/max-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import maxBy from 'lodash-es/maxBy';
2 |
3 | console.log(maxBy([], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/max-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { maxBy } from 'micro-dash';
2 |
3 | console.log(maxBy([], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/min-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import minBy from 'lodash-es/minBy';
2 |
3 | console.log(minBy([], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/min-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { minBy } from 'micro-dash';
2 |
3 | console.log(minBy([], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/random.lodash.ts:
--------------------------------------------------------------------------------
1 | import random from 'lodash-es/random';
2 |
3 | console.log(
4 | random(),
5 | random(true),
6 | random(5),
7 | random(5, true),
8 | random(1, 8),
9 | random(1, 8, false),
10 | );
11 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/random.microdash.ts:
--------------------------------------------------------------------------------
1 | import { random } from 'micro-dash';
2 |
3 | console.log(
4 | random(),
5 | random(true),
6 | random(5),
7 | random(5, true),
8 | random(1, 8),
9 | random(1, 8, false),
10 | );
11 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/round.lodash.ts:
--------------------------------------------------------------------------------
1 | import round from 'lodash-es/round';
2 |
3 | console.log(round(1.1, 1), round(16, -2));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/round.microdash.ts:
--------------------------------------------------------------------------------
1 | import { round } from 'micro-dash';
2 |
3 | console.log(round(1.1, 1), round(16, -2));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/sum-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import sumBy from 'lodash-es/sumBy';
2 |
3 | console.log(sumBy([1, 2], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/math/sum-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { sumBy } from 'micro-dash';
2 |
3 | console.log(sumBy([1, 2], () => 1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/number/clamp.lodash.ts:
--------------------------------------------------------------------------------
1 | import clamp from 'lodash-es/clamp';
2 |
3 | console.log(clamp(1, 2, 3));
4 | console.log(clamp(2, 1, 3));
5 | console.log(clamp(3, 1, 2));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/number/clamp.microdash.ts:
--------------------------------------------------------------------------------
1 | import { clamp } from 'micro-dash';
2 |
3 | console.log(clamp(1, 2, 3));
4 | console.log(clamp(2, 1, 3));
5 | console.log(clamp(3, 1, 2));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/number/in-range.lodash.ts:
--------------------------------------------------------------------------------
1 | import inRange from 'lodash-es/inRange';
2 |
3 | console.log(inRange(1, 2, 3));
4 | console.log(inRange(2, 1, 3));
5 | console.log(inRange(3, 1, 2));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/number/in-range.microdash.ts:
--------------------------------------------------------------------------------
1 | import { inRange } from 'micro-dash';
2 |
3 | console.log(inRange(1, 2, 3));
4 | console.log(inRange(2, 1, 3));
5 | console.log(inRange(3, 1, 2));
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/find-key.lodash.ts:
--------------------------------------------------------------------------------
1 | import findKey from 'lodash-es/findKey';
2 |
3 | console.log(
4 | findKey([1, 2, 3], (n) => n === 2),
5 | findKey({ a: 1, b: 2, c: 3 }, (n) => n === 2),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/find-key.microdash.ts:
--------------------------------------------------------------------------------
1 | import { findKey } from 'micro-dash';
2 |
3 | console.log(
4 | findKey([1, 2, 3], (n) => n === 2),
5 | findKey({ a: 1, b: 2, c: 3 }, (n) => n === 2),
6 | );
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/for-own-right.lodash.ts:
--------------------------------------------------------------------------------
1 | import forOwnRight from 'lodash-es/forOwnRight';
2 |
3 | forOwnRight({ a: 1 }, () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/for-own-right.microdash.ts:
--------------------------------------------------------------------------------
1 | import { forOwnRight } from 'micro-dash';
2 |
3 | forOwnRight({ a: 1 }, () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/for-own.lodash.ts:
--------------------------------------------------------------------------------
1 | import forOwn from 'lodash-es/forOwn';
2 |
3 | forOwn({ a: 1 }, () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/for-own.microdash.ts:
--------------------------------------------------------------------------------
1 | import { forOwn } from 'micro-dash';
2 |
3 | forOwn({ a: 1 }, () => true);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/functions.lodash.ts:
--------------------------------------------------------------------------------
1 | import functions from 'lodash-es/functions';
2 |
3 | console.log(functions({ a: 1 }), functions([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/functions.microdash.ts:
--------------------------------------------------------------------------------
1 | import { functions } from 'micro-dash';
2 |
3 | console.log(functions({ a: 1 }), functions([1]));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/get.lodash.ts:
--------------------------------------------------------------------------------
1 | import get from 'lodash-es/get';
2 |
3 | get({ a: 1 }, ['a'], 0);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/get.microdash.ts:
--------------------------------------------------------------------------------
1 | import { get } from 'micro-dash';
2 |
3 | get({ a: 1 }, ['a'], 0);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/invoke.lodash.ts:
--------------------------------------------------------------------------------
1 | import invoke from 'lodash-es/invoke';
2 | invoke({ a: (val: any) => console.log(val) }, ['hi']);
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/invoke.microdash.ts:
--------------------------------------------------------------------------------
1 | import { invoke } from 'micro-dash';
2 | invoke({ a: (val: any) => console.log(val) }, ['hi']);
3 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/keys.lodash.ts:
--------------------------------------------------------------------------------
1 | import keys from 'lodash-es/keys';
2 |
3 | console.log(keys({ a: 1 }), keys(1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/keys.microdash.ts:
--------------------------------------------------------------------------------
1 | import { keys } from 'micro-dash';
2 |
3 | console.log(keys({ a: 1 }), keys(1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/map-values.lodash.ts:
--------------------------------------------------------------------------------
1 | import mapValues from 'lodash-es/mapValues';
2 |
3 | mapValues({ a: 1 }, () => 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/map-values.microdash.ts:
--------------------------------------------------------------------------------
1 | import { mapValues } from 'micro-dash';
2 |
3 | mapValues({ a: 1 }, () => 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/merge.lodash.ts:
--------------------------------------------------------------------------------
1 | import merge from 'lodash-es/merge';
2 |
3 | merge({ a: 1 }, { b: 2 });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/merge.microdash.ts:
--------------------------------------------------------------------------------
1 | import { merge } from 'micro-dash';
2 |
3 | merge({ a: 1 }, { b: 2 });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/omit-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import omitBy from 'lodash-es/omitBy';
2 |
3 | omitBy({ a: 1 }, () => true);
4 | omitBy({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/omit-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { omitBy } from 'micro-dash';
2 |
3 | omitBy({ a: 1 }, () => true);
4 | omitBy({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/omit.lodash.ts:
--------------------------------------------------------------------------------
1 | import omit from 'lodash-es/omit';
2 |
3 | omit({ a: 1 }, 'a');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/omit.microdash.ts:
--------------------------------------------------------------------------------
1 | import { omit } from 'micro-dash';
2 |
3 | omit({ a: 1 }, 'a');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/pick-by.lodash.ts:
--------------------------------------------------------------------------------
1 | import pickBy from 'lodash-es/pickBy';
2 |
3 | pickBy({ a: 1 }, () => true);
4 | pickBy({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/pick-by.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pickBy } from 'micro-dash';
2 |
3 | pickBy({ a: 1 }, () => true);
4 | pickBy({ a: 1 }, () => false);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/pick.lodash.ts:
--------------------------------------------------------------------------------
1 | import pick from 'lodash-es/pick';
2 |
3 | console.log(pick({ a: 1, b: 2, c: 3 }, 'a', 'c'));
4 | console.log(pick(null as any, 'a'));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/pick.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pick } from 'micro-dash';
2 |
3 | console.log(pick({ a: 1, b: 2, c: 3 }, 'a', 'c'));
4 | console.log(pick(null as any, 'a'));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/set.lodash.ts:
--------------------------------------------------------------------------------
1 | import set from 'lodash-es/set';
2 |
3 | set({}, ['a'], 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/set.microdash.ts:
--------------------------------------------------------------------------------
1 | import { set } from 'micro-dash';
2 |
3 | set({}, ['a'], 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/to-pairs.lodash.ts:
--------------------------------------------------------------------------------
1 | import toPairs from 'lodash-es/toPairs';
2 |
3 | console.log(toPairs({ a: 1, b: 2 }));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/to-pairs.microdash.ts:
--------------------------------------------------------------------------------
1 | import { toPairs } from 'micro-dash';
2 |
3 | console.log(toPairs({ a: 1, b: 2 }));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/transform.lodash.ts:
--------------------------------------------------------------------------------
1 | import transform from 'lodash-es/transform';
2 |
3 | console.log(
4 | transform({ a: false, b: true }, (accum, value, key) => (accum[key] = value)),
5 | );
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/transform.microdash.ts:
--------------------------------------------------------------------------------
1 | import { transform } from 'micro-dash';
2 |
3 | console.log(
4 | transform({ a: false, b: true }, (accum, value, key) => (accum[key] = value)),
5 | );
6 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/update.lodash.ts:
--------------------------------------------------------------------------------
1 | import update from 'lodash-es/update';
2 |
3 | update({}, ['a'], () => 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/update.microdash.ts:
--------------------------------------------------------------------------------
1 | import { update } from 'micro-dash';
2 |
3 | update({}, ['a'], () => 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/values.lodash.ts:
--------------------------------------------------------------------------------
1 | import values from 'lodash-es/values';
2 |
3 | values({ a: 1 });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/object/values.microdash.ts:
--------------------------------------------------------------------------------
1 | import { values } from 'micro-dash';
2 |
3 | values({ a: 1 });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/camel-case.lodash.ts:
--------------------------------------------------------------------------------
1 | import camelCase from 'lodash-es/camelCase';
2 |
3 | camelCase('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/camel-case.microdash.ts:
--------------------------------------------------------------------------------
1 | import { camelCase } from 'micro-dash';
2 |
3 | camelCase('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/capitalize.lodash.ts:
--------------------------------------------------------------------------------
1 | import capitalize from 'lodash-es/capitalize';
2 |
3 | capitalize('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/capitalize.microdash.ts:
--------------------------------------------------------------------------------
1 | import { capitalize } from 'micro-dash';
2 |
3 | capitalize('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/kebab-case.lodash.ts:
--------------------------------------------------------------------------------
1 | import kebabCase from 'lodash-es/kebabCase';
2 |
3 | kebabCase('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/kebab-case.microdash.ts:
--------------------------------------------------------------------------------
1 | import { kebabCase } from 'micro-dash';
2 |
3 | kebabCase('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/lower-first.lodash.ts:
--------------------------------------------------------------------------------
1 | import lowerFirst from 'lodash-es/lowerFirst';
2 |
3 | console.log(lowerFirst('a string'), lowerFirst(undefined));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/lower-first.microdash.ts:
--------------------------------------------------------------------------------
1 | import { lowerFirst } from 'micro-dash';
2 |
3 | console.log(lowerFirst('a string'), lowerFirst(undefined));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad-end.lodash.ts:
--------------------------------------------------------------------------------
1 | import padEnd from 'lodash-es/padEnd';
2 |
3 | padEnd('a string', 12);
4 | padEnd('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad-end.microdash.ts:
--------------------------------------------------------------------------------
1 | import { padEnd } from 'micro-dash';
2 |
3 | padEnd('a string', 12);
4 | padEnd('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad-start.lodash.ts:
--------------------------------------------------------------------------------
1 | import padStart from 'lodash-es/padStart';
2 |
3 | padStart('a string', 12);
4 | padStart('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad-start.microdash.ts:
--------------------------------------------------------------------------------
1 | import { padStart } from 'micro-dash';
2 |
3 | padStart('a string', 12);
4 | padStart('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad.lodash.ts:
--------------------------------------------------------------------------------
1 | import pad from 'lodash-es/pad';
2 |
3 | pad('a string', 12);
4 | pad('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/pad.microdash.ts:
--------------------------------------------------------------------------------
1 | import { pad } from 'micro-dash';
2 |
3 | pad('a string', 12);
4 | pad('a string', 12, '0');
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/repeat.lodash.ts:
--------------------------------------------------------------------------------
1 | import repeat from 'lodash-es/repeat';
2 |
3 | console.log(repeat('hi', 3), repeat('', -1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/repeat.microdash.ts:
--------------------------------------------------------------------------------
1 | import { repeat } from 'micro-dash';
2 |
3 | console.log(repeat('hi', 3), repeat('', -1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/snake-case.lodash.ts:
--------------------------------------------------------------------------------
1 | import snakeCase from 'lodash-es/snakeCase';
2 |
3 | console.log(snakeCase('a string'));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/snake-case.microdash.ts:
--------------------------------------------------------------------------------
1 | import { snakeCase } from 'micro-dash';
2 |
3 | console.log(snakeCase('a string'));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/to-lower.lodash.ts:
--------------------------------------------------------------------------------
1 | import toLower from 'lodash-es/toLower';
2 |
3 | toLower('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/to-lower.microdash.ts:
--------------------------------------------------------------------------------
1 | import { toLower } from 'micro-dash';
2 |
3 | toLower('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/upper-first.lodash.ts:
--------------------------------------------------------------------------------
1 | import upperFirst from 'lodash-es/upperFirst';
2 |
3 | console.log(upperFirst('a string'), upperFirst(undefined));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/upper-first.microdash.ts:
--------------------------------------------------------------------------------
1 | import { upperFirst } from 'micro-dash';
2 |
3 | console.log(upperFirst('a string'), upperFirst(undefined));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/words.lodash.ts:
--------------------------------------------------------------------------------
1 | import words from 'lodash-es/words';
2 |
3 | words('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/string/words.microdash.ts:
--------------------------------------------------------------------------------
1 | import { words } from 'micro-dash';
2 |
3 | words('a string');
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/constant.lodash.ts:
--------------------------------------------------------------------------------
1 | import constant from 'lodash-es/constant';
2 |
3 | const fn = constant(1);
4 | console.log(fn, fn());
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/constant.microdash.ts:
--------------------------------------------------------------------------------
1 | import { constant } from 'micro-dash';
2 |
3 | const fn = constant(1);
4 | console.log(fn, fn());
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/flow-right.lodash.ts:
--------------------------------------------------------------------------------
1 | import flowRight from 'lodash-es/flowRight';
2 |
3 | const increment = (x: number) => x + 1;
4 | console.log(flowRight((flowRight as any)(), increment)(1));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/flow-right.microdash.ts:
--------------------------------------------------------------------------------
1 | import { flowRight } from 'micro-dash';
2 |
3 | const increment = (x: number) => x + 1;
4 | flowRight((flowRight as any)(), increment)(1);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/flow.lodash.ts:
--------------------------------------------------------------------------------
1 | import flow from 'lodash-es/flow';
2 |
3 | const increment = (x: number) => x + 1;
4 | flow(increment, (flow as any)())(1);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/flow.microdash.ts:
--------------------------------------------------------------------------------
1 | import { flow } from 'micro-dash';
2 |
3 | const increment = (x: number) => x + 1;
4 | flow(increment, flow())(1);
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/identity.lodash.ts:
--------------------------------------------------------------------------------
1 | import identity from 'lodash-es/identity';
2 |
3 | console.log(identity, identity(1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/identity.microdash.ts:
--------------------------------------------------------------------------------
1 | import { identity } from 'micro-dash';
2 |
3 | console.log(identity, identity(1));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/matches.lodash.ts:
--------------------------------------------------------------------------------
1 | import matches from 'lodash-es/matches';
2 |
3 | matches({ a: undefined })({ a: { b: [3, 4] } });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/matches.microdash.ts:
--------------------------------------------------------------------------------
1 | import { matches } from 'micro-dash';
2 |
3 | matches({ a: undefined })({ a: { b: [3, 4] } });
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/noop.lodash.ts:
--------------------------------------------------------------------------------
1 | import noop from 'lodash-es/noop';
2 |
3 | console.log(noop, [1].map(noop));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/noop.microdash.ts:
--------------------------------------------------------------------------------
1 | import { noop } from 'micro-dash';
2 |
3 | console.log(noop, [1].map(noop));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/range.lodash.ts:
--------------------------------------------------------------------------------
1 | import range from 'lodash-es/range';
2 |
3 | console.log(range(2));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/range.microdash.ts:
--------------------------------------------------------------------------------
1 | import { range } from 'micro-dash';
2 |
3 | console.log(range(2));
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/times.lodash.ts:
--------------------------------------------------------------------------------
1 | import times from 'lodash-es/times';
2 |
3 | times(3, (i) => i + 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/times.microdash.ts:
--------------------------------------------------------------------------------
1 | import { times } from 'micro-dash';
2 |
3 | times(3, (i) => i + 1);
4 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/unique-id.lodash.ts:
--------------------------------------------------------------------------------
1 | import uniqueId from 'lodash-es/uniqueId';
2 |
3 | console.log(uniqueId());
4 | console.log(uniqueId('a'));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/app/util/unique-id.microdash.ts:
--------------------------------------------------------------------------------
1 | import { uniqueId } from 'micro-dash';
2 |
3 | console.log(uniqueId());
4 | console.log(uniqueId('a'));
5 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Nothing to see here!
5 |
6 |
7 |
--------------------------------------------------------------------------------
/projects/calc-sizes/src/main.ts:
--------------------------------------------------------------------------------
1 | import "./app/math/min-by.microdash";
--------------------------------------------------------------------------------
/projects/calc-sizes/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "../../out-tsc/app",
6 | "types": []
7 | },
8 | "files": ["src/main.ts"],
9 | "include": ["src/**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: "",
7 | frameworks: ["jasmine", "@angular-devkit/build-angular"],
8 | plugins: [
9 | require("karma-jasmine"),
10 | require("karma-chrome-launcher"),
11 | require("karma-jasmine-html-reporter"),
12 | require("karma-coverage-istanbul-reporter"),
13 | require("@angular-devkit/build-angular/plugins/karma"),
14 | ],
15 | client: {
16 | clearContext: false, // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require("path").join(__dirname, "../../coverage/micro-dash"),
20 | reports: ["html", "lcovonly", "text-summary"],
21 | fixWebpackSourcePaths: true,
22 | },
23 | reporters: ["progress", "kjhtml"],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: [],
29 | customLaunchers: {
30 | ChromeHeadlessCI: {
31 | base: "ChromeHeadless",
32 | flags: ["--no-sandbox", "--disable-gpu"],
33 | },
34 | },
35 | singleRun: false,
36 | restartOnFileChange: true,
37 | });
38 | };
39 |
--------------------------------------------------------------------------------
/projects/micro-dash/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/micro-dash",
4 | "lib": {
5 | "entryFile": "src/public-api.ts"
6 | },
7 | "whitelistedNonPeerDependencies": ["utility-types"]
8 | }
9 |
--------------------------------------------------------------------------------
/projects/micro-dash/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "micro-dash",
3 | "version": "8.1.0",
4 | "description": "Lightweight implementations of simplified lodash functions",
5 | "author": "Simonton Software",
6 | "repository": "simontonsoftware/micro-dash",
7 | "license": "MIT",
8 | "dependencies": { "tslib": "^2.0.0", "utility-types": "~3.10.0" }
9 | }
10 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/chunk.spec.ts:
--------------------------------------------------------------------------------
1 | import { chunk } from './chunk';
2 |
3 | describe('chunk()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return chunked arrays', () => {
9 | const array = [0, 1, 2, 3, 4, 5];
10 | expect(chunk(array, 3)).toEqual([
11 | [0, 1, 2],
12 | [3, 4, 5],
13 | ]);
14 | });
15 |
16 | it('should return the last chunk as remaining elements', () => {
17 | const array = [0, 1, 2, 3, 4, 5];
18 | expect(chunk(array, 4)).toEqual([
19 | [0, 1, 2, 3],
20 | [4, 5],
21 | ]);
22 | });
23 |
24 | it('should ensure the minimum `size` is `0`', () => {
25 | const array = [0, 1, 2, 3, 4, 5];
26 | const expected = [[], [], [], [], [], []];
27 | expect(chunk(array, 0)).toEqual(expected);
28 | expect(chunk(array, -1)).toEqual(expected);
29 | expect(chunk(array, -Infinity)).toEqual(expected);
30 | });
31 |
32 | it('should coerce `size` to an integer', () => {
33 | const array = [0, 1, 2, 3, 4, 5];
34 | expect(chunk(array, 1.5)).toEqual([[0], [1], [2], [3], [4], [5]]);
35 | });
36 |
37 | it('should return an array', () => {
38 | const array = [1, 2, 3];
39 | const actual = chunk(array);
40 |
41 | expect(actual).toEqual(jasmine.any(Array));
42 | expect(actual).not.toBe(array as any);
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/chunk.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * 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.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 2,206 bytes
6 | * - Micro-dash: 129 bytes
7 | */
8 | export function chunk(array: T[], size = 1): T[][] {
9 | size = Math.max(Math.trunc(size), 0);
10 | const chunks = [];
11 | for (let i = 0; i < array.length; i += Math.max(1, size)) {
12 | chunks.push(array.slice(i, i + size));
13 | }
14 | return chunks;
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/compact.spec.ts:
--------------------------------------------------------------------------------
1 | import { compact } from './compact';
2 |
3 | describe('compact()', () => {
4 | it('should filter falsey values', () => {
5 | expect(
6 | compact([, null, undefined, false, 0, NaN, '', '0', '1', '2']),
7 | ).toEqual(['0', '1', '2']);
8 | });
9 |
10 | it('is OK when there are no falsey values', () => {
11 | expect(compact([1, 2])).toEqual([1, 2]);
12 | });
13 |
14 | it('is OK with all falsey values', () => {
15 | expect(compact([false, null, '']) as any[]).toEqual([]);
16 | });
17 |
18 | it('is OK with an empty array', () => {
19 | expect(compact([])).toEqual([]);
20 | });
21 |
22 | it('fancily narrows the type', () => {
23 | const before: Array = [
24 | 1,
25 | 2,
26 | false,
27 | null,
28 | undefined,
29 | 0,
30 | '',
31 | 3,
32 | ];
33 | const after: number[] = compact(before);
34 | expect(after).toEqual([1, 2, 3]);
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/compact.ts:
--------------------------------------------------------------------------------
1 | import { Falsey } from 'utility-types';
2 | import { identity } from '../util';
3 |
4 | /**
5 | * Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsey.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 96 bytes
9 | * - Micro-dash: 34 bytes
10 | */
11 | export function compact(array: Array): Array> {
12 | return array.filter(identity) as Array>;
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/concat.spec.ts:
--------------------------------------------------------------------------------
1 | import { concat } from './concat';
2 |
3 | describe('concat()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should shallow clone `array`', () => {
9 | const array = [1, 2, 3];
10 | const actual = concat(array);
11 |
12 | expect(actual).toEqual(array);
13 | expect(actual).not.toBe(array);
14 | });
15 |
16 | it('should concat arrays and values', () => {
17 | const array: Array = [1];
18 | const actual = concat(array, 2, [3], [[4]]);
19 |
20 | expect(actual).toEqual([1, 2, 3, [4]]);
21 | expect(array).toEqual([1]);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/concat.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a new array concatenating `array` with any additional arrays and/or values.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 1,410 bytes
6 | * - Micro-dash: 7 bytes
7 | */
8 | export function concat(array: T[], ...values: Array): T[] {
9 | return array.concat(...values);
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/difference.ts:
--------------------------------------------------------------------------------
1 | import { pullAll } from './pull-all';
2 | import { flatten } from './flatten';
3 |
4 | /**
5 | * Creates an array of array values not included in the other given arrays. The order and references of result values are determined by the first array.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 6,258 bytes
9 | * - Micro-dash: 249 bytes
10 | */
11 | export function difference(array: T[], ...values: T[][]): T[] {
12 | return pullAll(array.slice(), flatten(values));
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/flatten.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Flattens `array` a single level deep.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 1,183 bytes
6 | * - Micro-dash: 26 bytes
7 | */
8 | export function flatten(array: Array): T[] {
9 | return ([] as T[]).concat(...array);
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/index.ts:
--------------------------------------------------------------------------------
1 | export { chunk } from './chunk';
2 | export { compact } from './compact';
3 | export { concat } from './concat';
4 | export { difference } from './difference';
5 | export { flatten } from './flatten';
6 | export { initial } from './initial';
7 | export { last } from './last';
8 | export { pull } from './pull';
9 | export { pullAll } from './pull-all';
10 | export { pullAt } from './pull-at';
11 | export { remove } from './remove';
12 | export { sortedIndex } from './sorted-index';
13 | export { union } from './union';
14 | export { uniq } from './uniq';
15 | export { uniqBy } from './uniq-by';
16 | export { without } from './without';
17 | export { zip } from './zip';
18 | export { zipObject } from './zip-object';
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/initial.spec.ts:
--------------------------------------------------------------------------------
1 | import { map } from '../collection/map';
2 | import { initial } from './initial';
3 |
4 | describe('initial', () => {
5 | //
6 | // stolen from https://github.com/lodash/lodash
7 | //
8 |
9 | it('should exclude last element', () => {
10 | expect(initial([1, 2, 3])).toEqual([1, 2]);
11 | });
12 |
13 | it('should return an empty when querying empty arrays', () => {
14 | expect(initial([])).toEqual([]);
15 | });
16 |
17 | it('should work as an iteratee for methods like `_.map`', () => {
18 | const actual = map(
19 | [
20 | [1, 2, 3],
21 | [4, 5, 6],
22 | [7, 8, 9],
23 | ],
24 | initial,
25 | );
26 | expect(actual).toEqual([
27 | [1, 2],
28 | [4, 5],
29 | [7, 8],
30 | ]);
31 | });
32 |
33 | it('should return an array', () => {
34 | const array = [1, 2, 3];
35 | const actual = initial(array);
36 |
37 | expect(actual).toEqual(jasmine.any(Array));
38 | expect(actual).not.toBe(array);
39 | });
40 | });
41 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/initial.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Gets all but the last element of `array`.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 207 bytes
6 | * - Micro-dash: 15 bytes
7 | */
8 | export function initial(array: T[]): T[] {
9 | return array.slice(0, -1);
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/last.spec.ts:
--------------------------------------------------------------------------------
1 | import { last } from './last';
2 |
3 | describe('last()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return the last element', () => {
9 | expect(last([1, 2, 3, 4])).toBe(4);
10 | });
11 |
12 | it('should return `undefined` when querying empty arrays', () => {
13 | expect(last([])).toBeUndefined();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/last.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Gets the last element of array.
3 | *
4 | * Differences from lodash:
5 | * - no special consideration is given to string-keyed values set on the array
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 68 bytes
9 | * - Micro-dash: 23 bytes
10 | */
11 | export function last(array: T[]): T {
12 | return array[array.length - 1];
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/pull-all.ts:
--------------------------------------------------------------------------------
1 | import { remove } from './remove';
2 |
3 | /**
4 | * This method is like `pull` except that it accepts an array of values to remove.
5 | *
6 | * **Note:** Unlike `difference`, this method mutates array.
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 815 bytes
10 | * - Micro-dash: 174 bytes
11 | */
12 | export function pullAll(array: T[], values: T[]): T[] {
13 | for (const value of values.slice()) {
14 | remove(array, (item: T) => Object.is(item, value));
15 | }
16 | return array;
17 | }
18 | // TODO: return type could be narrower?
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/pull-at.ts:
--------------------------------------------------------------------------------
1 | import { flatten } from './flatten';
2 |
3 | /**
4 | * Removes elements from array corresponding to indexes and returns an array of removed elements.
5 | *
6 | * *Note:* This method mutates `array`.
7 | *
8 | * Differences from lodash:
9 | * - behavior is undefined when attempting to pull attributes keyed with anything other than positive integers
10 | * - does not support deep paths
11 | *
12 | * Contribution to minified bundle size, when it is the only function imported:
13 | * - Lodash: 7,672 bytes
14 | * - Micro-dash: 156 bytes
15 | */
16 | export function pullAt(
17 | array: any[],
18 | ...indexes: Array
19 | ): any[] {
20 | const flattenedIndexes = flatten(indexes);
21 | const result = flattenedIndexes.map((i) => array[i]);
22 |
23 | let lastI: number | undefined;
24 | for (const i of flattenedIndexes.sort((a, b) => b - a)) {
25 | if (i !== lastI) {
26 | array.splice(i, 1);
27 | }
28 | lastI = i;
29 | }
30 |
31 | return result;
32 | }
33 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/pull.spec.ts:
--------------------------------------------------------------------------------
1 | import { pull } from './pull';
2 |
3 | describe('pull()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should modify and return the array', () => {
9 | const argument = [1, 2, 3];
10 |
11 | const returned = pull(argument, 1, 3);
12 |
13 | expect(returned).toBe(argument);
14 | expect(returned).toEqual([2]);
15 | });
16 |
17 | it('should preserve holes in arrays', () => {
18 | const array = [1, 2, 3, 4];
19 | delete array[1];
20 | delete array[3];
21 |
22 | pull(array, 1);
23 |
24 | expect('0' in array).toBeFalsy();
25 | expect('1' in array).toBeTruthy();
26 | expect('2' in array).toBeFalsy();
27 | });
28 |
29 | it('should treat holes as `undefined`', () => {
30 | const array = [1, 2, 3];
31 | delete array[1];
32 |
33 | pull(array, undefined);
34 |
35 | expect(array).toEqual([1, 3]);
36 | });
37 |
38 | it('should match `NaN`', () => {
39 | const array = [1, NaN, 3, NaN];
40 |
41 | pull(array, NaN);
42 |
43 | expect(array).toEqual([1, 3]);
44 | });
45 |
46 | it('should return an array', () => {
47 | const array = [1, 2, 3];
48 | const actual = pull(array);
49 |
50 | expect(actual).toEqual(jasmine.any(Array));
51 | expect(actual).toBe(array);
52 | });
53 | });
54 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/pull.ts:
--------------------------------------------------------------------------------
1 | import { pullAll } from './pull-all';
2 |
3 | /**
4 | * Removes all given values from array using `SameValueZero` for equality comparisons.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 3,000 bytes
8 | * - Micro-dash: 166 bytes
9 | */
10 | export function pull(array: T[], ...values: T[]): T[] {
11 | return pullAll(array, values);
12 | }
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/remove.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ArrayNarrowingIteratee } from '../interfaces';
2 |
3 | /**
4 | * Removes all elements from array for which `predicate` returns truthy, and returns an array of the removed elements.
5 | *
6 | * Differences from lodash:
7 | * - iterates over `array` in reverse order
8 | *
9 | * Contribution to minified bundle size, when it is the only function imported:
10 | * - Lodash: 14,184 bytes
11 | * - Micro-dash: 82 bytes
12 | */
13 |
14 | export function remove(
15 | array: I[],
16 | predicate: ArrayNarrowingIteratee,
17 | ): O[]; // TODO: could be narrower?
18 | export function remove(
19 | array: T[],
20 | predicate: ArrayIteratee,
21 | ): T[];
22 |
23 | export function remove(
24 | array: T[],
25 | predicate: ArrayIteratee,
26 | ): T[] {
27 | const removed: T[] = [];
28 | for (let i = array.length; --i >= 0; ) {
29 | if (predicate(array[i], i)) {
30 | removed.unshift(array[i]);
31 | array.splice(i, 1);
32 | }
33 | }
34 | return removed;
35 | }
36 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/sorted-index.ts:
--------------------------------------------------------------------------------
1 | import { compareValues } from '../collection/sort-by';
2 | import { Nil } from '../interfaces';
3 |
4 | /**
5 | * Uses a binary search to determine the lowest index at which `value` should be inserted into `array` in order to maintain its sort order.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 1,266 bytes
9 | * - Micro-dash: 239 bytes
10 | */
11 | export function sortedIndex(array: T[] | Nil, value: T): number {
12 | let min = 0;
13 | let max = array ? array.length - 1 : 0;
14 | while (max > min) {
15 | const mid = Math.floor((max + min) / 2);
16 | if (compareValues(array![mid], value) < 0) {
17 | min = mid + 1;
18 | } else {
19 | max = mid;
20 | }
21 | }
22 | return min;
23 | }
24 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/union.spec.ts:
--------------------------------------------------------------------------------
1 | import { union } from './union';
2 |
3 | describe('union()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return the union of two arrays', () => {
9 | expect(union([2], [1, 2])).toEqual([2, 1]);
10 | });
11 |
12 | it('should return the union of multiple arrays', () => {
13 | expect(union([2], [1, 2], [2, 3])).toEqual([2, 1, 3]);
14 | });
15 |
16 | it('should not flatten nested arrays', () => {
17 | expect(union([1, 3, 2], [1, [5]], [2, [4]])).toEqual([1, 3, 2, [5], [4]]);
18 | });
19 |
20 | it('should return an array', () => {
21 | const array = [1, 2, 3];
22 | const actual = union(array);
23 |
24 | expect(actual).toEqual(jasmine.any(Array));
25 | expect(actual).not.toBe(array);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/union.ts:
--------------------------------------------------------------------------------
1 | import { flatten } from './flatten';
2 |
3 | /**
4 | * Creates an array of unique values, in order, from all given `arrays`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 6,197 bytes
8 | * - Micro-dash: 50 bytes
9 | */
10 | export function union(...arrays: T[][]): T[] {
11 | return Array.from(new Set(flatten(arrays)));
12 | }
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/uniq-by.ts:
--------------------------------------------------------------------------------
1 | import { ValueIteratee } from '../interfaces';
2 |
3 | /**
4 | * 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.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 9,004 bytes
8 | * - Micro-dash: 89 bytes
9 | */
10 | export function uniqBy(array: T[], iteratee: ValueIteratee): T[] {
11 | const seen = new Set();
12 | return array.filter((element) => {
13 | const key = iteratee(element);
14 | const isNew = !seen.has(key);
15 | seen.add(key);
16 | return isNew;
17 | });
18 | }
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/uniq.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a duplicate-free version of an array, using `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.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 4,580 bytes
6 | * - Micro-dash: 19 bytes
7 | */
8 | export function uniq(array: T[]): T[] {
9 | return Array.from(new Set(array));
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/without.spec.ts:
--------------------------------------------------------------------------------
1 | import { without } from './without';
2 |
3 | describe('without()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return the difference of values', () => {
9 | expect(without([2, 1, 2, 3], 1, 2)).toEqual([3]);
10 | });
11 |
12 | it('should use strict equality to determine the values to reject', () => {
13 | const object1 = { a: 1 };
14 | const object2 = { b: 2 };
15 | const array = [object1, object2];
16 |
17 | expect(without(array, { a: 1 })).toEqual(array);
18 | expect(without(array, object1)).toEqual([object2]);
19 | });
20 |
21 | it('should remove all occurrences of each value from an array', () => {
22 | expect(without([1, 2, 3, 1, 2, 3], 1, 2)).toEqual([3, 3]);
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/without.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates an array excluding all given values.
3 | *
4 | * Differences from lodash:
5 | * - Uses triple equals rather than `SameValueZero`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 5,643 bytes
9 | * - Micro-dash: 46 bytes
10 | */
11 | export function without(array: T[], ...values: T[]): T[] {
12 | return array.filter((item) => values.indexOf(item) === -1);
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/zip-object.spec.ts:
--------------------------------------------------------------------------------
1 | import { zipObject } from './zip-object';
2 |
3 | describe('zipObject()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const object = { barney: 36, fred: 40 };
9 |
10 | it('should zip together key/value arrays into an object', () => {
11 | expect(zipObject(['barney', 'fred'], [36, 40])).toEqual(object);
12 | });
13 |
14 | it('should ignore extra `values`', () => {
15 | expect(zipObject(['a'], [1, 2])).toEqual({ a: 1 });
16 | });
17 |
18 | it('should assign `undefined` values for extra `keys`', () => {
19 | expect(zipObject(['a', 'b'], [1])).toEqual({ a: 1, b: undefined });
20 | });
21 |
22 | it('should not support deep paths', () => {
23 | expect(zipObject(['a.b.c'], [1])).toEqual({ 'a.b.c': 1 });
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/array/zip.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 | import { times } from '../util';
3 |
4 | /**
5 | * 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.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 2,861 bytes
9 | * - Micro-dash: 155 bytes
10 | */
11 |
12 | export function zip(array1: T1[], array2: T2[]): Array<[T1, T2]>;
13 | export function zip(
14 | array1: T1[],
15 | array2: T2[],
16 | array3: T3[],
17 | ): Array<[T1, T2, T3]>;
18 | export function zip(
19 | array1: T1[],
20 | array2: T2[],
21 | array3: T3[],
22 | array4: T4[],
23 | ): Array<[T1, T2, T3, T4]>;
24 | export function zip(...arrays: Array): T[][];
25 | export function zip(...arrays: Array): Array>;
26 |
27 | export function zip(...arrays: Array): Array> {
28 | const length = Math.max(0, ...arrays.map((a) => (a ? a.length : 0)));
29 | return times(length, (i) => arrays.map((a) => (a ? a[i] : undefined)));
30 | }
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/every.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ObjectIteratee } from '../interfaces';
2 | import { forEach } from './for-each';
3 |
4 | /**
5 | * Checks if `predicate` returns truty for **all** elements of `collection`. Iteration is stopped once predicate returns falsey.
6 | *
7 | * **Note:** This method returns `true` for [empty collections](https://en.wikipedia.org/wiki/Empty_set) because [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of elements of empty collections.
8 | *
9 | * Contribution to minified bundle size, when it is the only function imported:
10 | * - Lodash: 14,279 bytes
11 | * - Micro-dash: 266 bytes
12 | */
13 |
14 | export function every(
15 | array: T[] | undefined,
16 | predicate: ArrayIteratee,
17 | ): boolean;
18 | export function every(
19 | object: T | undefined,
20 | predicate: ObjectIteratee,
21 | ): boolean;
22 |
23 | export function every(collection: any, predicate: any): boolean {
24 | let result = true;
25 | forEach(
26 | collection,
27 | (value, keyOrIndex) => (result = !!predicate(value, keyOrIndex)),
28 | );
29 | return result;
30 | }
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/flat-map.spec.ts:
--------------------------------------------------------------------------------
1 | import { flatten, identity, map } from 'lodash-es';
2 | import { flatMap } from './flat-map';
3 |
4 | describe('flatMap()', () => {
5 | //
6 | // stolen from https://github.com/lodash/lodash
7 | //
8 |
9 | const array = [1, 2, 3, 4];
10 |
11 | function duplicate(n: number): number[] {
12 | return [n, n];
13 | }
14 |
15 | it('should map values in `array` to a new flattened array', () => {
16 | expect(flatMap(array, duplicate)).toEqual(flatten(map(array, duplicate)));
17 | });
18 |
19 | it('should accept a falsey `collection`', () => {
20 | expect(flatMap(null, identity)).toEqual([]);
21 | expect(flatMap(undefined, identity)).toEqual([]);
22 | });
23 |
24 | it('should work with objects with non-number length properties', () => {
25 | expect(flatMap({ length: [1, 2] }, (a) => a)).toEqual([1, 2]);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/flat-map.ts:
--------------------------------------------------------------------------------
1 | import { flatten } from '../array';
2 | import { ArrayIteratee, Nil, ObjectIteratee } from '../interfaces';
3 | import { map } from './map';
4 |
5 | /**
6 | * Creates a flattened array of values by running each element in `collection` thru `iteratee` and flattening the mapped results.
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 14,344 bytes
10 | * - Micro-dash: 325 bytes
11 | */
12 |
13 | export function flatMap(
14 | array: I[] | Nil,
15 | iteratee: ArrayIteratee,
16 | ): O[];
17 | export function flatMap(
18 | object: T | Nil,
19 | iteratee: ObjectIteratee,
20 | ): O[];
21 |
22 | export function flatMap(collection: any, iteratee: any): any {
23 | return flatten(map(collection, iteratee));
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/for-each-right.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ObjectIteratee } from '../interfaces';
2 | import { forOwnRightOfNonArray } from '../object/for-own-right';
3 |
4 | /**
5 | * This method is like `forEach` except that it iterates over elements of `collection` from right to left.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 3,777 bytes
9 | * - Micro-dash: 217 bytes
10 | */
11 |
12 | export function forEachRight(
13 | array: T[] | undefined,
14 | iteratee: ArrayIteratee,
15 | ): T[];
16 | export function forEachRight(
17 | object: T | undefined,
18 | iteratee: ObjectIteratee,
19 | ): T;
20 |
21 | export function forEachRight(collection: any, iteratee: any): any {
22 | if (Array.isArray(collection)) {
23 | forEachRightOfArray(collection, iteratee);
24 | } else {
25 | forOwnRightOfNonArray(collection, iteratee);
26 | }
27 | return collection;
28 | }
29 |
30 | /** @hidden */
31 | export function forEachRightOfArray(
32 | array: T[],
33 | iteratee: ArrayIteratee,
34 | ): void {
35 | for (let i = array.length; --i >= 0; ) {
36 | if (iteratee(array[i], i) === false) {
37 | break;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/for-each.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ObjectIteratee } from '../interfaces';
2 | import { forOwnOfNonArray } from '../object/for-own';
3 |
4 | /**
5 | * Iterates over elements of `collection` and invokes `iteratee` for each element. Iteratee functions may exit iteration early by explicitly returning `false`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 3,798 bytes
9 | * - Micro-dash: 221 bytes
10 | */
11 |
12 | export function forEach(
13 | array: T[] | undefined,
14 | iteratee: ArrayIteratee,
15 | ): T[];
16 | export function forEach(
17 | object: T,
18 | iteratee: ObjectIteratee,
19 | ): T;
20 |
21 | export function forEach(collection: any, iteratee: any): any {
22 | if (Array.isArray(collection)) {
23 | forEachOfArray(collection, iteratee);
24 | } else {
25 | forOwnOfNonArray(collection, iteratee);
26 | }
27 | return collection;
28 | }
29 |
30 | /** @hidden */
31 | export function forEachOfArray(
32 | array: T[],
33 | iteratee: ArrayIteratee,
34 | ): void {
35 | for (let i = 0, len = array.length; i < len; ++i) {
36 | if (iteratee(array[i], i) === false) {
37 | break;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/group-by.ts:
--------------------------------------------------------------------------------
1 | import {
2 | IfIndexType,
3 | Key,
4 | Nil,
5 | ObjectWith,
6 | ValueIteratee,
7 | } from '../interfaces';
8 | import { transform } from '../object/transform';
9 |
10 | /**
11 | * 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.
12 | *
13 | * Contribution to minified bundle size, when it is the only function imported:
14 | * - Lodash: 14,388 bytes
15 | * - Micro-dash: 322 bytes
16 | */
17 | export function groupBy(
18 | collection: T[] | ObjectWith | Nil,
19 | iteratee: ValueIteratee,
20 | ): { [k in K]: IfIndexType } {
21 | return transform(
22 | collection as any,
23 | (accumulator, value: any) => {
24 | const key = iteratee(value);
25 | let group = accumulator[key];
26 | if (!Array.isArray(group)) {
27 | accumulator[key] = group = [];
28 | }
29 | group.push(value);
30 | },
31 | {} as any,
32 | );
33 | }
34 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/includes.ts:
--------------------------------------------------------------------------------
1 | import { isString, toArray } from '../lang';
2 |
3 | /**
4 | * Checks if `value` is in `collection`. If `collection` is a string, it's checked for a substring of `value`. If `fromIndex` is negative, it's used as the offset from the end of `collection`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 4,547 bytes
8 | * - Micro-dash: 269 bytes
9 | */
10 | export function includes(
11 | collection: T,
12 | value: T extends any[] ? T[0] : T extends string ? string : T[keyof T],
13 | fromIndex = 0,
14 | ): boolean {
15 | if (isString(collection)) {
16 | if (fromIndex > collection.length) {
17 | return false;
18 | }
19 | } else {
20 | collection = toArray(collection) as any;
21 | }
22 | return (collection as any).includes(value, fromIndex);
23 | }
24 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/index.ts:
--------------------------------------------------------------------------------
1 | export { every } from './every';
2 | export { filter } from './filter';
3 | export { find } from './find';
4 | export { flatMap } from './flat-map';
5 | export { forEach } from './for-each';
6 | export { groupBy } from './group-by';
7 | export { forEachRight } from './for-each-right';
8 | export { includes } from './includes';
9 | export { keyBy } from './key-by';
10 | export { map } from './map';
11 | export { reduce } from './reduce';
12 | export { reduceRight } from './reduce-right';
13 | export { sample } from './sample';
14 | export { size } from './size';
15 | export { some } from './some';
16 | export { sortBy } from './sort-by';
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/key-by.ts:
--------------------------------------------------------------------------------
1 | import { IfIndexType, Key, Nil, ValueIteratee } from '../interfaces';
2 | import { forEach } from './for-each';
3 |
4 | /**
5 | * 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.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 14,323 bytes
9 | * - Micro-dash: 265 bytes
10 | */
11 |
12 | export function keyBy(
13 | array: T[] | Nil,
14 | iteratee: ValueIteratee,
15 | ): IfIndexType;
16 | export function keyBy(
17 | object: T | Nil,
18 | iteratee: ValueIteratee,
19 | ): IfIndexType;
20 |
21 | export function keyBy(collection: any, iteratee: Function): any {
22 | const obj: any = {};
23 | forEach(collection, (value) => {
24 | obj[iteratee(value)] = value;
25 | });
26 | return obj;
27 | }
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/map.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ObjectIteratee } from '../interfaces';
2 | import { forEach } from './for-each';
3 |
4 | /**
5 | * Creates an array of values by running each element in `collection` thru `iteratee`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 14,041 bytes
9 | * - Micro-dash: 274 bytes
10 | */
11 |
12 | export function map(
13 | array: I[] | undefined,
14 | iteratee: ArrayIteratee,
15 | ): O[];
16 | export function map(
17 | object: T | undefined,
18 | iteratee: ObjectIteratee,
19 | ): O[];
20 |
21 | export function map(collection: any, iteratee: any): any[] {
22 | const mapped: any[] = [];
23 | forEach(collection, (value, keyOrIndex) => {
24 | mapped.push(iteratee(value, keyOrIndex));
25 | });
26 | return mapped;
27 | }
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/reduce-right.ts:
--------------------------------------------------------------------------------
1 | import { ObjectWith } from '../interfaces';
2 | import { forEachRight } from './for-each-right';
3 | import { doReduce } from './reduce-utils';
4 |
5 | /**
6 | * This method is like `_.reduce` except that it iterates over elements of `collection` from right to left.
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 14,164 bytes
10 | * - Micro-dash: 341 bytes
11 | */
12 | export function reduceRight(
13 | array: E[] | undefined,
14 | iteratee: (accumulator: E, value: E, index: number) => E,
15 | ): E;
16 | export function reduceRight(
17 | array: E[] | undefined,
18 | iteratee: (accumulator: A, value: E, index: number) => A,
19 | accumulator: A,
20 | ): A;
21 | export function reduceRight(
22 | array: ObjectWith | undefined,
23 | iteratee: (accumulator: E, value: E, key: keyof E) => E,
24 | ): E;
25 | export function reduceRight(
26 | array: ObjectWith | undefined,
27 | iteratee: (accumulator: A, value: E, key: keyof E) => A,
28 | accumulator: A,
29 | ): A;
30 |
31 | export function reduceRight(
32 | collection: any,
33 | iteratee: Function,
34 | accumulator?: any,
35 | ): any {
36 | return doReduce(
37 | forEachRight,
38 | collection,
39 | iteratee,
40 | accumulator,
41 | arguments.length < 3,
42 | );
43 | }
44 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/reduce-utils.ts:
--------------------------------------------------------------------------------
1 | /** @hidden */
2 | export function doReduce(
3 | iterationFn: Function,
4 | collection: any,
5 | iteratee: Function,
6 | accumulator: any,
7 | initAccum: boolean,
8 | ): any {
9 | iterationFn(collection, (value: any, indexOrKey: any) => {
10 | if (initAccum) {
11 | accumulator = value;
12 | initAccum = false;
13 | } else {
14 | accumulator = iteratee(accumulator, value, indexOrKey);
15 | }
16 | });
17 | return accumulator;
18 | }
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/sample.spec.ts:
--------------------------------------------------------------------------------
1 | import { times } from 'lodash-es';
2 | import { sample } from './sample';
3 |
4 | describe('sample()', () => {
5 | it('gets the full universe of elements', () => {
6 | const array = [1, 2, 3];
7 | expect(new Set(times(30, () => sample(array)))).toEqual(new Set(array));
8 |
9 | const object = { a: 1, b: 2, c: 3 };
10 | expect(new Set(times(30, () => sample(object)))).toEqual(new Set(array));
11 | });
12 |
13 | //
14 | // stolen from https://github.com/lodash/lodash
15 | //
16 |
17 | it('should return a random element', () => {
18 | const array = [1, 2, 3];
19 | expect(array.includes(sample(array))).toBe(true);
20 | });
21 |
22 | it('should return `undefined` when sampling empty collections', () => {
23 | expect(sample([])).toBeUndefined();
24 | expect(sample({})).toBeUndefined();
25 | });
26 |
27 | it('should sample an object', () => {
28 | expect([1, 2, 3].includes(sample({ a: 1, b: 2, c: 3 }))).toBe(true);
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/sample.ts:
--------------------------------------------------------------------------------
1 | import { ObjectWith } from '../interfaces';
2 | import { toArray } from '../lang';
3 | import { random } from '../math';
4 |
5 | /**
6 | * Gets a random element from `collection`.
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 3,655 bytes
10 | * - Micro-dash: 435 bytes
11 | */
12 | export function sample(collection: T[] | ObjectWith): T {
13 | collection = toArray(collection as any);
14 | return (collection as any)[random((collection as any[]).length - 1)];
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/size.spec.ts:
--------------------------------------------------------------------------------
1 | import { size } from './size';
2 |
3 | describe('size()', () => {
4 | const array = [1, 2, 3];
5 |
6 | it('should return the number of own enumerable string keyed properties of an object', () => {
7 | expect(size({ one: 1, two: 2, three: 3 })).toBe(3);
8 | });
9 |
10 | it('should return the length of an array', () => {
11 | expect(size(array)).toBe(3);
12 | });
13 |
14 | it('should accept a falsey `object`', () => {
15 | expect(size('')).toBe(0);
16 | });
17 |
18 | it('should not treat objects with negative lengths as array-like', () => {
19 | expect(size({ length: -1 })).toBe(1);
20 | });
21 |
22 | it('should not treat objects with lengths larger than `MAX_SAFE_INTEGER` as array-like', () => {
23 | const MAX_SAFE_INTEGER = 9007199254740991;
24 | expect(size({ length: MAX_SAFE_INTEGER + 1 })).toBe(1);
25 | });
26 |
27 | it('should not treat objects with non-number lengths as array-like', () => {
28 | expect(size({ length: '0' })).toBe(1);
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/size.ts:
--------------------------------------------------------------------------------
1 | import { keys } from '../object';
2 |
3 | /**
4 | * Gets the size of collection by returning the number of its own enumerable string keyed properties.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 3,301 bytes
8 | * - Micro-dash: 178 bytes
9 | */
10 |
11 | export function size(collection: object): number;
12 | // tslint:disable-next-line:unified-signatures
13 | export function size(collection: any[] | string): number;
14 |
15 | export function size(collection: object | any[] | string): number {
16 | return keys(collection).length;
17 | }
18 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/collection/some.ts:
--------------------------------------------------------------------------------
1 | import { ArrayIteratee, ObjectIteratee } from '../interfaces';
2 | import { forEach } from './for-each';
3 |
4 | /**
5 | * Checks if `predicate` returns truthy for **any** element of `collection`. Iteration is stopped once `predicate` returns truthy.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 14,175 bytes
9 | * - Micro-dash: 266 bytes
10 | */
11 |
12 | export function some(
13 | array: T[] | undefined,
14 | predicate: ArrayIteratee,
15 | ): boolean;
16 | export function some(
17 | object: T | undefined,
18 | predicate: ObjectIteratee,
19 | ): boolean;
20 |
21 | export function some(collection: any, predicate: any): boolean {
22 | let none = true;
23 | forEach(
24 | collection,
25 | (item, keyOrIndex) => (none = !predicate(item, keyOrIndex)),
26 | );
27 | return !none;
28 | }
29 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/function/debounce.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a debounced function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a `cancel` method to cancel delayed `func` invocations. The `func` is invoked with the last arguments provided to the debounced function.
3 | *
4 | * If `wait` is 0, `func` invocation is deferred until to the next tick, similar to `setTimeout` with a timeout of `0`.
5 | *
6 | * Differences from lodash:
7 | * - the debounced function does not come with a `flush` method
8 | * - does not accept options
9 | * - does not return the results of the last invocation
10 | * - does not make any guarantees about the value of `this` in `func`
11 | *
12 | * Contribution to minified bundle size, when it is the only function imported:
13 | * - Lodash: 2,064 bytes
14 | * - Micro-dash: 124 bytes
15 | */
16 | export function debounce any>(
17 | func: T,
18 | wait = 0,
19 | ): ((...args: Parameters) => void) & { cancel(): void } {
20 | let timeoutId: ReturnType;
21 | const cancel = () => {
22 | clearTimeout(timeoutId);
23 | };
24 | const debounced = (...args: unknown[]) => {
25 | cancel();
26 | timeoutId = setTimeout(func, wait, ...args);
27 | };
28 | return Object.assign(debounced, { cancel });
29 | }
30 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/function/index.ts:
--------------------------------------------------------------------------------
1 | export { bindKey } from './bind-key';
2 | export { curry } from './curry';
3 | export { debounce } from './debounce';
4 | export { memoize } from './memoize';
5 | export { once } from './once';
6 | export { partial } from './partial';
7 | export { throttle } from './throttle';
8 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/function/once.spec.ts:
--------------------------------------------------------------------------------
1 | import { once } from './once';
2 |
3 | describe('once()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should invoke `func` once', () => {
9 | let count = 0;
10 |
11 | const oncedFn = once(() => ++count);
12 | oncedFn();
13 | expect(oncedFn()).toBe(1);
14 | expect(count).toBe(1);
15 | });
16 |
17 | it('should ignore recursive calls', () => {
18 | let count = 0;
19 |
20 | const oncedFn = once(() => {
21 | oncedFn();
22 | return ++count;
23 | });
24 | expect(oncedFn()).toBe(1);
25 | expect(count).toBe(1);
26 | });
27 |
28 | it('should not throw more than once', () => {
29 | const oncedFn = once(() => {
30 | throw new Error();
31 | });
32 |
33 | expect(oncedFn).toThrowError();
34 | expect(oncedFn).not.toThrowError();
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/function/once.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation. The `func` is invoked with the `this` binding and arguments of the created function.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 1,423 bytes
6 | * - Micro-dash: 87 bytes
7 | */
8 | export function once any>(
9 | func: T,
10 | ): (this: ThisParameterType, ...args: Parameters) => ReturnType {
11 | let result: ReturnType;
12 | let needsCall = true;
13 | return function (
14 | this: ThisParameterType,
15 | ...args: Parameters
16 | ): ReturnType {
17 | if (needsCall) {
18 | needsCall = false;
19 | result = func.apply(this, args);
20 |
21 | // allow func and any of its variables to be garbage collected
22 | (func as any) = 0;
23 | }
24 | return result;
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/cast-array.spec.ts:
--------------------------------------------------------------------------------
1 | import { castArray } from './cast-array';
2 |
3 | describe('castArray()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should wrap non-array items in an array', () => {
9 | expect(castArray(false)).toEqual([false]);
10 | expect(castArray(0)).toEqual([0]);
11 | expect(castArray('')).toEqual(['']);
12 | expect(castArray(null)).toEqual([null]);
13 | expect(castArray(undefined)).toEqual([undefined]);
14 | expect(castArray(NaN)).toEqual([NaN]);
15 | expect(castArray(true)).toEqual([true]);
16 | expect(castArray(1)).toEqual([1]);
17 | expect(castArray('a')).toEqual(['a']);
18 | expect(castArray({ a: 1 })).toEqual([{ a: 1 }]);
19 | });
20 |
21 | it('should return array values by reference', () => {
22 | const array = [1];
23 | expect(castArray(array)).toBe(array);
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/cast-array.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Casts `value` as an array if it's not one.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 128 bytes
6 | * - Micro-dash: 44 bytes
7 | */
8 | export function castArray(value: T): T extends unknown[] ? T : T[] {
9 | return (Array.isArray(value) ? value : [value]) as any;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/clone-deep.ts:
--------------------------------------------------------------------------------
1 | import { forOwn } from '../object';
2 | import { clone } from './clone';
3 |
4 | /**
5 | * This method is like `clone` except that it recursively clones `value`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 12,289 bytes
9 | * - Micro-dash: 397 bytes
10 | */
11 | export function cloneDeep(value: T): T {
12 | if (value instanceof Object) {
13 | value = clone(value);
14 | forOwn(value, (item, key) => {
15 | value[key as keyof T] = cloneDeep(item);
16 | });
17 | }
18 | return value;
19 | }
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/clone.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a shallow clone of `value`.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 12,289 bytes
6 | * - Micro-dash: 90 bytes
7 | */
8 | export function clone(value: T): T {
9 | if (Array.isArray(value)) {
10 | return value.slice() as any;
11 | } else if (value instanceof Object) {
12 | return Object.assign({}, value);
13 | } else {
14 | return value;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/index.ts:
--------------------------------------------------------------------------------
1 | export { castArray } from './cast-array';
2 | export { clone } from './clone';
3 | export { cloneDeep } from './clone-deep';
4 | export { isBoolean } from './is-boolean';
5 | export { isEmpty } from './is-empty';
6 | export { isEqual } from './is-equal';
7 | export { isFunction } from './is-function';
8 | export { isMatch } from './is-match';
9 | export { isNil } from './is-nil';
10 | export { isNumber } from './is-number';
11 | export { isRegExp } from './is-reg-exp';
12 | export { isString } from './is-string';
13 | export { isUndefined } from './is-undefined';
14 | export { toArray } from './to-array';
15 | export { toString } from './to-string';
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-boolean.spec.ts:
--------------------------------------------------------------------------------
1 | import { isBoolean } from './is-boolean';
2 |
3 | describe('isBoolean()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return `true` for booleans', () => {
9 | expect(isBoolean(true)).toBe(true);
10 | expect(isBoolean(false)).toBe(true);
11 | });
12 |
13 | // tslint:disable-next-line:only-arrow-functions
14 | it('should return `false` for non-booleans', function (): void {
15 | expect(isBoolean(null)).toBe(false);
16 | expect(isBoolean(undefined)).toBe(false);
17 | expect(isBoolean(0)).toBe(false);
18 | expect(isBoolean(NaN)).toBe(false);
19 | expect(isBoolean('')).toBe(false);
20 | expect(isBoolean(arguments)).toBe(false);
21 | expect(isBoolean([1, 2, 3])).toBe(false);
22 | expect(isBoolean(new Date())).toBe(false);
23 | expect(isBoolean(new Error())).toBe(false);
24 | expect(isBoolean(Array.prototype.slice)).toBe(false);
25 | expect(isBoolean({ a: 1 })).toBe(false);
26 | expect(isBoolean(1)).toBe(false);
27 | expect(isBoolean(/x/)).toBe(false);
28 | expect(isBoolean('a')).toBe(false);
29 | expect(isBoolean(Symbol('a'))).toBe(false);
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-boolean.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is classified as a boolean primitive.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 693 bytes
6 | * - Micro-dash: 35 bytes
7 | */
8 | export function isBoolean(value: any): value is boolean {
9 | return value === true || value === false;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-empty.spec.ts:
--------------------------------------------------------------------------------
1 | import { isEmpty } from './is-empty';
2 |
3 | describe('isEmpty()', () => {
4 | it('should return `true` for empty values', () => {
5 | expect(isEmpty({})).toBe(true);
6 | expect(isEmpty([])).toBe(true);
7 | expect(isEmpty(null)).toBe(true);
8 | expect(isEmpty(undefined)).toBe(true);
9 | expect(isEmpty(false)).toBe(true);
10 | expect(isEmpty(0)).toBe(true);
11 | expect(isEmpty(NaN)).toBe(true);
12 | expect(isEmpty('')).toBe(true);
13 | expect(isEmpty(true)).toBe(true);
14 | expect(isEmpty(1)).toBe(true);
15 | expect(isEmpty(NaN)).toBe(true);
16 | });
17 |
18 | it('should return `false` for non-empty values', () => {
19 | expect(isEmpty([0])).toBe(false);
20 | expect(isEmpty({ a: 0 })).toBe(false);
21 | expect(isEmpty('a')).toBe(false);
22 | });
23 |
24 | it('should work with an object that has a `length` property', () => {
25 | expect(isEmpty({ length: 0 })).toBe(false);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-empty.ts:
--------------------------------------------------------------------------------
1 | import { keysOfNonArray } from '../object/keys';
2 |
3 | /**
4 | * Checks if `value` is an empty object or collection.
5 | *
6 | * Objects are considered empty if they have no own enumerable string keyed properties.
7 | *
8 | * Arrays are considered empty if they have a `length` of `0`.
9 | *
10 | * Contribution to minified bundle size, when it is the only function imported:
11 | * - Lodash: 4,321 bytes
12 | * - Micro-dash: 127 bytes
13 | */
14 | export function isEmpty(value: any): boolean {
15 | if (!Array.isArray(value)) {
16 | value = keysOfNonArray(value);
17 | }
18 | return value.length === 0;
19 | }
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-equal.ts:
--------------------------------------------------------------------------------
1 | import { keysOfNonArray } from '../object/keys';
2 |
3 | /**
4 | * Performs a deep comparison between two values to determine if they are equivalent.
5 | *
6 | * Differences from lodash:
7 | * - cannot handle circular references
8 | * - does not give special treatment to arrays; their own properties are compared just like other objects. Note this means sparse arrays are not equal to their dense "equivalents".
9 | * - `isEqual(0, -0) === false`
10 | *
11 | * Contribution to minified bundle size, when it is the only function imported:
12 | * - Lodash: 10,811 bytes
13 | * - Micro-dash: 276 bytes
14 | */
15 | export function isEqual(value: any, other: any): boolean {
16 | if (Object.is(value, other)) {
17 | // covers e.g. NaN === NaN
18 | return true;
19 | }
20 | if (!(value instanceof Object && other instanceof Object)) {
21 | return false;
22 | }
23 | for (const key of keysOfNonArray(value)) {
24 | if (!other.hasOwnProperty(key)) {
25 | return false;
26 | }
27 | }
28 | for (const key of keysOfNonArray(other)) {
29 | if (!isEqual(value[key], other[key])) {
30 | return false;
31 | }
32 | }
33 | return true;
34 | }
35 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-function.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is classified as a `Function` object.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 824 bytes
6 | * - Micro-dash: 41 bytes
7 | */
8 | export function isFunction(value: any): value is (...args: any[]) => any {
9 | return typeof value === 'function';
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-nil.spec.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 | import { isNil } from './is-nil';
3 |
4 | describe('isNil()', () => {
5 | it('works', () => {
6 | expect(isNil(undefined)).toBe(true);
7 | expect(isNil(null)).toBe(true);
8 |
9 | expect(isNil(false)).toBe(false);
10 | expect(isNil(0)).toBe(false);
11 | expect(isNil('')).toBe(false);
12 | expect(isNil({})).toBe(false);
13 | });
14 |
15 | it('fancily narrows types', () => {
16 | const maybeNull: string | null = 'a';
17 | const maybeUndefined: string | undefined = 'b';
18 | const maybeBoth: string | Nil = 'c';
19 |
20 | let str: string;
21 |
22 | if (isNil(maybeNull)) {
23 | throw new Error('fail');
24 | } else {
25 | str = maybeNull;
26 | }
27 | expect(str).toBe('a');
28 |
29 | if (isNil(maybeUndefined)) {
30 | throw new Error('fail');
31 | } else {
32 | str = maybeUndefined;
33 | }
34 | expect(str).toBe('b');
35 |
36 | if (isNil(maybeBoth)) {
37 | throw new Error('fail');
38 | } else {
39 | str = maybeBoth;
40 | }
41 | expect(str).toBe('c');
42 | });
43 | });
44 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-nil.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 |
3 | /**
4 | * Checks if value is `null` or `undefined`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 78 bytes
8 | * - Micro-dash: 29 bytes
9 | */
10 | export function isNil(value: any): value is Nil {
11 | return value == null;
12 | }
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-number.spec.ts:
--------------------------------------------------------------------------------
1 | import { isNumber } from './is-number';
2 |
3 | describe('isNumber()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return `true` for numbers', () => {
9 | expect(isNumber(0)).toBe(true);
10 | expect(isNumber(NaN)).toBe(true);
11 | });
12 |
13 | // tslint:disable-next-line:only-arrow-functions
14 | it('should return `false` for non-numbers', function (): void {
15 | expect(isNumber(null)).toBe(false);
16 | expect(isNumber(undefined)).toBe(false);
17 | expect(isNumber(false)).toBe(false);
18 | expect(isNumber('')).toBe(false);
19 | expect(isNumber(arguments)).toBe(false);
20 | expect(isNumber([1, 2, 3])).toBe(false);
21 | expect(isNumber(true)).toBe(false);
22 | expect(isNumber(new Date())).toBe(false);
23 | expect(isNumber(new Error())).toBe(false);
24 | expect(isNumber(Array.prototype.slice)).toBe(false);
25 | expect(isNumber({ a: 1 })).toBe(false);
26 | expect(isNumber(/x/)).toBe(false);
27 | expect(isNumber('a')).toBe(false);
28 | expect(isNumber(Symbol('a'))).toBe(false);
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-number.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is classified as a `Number` primitive.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 695 bytes
6 | * - Micro-dash: 39 bytes
7 | */
8 | export function isNumber(value: any): value is number {
9 | return typeof value === 'number';
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-reg-exp.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is classified as a `RegExp` object.
3 | *
4 | * Differences from lodash:
5 | * - returns `true` for subclasses of `RegExp`
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 1,040 bytes
9 | * - Micro-dash: 41 bytes
10 | */
11 | export function isRegExp(value: any): value is RegExp {
12 | return value instanceof RegExp;
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-string.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is classified as a String primitive.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 752 bytes
6 | * - Micro-dash: 39 bytes
7 | */
8 | export function isString(value: any): value is string {
9 | return typeof value === 'string';
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-undefined.spec.ts:
--------------------------------------------------------------------------------
1 | import { isUndefined } from './is-undefined';
2 |
3 | describe('isUndefined', () => {
4 | it('should return `true` for `undefined`', () => {
5 | expect(isUndefined(undefined)).toBe(true);
6 | });
7 |
8 | // tslint:disable-next-line:only-arrow-functions
9 | it('should return `false` for non `undefined` values', function (): void {
10 | // falsey values
11 | expect(isUndefined(null)).toBe(false);
12 | expect(isUndefined(false)).toBe(false);
13 | expect(isUndefined(0)).toBe(false);
14 | expect(isUndefined(NaN)).toBe(false);
15 | expect(isUndefined('')).toBe(false);
16 |
17 | // all the other things
18 | expect(isUndefined(arguments)).toBe(false);
19 | expect(isUndefined([1, 2, 3])).toBe(false);
20 | expect(isUndefined(true)).toBe(false);
21 | expect(isUndefined(new Date())).toBe(false);
22 | expect(isUndefined(new Error())).toBe(false);
23 | expect(isUndefined(Array.prototype.slice)).toBe(false);
24 | expect(isUndefined({ a: 1 })).toBe(false);
25 | expect(isUndefined(1)).toBe(false);
26 | expect(isUndefined(/x/)).toBe(false);
27 | expect(isUndefined('a')).toBe(false);
28 | expect(isUndefined(Symbol('a'))).toBe(false);
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/is-undefined.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `value` is `undefined`.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 81 bytes
6 | * - Micro-dash: 32 bytes
7 | */
8 | export function isUndefined(value: any): value is undefined {
9 | return value === undefined;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/to-array.ts:
--------------------------------------------------------------------------------
1 | import { Nil, Primitive } from '../interfaces';
2 | import { valuesOfNonArray } from '../object/values';
3 |
4 | /**
5 | * Converts `value` to an array.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 5,938 bytes
9 | * - Micro-dash: 149 bytes
10 | */
11 |
12 | export function toArray(value: string): string[];
13 | export function toArray(value: T): T;
14 | export function toArray(value: T): Array;
15 | export function toArray(value: Primitive | Nil): [];
16 | export function toArray(value: any): any[];
17 |
18 | export function toArray(value: any): any[] {
19 | if (value && value[Symbol.iterator]) {
20 | return Array.from(value);
21 | } else {
22 | return valuesOfNonArray(value);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/to-string.spec.ts:
--------------------------------------------------------------------------------
1 | import { toString } from './to-string';
2 |
3 | describe('toString()', () => {
4 | it('works', () => {
5 | expect(toString('already a string')).toBe('already a string');
6 | expect(toString('')).toBe('');
7 | expect(toString(1)).toBe('1');
8 | expect(toString([1, 2, 3])).toBe('1,2,3');
9 | expect(toString([undefined, null])).toBe(',');
10 | expect(toString({ hi: 'there' })).toBe('[object Object]');
11 | expect(toString({ toString: () => 'custom toString()' })).toBe(
12 | 'custom toString()',
13 | );
14 | });
15 |
16 | //
17 | // stolen from https://github.com/lodash/lodash
18 | //
19 |
20 | it('treats nullish values as empty strings', () => {
21 | expect(toString(null)).toBe('');
22 | expect(toString(undefined)).toBe('');
23 | expect(toString([undefined, null, undefined, null])).toBe(',,,');
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/lang/to-string.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts `value` to a string. An empty string is returned for `null` and `undefined` values.
3 | *
4 | * Differences:
5 | * - `null` and `undefined` array references are blank
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 1,049 bytes
9 | * - Micro-dash: 35 bytes
10 | */
11 | export function toString(value: any): string {
12 | return [value].toString();
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/extreme-utils.ts:
--------------------------------------------------------------------------------
1 | import { forEachOfArray } from '../collection/for-each';
2 | import { Existent, Primitive, ValueIteratee } from '../interfaces';
3 |
4 | /** @hidden */
5 | export function findExtreme(
6 | array: T[],
7 | iteratee: ValueIteratee,
8 | shouldReplace: (candidate: Primitive, current: Primitive) => boolean,
9 | ): T {
10 | let current: T | undefined;
11 | let currentCriterion: Primitive;
12 | forEachOfArray(array, (candidate) => {
13 | const candidateCriterion = iteratee(candidate);
14 | if (
15 | current === undefined ||
16 | shouldReplace(candidateCriterion, currentCriterion)
17 | ) {
18 | current = candidate;
19 | currentCriterion = candidateCriterion;
20 | }
21 | });
22 | // tslint:disable-next-line:no-non-null-assertion
23 | return current!;
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/index.ts:
--------------------------------------------------------------------------------
1 | export { maxBy } from './max-by';
2 | export { minBy } from './min-by';
3 | export { random } from './random';
4 | export { round } from './round';
5 | export { sumBy } from './sum-by';
6 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/max-by.ts:
--------------------------------------------------------------------------------
1 | import { Existent, Primitive, ValueIteratee } from '../interfaces';
2 | import { findExtreme } from './extreme-utils';
3 |
4 | /**
5 | * 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.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 8,343 bytes
9 | * - Micro-dash: 143 bytes
10 | */
11 | export function maxBy(
12 | array: T[],
13 | iteratee: ValueIteratee,
14 | ): T {
15 | return findExtreme(
16 | array,
17 | iteratee,
18 | (candidate, current) => candidate > current,
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/min-by.ts:
--------------------------------------------------------------------------------
1 | import { Existent, Primitive, ValueIteratee } from '../interfaces';
2 | import { findExtreme } from './extreme-utils';
3 |
4 | /**
5 | * 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.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 8,343 bytes
9 | * - Micro-dash: 143 bytes
10 | */
11 | export function minBy(
12 | array: T[],
13 | iteratee: ValueIteratee,
14 | ): T {
15 | return findExtreme(
16 | array,
17 | iteratee,
18 | (candidate, current) => candidate < current,
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/round.spec.ts:
--------------------------------------------------------------------------------
1 | import { round } from './round';
2 |
3 | describe('round()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return a rounded number without a precision', () => {
9 | expect(round(4.006)).toBe(4);
10 | });
11 |
12 | it('should work with a precision of `0`', () => {
13 | expect(round(4.006, 0)).toBe(4);
14 | });
15 |
16 | it('should work with a positive precision', () => {
17 | expect(round(4.016, 2)).toBe(4.02);
18 | expect(round(4.1, 2)).toBe(4.1);
19 | });
20 |
21 | it('should work with a negative precision', () => {
22 | expect(round(4160, -2)).toBe(4200);
23 | });
24 |
25 | it('should coerce `precision` to an integer', () => {
26 | expect(round(4.006, 0)).toBe(4);
27 | expect(round(4.016, 2.6)).toBe(4.02);
28 | });
29 |
30 | it('should work with exponential notation and `precision`', () => {
31 | expect(round(5e1, 2)).toBe(50);
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/round.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Computes `number` rounded to `precision`.
3 | *
4 | * ```ts
5 | * round(4.006); // 4
6 | * round(4.006, 2); // 4.01
7 | * round(4060, -2); // 4100
8 | * ```
9 | *
10 | * Differences from lodash:
11 | * - may return `NaN` with large `precision` values
12 | *
13 | * Contribution to minified bundle size, when it is the only function imported:
14 | * - Lodash: 1,822 bytes
15 | * - Micro-dash: 78 bytes
16 | */
17 | // tslint:disable-next-line:variable-name
18 | export function round(number: number, precision = 0): number {
19 | const factor = 10 ** Math.trunc(precision);
20 | return Math.round(number * factor) / factor;
21 | }
22 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/sum-by.spec.ts:
--------------------------------------------------------------------------------
1 | import { identity } from 'lodash-es';
2 | import { stub } from 'sinon';
3 | import { sumBy } from './sum-by';
4 |
5 | describe('sumBy()', () => {
6 | //
7 | // stolen from https://github.com/lodash/lodash
8 | //
9 |
10 | const array = [6, 4, 2];
11 | const objects = [{ a: 2 }, { a: 3 }, { a: 1 }];
12 |
13 | it('should work with an `iteratee`', () => {
14 | expect(sumBy(objects, (object) => object.a)).toBe(6);
15 | });
16 |
17 | it('should provide correct `iteratee` arguments', () => {
18 | const logger = stub();
19 | sumBy([6], logger);
20 | expect(logger.args).toEqual([[6]]);
21 | });
22 |
23 | it('should return the sum of an array of numbers', () => {
24 | expect(sumBy(array, identity)).toBe(12);
25 | });
26 |
27 | it('should return `0` when passing empty `array` values', () => {
28 | expect(sumBy([], identity)).toBe(0);
29 | });
30 |
31 | it('should not skip `NaN` values', () => {
32 | expect(sumBy([1, NaN], identity)).toBeNaN();
33 | });
34 | });
35 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/math/sum-by.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * 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).
3 | *
4 | * Differences from lodash:
5 | * - does not skip `undefined` values
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 8,292 bytes
9 | * - Micro-dash: 22 bytes
10 | */
11 | export function sumBy(array: T[], iteratee: (element: T) => number): number {
12 | return array.reduce((sum, element) => sum + iteratee(element), 0);
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/number/clamp.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Clamps `number` within the inclusive lower and upper bounds.
3 | *
4 | * Differences from lodash:
5 | * - `lower` is required
6 | * - does not coerce bounds that are `NaN` to be `0`
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 1,367 bytes
10 | * - Micro-dash: 51 bytes
11 | */
12 | // tslint:disable-next-line:variable-name
13 | export function clamp(number: number, lower: number, upper: number): number {
14 | return Math.min(upper, Math.max(lower, number));
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/number/in-range.spec.ts:
--------------------------------------------------------------------------------
1 | import { inRange } from './in-range';
2 |
3 | describe('inRange()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should work with a `start` and `end`', () => {
9 | expect(inRange(1, 1, 5)).toBe(true);
10 | expect(inRange(3, 1, 5)).toBe(true);
11 | expect(inRange(0, 1, 5)).toBe(false);
12 | expect(inRange(5, 1, 5)).toBe(false);
13 | });
14 |
15 | it('should swap `start` and `end` when `start` > `end`', () => {
16 | expect(inRange(2, 5, 1)).toBe(true);
17 | expect(inRange(-3, -2, -6)).toBe(true);
18 | });
19 |
20 | it('should work with a floating point `n` value', () => {
21 | expect(inRange(1.2, 1, 5)).toBe(true);
22 | expect(inRange(0.5, 1, 5)).toBe(false);
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/number/in-range.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if `n` is between `start` and up to, but not including, `end`. If start is greater than end the params are swapped to support negative ranges.
3 | *
4 | * Differences from lodash:
5 | * - `start` and `end` are both required
6 | * - does not coerce falsey bounds to `0`
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 1,396 bytes
10 | * - Micro-dash: 59 bytes
11 | */
12 | // tslint:disable-next-line:variable-name
13 | export function inRange(number: number, start: number, end: number): boolean {
14 | return number >= Math.min(start, end) && number < Math.max(start, end);
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/number/index.ts:
--------------------------------------------------------------------------------
1 | export { clamp } from './clamp';
2 | export { inRange } from './in-range';
3 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/for-own-right.ts:
--------------------------------------------------------------------------------
1 | import { forEachRightOfArray } from '../collection/for-each-right';
2 | import { ObjectIteratee } from '../interfaces';
3 | import { keys, keysOfNonArray } from './keys';
4 |
5 | /**
6 | * This method is like `forOwn` except that it iterates over properties of `object` in the opposite order.
7 | *
8 | * Differences from lodash:
9 | * - does not treat sparse arrays as dense
10 | *
11 | * Contribution to minified bundle size, when it is the only function imported:
12 | * - Lodash: 3,507 bytes
13 | * - Micro-dash: 191 bytes
14 | */
15 | export function forOwnRight(
16 | object: T,
17 | iteratee: ObjectIteratee,
18 | ): T {
19 | forEachRightOfArray(keys(object), (key) =>
20 | iteratee(object[key as keyof T], key),
21 | );
22 | return object;
23 | }
24 |
25 | /** @hidden */
26 | export function forOwnRightOfNonArray(
27 | object: T,
28 | iteratee: ObjectIteratee,
29 | ): T {
30 | forEachRightOfArray(keysOfNonArray(object), (key) =>
31 | iteratee(object[key as keyof T], key),
32 | );
33 | return object;
34 | }
35 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/for-own.ts:
--------------------------------------------------------------------------------
1 | import { forEachOfArray } from '../collection/for-each';
2 | import { ObjectIteratee } from '../interfaces';
3 | import { keys, keysOfNonArray } from './keys';
4 |
5 | /**
6 | * Iterates over own enumerable string keyed properties of an object and invokes `iteratee` for each property. Iteratee functions may exit iteration early by explicitly returning `false`.
7 | *
8 | * Differences from lodash:
9 | * - does not treat sparse arrays as dense
10 | *
11 | * Contribution to minified bundle size, when it is the only function imported:
12 | * - Lodash: 3,514 bytes
13 | * - Micro-dash: 213 bytes
14 | */
15 | export function forOwn(
16 | object: T,
17 | iteratee: ObjectIteratee,
18 | ): T {
19 | forEachOfArray(keys(object), (key) => iteratee(object[key as keyof T], key));
20 | return object;
21 | }
22 |
23 | /** @hidden */
24 | export function forOwnOfNonArray(
25 | object: T,
26 | iteratee: ObjectIteratee,
27 | ): T {
28 | forEachOfArray(keysOfNonArray(object), (key) =>
29 | iteratee(object[key as keyof T], key),
30 | );
31 | return object;
32 | }
33 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/functions.spec.ts:
--------------------------------------------------------------------------------
1 | import { identity, isArray, noop } from 'lodash-es';
2 | import { functions } from './functions';
3 |
4 | describe('functions()', () => {
5 | it('does not include constructors', () => {
6 | class MyClass {
7 | a = 1;
8 |
9 | b(): number {
10 | return 2;
11 | }
12 | }
13 | expect(functions(MyClass.prototype)).toEqual(['b']);
14 | });
15 |
16 | //
17 | // stolen from https://github.com/lodash/lodash
18 | //
19 |
20 | it('should return the function names of an object', () => {
21 | const object = { a: 'a', b: identity, c: /x/, d: noop };
22 | expect(functions(object).sort()).toEqual(['b', 'd']);
23 | });
24 |
25 | it('should not include inherited functions', () => {
26 | function Foo(this: any): void {
27 | this.a = identity;
28 | this.b = 'b';
29 | }
30 | Foo.prototype.c = noop;
31 |
32 | expect(functions(new (Foo as any)())).toEqual(['a']);
33 | });
34 |
35 | it('should return an array', () => {
36 | const array = [1, 2, 3];
37 | const actual = functions(array);
38 | expect(isArray(actual)).toBe(true);
39 | expect(actual as any).not.toBe(array);
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/functions.ts:
--------------------------------------------------------------------------------
1 | import { isFunction, keys } from '../../public-api';
2 | import { StringifiedKey } from '../interfaces';
3 |
4 | /**
5 | * Creates an array of function property names from own enumerable properties of `object`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 3,504 bytes
9 | * - Micro-dash: 225 bytes
10 | */
11 | export function functions(obj: T): Array> {
12 | return keys(obj).filter(
13 | (key) => key !== 'constructor' && isFunction(obj[key as keyof T]),
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/index.ts:
--------------------------------------------------------------------------------
1 | export { findKey } from './find-key';
2 | export { forOwn } from './for-own';
3 | export { forOwnRight } from './for-own-right';
4 | export { functions } from './functions';
5 | export { get } from './get';
6 | export { invoke } from './invoke';
7 | export { keys } from './keys';
8 | export { mapValues } from './map-values';
9 | export { merge } from './merge';
10 | export { omit } from './omit';
11 | export { omitBy } from './omit-by';
12 | export { pick } from './pick';
13 | export { pickBy } from './pick-by';
14 | export { set } from './set';
15 | export { toPairs } from './to-pairs';
16 | export { transform } from './transform';
17 | export { update } from './update';
18 | export { values } from './values';
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/keys.ts:
--------------------------------------------------------------------------------
1 | import { Nil, StringifiedKey } from '../interfaces';
2 |
3 | /**
4 | * Creates an array of the own enumerable property names of object.
5 | *
6 | * Differences from lodash:
7 | * - does not give any special consideration for arguments objects, strings, or prototype objects (e.g. many will have `'length'` in the returned array)
8 | *
9 | * Contribution to minified bundle size, when it is the only function imported:
10 | * - Lodash: 3,326 bytes
11 | * - Micro-dash: 148 bytes
12 | */
13 |
14 | export function keys(object: T | Nil): Array> {
15 | let val = keysOfNonArray(object);
16 | if (Array.isArray(object)) {
17 | val = val.filter((item) => item !== 'length');
18 | }
19 | return val as any;
20 | }
21 |
22 | /** @hidden */
23 | export function keysOfNonArray(object: T | Nil): Array> {
24 | let val: string[] = [];
25 | if (object) {
26 | val = Object.getOwnPropertyNames(object);
27 | }
28 | return val as any;
29 | }
30 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/map-values.ts:
--------------------------------------------------------------------------------
1 | import { IfCouldBe, Nil, ObjectIteratee } from '../interfaces';
2 | import { forOwn } from './for-own';
3 |
4 | /**
5 | * Creates an object with the same keys as `object` and values generated by running each own enumerable string keyed property of `object` thru `iteratee`.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 13,946 bytes
9 | * - Micro-dash: 278 bytes
10 | */
11 |
12 | export function mapValues(
13 | array: A,
14 | iteratee: (item: NonNullable[number], index: number) => O,
15 | ): { [index: number]: O } | IfCouldBe;
16 |
17 | export function mapValues(
18 | object: T,
19 | iteratee: ObjectIteratee,
20 | ): { [key in keyof NonNullable]: O } | IfCouldBe;
21 |
22 | export function mapValues(object: any, iteratee: Function): any {
23 | const obj: any = {};
24 | forOwn(object, (value, key) => {
25 | obj[key] = iteratee(value, key);
26 | });
27 | return obj;
28 | }
29 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/omit.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 | import { clone } from '../lang';
3 |
4 | /**
5 | * The opposite of `pick`; this method creates an object composed of the own enumerable string properties of object that are not omitted.
6 | *
7 | * Differences from lodash:
8 | * - `paths` must be direct keys of `object` (they cannot refer to deeper properties)
9 | * - does not work with arrays
10 | *
11 | * Contribution to minified bundle size, when it is the only function imported:
12 | * - Lodash: 15,603 bytes
13 | * - Micro-dash: 138 bytes
14 | */
15 | export function omit(
16 | object: T,
17 | ...paths: Array
18 | ): Partial {
19 | const obj: any = clone(object) || {};
20 | for (const path of paths) {
21 | delete obj[path];
22 | }
23 | return obj;
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/pick.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 |
3 | /**
4 | * Creates an object composed of the picked `object` properties.
5 | *
6 | * Differences from lodash:
7 | * - `paths` must be direct properties of `object` (they cannot references deep properties)
8 | *
9 | * Contribution to minified bundle size, when it is the only function imported:
10 | * - Lodash: 7,691 bytes
11 | * - Micro-dash: 77 bytes
12 | */
13 | export function pick(
14 | object: T | Nil,
15 | ...paths: K[]
16 | ): T extends Nil ? {} : Pick {
17 | const result: any = {};
18 | if (object != null) {
19 | for (const path of paths) {
20 | result[path] = object[path];
21 | }
22 | }
23 | return result;
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/set.ts:
--------------------------------------------------------------------------------
1 | import { constant } from '../util';
2 | import { update } from './update';
3 |
4 | /**
5 | * 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.
6 | *
7 | * **Note:** This method mutates `object`.
8 | *
9 | * Differences from lodash:
10 | * - only accepts an array for `path`, not a dot-separated string
11 | * - does not handle `customizer` returning `undefined`
12 | *
13 | * Contribution to minified bundle size, when it is the only function imported:
14 | * - Lodash: 5,639 bytes
15 | * - Micro-dash: 178 bytes
16 | */
17 | export function set(object: T, path: Array, value: any): T {
18 | return update(object, path, constant(value));
19 | }
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/to-pairs.ts:
--------------------------------------------------------------------------------
1 | import { StringifiedKey } from '../interfaces';
2 | import { keys } from './keys';
3 |
4 | /**
5 | * Creates an array of own enumerable string keyed-value pairs for `object` which can be consumed by `fromPairs`.
6 | *
7 | * Differences from lodash:
8 | * - does not give any special consideration for arguments objects, strings, or prototype objects (e.g. many will have `'length'` in the returned array)
9 | *
10 | * Contribution to minified bundle size, when it is the only function imported:
11 | * - Lodash: 4,911 bytes
12 | * - Micro-dash: 175 bytes
13 | */
14 | export function toPairs(object: T): Array<[StringifiedKey, T[keyof T]]> {
15 | return keys(object).map((key) => [key, object[key as keyof T]]);
16 | }
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/update.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This method is like `set()` except that it accepts `updater` to produce the value to set.
3 | *
4 | * **Note:** This method mutates `object`.
5 | *
6 | * Differences from lodash:
7 | * - only accepts an array for `path`, not a dot-separated string
8 | * - does not handle `customizer` returning `undefined`
9 | *
10 | * Contribution to minified bundle size, when it is the only function imported:
11 | * - Lodash: 5,842 bytes
12 | * - Micro-dash: 177 bytes
13 | */
14 | export function update(
15 | object: T,
16 | path: Array,
17 | updater: (val: any) => any,
18 | ): T {
19 | if (object && path.length) {
20 | let current: any = object;
21 | const length = path.length;
22 | for (let i = 0; i < length; ++i) {
23 | const key = path[i];
24 | let value = current[key];
25 | if (i < length - 1) {
26 | if (!(value instanceof Object)) {
27 | value = Number.isInteger(path[i + 1] as any) ? [] : {};
28 | }
29 | } else {
30 | value = updater(value);
31 | }
32 | current = current[key] = value;
33 | }
34 | }
35 | return object;
36 | }
37 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/values.spec.ts:
--------------------------------------------------------------------------------
1 | import { values } from './values';
2 |
3 | describe('values()', () => {
4 | it('works for null & undefined', () => {
5 | expect(values(null)).toEqual([]);
6 | expect(values(undefined)).toEqual([]);
7 | });
8 |
9 | it('does not consider `length` for an array', () => {
10 | expect(values([1, 2, 3]).sort()).toEqual([1, 2, 3]);
11 | });
12 |
13 | //
14 | // stolen from https://github.com/lodash/lodash
15 | //
16 |
17 | it('should get string keyed values of `object`', () => {
18 | expect(values({ a: 1, b: 2 }).sort()).toEqual([1, 2]);
19 | });
20 |
21 | it('should work with an object that has a `length` property', () => {
22 | expect(values({ 0: 'a', 1: 'b', length: 2 }).sort()).toEqual([2, 'a', 'b']);
23 | });
24 |
25 | it('should not include inherited string keyed property values', () => {
26 | function Foo(this: any): void {
27 | this.a = 1;
28 | }
29 |
30 | Foo.prototype.b = 2;
31 |
32 | expect(values(new (Foo as any)())).toEqual([1]);
33 | });
34 | });
35 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/object/values.ts:
--------------------------------------------------------------------------------
1 | import { keys, keysOfNonArray } from './keys';
2 |
3 | /**
4 | * Creates an array of the own enumerable string keyed property values of `object`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 3,422 bytes
8 | * - Micro-dash: 170 bytes
9 | */
10 | export function values(object: T): T[keyof T][] {
11 | return keys(object).map((key) => object[key as keyof T]);
12 | }
13 |
14 | /** @hidden */
15 | export function valuesOfNonArray(object: T): T[keyof T][] {
16 | return keysOfNonArray(object).map((key) => object[key as keyof T]);
17 | }
18 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/camel-case.ts:
--------------------------------------------------------------------------------
1 | import { capitalize } from './capitalize';
2 | import { words } from './words';
3 |
4 | /**
5 | * Converts `string` to camel case.
6 | *
7 | * Differences from lodash:
8 | * - requires `string` to be a string
9 | *
10 | * Contribution to minified bundle size, when it is the only function imported:
11 | * - Lodash: 6,180 bytes
12 | * - Micro-dash: 322 bytes
13 | */
14 | // tslint:disable-next-line:variable-name
15 | export function camelCase(string: string): string {
16 | return words(string)
17 | .map((w, i) => (i ? capitalize(w) : w.toLowerCase()))
18 | .join('');
19 | }
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/capitalize.spec.ts:
--------------------------------------------------------------------------------
1 | import { capitalize } from './capitalize';
2 |
3 | describe('capitalize()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should capitalize the first character of a string', () => {
9 | expect(capitalize('fred')).toBe('Fred');
10 | expect(capitalize('Fred')).toBe('Fred');
11 | expect(capitalize(' fred')).toBe(' fred');
12 | });
13 |
14 | it('should return an empty string for empty values', () => {
15 | expect(capitalize('')).toBe('');
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/capitalize.ts:
--------------------------------------------------------------------------------
1 | import { upperFirst } from './upper-first';
2 |
3 | /**
4 | * Converts the first character of `string` to upper case and the remaining to lower case.
5 | *
6 | * Differences from lodash:
7 | * - requires `string` to be a string
8 | *
9 | * Contribution to minified bundle size, when it is the only function imported:
10 | * - Lodash: 1,948 bytes
11 | * - Micro-dash: 72 bytes
12 | */
13 | // tslint:disable-next-line:variable-name
14 | export function capitalize(string: string): string {
15 | return upperFirst(string.toLowerCase());
16 | }
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/index.ts:
--------------------------------------------------------------------------------
1 | export { camelCase } from './camel-case';
2 | export { capitalize } from './capitalize';
3 | export { kebabCase } from './kebab-case';
4 | export { lowerFirst } from './lower-first';
5 | export { pad } from './pad';
6 | export { padStart } from './pad-start';
7 | export { padEnd } from './pad-end';
8 | export { repeat } from './repeat';
9 | export { snakeCase } from './snake-case';
10 | export { toLower } from './to-lower';
11 | export { upperFirst } from './upper-first';
12 | export { words } from './words';
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/kebab-case.spec.ts:
--------------------------------------------------------------------------------
1 | import { kebabCase } from './kebab-case';
2 |
3 | describe('kebabCase()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should convert `string` to kebab case', () => {
9 | const strings = [
10 | 'foo bar',
11 | 'Foo bar',
12 | 'foo Bar',
13 | 'Foo Bar',
14 | 'FOO BAR',
15 | 'fooBar',
16 | '--foo-bar--',
17 | '__foo_bar__',
18 | ];
19 |
20 | for (const str of strings) {
21 | expect(kebabCase(str)).toBe('foo-bar');
22 | }
23 | });
24 |
25 | it('should handle double-converting strings', () => {
26 | const strings = [
27 | 'foo bar',
28 | 'Foo bar',
29 | 'foo Bar',
30 | 'Foo Bar',
31 | 'FOO BAR',
32 | 'fooBar',
33 | '--foo-bar--',
34 | '__foo_bar__',
35 | ];
36 |
37 | for (const str of strings) {
38 | expect(kebabCase(kebabCase(str))).toBe('foo-bar');
39 | }
40 | });
41 |
42 | it('should remove Latin mathematical operators', () => {
43 | expect(kebabCase('\xd7')).toBe('');
44 | expect(kebabCase('\xf7')).toBe('');
45 | });
46 |
47 | it('should return an empty string for empty values', () => {
48 | expect(kebabCase('')).toBe('');
49 | });
50 | });
51 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/kebab-case.ts:
--------------------------------------------------------------------------------
1 | import { toLower } from './to-lower';
2 | import { words } from './words';
3 |
4 | /**
5 | * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 5,232 bytes
9 | * - Micro-dash: 234 bytes
10 | */
11 | // tslint:disable-next-line:variable-name
12 | export function kebabCase(string: string): string {
13 | return words(string).map(toLower).join('-');
14 | }
15 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/lower-first.spec.ts:
--------------------------------------------------------------------------------
1 | import { lowerFirst } from './lower-first';
2 |
3 | describe('lowerFirst()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should lowercase only the first character', () => {
9 | expect(lowerFirst('fred')).toBe('fred');
10 | expect(lowerFirst('Fred')).toBe('fred');
11 | expect(lowerFirst('FRED')).toBe('fRED');
12 | });
13 |
14 | it('should return an empty string for empty values', () => {
15 | expect(lowerFirst(null)).toBe('');
16 | expect(lowerFirst(undefined)).toBe('');
17 | expect(lowerFirst('')).toBe('');
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/lower-first.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 |
3 | /**
4 | * Converts the first character of `string` to lower case.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 1,951 bytes
8 | * - Micro-dash: 63 bytes
9 | */
10 | // tslint:disable-next-line:variable-name
11 | export function lowerFirst(string: string | Nil): string {
12 | return string ? string.charAt(0).toLowerCase() + string.slice(1) : '';
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad-end.spec.ts:
--------------------------------------------------------------------------------
1 | import { padEnd } from './pad-end';
2 |
3 | describe('padEnd()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const abc = 'abc';
9 |
10 | it('should pad a string to a given length', () => {
11 | expect(padEnd(abc, 6)).toEqual('abc ');
12 | expect(padEnd(abc, 6, undefined)).toEqual('abc ');
13 | });
14 |
15 | it('should truncate pad characters to fit the pad length', () => {
16 | expect(padEnd(abc, 6, '_-')).toEqual('abc_-_');
17 | });
18 |
19 | it('should not pad if string is >= `length`', () => {
20 | expect(padEnd(abc, 2)).toEqual(abc);
21 | expect(padEnd(abc, 3)).toEqual(abc);
22 | });
23 |
24 | it('should treat negative `length` as `0`', () => {
25 | expect(padEnd(abc, 0)).toEqual(abc);
26 | expect(padEnd(abc, -2)).toEqual(abc);
27 | });
28 |
29 | it('should return `string` when `chars` is the empty string', () => {
30 | expect(padEnd(abc, 6, '')).toEqual(abc);
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad-end.ts:
--------------------------------------------------------------------------------
1 | import { makePadding } from './pad';
2 |
3 | /**
4 | * Pads `string` on the right side if it's shorter than `length`. Padding characters are truncated if they exceed `length`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 3,308 bytes
8 | * - Micro-dash: 161 bytes
9 | */
10 | export function padEnd(s: string, length: number, chars = ' '): string {
11 | return s + makePadding(s, length, chars);
12 | }
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad-start.spec.ts:
--------------------------------------------------------------------------------
1 | import { padStart } from './pad-start';
2 |
3 | describe('padStart()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const abc = 'abc';
9 |
10 | it('should pad a string to a given length', () => {
11 | expect(padStart(abc, 6)).toEqual(' abc');
12 | expect(padStart(abc, 6, undefined)).toEqual(' abc');
13 | });
14 |
15 | it('should truncate pad characters to fit the pad length', () => {
16 | expect(padStart(abc, 6, '_-')).toEqual('_-_abc');
17 | });
18 |
19 | it('should not pad if string is >= `length`', () => {
20 | expect(padStart(abc, 2)).toEqual(abc);
21 | expect(padStart(abc, 3)).toEqual(abc);
22 | });
23 |
24 | it('should treat negative `length` as `0`', () => {
25 | expect(padStart(abc, 0)).toEqual(abc);
26 | expect(padStart(abc, -2)).toEqual(abc);
27 | });
28 |
29 | it('should return `string` when `chars` is the empty string', () => {
30 | expect(padStart(abc, 6, '')).toEqual(abc);
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad-start.ts:
--------------------------------------------------------------------------------
1 | import { makePadding } from './pad';
2 |
3 | /**
4 | * Pads `string` on the left side if it's shorter than `length`. Padding characters are truncated if they exceed `length`.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 3,308 bytes
8 | * - Micro-dash: 161 bytes
9 | */
10 | export function padStart(s: string, length: number, chars = ' '): string {
11 | return makePadding(s, length, chars) + s;
12 | }
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad.spec.ts:
--------------------------------------------------------------------------------
1 | import { pad } from './pad';
2 |
3 | describe('pad()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const abc = 'abc';
9 |
10 | it('should pad a string to a given length', () => {
11 | expect(pad(abc, 6)).toEqual(' abc ');
12 | expect(pad(abc, 6, undefined)).toEqual(' abc ');
13 | });
14 |
15 | it('should truncate pad characters to fit the pad length', () => {
16 | expect(pad(abc, 8)).toEqual(' abc ');
17 | expect(pad(abc, 8, '_-')).toEqual('_-abc_-_');
18 | });
19 |
20 | it('should not pad if string is >= `length`', () => {
21 | expect(pad(abc, 2)).toEqual(abc);
22 | expect(pad(abc, 3)).toEqual(abc);
23 | });
24 |
25 | it('should treat negative `length` as `0`', () => {
26 | expect(pad(abc, 0)).toEqual(abc);
27 | expect(pad(abc, -2)).toEqual(abc);
28 | });
29 |
30 | it('should return `string` when `chars` is the empty string', () => {
31 | expect(pad(abc, 6, '')).toEqual(abc);
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/pad.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * 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`.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 3,359 bytes
6 | * - Micro-dash: 177 bytes
7 | */
8 | export function pad(s: string, length: number, chars = ' '): string {
9 | const needed = (length - s.length) / 2;
10 | return (
11 | _makePadding(Math.floor(needed), chars) +
12 | s +
13 | _makePadding(Math.ceil(needed), chars)
14 | );
15 | }
16 |
17 | /** @hidden */
18 | export function makePadding(s: string, length: number, chars: string): string {
19 | return _makePadding(length - s.length, chars);
20 | }
21 |
22 | /** @hidden */
23 | function _makePadding(needed: number, chars: string): string {
24 | return needed > 0 && chars.length > 0
25 | ? chars.repeat(Math.ceil(needed / chars.length)).substr(0, needed)
26 | : '';
27 | }
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/repeat.spec.ts:
--------------------------------------------------------------------------------
1 | import { repeat } from './repeat';
2 |
3 | describe('repeat()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const str = 'abc';
9 |
10 | it('should repeat a string `n` times', () => {
11 | expect(repeat('*', 3)).toBe('***');
12 | expect(repeat(str, 2)).toBe('abcabc');
13 | });
14 |
15 | it('should return an empty string if `n` is <= `0`', () => {
16 | expect(repeat(str, 0)).toBe('');
17 | expect(repeat(str, -2)).toBe('');
18 | });
19 |
20 | it('should coerce `n` to an integer', () => {
21 | expect(repeat(str, 2.6)).toBe('abcabc');
22 | });
23 |
24 | it('should return an empty string for empty values', () => {
25 | expect(repeat('', 2)).toBe('');
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/repeat.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Repeats the given string `n` times.
3 | *
4 | * Differences from lodash:
5 | * - does not work as an iteratee for methods like `map`
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 2,357 bytes
9 | * - Micro-dash: 62 bytes
10 | */
11 | // tslint:disable-next-line:variable-name
12 | export function repeat(string: string, n: number): string {
13 | // tslint:disable-next-line:no-bitwise
14 | return n < 0 ? '' : new Array(n | 0).fill(string).join('');
15 | }
16 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/snake-case.spec.ts:
--------------------------------------------------------------------------------
1 | import { snakeCase } from './snake-case';
2 |
3 | describe('snakeCase()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | const strings = [
9 | 'foo bar',
10 | 'Foo bar',
11 | 'foo Bar',
12 | 'Foo Bar',
13 | 'FOO BAR',
14 | 'fooBar',
15 | '--foo-bar--',
16 | '__foo_bar__',
17 | ];
18 |
19 | it('should convert `string` to snake case', () => {
20 | for (const str of strings) {
21 | expect(snakeCase(str)).toBe('foo_bar');
22 | }
23 | });
24 |
25 | it('should handle double-converting strings', () => {
26 | for (const str of strings) {
27 | expect(snakeCase(snakeCase(str))).toBe('foo_bar');
28 | }
29 | });
30 |
31 | it('should remove Latin mathematical operators', () => {
32 | expect(snakeCase('\xd7')).toBe('');
33 | expect(snakeCase('\xf7')).toBe('');
34 | });
35 |
36 | it('should return an empty string for empty values', () => {
37 | expect(snakeCase('')).toBe('');
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/snake-case.ts:
--------------------------------------------------------------------------------
1 | import { toLower } from './to-lower';
2 | import { words } from './words';
3 |
4 | /**
5 | * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case)
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 5,249 bytes
9 | * - Micro-dash: 235 bytes
10 | */
11 | // tslint:disable-next-line:variable-name
12 | export function snakeCase(string: string): string {
13 | return words(string).map(toLower).join('_');
14 | }
15 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/to-lower.spec.ts:
--------------------------------------------------------------------------------
1 | import { toLower } from './to-lower';
2 |
3 | describe('toLower()', () => {
4 | it('should convert whole string to lower case', () => {
5 | expect(toLower('--Foo-Bar--')).toBe('--foo-bar--');
6 | expect(toLower('fooBar')).toBe('foobar');
7 | expect(toLower('__FOO_BAR__')).toBe('__foo_bar__');
8 | });
9 |
10 | it('should return an empty string for empty values', () => {
11 | expect(toLower('')).toBe('');
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/to-lower.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts `string`, as a whole, to lower case just like `String#toLowerCase`.
3 | *
4 | * Differences from lodash:
5 | * - requires `string` to be a string
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 1,001 bytes
9 | * - Micro-dash: 16 bytes
10 | */
11 | // tslint:disable-next-line:variable-name
12 | export function toLower(string: string): string {
13 | return string.toLowerCase();
14 | }
15 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/upper-first.spec.ts:
--------------------------------------------------------------------------------
1 | import { upperFirst } from './upper-first';
2 |
3 | describe('upperFirst()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should uppercase only the first character', () => {
9 | expect(upperFirst('fred')).toBe('Fred');
10 | expect(upperFirst('Fred')).toBe('Fred');
11 | expect(upperFirst('FRED')).toBe('FRED');
12 | });
13 |
14 | it('should return an empty string for empty values', () => {
15 | expect(upperFirst(null)).toBe('');
16 | expect(upperFirst(undefined)).toBe('');
17 | expect(upperFirst('')).toBe('');
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/upper-first.ts:
--------------------------------------------------------------------------------
1 | import { Nil } from '../interfaces';
2 |
3 | /**
4 | * Converts the first character of `string` to upper case.
5 | *
6 | * Contribution to minified bundle size, when it is the only function imported:
7 | * - Lodash: 1,951 bytes
8 | * - Micro-dash: 63 bytes
9 | */
10 | // tslint:disable-next-line:variable-name
11 | export function upperFirst(string: string | Nil): string {
12 | return string ? string.charAt(0).toUpperCase() + string.slice(1) : '';
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/string/words.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Splits `string` into an array of its words.
3 | *
4 | * Differences from lodash:
5 | * - does not accept a `pattern` argument
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 2,361 bytes
9 | * - Micro-dash: 176 bytes
10 | */
11 | // tslint:disable-next-line:variable-name
12 | export function words(string: string): string[] {
13 | return (
14 | string
15 | // between lower & upper
16 | .replace(/([a-z])([A-Z])/g, '$1 $2')
17 | // between number & letter
18 | .replace(/(\d)([A-Za-z])/g, '$1 $2')
19 | .replace(/([A-Za-z])(\d)/g, '$1 $2')
20 | // before last upper in a sequence followed by lower
21 | .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
22 | .match(/[A-Za-z0-9]+/g) || []
23 | );
24 | }
25 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/constant.spec.ts:
--------------------------------------------------------------------------------
1 | import { constant } from './constant';
2 |
3 | describe('constant()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should create a function that returns `value`', () => {
9 | const object = { a: 1 };
10 | const resultFn: any = constant(object);
11 | const values = [[], {}, null, undefined, false, 0, NaN, '', true, 1, 'a'];
12 |
13 | expect(resultFn.call({})).toBe(object);
14 | expect(resultFn()).toBe(object);
15 | for (const value of values) {
16 | expect(resultFn(value)).toBe(object);
17 | }
18 | });
19 |
20 | it('should work with falsey values', () => {
21 | const falsey = [null, undefined, false, 0, NaN, ''];
22 |
23 | expect((constant as any)()()).toBeUndefined();
24 | for (const value of falsey) {
25 | expect(constant(value)()).toEqual(value);
26 | }
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/constant.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a function that returns `value`.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 48 bytes
6 | * - Micro-dash: 4 bytes
7 | */
8 | export function constant(value: T): () => T {
9 | return () => value;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/flow-right.spec.ts:
--------------------------------------------------------------------------------
1 | import { curry, head, identity } from 'lodash';
2 | import { flowRight } from './flow-right';
3 |
4 | describe('flowRight()', () => {
5 | //
6 | // stolen from https://github.com/lodash/lodash
7 | //
8 |
9 | it('should supply each function with the return value of the previous', () => {
10 | const increment = (x: number) => x + 1;
11 | const square = (x: number) => x * x;
12 | const fixed = (n: number) => n.toFixed(1);
13 |
14 | expect(flowRight(fixed, square, increment)(2)).toBe('9.0');
15 | });
16 |
17 | it('should return an identity function when no arguments are given', () => {
18 | expect(flowRight()('a')).toBe('a');
19 | });
20 |
21 | it('should work with a curried function and `_.head`', () => {
22 | const curried: any = curry(identity);
23 | const combined: any = flowRight(head as any, curried);
24 |
25 | expect(combined([1])).toBe(1);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/flow.spec.ts:
--------------------------------------------------------------------------------
1 | import { curry, head, identity } from 'lodash';
2 | import { flow } from './flow';
3 |
4 | describe('flow()', () => {
5 | //
6 | // stolen from https://github.com/lodash/lodash
7 | //
8 |
9 | it('should supply each function with the return value of the previous', () => {
10 | const increment = (x: number) => x + 1;
11 | const square = (x: number) => x * x;
12 | const fixed = (n: number) => n.toFixed(1);
13 |
14 | expect(flow(increment, square, fixed)(2)).toBe('9.0');
15 | });
16 |
17 | it('should return an identity function when no arguments are given', () => {
18 | expect(flow()('a')).toBe('a');
19 | });
20 |
21 | it('should work with a curried function and `_.head`', () => {
22 | const curried: any = curry(identity);
23 | const combined: any = flow(head as any, curried);
24 | expect(combined([1])).toBe(1);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/identity.spec.ts:
--------------------------------------------------------------------------------
1 | import { identity } from './identity';
2 |
3 | describe('identity()', () => {
4 | it('works when given too many arguments', () => {
5 | expect((identity as any)(1, 2)).toBe(1);
6 | });
7 |
8 | //
9 | // stolen from https://github.com/lodash/lodash
10 | //
11 |
12 | it('should return the first argument given', () => {
13 | const object = { name: 'fred' };
14 | expect(identity(object)).toBe(object);
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/identity.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This method returns the first argument it receives.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 41 bytes
6 | * - Micro-dash: 23 bytes
7 | */
8 | export function identity(value: T): T {
9 | return value;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/index.ts:
--------------------------------------------------------------------------------
1 | export { constant } from './constant';
2 | export { flow } from './flow';
3 | export { flowRight } from './flow-right';
4 | export { identity } from './identity';
5 | export { matches } from './matches';
6 | export { noop } from './noop';
7 | export { range } from './range';
8 | export { times } from './times';
9 | export { uniqueId } from './unique-id';
10 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/matches.ts:
--------------------------------------------------------------------------------
1 | import { cloneDeep, isMatch } from '../lang';
2 |
3 | /**
4 | * 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`.
5 | *
6 | * Note: The created function is equivalent to `isMatch` with source partially applied.
7 | *
8 | * Partial comparisons will match empty array and empty object source values against any array or object value, respectively.
9 | *
10 | * Differences from lodash:
11 | * - does not match `0` to `-0`
12 | *
13 | * Contribution to minified bundle size, when it is the only function imported:
14 | * - Lodash: 15,939 bytes
15 | * - Micro-dash: 955 bytes
16 | */
17 | export function matches(source: any): (value: any) => boolean {
18 | source = cloneDeep(source);
19 | return (value: any) => isMatch(value, source);
20 | }
21 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/noop.spec.ts:
--------------------------------------------------------------------------------
1 | import { noop } from './noop';
2 |
3 | describe('noop()', () => {
4 | //
5 | // stolen from https://github.com/lodash/lodash
6 | //
7 |
8 | it('should return undefined', () => {
9 | const values = [[], {}, null, undefined, false, 0, NaN, '', true, 1, 'a'];
10 |
11 | expect(noop.call({})).toBeUndefined();
12 | expect(noop()).toBeUndefined();
13 | for (const value of values) {
14 | expect((noop as any)(value)).toBeUndefined();
15 | }
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/noop.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This method returns undefined.
3 | *
4 | * Contribution to minified bundle size, when it is the only function imported:
5 | * - Lodash: 47 bytes
6 | * - Micro-dash: 14 bytes
7 | */
8 | export function noop(): void {}
9 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/range.ts:
--------------------------------------------------------------------------------
1 | import { isUndefined } from '../lang';
2 | import { times } from './times';
3 |
4 | /**
5 | * 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` with `start` then set to `0`.
6 | *
7 | * **Note:** JavaScript follows the IEEE-754 standard for resolving floating-point values which can produce unexpected results.
8 | *
9 | * Differences from lodash:
10 | * - does not work as an iteratee for methods like `map`
11 | *
12 | * Contribution to minified bundle size, when it is the only function imported:
13 | * - Lodash: 2,020 bytes
14 | * - Micro-dash: 181 bytes
15 | */
16 |
17 | export function range(end: number): number[];
18 | // tslint:disable-next-line:unified-signatures
19 | export function range(start: number, end: number, step?: number): number[];
20 |
21 | export function range(start: number, end?: number, step?: number): number[] {
22 | if (isUndefined(end)) {
23 | end = start;
24 | start = 0;
25 | }
26 | if (isUndefined(step)) {
27 | step = end < start ? -1 : 1;
28 | }
29 | return times(Math.abs((end - start) / (step || 1)), (i) => start + step! * i);
30 | }
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/times.spec.ts:
--------------------------------------------------------------------------------
1 | import { stub } from 'sinon';
2 | import { times } from './times';
3 |
4 | describe('times()', () => {
5 | it('handles n=0', () => {
6 | const logger = stub();
7 |
8 | const result = times(0, logger);
9 |
10 | expect(result).toEqual([]);
11 | expect(logger.args).toEqual([]);
12 | });
13 |
14 | //
15 | // stolen from https://github.com/lodash/lodash
16 | //
17 |
18 | it('should provide correct `iteratee` arguments', () => {
19 | const logger = stub();
20 |
21 | times(1, logger);
22 |
23 | expect(logger.args).toEqual([[0]]);
24 | });
25 |
26 | it('should return an array of the results of each `iteratee` execution', () => {
27 | expect(times(3, (i) => 2 * i)).toEqual([0, 2, 4]);
28 | });
29 | });
30 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/times.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Invokes the iteratee `n` times, returning an array of the results of each invocation.
3 | *
4 | * Differences from lodash:
5 | * - has undefined behavior when given a non natural number for `n`
6 | * - does not provide a default for `iteratee`
7 | *
8 | * Contribution to minified bundle size, when it is the only function imported:
9 | * - Lodash: 1,497 bytes
10 | * - Micro-dash: 51 bytes
11 | */
12 | export function times(n: number, iteratee: (index: number) => T): T[] {
13 | const result: T[] = [];
14 | for (let i = 0; i < n; ++i) {
15 | result[i] = iteratee(i);
16 | }
17 | return result;
18 | }
19 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/unique-id.spec.ts:
--------------------------------------------------------------------------------
1 | import { times, uniq } from 'lodash';
2 | import { uniqueId } from './unique-id';
3 |
4 | describe('uniqueId()', () => {
5 | it('uses the given prefix', () => {
6 | expect(uniqueId('one').startsWith('one')).toBeTruthy();
7 | expect(uniqueId('two').startsWith('two')).toBeTruthy();
8 | expect(uniqueId('repeat').startsWith('repeat')).toBeTruthy();
9 | expect(uniqueId('repeat').startsWith('repeat')).toBeTruthy();
10 | });
11 |
12 | //
13 | // stolen from https://github.com/lodash/lodash
14 | //
15 |
16 | it('should generate unique ids', () => {
17 | const actual = times(1000, () => uniqueId());
18 |
19 | expect(uniq(actual).length).toBe(actual.length);
20 | });
21 |
22 | it('should return a string value when not providing a `prefix`', () => {
23 | expect(typeof uniqueId()).toBe('string');
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/lib/util/unique-id.ts:
--------------------------------------------------------------------------------
1 | /** @hidden */
2 | let nextId = 1;
3 |
4 | /**
5 | * Generates a unique ID. If `prefix` is given, the ID is appended to it.
6 | *
7 | * Contribution to minified bundle size, when it is the only function imported:
8 | * - Lodash: 1,062 bytes
9 | * - Micro-dash: 38 bytes
10 | */
11 | export function uniqueId(prefix = ''): string {
12 | return prefix + nextId++;
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/public-api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of micro-dash
3 | */
4 |
5 | export * from './lib/array';
6 | export * from './lib/collection';
7 | export * from './lib/function';
8 | export * from './lib/lang';
9 | export * from './lib/math';
10 | export * from './lib/number';
11 | export * from './lib/object';
12 | export * from './lib/string';
13 | export * from './lib/util';
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone';
4 | import 'zone.js/dist/zone-testing';
5 | import { getTestBed } from '@angular/core/testing';
6 | import {
7 | BrowserDynamicTestingModule,
8 | platformBrowserDynamicTesting,
9 | } from '@angular/platform-browser-dynamic/testing';
10 |
11 | declare const require: {
12 | context(
13 | path: string,
14 | deep?: boolean,
15 | filter?: RegExp,
16 | ): {
17 | keys(): string[];
18 | (id: string): T;
19 | };
20 | };
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting(),
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/concat.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { concat } from '../../public-api';
2 |
3 | // $ExpectType number[]
4 | concat([1], 2);
5 | // $ExpectType number[]
6 | concat([1], [2]);
7 | // $ExpectType number[]
8 | concat([1], [2], 3);
9 | // $ExpectType number[]
10 | concat([], 1);
11 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/difference.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { difference } from '../../lib/array';
2 |
3 | // $ExpectType number[]
4 | difference([1]);
5 | // $ExpectType string[]
6 | difference(['hi'], ['mom']);
7 | // $ExpectType (string | number)[]
8 | difference([1], ['hi']);
9 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/initial.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { initial } from '../../lib/array';
2 |
3 | // $ExpectType number[]
4 | initial([1]);
5 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/union.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { union } from '../../lib/array';
2 |
3 | // $ExpectType number[]
4 | union([1]);
5 | // $ExpectType string[]
6 | union(['hi'], ['mom']);
7 | // $ExpectType (string | number)[]
8 | union([1], ['hi']);
9 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/zip-object.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { zipObject } from '../../lib/array';
2 |
3 | // $ExpectType { [x: string]: string; }
4 | zipObject(['a'], ['yes']);
5 |
6 | // $ExpectType { [x: string]: number; }
7 | zipObject(['a'], [1, 'no']);
8 |
9 | // $ExpectType { [x: number]: number; } & { [x: string]: string; }
10 | zipObject([1, 'b'], [1, 'yes']);
11 |
12 | // $ExpectType { [x: number]: number; } & { [x: string]: number; }
13 | zipObject([1, 'b'], [1, 2, 'no']);
14 |
15 | // $ExpectType { [x: number]: number; } & { [x: string]: number; } & { [x: string]: string; }
16 | zipObject([1, 'b', 'c'], [1, 2, 'yes']);
17 |
18 | // $ExpectType { [x: number]: number; } & { [x: string]: number; } & { [x: string]: number; }
19 | zipObject([1, 'b', 'c'], [1, 2, 3, 'no']);
20 |
21 | // $ExpectType { [x: number]: number; } & { [x: string]: number; } & { [x: string]: number; } & { [x: string]: string; }
22 | zipObject([1, 'b', 'c', 'd'], [1, 2, 3, 'yes']);
23 |
24 | // $ExpectType { [x: number]: number; } & { [x: string]: number; } & { [x: string]: number; } & { [x: string]: number; }
25 | zipObject([1, 'b', 'c', 'd'], [1, 2, 3, 4, 'no']);
26 |
27 | // $ExpectType { [x: string]: number | undefined; }
28 | zipObject(['a', 'b'] as string[], [1, 2]);
29 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/array/zip.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { zip } from '../../public-api';
2 |
3 | // $ExpectType [string, string][]
4 | zip(['a'], ['yes']);
5 | // $ExpectType [string, string | number][]
6 | zip(['a'], [1, 'no']);
7 | // $ExpectType [string, number, Date][]
8 | zip(['a'], [2], [new Date()]);
9 | // $ExpectType [string, number, Date, null][]
10 | zip(['a'], [2], [new Date()], [null]);
11 | // $ExpectType string[][]
12 | zip(['a'], ['b'], ['c'], ['d'], ['e']);
13 | // $ExpectType (string | number)[][]
14 | zip(['a'], [2], ['c'], [4], ['e']);
15 | // $ExpectType (string | null | undefined)[][]
16 | zip(['a'], null, ['c'], undefined, ['e']);
17 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/collection/group-by.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { groupBy } from '../../lib/collection/group-by';
2 |
3 | const a = [1] as number[];
4 | const aOrU = [1] as number[] | undefined;
5 | const aOrN = [1] as number[] | null;
6 | const o = { a: 1 } as { a: number };
7 | const oOrU = { a: 1 } as { a: number } | undefined;
8 | const oOrN = { a: 1 } as { a: number } | null;
9 |
10 | // $ExpectType { [x: string]: number[]; }
11 | groupBy(a, (): string => 'hi');
12 | // $ExpectType { hi: number[] | undefined; there: number[] | undefined; }
13 | groupBy(a, (): 'hi' | 'there' => 'hi');
14 | // $ExpectType { [x: number]: number[]; }
15 | groupBy(o, (): number => 1);
16 | // $ExpectType { 1: number[] | undefined; 2: number[] | undefined; }
17 | groupBy(o, (): 1 | 2 => 1);
18 |
19 | // $ExpectType { [x: string]: number[]; }
20 | groupBy(aOrN, (): string => 'a');
21 | // $ExpectType { [x: string]: number[]; }
22 | groupBy(oOrU, (): string => 'a');
23 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/function/debounce.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { debounce } from '../../lib/function';
2 |
3 | // $ExpectType ((_s: string, _n: number) => void) & { cancel(): void; }
4 | debounce((_s: string, _n: number) => 'hi');
5 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/function/once.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { once } from '../../lib/function';
2 |
3 | // $ExpectType (this: unknown, _a1: number, _a2: string) => Date
4 | once((_a1: number, _a2: string) => new Date());
5 | // $ExpectType (this: [], _a1: number) => void
6 | once(function (this: [], _a1: number): void {});
7 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/index.d.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simontonsoftware/micro-dash/8669d2ecb22addd5e82b0e63fdc858122cca5095/projects/micro-dash/src/typing-tests/index.d.ts
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/lang/to-array.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { toArray } from '../../lib/lang';
2 |
3 | // $ExpectType string[]
4 | toArray('hi');
5 | // $ExpectType number[]
6 | toArray([1, 2, 3]);
7 | // $ExpectType number[]
8 | toArray({ a: 1, b: 2 });
9 | // $ExpectType []
10 | toArray(1);
11 | // $ExpectType []
12 | toArray(null);
13 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/object/functions.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { functions } from '../../public-api';
2 |
3 | // $ExpectType string[]
4 | functions(['a', 'b']);
5 | // $ExpectType ("a" | "b")[]
6 | functions({ a: 1, b: 'hi ' });
7 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/object/keys.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { keys } from '../../public-api';
2 |
3 | interface O {
4 | a: number;
5 | b: number;
6 | }
7 | interface W {
8 | a: number;
9 | 2: string;
10 | }
11 | type A = number[];
12 | const oOrU = undefined as undefined | O;
13 | const oOrN = null as null | O;
14 | const wOrU = undefined as undefined | W;
15 | const wOrN = null as null | W;
16 | const aOrU = undefined as undefined | A;
17 | const aOrN = null as null | A;
18 |
19 | // $ExpectType ("a" | "b")[]
20 | keys({ a: 1, b: 2 });
21 | // $ExpectType ("a" | "b")[]
22 | keys(oOrU);
23 | // $ExpectType ("a" | "b")[]
24 | keys(oOrN);
25 | // $ExpectType string[]
26 | keys({ a: 2, 2: 'b' });
27 | // $ExpectType string[]
28 | keys(wOrU);
29 | // $ExpectType string[]
30 | keys(wOrN);
31 | // $ExpectType string[]
32 | keys([1, 2]);
33 | // $ExpectType string[]
34 | keys(aOrU);
35 | // $ExpectType string[]
36 | keys(aOrN);
37 |
38 | // $ExpectType string[]
39 | keys(['a', 'b']);
40 | // $ExpectType ("a" | "b")[]
41 | keys({ a: 1, b: 'hi ' });
42 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/object/map-values.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { mapValues } from '../../lib/object';
2 |
3 | type A = number[];
4 | const a = (null as unknown) as A;
5 | const aOrN = a as A | null;
6 | const aOrU = a as A | undefined;
7 |
8 | // $ExpectType { [index: number]: string; }
9 | mapValues(a, String);
10 | // $ExpectType {} | { [index: number]: string; }
11 | mapValues(aOrN, String);
12 | // $ExpectType {} | { [index: number]: string; }
13 | mapValues(aOrU, String);
14 |
15 | interface O {
16 | a: number;
17 | b: number;
18 | }
19 | const o = (null as unknown) as O;
20 | const oOrN = o as O | null;
21 | const oOrU = o as O | undefined;
22 |
23 | // $ExpectType { a: string; b: string; }
24 | mapValues(o, String);
25 | // $ExpectType {} | { a: string; b: string; }
26 | mapValues(oOrN, String);
27 | // $ExpectType {} | { a: string; b: string; }
28 | mapValues(oOrU, String);
29 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/object/to-pairs.dts-spec.ts:
--------------------------------------------------------------------------------
1 | import { toPairs } from '../../lib/object';
2 |
3 | // $ExpectType ["a" | "b", number][]
4 | toPairs({ a: 1, b: 2 });
5 | // todo: fancier typing for arrays
6 |
--------------------------------------------------------------------------------
/projects/micro-dash/src/typing-tests/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "noImplicitAny": true,
5 | "noImplicitThis": true,
6 | "strictNullChecks": true,
7 | "strictFunctionTypes": true,
8 | "lib": ["es2018", "dom"],
9 | "noEmit": true,
10 | "target": "es2015",
11 |
12 | "baseUrl": "../lib"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/projects/micro-dash/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "../../out-tsc/lib",
6 | "target": "es2015",
7 | "declaration": true,
8 | "inlineSources": true,
9 | "types": [],
10 | "lib": ["dom", "es2018"],
11 |
12 | // Special just for micro-dash library functions, to reduce bundle size
13 | "noImplicitReturns": false
14 | },
15 | "angularCompilerOptions": {
16 | "skipTemplateCodegen": true,
17 | "strictMetadataEmit": true,
18 | "enableResourceInlining": true
19 | },
20 | "exclude": ["src/test.ts", "**/*.spec.ts"]
21 | }
22 |
--------------------------------------------------------------------------------
/projects/micro-dash/tsconfig.lib.prod.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.lib.json",
4 | "angularCompilerOptions": {
5 | "enableIvy": false
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/projects/micro-dash/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "../../out-tsc/spec",
6 | "types": ["jasmine"],
7 |
8 | // Special just for micro-dash library functions, to reduce bundle size
9 | "noImplicitReturns": false
10 | },
11 | "files": ["src/test.ts"],
12 | "include": ["**/*.spec.ts", "**/*.d.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/projects/micro-dash/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [true, "attribute", "lib", "camelCase"],
5 | "component-selector": [true, "element", "lib", "kebab-case"]
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { kebabCase } from 'micro-dash';
3 |
4 | @Component({
5 | selector: 'app-root',
6 | templateUrl: './app.component.html',
7 | })
8 | export class AppComponent {
9 | title = kebabCase('micro dash');
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 |
6 | @NgModule({
7 | declarations: [AppComponent],
8 | imports: [BrowserModule],
9 | providers: [],
10 | bootstrap: [AppComponent],
11 | })
12 | export class AppModule {}
13 |
--------------------------------------------------------------------------------
/src/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "the-project",
3 | "private": true,
4 | "description_1": "This is a special package.json file that is not used by package managers.",
5 | "description_2": "It is used to tell the tools and bundlers whether the code under this directory is free of code with non-local side-effect. Any code that does have non-local side-effects can't be well optimized (tree-shaken) and will result in unnecessary increased payload size.",
6 | "description_3": "It should be safe to set this option to 'false' for new applications, but existing code bases could be broken when built with the production config if the application code does contain non-local side-effects that the application depends on.",
7 | "description_4": "To learn more about this file see: https://angular.io/config/app-package-json.",
8 | "sideEffects": false
9 | }
10 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simontonsoftware/micro-dash/8669d2ecb22addd5e82b0e63fdc858122cca5095/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | };
8 |
9 | /*
10 | * In development mode, to ignore zone related error stack frames such as
11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
12 | * import the following file, but please comment it out in production mode
13 | * because it will have performance impact when throw error
14 | */
15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simontonsoftware/micro-dash/8669d2ecb22addd5e82b0e63fdc858122cca5095/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MicroDashPlatform
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic()
12 | .bootstrapModule(AppModule)
13 | .catch((err) => console.log(err));
14 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting,
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: {
11 | context(
12 | path: string,
13 | deep?: boolean,
14 | filter?: RegExp,
15 | ): {
16 | keys(): string[];
17 | (id: string): T;
18 | };
19 | };
20 |
21 | // First, initialize the Angular testing environment.
22 | getTestBed().initTestEnvironment(
23 | BrowserDynamicTestingModule,
24 | platformBrowserDynamicTesting(),
25 | );
26 | // Then we find all the tests.
27 | const context = require.context('./', true, /\.spec\.ts$/);
28 | // And load the modules.
29 | context.keys().map(context);
30 |
--------------------------------------------------------------------------------
/standard-version-postbump.ts:
--------------------------------------------------------------------------------
1 | import { writeFileSync } from 'fs';
2 | import { format } from 'prettier';
3 |
4 | const packageJson = require('./package.json');
5 | const libPackageJson = require('./projects/micro-dash/package.json');
6 | writeFileSync(
7 | './projects/micro-dash/package.json',
8 | format(JSON.stringify({ ...libPackageJson, version: packageJson.version }), {
9 | parser: 'json',
10 | }),
11 | );
12 |
--------------------------------------------------------------------------------
/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/app",
6 | "types": []
7 | },
8 | "files": ["src/main.ts", "src/polyfills.ts"],
9 | "include": ["src/**/*.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/tsconfig.base.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | //
5 | // from the Angular CLI
6 | //
7 | "baseUrl": "./",
8 | "outDir": "./dist/out-tsc",
9 | "forceConsistentCasingInFileNames": true,
10 | "strict": true,
11 | "noImplicitReturns": true,
12 | "noFallthroughCasesInSwitch": true,
13 | "sourceMap": true,
14 | "declaration": false,
15 | "downlevelIteration": true,
16 | "experimentalDecorators": true,
17 | "moduleResolution": "node",
18 | "importHelpers": true,
19 | "target": "es2015",
20 | "module": "es2020",
21 | "lib": ["es2018", "dom"],
22 | "paths": {
23 | "micro-dash": ["dist/micro-dash/micro-dash", "dist/micro-dash"]
24 | },
25 |
26 | //
27 | // Simonton Software additions
28 | //
29 | "noUnusedLocals": true,
30 | "noUnusedParameters": true
31 | },
32 | "angularCompilerOptions": {
33 | "strictInjectionParameters": true,
34 | "strictTemplates": true
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | /*
2 | This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
3 | It is not intended to be used to perform a compilation.
4 | To learn more about this file see: https://angular.io/config/solution-tsconfig.
5 | */
6 | {
7 | "files": [],
8 | "references": [
9 | { "path": "./tsconfig.app.json" },
10 | { "path": "./tsconfig.spec.json" },
11 | { "path": "./e2e/tsconfig.json" },
12 | { "path": "./projects/calc-sizes/tsconfig.app.json" },
13 | { "path": "./projects/micro-dash/tsconfig.lib.json" },
14 | { "path": "./projects/micro-dash/tsconfig.spec.json" }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.base.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/spec",
6 | "types": ["jasmine"]
7 | },
8 | "files": ["src/test.ts", "src/polyfills.ts"],
9 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "s-ng-dev-utils/tslint"
3 | }
4 |
--------------------------------------------------------------------------------