0.0.30 • Published 8 years ago
timeoutobject v0.0.30
TimeoutObject
automatically delete element in {}/[] after timeout
install
npm install timeoutobject --save
usage
const TimeoutObject = require("timeoutobject");
let wrapObj = {};// timeout object
let mapOperation = TimeoutObject.newInstanceMap(1000, wrapObj);
let key = {};
wrapObj['a'] = 1;
mapOperation.add(key, 'suppose remove');
mapOperation.remove(key);
mapOperation.add(2, 'suppose remain');
setTimeout(() => console.log(mapOperation.wrapObj, wrapObj), 500);// { '2': 'suppose remain' } { a: 1 }
setTimeout(() => console.log(mapOperation.wrapObj, wrapObj), 1500);// {} { a: 1 }
let wrapArr = [1, 1, new Number(12),true];// timeout set
let setOperation = TimeoutObject.newInstanceSet(1000, wrapArr);
let value = "suppose remove";
setOperation.add(value);
setOperation.remove(value);
setOperation.add("suppose remain");
setTimeout(() => console.log(setOperation.wrapSet.toArray(), wrapArr), 600);// [ 1, [Number: 12], true, 'suppose remain' ] [ 1, 1, [Number: 12], true ]
setTimeout(() => console.log(setOperation.wrapSet.toArray(), wrapArr), 1600);// [ 1, [Number: 12], true ] [ 1, 1, [Number: 12], true ]
0.0.30
8 years ago
0.0.29
8 years ago
0.0.28
8 years ago
0.0.27
8 years ago
0.0.26
8 years ago
0.0.25
8 years ago
0.0.24
8 years ago
0.0.23
8 years ago
0.0.22
8 years ago
0.0.21
8 years ago
0.0.20
8 years ago
0.0.19
8 years ago
0.0.18
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15
8 years ago
0.0.13
8 years ago
0.0.11
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.1
8 years ago