summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/generate-function
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-08-16 07:00:34 -0700
committerMyles Borins <mylesborins@google.com>2017-09-05 12:49:53 -0400
commitc5adb5f0083d47317fb6cf1dbd9b6873738e01f7 (patch)
tree7c51778b607f8f7c7b7cbb0750d88a19ab149a09 /tools/eslint/node_modules/generate-function
parent688e5ed6fd9aee2ecab576282dfd131db0a4711e (diff)
downloadnode-new-c5adb5f0083d47317fb6cf1dbd9b6873738e01f7.tar.gz
tools: update ESLint to 4.2.0
ESLint 4.2.0 contains a fix for a bug that is blocking us from moving to the non-legacy stricter indentation linting. Update to 4.2.0 to remove the blocking issue. Backport-PR-URL: https://github.com/nodejs/node/pull/14859 PR-URL: https://github.com/nodejs/node/pull/14155 Ref: https://github.com/eslint/eslint/issues/8882 Ref: https://github.com/eslint/eslint/pull/8885 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'tools/eslint/node_modules/generate-function')
-rw-r--r--tools/eslint/node_modules/generate-function/README.md72
-rw-r--r--tools/eslint/node_modules/generate-function/example.js27
-rw-r--r--tools/eslint/node_modules/generate-function/index.js61
-rw-r--r--tools/eslint/node_modules/generate-function/package.json56
4 files changed, 0 insertions, 216 deletions
diff --git a/tools/eslint/node_modules/generate-function/README.md b/tools/eslint/node_modules/generate-function/README.md
deleted file mode 100644
index 693bff87cf..0000000000
--- a/tools/eslint/node_modules/generate-function/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# generate-function
-
-Module that helps you write generated functions in Node
-
-```
-npm install generate-function
-```
-
-[![build status](http://img.shields.io/travis/mafintosh/generate-function.svg?style=flat)](http://travis-ci.org/mafintosh/generate-function)
-
-## Disclamer
-
-Writing code that generates code is hard.
-You should only use this if you really, really, really need this for performance reasons (like schema validators / parsers etc).
-
-## Usage
-
-``` js
-var genfun = require('generate-function')
-
-var addNumber = function(val) {
- var fn = genfun()
- ('function add(n) {')
- ('return n + %d', val) // supports format strings to insert values
- ('}')
-
- return fn.toFunction() // will compile the function
-}
-
-var add2 = addNumber(2)
-
-console.log('1+2=', add2(1))
-console.log(add2.toString()) // prints the generated function
-```
-
-If you need to close over variables in your generated function pass them to `toFunction(scope)`
-
-``` js
-var multiply = function(a, b) {
- return a * b
-}
-
-var addAndMultiplyNumber = function(val) {
- var fn = genfun()
- ('function(n) {')
- ('if (typeof n !== "number") {') // ending a line with { will indent the source
- ('throw new Error("argument should be a number")')
- ('}')
- ('var result = multiply(%d, n+%d)', val, val)
- ('return result')
- ('}')
-
- // use fn.toString() if you want to see the generated source
-
- return fn.toFunction({
- multiply: multiply
- })
-}
-
-var addAndMultiply2 = addAndMultiplyNumber(2)
-
-console.log('(3 + 2) * 2 =', addAndMultiply2(3))
-```
-
-## Related
-
-See [generate-object-property](https://github.com/mafintosh/generate-object-property) if you need to safely generate code that
-can be used to reference an object property
-
-## License
-
-MIT \ No newline at end of file
diff --git a/tools/eslint/node_modules/generate-function/example.js b/tools/eslint/node_modules/generate-function/example.js
deleted file mode 100644
index 8d1fee1626..0000000000
--- a/tools/eslint/node_modules/generate-function/example.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var genfun = require('./')
-
-var multiply = function(a, b) {
- return a * b
-}
-
-var addAndMultiplyNumber = function(val) {
- var fn = genfun()
- ('function(n) {')
- ('if (typeof n !== "number") {') // ending a line with { will indent the source
- ('throw new Error("argument should be a number")')
- ('}')
- ('var result = multiply(%d, n+%d)', val, val)
- ('return result')
- ('}')
-
- // use fn.toString() if you want to see the generated source
-
- return fn.toFunction({
- multiply: multiply
- })
-}
-
-var addAndMultiply2 = addAndMultiplyNumber(2)
-
-console.log(addAndMultiply2.toString())
-console.log('(3 + 2) * 2 =', addAndMultiply2(3)) \ No newline at end of file
diff --git a/tools/eslint/node_modules/generate-function/index.js b/tools/eslint/node_modules/generate-function/index.js
deleted file mode 100644
index 37e064bb47..0000000000
--- a/tools/eslint/node_modules/generate-function/index.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var util = require('util')
-
-var INDENT_START = /[\{\[]/
-var INDENT_END = /[\}\]]/
-
-module.exports = function() {
- var lines = []
- var indent = 0
-
- var push = function(str) {
- var spaces = ''
- while (spaces.length < indent*2) spaces += ' '
- lines.push(spaces+str)
- }
-
- var line = function(fmt) {
- if (!fmt) return line
-
- if (INDENT_END.test(fmt.trim()[0]) && INDENT_START.test(fmt[fmt.length-1])) {
- indent--
- push(util.format.apply(util, arguments))
- indent++
- return line
- }
- if (INDENT_START.test(fmt[fmt.length-1])) {
- push(util.format.apply(util, arguments))
- indent++
- return line
- }
- if (INDENT_END.test(fmt.trim()[0])) {
- indent--
- push(util.format.apply(util, arguments))
- return line
- }
-
- push(util.format.apply(util, arguments))
- return line
- }
-
- line.toString = function() {
- return lines.join('\n')
- }
-
- line.toFunction = function(scope) {
- var src = 'return ('+line.toString()+')'
-
- var keys = Object.keys(scope || {}).map(function(key) {
- return key
- })
-
- var vals = keys.map(function(key) {
- return scope[key]
- })
-
- return Function.apply(null, keys.concat(src)).apply(null, vals)
- }
-
- if (arguments.length) line.apply(null, arguments)
-
- return line
-}
diff --git a/tools/eslint/node_modules/generate-function/package.json b/tools/eslint/node_modules/generate-function/package.json
deleted file mode 100644
index cc950e8948..0000000000
--- a/tools/eslint/node_modules/generate-function/package.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "_from": "generate-function@^2.0.0",
- "_id": "generate-function@2.0.0",
- "_inBundle": false,
- "_integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=",
- "_location": "/eslint/generate-function",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "generate-function@^2.0.0",
- "name": "generate-function",
- "escapedName": "generate-function",
- "rawSpec": "^2.0.0",
- "saveSpec": null,
- "fetchSpec": "^2.0.0"
- },
- "_requiredBy": [
- "/eslint/is-my-json-valid"
- ],
- "_resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
- "_shasum": "6858fe7c0969b7d4e9093337647ac79f60dfbe74",
- "_spec": "generate-function@^2.0.0",
- "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/is-my-json-valid",
- "author": {
- "name": "Mathias Buus"
- },
- "bugs": {
- "url": "https://github.com/mafintosh/generate-function/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Module that helps you write generated functions in Node",
- "devDependencies": {
- "tape": "^2.13.4"
- },
- "homepage": "https://github.com/mafintosh/generate-function",
- "keywords": [
- "generate",
- "code",
- "generation",
- "function",
- "performance"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "generate-function",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/mafintosh/generate-function.git"
- },
- "scripts": {
- "test": "tape test.js"
- },
- "version": "2.0.0"
-}