diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/state-toggle')
5 files changed, 263 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/state-toggle/LICENSE b/tools/node_modules/eslint/node_modules/state-toggle/LICENSE new file mode 100644 index 0000000000..8d8660d36e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/state-toggle/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com> + +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. diff --git a/tools/node_modules/eslint/node_modules/state-toggle/history.md b/tools/node_modules/eslint/node_modules/state-toggle/history.md new file mode 100644 index 0000000000..f20d503569 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/state-toggle/history.md @@ -0,0 +1,6 @@ +<!--remark setext--> + +<!--lint disable no-multiple-toplevel-headings --> + +1.0.0 / 2016-07-16 +================== diff --git a/tools/node_modules/eslint/node_modules/state-toggle/index.js b/tools/node_modules/eslint/node_modules/state-toggle/index.js new file mode 100644 index 0000000000..d5aff1857f --- /dev/null +++ b/tools/node_modules/eslint/node_modules/state-toggle/index.js @@ -0,0 +1,45 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module state-toggle + * @fileoverview Enter/exit a state. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* Expose. */ +module.exports = factory; + +/** + * Construct a state `toggler`: a function which inverses + * `property` in context based on its current value. + * The by `toggler` returned function restores that value. + * + * @param {string} key - Property to toggle. + * @param {boolean} state - Default state. + * @param {Object?} [ctx] - Context object. + * @return {Function} - Enter. + */ +function factory(key, state, ctx) { + /** + * Enter a state. + * + * @return {Function} - Exit state. + */ + return function () { + var context = ctx || this; + var current = context[key]; + + context[key] = !state; + + /** + * Cancel state to its value before entering. + */ + return function () { + context[key] = current; + }; + }; +} diff --git a/tools/node_modules/eslint/node_modules/state-toggle/package.json b/tools/node_modules/eslint/node_modules/state-toggle/package.json new file mode 100644 index 0000000000..81b7c116ad --- /dev/null +++ b/tools/node_modules/eslint/node_modules/state-toggle/package.json @@ -0,0 +1,107 @@ +{ + "_from": "state-toggle@^1.0.0", + "_id": "state-toggle@1.0.0", + "_inBundle": false, + "_integrity": "sha1-0g+aYWu08MO5i5GSLSW2QKorxCU=", + "_location": "/state-toggle", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "state-toggle@^1.0.0", + "name": "state-toggle", + "escapedName": "state-toggle", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/remark-parse" + ], + "_resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.0.tgz", + "_shasum": "d20f9a616bb4f0c3b98b91922d25b640aa2bc425", + "_spec": "state-toggle@^1.0.0", + "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/remark-parse", + "author": { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + "bugs": { + "url": "https://github.com/wooorm/state-toggle/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + } + ], + "dependencies": {}, + "deprecated": false, + "description": "Enter/exit a state", + "devDependencies": { + "browserify": "^13.0.1", + "esmangle": "^1.0.1", + "nyc": "^7.0.0", + "remark-cli": "^1.0.0", + "remark-comment-config": "^4.0.0", + "remark-github": "^5.0.0", + "remark-lint": "^4.0.0", + "remark-validate-links": "^4.0.0", + "tape": "^4.0.0", + "xo": "^0.16.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/wooorm/state-toggle#readme", + "keywords": [ + "enter", + "exit", + "state" + ], + "license": "MIT", + "name": "state-toggle", + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, + "remarkConfig": { + "output": true, + "plugins": [ + "comment-config", + "github", + "lint", + "validate-links" + ], + "settings": { + "bullet": "*" + } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/state-toggle.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js --bare -s stateToggle > state-toggle.js", + "build-mangle": "esmangle < state-toggle.js > state-toggle.min.js", + "build-md": "remark . --quiet --frail", + "lint": "xo", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test", + "test-coverage": "nyc --reporter lcov tape test.js" + }, + "version": "1.0.0", + "xo": { + "space": true, + "ignores": [ + "state-toggle.js", + "state-toggle.min.js" + ] + } +} diff --git a/tools/node_modules/eslint/node_modules/state-toggle/readme.md b/tools/node_modules/eslint/node_modules/state-toggle/readme.md new file mode 100644 index 0000000000..e2282d113b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/state-toggle/readme.md @@ -0,0 +1,83 @@ +# state-toggle [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] + +<!--lint disable heading-increment no-duplicate-headings--> + +Enter/exit a state. + +## Installation + +[npm][npm-install]: + +```bash +npm install state-toggle +``` + +## Usage + +```javascript +var toggle = require('state-toggle'); +var ctx = {on: false}; +var enter = toggle('on', ctx.on, ctx); +var exit; + +// Entering: +exit = enter(); +console.log(ctx.on); // true + +// Exiting: +exit(); +console.log(ctx.on); // false +``` + +## API + +### `toggle(key, initial[, ctx])` + +Create a toggle, which when entering toggles `key` on `ctx` (or `this`, +if `ctx` is not given) to `!initial`, and when exiting, sets `key` on +the context back to the value it had before entering. + +###### Returns + +`Function` — [`enter`][enter]. + +### `enter()` + +Enter the state. + +###### Context + +If no `ctx` was given to `toggle`, the context object (`this`) of `enter()` +is used to toggle. + +###### Returns + +`Function` — [`exit`][exit]. + +### `exit()` + +Exit the state, reverting `key` to the value it had before entering. + +## License + +[MIT][license] © [Titus Wormer][author] + +<!-- Definitions --> + +[travis-badge]: https://img.shields.io/travis/wooorm/state-toggle.svg + +[travis]: https://travis-ci.org/wooorm/state-toggle + +[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/state-toggle.svg + +[codecov]: https://codecov.io/github/wooorm/state-toggle + +[npm-install]: https://docs.npmjs.com/cli/install + +[license]: LICENSE + +[author]: http://wooorm.com + +[enter]: #enter + +[exit]: #exit |