0.0.30 • Published 8 years ago

timeoutobject v0.0.30

Weekly downloads
5
License
MIT
Repository
github
Last release
8 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

8 years ago

0.0.29

8 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.19

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.13

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.1

9 years ago