@newdash/newdash
Version:
javascript/typescript utility library
97 lines (68 loc) • 4.43 kB
Markdown
# NewDash
[](https://github.com/newdash/newdash/actions/workflows/nodejs.yml)
[](https://github.com/newdash/newdash/actions/workflows/deno.yml)
[](https://codecov.io/gh/newdash/newdash)
[](https://sonarcloud.io/dashboard?id=newdash_newdash)
[](https://sonarcloud.io/dashboard?id=newdash_newdash)
[](https://newdash.netlify.fornever.org/)
[](https://www.npmjs.com/package/@newdash/newdash)
[](https://www.npmjs.com/package/@newdash/newdash-deno)
[](https://www.npmjs.com/package/@newdash/newdash-es5)
[](https://www.npmjs.com/package/@newdash/newdash-es6)
[](https://www.npmjs.com/package/@newdash/newdash-umd)
**NewDash** is a hard fork of the [lodash](https://github.com/lodash/lodash) utility project, and re-build it with `typescript`.
## Quick Start
### ESM
```js
import first from "@newdash/newdash-es6/first" // only load `first` function
first("abc")
// => "a"
```
### NodeJS
works as you want.
```js
// const { first } = require("@newdash/newdash")
const { first } = require("@newdash/newdash/first") // Compatible with es6 module
first("abc")
// => "a"
```
### ES6 or Typescript
```js
// import { first } from "@newdash/newdash" // load all functions of @newdash
import first from "@newdash/newdash/first" // only load `first` function
first("abc")
// => "a"
```
### Deno Runtime
import from CDN, remember to add `.ts` suffix.
```js
// import { add } from "https://cdn.jsdelivr.net/npm/@newdash/newdash-deno/index.ts"
import { add } from "https://cdn.jsdelivr.net/npm/@newdash/newdash-deno/add.ts"
add(1, 2)
// => 3
add('1', '2')
// => '12'
add('1', 2) // different types
// throw error: TS2345 [ERROR]: Argument of type '2' is not assignable to parameter of type '"1"'.
```
### UMD Module (Browser Native)
just introduce `script` with html.
```html
<script src="https://cdn.jsdelivr.net/npm/@newdash/newdash-umd/newdash.min.js"></script>
```
## [API Document](https://newdash.netlify.fornever.org/)
### Highlight
- [`concurrency/limit`](https://newdash.netlify.fornever.org/modules/concurrency_limit.html#limit) - limit concurrency of async operations
- [`Mutex`](https://newdash.netlify.fornever.org/classes/functional_mutex.mutex#constructor) - exclusive executing
- [`hash`](https://newdash.netlify.fornever.org/modules/functional_hash.html#hash) - hash js object to stable string (MD5 based)
- [`fallback`](https://newdash.netlify.fornever.org/variables/fallback.fallback.html) - fallback functions for resilience
- [`LRUMap`](https://newdash.netlify.fornever.org/classes/functional_lrumap.lrumap#constructor) and [`TTLMap`](https://newdash.netlify.fornever.org/classes/functional_ttlmap.ttlmap#constructor) - Map implementations which concern about eviction
## Different Release
In most cases, just use the `@newdash/newdash` package is enough.
- `@newdash/newdash` - for modern `nodejs` environment, ready for all build tools which based on the nodejs `commonjs` module system (node, react, vuejs, webpack and more).
- `@newdash/newdash-deno` - for deno language support, with some transform, like add the '.ts' suffix for modules.
- `@newdash/newdash-es5` - for old `nodejs` environment, ready for `0.12 <= node version <= 8`.
- `@newdash/newdash-es6` - for modern build system, with `es6` module keywords so that build tool could strip the unused modules.
- `@newdash/newdash-umd` - for native browser without any build system, please access it with `unpkg` or `jsdeliver`
## [CHANGELOG](./CHANGELOG.md)
## [LICENSE](./LICENSE)