add docs
This commit is contained in:
parent
1808c72248
commit
19f1fe67ff
4 changed files with 43 additions and 3 deletions
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# v0.1.0
|
||||
|
||||
- Initial release
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018
|
||||
Copyright (c) 2018 Conduitry
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
40
README.md
40
README.md
|
@ -1,2 +1,38 @@
|
|||
# memor
|
||||
More memoization.
|
||||
# Memor: More memoization.
|
||||
|
||||
[](https://www.npmjs.com/package/memor)
|
||||
|
||||
Memoization, but good. Works with functions of an arbitrary and/or variable number of arguments. For arrays, regexes, dates, buffers, and POJOs, caching is done according to the *value* (and not the *identity*) of the objects. Order of keys in POJOs does not matter. For other non-primitive values, memoization still works, but the caching is done by object identity.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Node.js](https://nodejs.org/) 4+
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import { memoize } from 'memor'
|
||||
|
||||
const memoizedFunction = memoize(originalFunction)
|
||||
|
||||
memoizedFunction(/* ... */)
|
||||
```
|
||||
|
||||
`originalFunction` can accept any number or a variable number of arguments. Re-memoizing the same function (i.e., calling `memoize(originalFunction)` elsewhere later) will share the cached values.
|
||||
|
||||
Keying of primitives, arrays, regexes, dates, and buffers works according to their values. Any additional custom properties added to the objects will *not* be considered as part of the key. (More specifically, arrays are keyed according to their length and their elements, regexes and buffers are keyed according to their `.toString()`s, and dates are keyed according to their `.getTime()`s.)
|
||||
|
||||
Keying of POJOs works according to their (own) enumerable and non-enumerable property names and values, without regard to order. Symbolic keys and their values are not considered, due to the lack of a canonical ordering on symbols.
|
||||
|
||||
Other objects (those without a prototype of `Object.prototype`) are simply keyed according to their identity (i.e., `===`).
|
||||
|
||||
## Misc
|
||||
|
||||
- [changelog](CHANGELOG.md#readme)
|
||||
- [homepage](https://cndtr.io/memor/)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2018 Conduitry
|
||||
|
||||
- [MIT](LICENSE)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name": "memor",
|
||||
"version": "0.1.0",
|
||||
"description": "More memoization",
|
||||
"keywords": ["memoize", "memoization"],
|
||||
"main": "./dist/index.cjs.js",
|
||||
"module": "./dist/index.es.js",
|
||||
"files": ["dist"],
|
||||
|
|
Loading…
Add table
Reference in a new issue