0.0.30 • Published 6 years ago

timeoutobject v0.0.30

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

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

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.13

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.1

6 years ago