This commit is contained in:
Tutur33
2023-11-24 23:58:26 +01:00
parent 25395c0ee1
commit 938ad9d309
4191 changed files with 41 additions and 518781 deletions
-9
View File
@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sam Verschueren <sam.verschueren@gmail.com> (github.com/SamVerschueren)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-59
View File
@@ -1,59 +0,0 @@
{
"name": "map-age-cleaner",
"version": "0.1.3",
"description": "Automatically cleanup expired items in a Map",
"license": "MIT",
"repository": "SamVerschueren/map-age-cleaner",
"author": {
"name": "Sam Verschueren",
"email": "sam.verschueren@gmail.com",
"url": "github.com/SamVerschueren"
},
"main": "dist/index.js",
"engines": {
"node": ">=6"
},
"scripts": {
"prepublishOnly": "npm run build",
"pretest": "npm run build -- --sourceMap",
"test": "npm run lint && nyc ava dist/test.js",
"lint": "tslint --format stylish --project .",
"build": "npm run clean && tsc",
"clean": "del-cli dist"
},
"files": [
"dist/index.js",
"dist/index.d.ts"
],
"keywords": [
"map",
"age",
"cleaner",
"maxage",
"expire",
"expiration",
"expiring"
],
"dependencies": {
"p-defer": "^1.0.0"
},
"devDependencies": {
"@types/delay": "^2.0.1",
"@types/node": "^10.7.1",
"ava": "^0.25.0",
"codecov": "^3.0.0",
"del-cli": "^1.1.0",
"delay": "^3.0.0",
"nyc": "^12.0.0",
"tslint": "^5.11.0",
"tslint-xo": "^0.9.0",
"typescript": "^3.0.1"
},
"typings": "dist/index.d.ts",
"sideEffects": false,
"nyc": {
"exclude": [
"dist/test.js"
]
}
}
-67
View File
@@ -1,67 +0,0 @@
# map-age-cleaner
[![Build Status](https://travis-ci.org/SamVerschueren/map-age-cleaner.svg?branch=master)](https://travis-ci.org/SamVerschueren/map-age-cleaner) [![codecov](https://codecov.io/gh/SamVerschueren/map-age-cleaner/badge.svg?branch=master)](https://codecov.io/gh/SamVerschueren/map-age-cleaner?branch=master)
> Automatically cleanup expired items in a Map
## Install
```
$ npm install map-age-cleaner
```
## Usage
```js
import mapAgeCleaner from 'map-age-cleaner';
const map = new Map([
['unicorn', {data: '🦄', maxAge: Date.now() + 1000}]
]);
mapAgeCleaner(map);
map.has('unicorn');
//=> true
// Wait for 1 second...
map.has('unicorn');
//=> false
```
> **Note**: Items have to be ordered ascending based on the expiry property. This means that the item which will be expired first, should be in the first position of the `Map`.
## API
### mapAgeCleaner(map, [property])
Returns the `Map` instance.
#### map
Type: `Map`
Map instance which should be cleaned up.
#### property
Type: `string`<br>
Default: `maxAge`
Name of the property which olds the expiry timestamp.
## Related
- [expiry-map](https://github.com/SamVerschueren/expiry-map) - A `Map` implementation with expirable items
- [expiry-set](https://github.com/SamVerschueren/expiry-set) - A `Set` implementation with expirable keys
- [mem](https://github.com/sindresorhus/mem) - Memoize functions
## License
MIT © [Sam Verschueren](https://github.com/SamVerschueren)