Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

View File

@@ -0,0 +1,13 @@
root = true
[*]
indent_style = tab;
insert_final_newline = true;
quote_type = auto;
space_after_anonymous_functions = true;
space_after_control_statements = true;
spaces_around_operators = true;
trim_trailing_whitespace = true;
spaces_in_brackets = false;
end_of_line = lf;

View File

@@ -0,0 +1,13 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"id-length": [2, { "min": 1, "max": 26 }],
"max-statements": [2, 14],
"new-cap": [2, { capIsNewExceptions: ["ToObject", "ToInteger", "ToLength", "SameValueZero", "RequireObjectCoercible"] }],
"no-magic-numbers": [0],
"no-useless-call": [1]
}
}

View File

@@ -0,0 +1,176 @@
{
"es3": true,
"additionalRules": [],
"requireSemicolons": true,
"disallowMultipleSpaces": true,
"disallowIdentifierNames": [],
"requireCurlyBraces": {
"allExcept": [],
"keywords": ["if", "else", "for", "while", "do", "try", "catch"]
},
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
"disallowSpaceAfterKeywords": [],
"disallowSpaceBeforeComma": true,
"disallowSpaceAfterComma": false,
"disallowSpaceBeforeSemicolon": true,
"disallowNodeTypes": [
"DebuggerStatement",
"ForInStatement",
"LabeledStatement",
"SwitchCase",
"SwitchStatement",
"WithStatement"
],
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
"requireSpaceBetweenArguments": true,
"disallowSpacesInsideParentheses": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"requireSpaceAfterPrefixUnaryOperators": [],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforePostfixUnaryOperators": [],
"disallowSpaceBeforeBinaryOperators": [],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"disallowSpaceAfterBinaryOperators": [],
"disallowImplicitTypeConversion": ["binary", "string"],
"disallowKeywords": ["with", "eval"],
"requireKeywordsOnNewLine": [],
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"excludeFiles": ["node_modules/**", "vendor/**"],
"disallowMultipleLineStrings": true,
"requireDotNotation": { "allExcept": ["keywords"] },
"requireParenthesesAroundIIFE": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": {
"escape": true,
"mark": "'"
},
"disallowOperatorBeforeLineBreak": [],
"requireSpaceBeforeKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"finally",
"while",
"with",
"return"
],
"validateAlignedFunctionParameters": {
"lineBreakAfterOpeningBraces": true,
"lineBreakBeforeClosingBraces": true
},
"requirePaddingNewLinesBeforeExport": true,
"validateNewlineAfterArrayElements": {
"maximum": 3
},
"requirePaddingNewLinesAfterUseStrict": true,
"disallowArrowFunctions": true,
"disallowMultiLineTernary": true,
"validateOrderInObjectKeys": false,
"disallowIdenticalDestructuringNames": true,
"disallowNestedTernaries": { "maxLevel": 1 },
"requireSpaceAfterComma": { "allExcept": ["trailing"] },
"requireAlignedMultilineParams": false,
"requireSpacesInGenerator": {
"afterStar": true
},
"disallowSpacesInGenerator": {
"beforeStar": true
},
"disallowVar": false,
"requireArrayDestructuring": false,
"requireEnhancedObjectLiterals": false,
"requireObjectDestructuring": false,
"requireEarlyReturn": false,
"requireCapitalizedConstructorsNew": {
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
},
"requireImportAlphabetized": false,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBeforeDestructuredValues": true,
"disallowSpacesInsideTemplateStringPlaceholders": true,
"disallowArrayDestructuringReturn": false,
"requireNewlineBeforeSingleStatementsInIf": false,
"disallowUnusedVariables": true,
"requireSpacesInsideImportedObjectBraces": true,
"requireUseStrict": true
}

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,182 @@
language: node_js
os:
- linux
node_js:
- "7.9"
- "6.10"
- "5.12"
- "4.8"
- "iojs-v3.3"
- "iojs-v2.5"
- "iojs-v1.8"
- "0.12"
- "0.10"
- "0.8"
before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
script:
- 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
- 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
- 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
- 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
sudo: false
env:
- TEST=true
matrix:
fast_finish: true
include:
- node_js: "node"
env: PRETEST=true
- node_js: "node"
env: POSTTEST=true
- node_js: "4"
env: COVERAGE=true
- node_js: "7.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.4"
env: TEST=true ALLOW_FAILURE=true
##- node_js: "7"
#env: TEST=true
#os: osx
#- node_js: "6"
#env: TEST=true
#os: osx
#- node_js: "5"
#env: TEST=true
#os: osx
#- node_js: "4"
#env: TEST=true
#os: osx
#- node_js: "iojs"
#env: TEST=true
#os: osx
#- node_js: "0.12"
#env: TEST=true
#os: osx
#- node_js: "0.10"
#env: TEST=true
#os: osx
#- node_js: "0.8"
#env: TEST=true
#os: osx
allow_failures:
- os: osx
- env: TEST=true ALLOW_FAILURE=true
- env: COVERAGE=true

View File

@@ -0,0 +1,75 @@
3.0.3 / 2017-04-18
=================
* [Fix] ensure that `shim.js` actually shims when the polyfill differs from native
* [Tests] up to `node` `v7.9`, `v6.10`, `v4.8`; comment out OS X builds; improve test matrix
* [Dev Deps] update `nsp`, `eslint`, `@ljharb/eslint-config`, `tape`, `jscs`, `semver`, `function-bind`, `@es-shims/api`
* [Deps] update `es-abstract`
* [Docs] update readme: add “getting started” and “usage” (#19)
3.0.2 / 2015-06-06
=================
* Use the polyfill, not the implementation, as the default export
* [Deps] update `es-abstract`
* [Dev Deps] update `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`
* [Tests] up to `node` `v5.5`
* [Tests] keep tests passing in `node` `v0.8`
* [Tests] Only run `evalmd` as part of the full test suite, since it's more like a linter
* [Tests] fix npm upgrades for older nodes
3.0.1 / 2015-05-23
=================
* [Fix] in "shim", assign the polyfill, not the implementation
3.0.0 / 2015-05-23
=================
* [Breaking] Implement the [es-shim API](es-shims/api)
* [Deps] update `define-properties`, `es-abstract`
* [Dev Deps] update `eslint`, `semver`, `nsp`, `semver`, `jscs`
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
* [Tests] use my personal shared `eslint` config
* [Tests] up to `io.js` `v3.0`
2.0.0 / 2015-05-23
=================
* Fix to not skip holes, per https://github.com/tc39/Array.prototype.includes/issues/15
1.1.1 / 2015-05-23
=================
* Test up to `io.js` `v2.0`
* Update `es-abstract`, `tape`, `eslint`, `semver`, `jscs`, `semver`
1.1.0 / 2015-03-19
=================
* Update `es-abstract`, `editorconfig-tools`, `nsp`, `eslint`, `semver`
1.0.6 / 2015-02-17
=================
* All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`.
* Run `travis-ci` tests on `iojs` and `node` v0.12; allow 0.8 failures.
* Update `tape`, `jscs`, `es-abstract`, remove `is`.
1.0.5 / 2015-01-30
=================
* Update `tape`, `jscs`, `nsp`, `eslint`, `es-abstract`
1.0.4 / 2015-01-10
=================
* Use `es-abstract` for ECMAScript spec internal abstract operations
1.0.3 / 2015-01-06
=================
* Speed optimization: use Array#indexOf when available
* Fix ES3, IE 6-8, Opera 10.6, Opera 11.1 support
* Run testling on both sets of tests
1.0.2 / 2015-01-05
=================
* Ensure tests are includes in the module on `npm`
1.0.1 / 2015-01-04
=================
* Remove mistaken auto-shim.
1.0.0 / 2015-01-04
=================
* v1.0.0

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (C) 2015 Jordan Harband
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.

View File

@@ -0,0 +1,61 @@
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
# The files that need updating when incrementing the version number.
VERSIONED_FILES := *.js *.json README*
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
UTILS := semver
# Make sure that all required utilities can be located.
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
# Default target (by virtue of being the first non '.'-prefixed in the file).
.PHONY: _no-target-specified
_no-target-specified:
$(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests)
# Lists all targets defined in this makefile.
.PHONY: list
list:
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
.PHONY: test
test:
@npm test
.PHONY: _ensure-tag
_ensure-tag:
ifndef TAG
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
endif
CHANGELOG_ERROR = $(error No CHANGELOG specified)
.PHONY: _ensure-changelog
_ensure-changelog:
@ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2)
# Ensures that the git workspace is clean.
.PHONY: _ensure-clean
_ensure-clean:
@[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; }
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
.PHONY: release
release: _ensure-tag _ensure-changelog _ensure-clean
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | command grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \
git tag -a -m "v$$new_ver" "v$$new_ver"

View File

@@ -0,0 +1,103 @@
#array-includes <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
[![browser support][testling-svg]][testling-url]
An ES7/ES2016 spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the proposed [spec](http://www.ecma-international.org/ecma-262/6.0/).
Because `Array.prototype.includes` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.
## Getting started
```sh
npm install --save array-includes
```
## Usage
Basic usage: **includes(array, value[, fromIndex=0])**
```js
var includes = require('array-includes');
var arr = [ 'one', 'two' ];
includes(arr, 'one'); // true
includes(arr, 'three'); // false
includes(arr, 'one', 1); // false
```
## Example
```js
var includes = require('array-includes');
var assert = require('assert');
var arr = [
1,
'foo',
NaN,
-0
];
assert.equal(arr.indexOf(0) > -1, true);
assert.equal(arr.indexOf(-0) > -1, true);
assert.equal(includes(arr, 0), true);
assert.equal(includes(arr, -0), true);
assert.equal(arr.indexOf(NaN) > -1, false);
assert.equal(includes(arr, NaN), true);
assert.equal(includes(arr, 'foo', 0), true);
assert.equal(includes(arr, 'foo', 1), true);
assert.equal(includes(arr, 'foo', 2), false);
```
```js
var includes = require('array-includes');
var assert = require('assert');
/* when Array#includes is not present */
delete Array.prototype.includes;
var shimmedIncludes = includes.shim();
assert.equal(shimmedIncludes, includes.getPolyfill());
assert.deepEqual(arr.includes('foo', 1), includes(arr, 'foo', 1));
```
```js
var includes = require('array-includes');
var assert = require('assert');
/* when Array#includes is present */
var shimmedIncludes = includes.shim();
assert.equal(shimmedIncludes, Array.prototype.includes);
assert.deepEqual(arr.includes(1, 'foo'), includes(arr, 1, 'foo'));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/array-includes
[npm-version-svg]: http://versionbadg.es/ljharb/array-includes.svg
[travis-svg]: https://travis-ci.org/ljharb/array-includes.svg
[travis-url]: https://travis-ci.org/ljharb/array-includes
[deps-svg]: https://david-dm.org/ljharb/array-includes.svg
[deps-url]: https://david-dm.org/ljharb/array-includes
[dev-deps-svg]: https://david-dm.org/ljharb/array-includes/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/array-includes#info=devDependencies
[testling-svg]: https://ci.testling.com/ljharb/array-includes.png
[testling-url]: https://ci.testling.com/ljharb/array-includes
[npm-badge-png]: https://nodei.co/npm/array-includes.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/array-includes.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/array-includes.svg
[downloads-url]: http://npm-stat.com/charts.html?package=array-includes

View File

@@ -0,0 +1,31 @@
'use strict';
var ES = require('es-abstract/es6');
var $isNaN = Number.isNaN || function isNaN(a) {
return a !== a;
};
var $isFinite = Number.isFinite || function isFinite(n) {
return typeof n === 'number' && global.isFinite(n);
};
var indexOf = Array.prototype.indexOf;
module.exports = function includes(searchElement) {
var fromIndex = arguments.length > 1 ? ES.ToInteger(arguments[1]) : 0;
if (indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
return indexOf.apply(this, arguments) > -1;
}
var O = ES.ToObject(this);
var length = ES.ToLength(O.length);
if (length === 0) {
return false;
}
var k = fromIndex >= 0 ? fromIndex : Math.max(0, length + fromIndex);
while (k < length) {
if (ES.SameValueZero(searchElement, O[k])) {
return true;
}
k += 1;
}
return false;
};

View File

@@ -0,0 +1,25 @@
'use strict';
var define = require('define-properties');
var ES = require('es-abstract/es6');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var polyfill = getPolyfill();
var shim = require('./shim');
var slice = Array.prototype.slice;
/* eslint-disable no-unused-vars */
var boundIncludesShim = function includes(array, searchElement) {
/* eslint-enable no-unused-vars */
ES.RequireObjectCoercible(array);
return polyfill.apply(array, slice.call(arguments, 1));
};
define(boundIncludesShim, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = boundIncludesShim;

View File

@@ -0,0 +1,125 @@
{
"_args": [
[
"array-includes@3.0.3",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "array-includes@3.0.3",
"_id": "array-includes@3.0.3",
"_inBundle": false,
"_integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=",
"_location": "/react-scripts/array-includes",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "array-includes@3.0.3",
"name": "array-includes",
"escapedName": "array-includes",
"rawSpec": "3.0.3",
"saveSpec": null,
"fetchSpec": "3.0.3"
},
"_requiredBy": [
"/react-scripts/eslint-plugin-jsx-a11y",
"/react-scripts/eslint-plugin-react/jsx-ast-utils",
"/react-scripts/webpack-dev-server"
],
"_resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz",
"_spec": "3.0.3",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
},
"bugs": {
"url": "https://github.com/ljharb/array-includes/issues"
},
"contributors": [
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
}
],
"dependencies": {
"define-properties": "^1.1.2",
"es-abstract": "^1.7.0"
},
"description": "An ES7/ES2016 spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.",
"devDependencies": {
"@es-shims/api": "^1.2.0",
"@ljharb/eslint-config": "^11.0.0",
"covert": "^1.1.0",
"eslint": "^3.19.0",
"evalmd": "^0.0.17",
"foreach": "^2.0.5",
"function-bind": "^1.1.0",
"indexof": "^0.0.1",
"jscs": "^3.0.7",
"nsp": "^2.6.3",
"replace": "^0.3.0",
"semver": "^5.3.0",
"tape": "^4.6.3"
},
"engines": {
"node": ">= 0.4"
},
"homepage": "https://github.com/ljharb/array-includes#readme",
"keywords": [
"Array.prototype.includes",
"includes",
"array",
"ES7",
"shim",
"polyfill",
"contains",
"Array.prototype.contains",
"es-shim API"
],
"license": "MIT",
"main": "index.js",
"name": "array-includes",
"repository": {
"type": "git",
"url": "git://github.com/ljharb/array-includes.git"
},
"scripts": {
"coverage": "covert test/*.js",
"coverage:quiet": "covert test/*.js --quiet",
"eslint": "eslint test/*.js *.js",
"jscs": "jscs test/*.js *.js",
"lint": "npm run --silent jscs && npm run --silent eslint",
"posttest": "npm run --silent security",
"pretest": "npm run --silent lint && evalmd README.md",
"security": "nsp check",
"test": "npm run --silent tests-only",
"test:module": "node test/index.js",
"test:shimmed": "node test/shimmed.js",
"tests-only": "es-shim-api --bound && npm run --silent test:shimmed && npm run --silent test:module"
},
"testling": {
"files": [
"test/index.js",
"test/shimmed.js"
],
"browsers": [
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2"
]
},
"version": "3.0.3"
}

View File

@@ -0,0 +1,7 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return Array.prototype.includes || implementation;
};

View File

@@ -0,0 +1,14 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimArrayPrototypeIncludes() {
var polyfill = getPolyfill();
define(
Array.prototype,
{ includes: polyfill },
{ includes: function () { return Array.prototype.includes !== polyfill; } }
);
return polyfill;
};

View File

@@ -0,0 +1,8 @@
{
"rules": {
"max-nested-callbacks": [2, 3],
"max-statements-per-line": [2, { "max": 2 }],
"no-invalid-this": [1],
"sort-keys": [0]
}
}

View File

@@ -0,0 +1,17 @@
'use strict';
var includes = require('../');
var test = require('tape');
var runTests = require('./tests');
test('as a function', function (t) {
t.test('bad array/this value', function (st) {
st.throws(includes.bind(null, undefined, 'a'), TypeError, 'undefined is not an object');
st.throws(includes.bind(null, null, 'a'), TypeError, 'null is not an object');
st.end();
});
runTests(includes, t);
t.end();
});

View File

@@ -0,0 +1,36 @@
'use strict';
require('../shim')();
var test = require('tape');
var defineProperties = require('define-properties');
var bind = require('function-bind');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = function f() {}.name === 'f';
var runTests = require('./tests');
test('shimmed', function (t) {
t.equal(Array.prototype.includes.length, 1, 'Array#includes has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Array.prototype.includes.name, 'includes', 'Array#includes has name "includes"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Array.prototype, 'includes'), 'Array#includes is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
st.throws(function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
st.throws(function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
st.end();
});
runTests(bind.call(Function.call, Array.prototype.includes), t);
t.end();
});

View File

@@ -0,0 +1,80 @@
'use strict';
module.exports = function (includes, t) {
var sparseish = { length: 5, 0: 'a', 1: 'b' };
var overfullarrayish = { length: 2, 0: 'a', 1: 'b', 2: 'c' };
var thrower = { valueOf: function () { throw new RangeError('whoa'); } };
var numberish = { valueOf: function () { return 2; } };
t.test('simple examples', function (st) {
st.equal(true, includes([1, 2, 3], 1), '[1, 2, 3] includes 1');
st.equal(false, includes([1, 2, 3], 4), '[1, 2, 3] does not include 4');
st.equal(true, includes([NaN], NaN), '[NaN] includes NaN');
st.end();
});
t.test('does not skip holes', function (st) {
st.equal(true, includes(Array(1)), 'Array(1) includes undefined');
st.end();
});
t.test('exceptions', function (et) {
et.test('fromIndex conversion', function (st) {
st.throws(includes.bind(null, [0], 0, thrower), RangeError, 'fromIndex conversion throws');
st.end();
});
et.test('ToLength', function (st) {
st.throws(includes.bind(null, { length: thrower, 0: true }, true), RangeError, 'ToLength conversion throws');
st.end();
});
et.end();
});
t.test('arraylike', function (st) {
st.equal(true, includes(sparseish, 'a'), 'sparse array-like object includes "a"');
st.equal(false, includes(sparseish, 'c'), 'sparse array-like object does not include "c"');
st.equal(true, includes(overfullarrayish, 'b'), 'sparse array-like object includes "b"');
st.equal(false, includes(overfullarrayish, 'c'), 'sparse array-like object does not include "c"');
st.end();
});
t.test('fromIndex', function (ft) {
ft.equal(true, includes([1], 1, NaN), 'NaN fromIndex -> 0 fromIndex');
ft.test('number coercion', function (st) {
st.equal(false, includes(['a', 'b', 'c'], 'a', numberish), 'does not find "a" with object fromIndex coercing to 2');
st.equal(false, includes(['a', 'b', 'c'], 'a', '2'), 'does not find "a" with string fromIndex coercing to 2');
st.equal(true, includes(['a', 'b', 'c'], 'c', numberish), 'finds "c" with object fromIndex coercing to 2');
st.equal(true, includes(['a', 'b', 'c'], 'c', '2'), 'finds "c" with string fromIndex coercing to 2');
st.end();
});
ft.test('fromIndex greater than length', function (st) {
st.equal(false, includes([1], 1, 2), 'array of length 1 is not searched if fromIndex is > 1');
st.equal(false, includes([1], 1, 1), 'array of length 1 is not searched if fromIndex is >= 1');
st.equal(false, includes([1], 1, 1.1), 'array of length 1 is not searched if fromIndex is 1.1');
st.equal(false, includes([1], 1, Infinity), 'array of length 1 is not searched if fromIndex is Infinity');
st.end();
});
ft.test('negative fromIndex', function (st) {
st.equal(true, includes([1, 3], 1, -4), 'computed length would be negative; fromIndex is thus 0');
st.equal(true, includes([1, 3], 3, -4), 'computed length would be negative; fromIndex is thus 0');
st.equal(true, includes([1, 3], 1, -Infinity), 'computed length would be negative; fromIndex is thus 0');
st.equal(true, includes([12, 13], 13, -1), 'finds -1st item with -1 fromIndex');
st.equal(false, includes([12, 13], 12, -1), 'does not find -2nd item with -1 fromIndex');
st.equal(true, includes([12, 13], 13, -2), 'finds -2nd item with -2 fromIndex');
st.equal(true, includes(sparseish, 'b', -4), 'finds -4th item with -4 fromIndex');
st.equal(false, includes(sparseish, 'a', -4), 'does not find -5th item with -4 fromIndex');
st.equal(true, includes(sparseish, 'a', -5), 'finds -5th item with -5 fromIndex');
st.end();
});
ft.end();
});
};