WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

19
node_modules/es6-promisify/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2014 Mike Hall / Digital Design Labs
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.

93
node_modules/es6-promisify/README.md generated vendored Normal file
View File

@ -0,0 +1,93 @@
[![Travis CI](https://travis-ci.org/digitaldesignlabs/es6-promisify.svg)](https://travis-ci.org/digitaldesignlabs/es6-promisify)
# es6-promisify
Converts callback-based functions to ES6/ES2015 Promises, using a boilerplate callback function.
NOTE: All-new API for Version 6.0.0; please read carefully!
===========================================================
## Install
Install with [npm](https://npmjs.org/package/es6-promisify)
```bash
npm install es6-promisify
```
## Example
```js
const {promisify} = require("es6-promisify");
// Convert the stat function
const fs = require("fs");
const stat = promisify(fs.stat);
// Now usable as a promise!
stat("example.txt").then(function (stats) {
console.log("Got stats", stats);
}).catch(function (err) {
console.error("Yikes!", err);
});
```
## Promisify methods
```js
const {promisify} = require("es6-promisify");
// Create a promise-based version of send_command
const redis = require("redis").createClient(6379, "localhost");
const client = promisify(redis.send_command.bind(redis));
// Send commands to redis and get a promise back
client("ping").then(function (pong) {
console.log("Got", pong);
}).catch(function (err) {
console.error("Unexpected error", err);
}).then(function () {
redis.quit();
});
```
## Handle multiple callback arguments, with named parameters
```js
const {promisify} = require("es6-promisify");
function test(cb) {
return cb(undefined, 1, 2, 3);
}
// Create promise-based version of test
test[promisify.argumentNames] = ["one", "two", "three"];
const multi = promisify(test);
// Returns named arguments
multi().then(result => {
console.log(result); // {one: 1, two: 2, three: 3}
});
```
## Provide your own Promise implementation
```js
const {promisify} = require("es6-promisify");
// Now uses Bluebird
promisify.Promise = require("bluebird");
const test = promisify(cb => cb(undefined, "test"));
test().then(result => {
console.log(result); // "test", resolved using Bluebird
});
```
### Tests
Test with tape
```bash
$ npm test
```
### Changes from v5.0.0
- Allow developer to specify a different implementations of `Promise`
- No longer ships with a polyfill for `Promise`. If your environment has no native `Promise` you must polyfill yourself, or set `promisify.Promise` to an A+ compatible `Promise` implementation.
- Removed support for `settings.thisArg`: use `.bind()` instead.
- Removed support for `settings.multiArgs`: use named arguments instead.
Published under the [MIT License](http://opensource.org/licenses/MIT).

84
node_modules/es6-promisify/dist/promisify.js generated vendored Normal file
View File

@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// Symbols is a better way to do this, but not all browsers have good support,
// so instead we'll just make do with a very unlikely string.
var customArgumentsToken = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";
/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
*/
function promisify(original) {
// Ensure the argument is a function
if (typeof original !== "function") {
throw new TypeError("Argument to promisify must be a function");
}
// If the user has asked us to decode argument names for them, honour that
var argumentNames = original[customArgumentsToken];
// If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
var ES6Promise = promisify.Promise || Promise;
// If we can find no Promise implemention, then fail now.
if (typeof ES6Promise !== "function") {
throw new Error("No Promise implementation found; do you need a polyfill?");
}
return function () {
var _this = this;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return new ES6Promise(function (resolve, reject) {
// Append the callback bound to the context
args.push(function callback(err) {
if (err) {
return reject(err);
}
for (var _len2 = arguments.length, values = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
values[_key2 - 1] = arguments[_key2];
}
if (values.length === 1 || !argumentNames) {
return resolve(values[0]);
}
var o = {};
values.forEach(function (value, index) {
var name = argumentNames[index];
if (name) {
o[name] = value;
}
});
resolve(o);
});
// Call the function.
original.call.apply(original, [_this].concat(args));
});
};
}
// Attach this symbol to the exported function, so users can use it
promisify.argumentNames = customArgumentsToken;
promisify.Promise = undefined;
// Export the public API
exports.promisify = promisify;

73
node_modules/es6-promisify/package.json generated vendored Normal file
View File

@ -0,0 +1,73 @@
{
"_from": "es6-promisify@^6.0.0",
"_id": "es6-promisify@6.0.1",
"_inBundle": false,
"_integrity": "sha512-J3ZkwbEnnO+fGAKrjVpeUAnZshAdfZvbhQpqfIH9kSAspReRC4nJnu8ewm55b4y9ElyeuhCTzJD0XiH8Tsbhlw==",
"_location": "/es6-promisify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "es6-promisify@^6.0.0",
"name": "es6-promisify",
"escapedName": "es6-promisify",
"rawSpec": "^6.0.0",
"saveSpec": null,
"fetchSpec": "^6.0.0"
},
"_requiredBy": [
"/cache-manager-fs-hash"
],
"_resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.0.1.tgz",
"_shasum": "6edaa45f3bd570ffe08febce66f7116be4b1cdb6",
"_spec": "es6-promisify@^6.0.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/cache-manager-fs-hash",
"author": {
"name": "Mike Hall",
"email": "mikehall314@gmail.com"
},
"bugs": {
"url": "http://github.com/digitaldesignlabs/es6-promisify/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Converts callback-based functions to ES6 Promises",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"es6-promise": "^4.2.5",
"eslint": "^5.7.0",
"istanbul": "^0.4.5",
"sinon": "^7.0.0",
"tape": "^4.9.1"
},
"files": [
"dist/promisify.js"
],
"greenkeeper": {
"ignore": [
"eslint"
]
},
"homepage": "https://github.com/digitaldesignlabs/es6-promisify#readme",
"keywords": [
"promises",
"es6",
"promisify"
],
"license": "MIT",
"main": "dist/promisify.js",
"name": "es6-promisify",
"repository": {
"type": "git",
"url": "git+https://github.com/digitaldesignlabs/es6-promisify.git"
},
"scripts": {
"build": "babel lib -d dist",
"pretest": "eslint lib/*.js test/*.js",
"test": "npm run build && ./node_modules/.bin/tape test",
"test:cover": "npm run build && ./node_modules/.bin/istanbul cover test"
},
"version": "6.0.1"
}