0.0.1-security.1 • Published 1 year ago
@swenkerorg/quam-ipsum v0.0.1-security.1
@swenkerorg/quam-ipsum 
Which kind of Collection (Map, Set, WeakMap, WeakSet) is this JavaScript value? Works cross-realm, without instanceof
, and despite Symbol.toStringTag.
Example
var whichCollection = require('@swenkerorg/quam-ipsum');
var assert = require('assert');
assert.equal(false, whichCollection(undefined));
assert.equal(false, whichCollection(null));
assert.equal(false, whichCollection(false));
assert.equal(false, whichCollection(true));
assert.equal(false, whichCollection([]));
assert.equal(false, whichCollection({}));
assert.equal(false, whichCollection(/a/g));
assert.equal(false, whichCollection(new RegExp('a', 'g')));
assert.equal(false, whichCollection(new Date()));
assert.equal(false, whichCollection(42));
assert.equal(false, whichCollection(NaN));
assert.equal(false, whichCollection(Infinity));
assert.equal(false, whichCollection(new Number(42)));
assert.equal(false, whichCollection(42n));
assert.equal(false, whichCollection(Object(42n)));
assert.equal(false, whichCollection('foo'));
assert.equal(false, whichCollection(Object('foo')));
assert.equal(false, whichCollection(function () {}));
assert.equal(false, whichCollection(function* () {}));
assert.equal(false, whichCollection(x => x * x));
assert.equal(false, whichCollection([]));
assert.equal('Map', whichCollection(new Map()));
assert.equal('Set', whichCollection(new Set()));
assert.equal('WeakMap', whichCollection(new WeakMap()));
assert.equal('WeakSet', whichCollection(new WeakSet()));
Tests
Simply clone the repo, npm install
, and run npm test
3.1.34
1 year ago
3.0.23
1 year ago
3.1.33
1 year ago
3.0.24
1 year ago
3.1.36
1 year ago
3.1.35
1 year ago
0.0.1-security.0
1 year ago
0.0.1-security.1
1 year ago
3.1.30
1 year ago
3.1.32
1 year ago
3.1.31
1 year ago
0.0.1-security
1 year ago
3.1.25
1 year ago
3.1.24
1 year ago
3.1.27
1 year ago
3.1.26
1 year ago
3.1.29
1 year ago
3.1.28
1 year ago
2.0.19
1 year ago
2.0.17
1 year ago
2.0.18
1 year ago
2.0.22
1 year ago
2.0.23
1 year ago
2.0.20
1 year ago
2.0.21
1 year ago
2.0.16
1 year ago
1.0.16
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago