pax_global_header 0000666 0000000 0000000 00000000064 13613400247 0014512 g ustar 00root root 0000000 0000000 52 comment=088b8ceb3b645f51fdc962618717eb45562bbce5
which-collection-1.0.1/ 0000775 0000000 0000000 00000000000 13613400247 0014744 5 ustar 00root root 0000000 0000000 which-collection-1.0.1/.eslintrc 0000664 0000000 0000000 00000000242 13613400247 0016566 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"overrides": [
{
"files": "test/**",
"globals": {
"WeakMap": false,
"WeakSet": false,
},
},
],
}
which-collection-1.0.1/.github/ 0000775 0000000 0000000 00000000000 13613400247 0016304 5 ustar 00root root 0000000 0000000 which-collection-1.0.1/.github/FUNDING.yml 0000664 0000000 0000000 00000001113 13613400247 0020115 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/which-collection
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
which-collection-1.0.1/.github/workflows/ 0000775 0000000 0000000 00000000000 13613400247 0020341 5 ustar 00root root 0000000 0000000 which-collection-1.0.1/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000372 13613400247 0022327 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
which-collection-1.0.1/.gitignore 0000664 0000000 0000000 00000001745 13613400247 0016743 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
which-collection-1.0.1/.npmrc 0000664 0000000 0000000 00000000067 13613400247 0016067 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
which-collection-1.0.1/.travis.yml 0000664 0000000 0000000 00000000243 13613400247 0017054 0 ustar 00root root 0000000 0000000 version: ~> 1.0
language: node_js
os:
- linux
import:
- ljharb/travis-ci:node/all.yml
- ljharb/travis-ci:node/pretest.yml
- ljharb/travis-ci:node/posttest.yml
which-collection-1.0.1/CHANGELOG.md 0000664 0000000 0000000 00000005032 13613400247 0016555 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
## [v1.0.1](https://github.com/inspect-js/which-collection/compare/v1.0.0...v1.0.1) - 2020-01-26
### Commits
- [actions] add automatic rebasing / merge commit blocking [`c3820b2`](https://github.com/inspect-js/which-collection/commit/c3820b2e8c88548f2c7da4080b1d1b6b41be97a4)
- [patch] add "exports" [`10983b5`](https://github.com/inspect-js/which-collection/commit/10983b5fdcc453c64216c3d6aa3fb93340091818)
- [Deps] update `is-map`, `is-set`, `is-weakmap`, `is-weakset` [`1565925`](https://github.com/inspect-js/which-collection/commit/1565925705c4abfe88065b211d1d960791f7cd3c)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`92ef871`](https://github.com/inspect-js/which-collection/commit/92ef871338395352f1bafc3156088361a3fd917a)
- [Dev Deps] update `@ljharb/eslint-config` [`61e9cde`](https://github.com/inspect-js/which-collection/commit/61e9cde1830ccc2b551dd6a1a873ae2cf27a74c7)
## v1.0.0 - 2019-11-13
### Commits
- Initial commit [`a21fddf`](https://github.com/inspect-js/which-collection/commit/a21fddffef3b2f21923e4d056295dd63661d8155)
- Tests [`ec86bc1`](https://github.com/inspect-js/which-collection/commit/ec86bc12f0516bd662c6e2966b36de2e1128a431)
- readme [`ffe969c`](https://github.com/inspect-js/which-collection/commit/ffe969cf4388d18e12c664cc51498bbdef08e565)
- implementation [`9acb669`](https://github.com/inspect-js/which-collection/commit/9acb6695e6a5e60f4c0b6de59eaf8b1f681d78e5)
- npm init [`124a63e`](https://github.com/inspect-js/which-collection/commit/124a63ee68a0015b47cbcc08b0d5598e553e7c9a)
- [meta] add `auto-changelog`, `safe-publish-latest` [`df0d6d4`](https://github.com/inspect-js/which-collection/commit/df0d6d4f1efbc4d9b327471b9c659bd487b25b49)
- [meta] add `funding` field; create FUNDING.yml [`032c81c`](https://github.com/inspect-js/which-collection/commit/032c81c826d68acd6242fa87fd6348db70135506)
- [Tests] add `npm run lint` [`6ae406d`](https://github.com/inspect-js/which-collection/commit/6ae406d9e459779abbdd90f48559552f740b05c9)
- fixup [`a2cad36`](https://github.com/inspect-js/which-collection/commit/a2cad363f12e30afe7619597187c5d4dc840a2a7)
- Only apps should have lockfiles [`30b3aae`](https://github.com/inspect-js/which-collection/commit/30b3aae37155f0786e4582501369f738b3282cd7)
which-collection-1.0.1/LICENSE 0000664 0000000 0000000 00000002053 13613400247 0015751 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2019 Inspect JS
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.
which-collection-1.0.1/README.md 0000664 0000000 0000000 00000005211 13613400247 0016222 0 ustar 00root root 0000000 0000000 # which-collection [![Version Badge][2]][1]
[![Build Status][3]][4]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
Which kind of Collection (Map, Set, WeakMap, WeakSet) is this JavaScript value? Works cross-realm, without `instanceof`, and despite Symbol.toStringTag.
## Example
```js
var whichCollection = require('which-collection');
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`
[1]: https://npmjs.org/package/which-collection
[2]: http://versionbadg.es/inspect-js/which-collection.svg
[3]: https://travis-ci.org/inspect-js/which-collection.svg
[4]: https://travis-ci.org/inspect-js/which-collection
[5]: https://david-dm.org/inspect-js/which-collection.svg
[6]: https://david-dm.org/inspect-js/which-collection
[7]: https://david-dm.org/inspect-js/which-collection/dev-status.svg
[8]: https://david-dm.org/inspect-js/which-collection#info=devDependencies
[9]: https://ci.testling.com/inspect-js/which-collection.png
[10]: https://ci.testling.com/inspect-js/which-collection
[11]: https://nodei.co/npm/which-collection.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/which-collection.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/which-collection.svg
[downloads-url]: http://npm-stat.com/charts.html?package=which-collection
which-collection-1.0.1/index.js 0000664 0000000 0000000 00000000713 13613400247 0016412 0 ustar 00root root 0000000 0000000 'use strict';
var isMap = require('is-map');
var isSet = require('is-set');
var isWeakMap = require('is-weakmap');
var isWeakSet = require('is-weakset');
module.exports = function whichCollection(value) {
if (value && typeof value === 'object') {
if (isMap(value)) {
return 'Map';
}
if (isSet(value)) {
return 'Set';
}
if (isWeakMap(value)) {
return 'WeakMap';
}
if (isWeakSet(value)) {
return 'WeakSet';
}
}
return false;
};
which-collection-1.0.1/package.json 0000664 0000000 0000000 00000003405 13613400247 0017234 0 ustar 00root root 0000000 0000000 {
"name": "which-collection",
"version": "1.0.1",
"description": "Which kind of Collection (Map, Set, WeakMap, WeakSet) is this JavaScript value? Works cross-realm, without `instanceof`, and despite Symbol.toStringTag.",
"main": "index.js",
"type": "commonjs",
"exports": {
".": [
{
"default": "./index.js"
},
"./index.js"
],
"./package.json": "./package.json"
},
"scripts": {
"prepublish": "safe-publish-latest",
"lint": "eslint .",
"pretest": "npm run lint",
"tests-only": "node test",
"test": "npm run tests-only",
"posttest": "npx aud",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/inspect-js/which-collection.git"
},
"keywords": [
"map",
"set",
"weakmap",
"weakset",
"collection.es6",
"es2015"
],
"author": "Jordan Harband ",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/inspect-js/which-collection/issues"
},
"homepage": "https://github.com/inspect-js/which-collection#readme",
"devDependencies": {
"@ljharb/eslint-config": "^16.0.0",
"auto-changelog": "^1.16.2",
"eslint": "^6.8.0",
"for-each": "^0.3.3",
"object-inspect": "^1.7.0",
"safe-publish-latest": "^1.1.4",
"tape": "^5.0.0-next.4"
},
"dependencies": {
"is-map": "^2.0.1",
"is-set": "^2.0.1",
"is-weakmap": "^2.0.1",
"is-weakset": "^2.0.1"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false
}
}
which-collection-1.0.1/test/ 0000775 0000000 0000000 00000000000 13613400247 0015723 5 ustar 00root root 0000000 0000000 which-collection-1.0.1/test/index.js 0000664 0000000 0000000 00000002226 13613400247 0017372 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var debug = require('object-inspect');
var forEach = require('for-each');
var whichCollection = require('..');
test('non-collections', function (t) {
forEach([
null,
undefined,
true,
false,
42,
0,
-0,
NaN,
Infinity,
'',
'foo',
/a/g,
[],
{},
function () {}
], function (nonCollection) {
t.equal(whichCollection(nonCollection), false, debug(nonCollection) + ' is not a collection');
});
t.end();
});
test('Maps', { skip: typeof Map !== 'function' }, function (t) {
var m = new Map();
t.equal(whichCollection(m), 'Map', debug(m) + ' is a Map');
t.end();
});
test('Sets', { skip: typeof Set !== 'function' }, function (t) {
var s = new Set();
t.equal(whichCollection(s), 'Set', debug(s) + ' is a Set');
t.end();
});
test('WeakMaps', { skip: typeof WeakMap !== 'function' }, function (t) {
var wm = new WeakMap();
t.equal(whichCollection(wm), 'WeakMap', debug(wm) + ' is a WeakMap');
t.end();
});
test('WeakSets', { skip: typeof WeakSet !== 'function' }, function (t) {
var ws = new WeakSet();
t.equal(whichCollection(ws), 'WeakSet', debug(ws) + ' is a WeakSet');
t.end();
});