composer and npm

This commit is contained in:
Henry Whitaker
2020-08-25 00:59:44 +01:00
parent 6726d93cc6
commit c8f853dc84
2504 changed files with 88530 additions and 41367 deletions

View File

@@ -1,3 +1,23 @@
<a name="3.3.12"></a>
# 3.3.12 (2020-06-03)
[Full Changelog](https://github.com/webpack/webpack-cli/compare/v3.3.11...v3.3.12)
## Chore
- update dependencies
<a name="3.3.11"></a>
# 3.3.11 (2020-02-11)
[Full Changelog](https://github.com/webpack/webpack-cli/compare/v3.3.10...v3.3.11)
## Chore
- update dependencies
<a name="3.3.10"></a>
# 3.3.10 (2019-10-31)

View File

@@ -1 +0,0 @@
../json5/lib/cli.js

View File

@@ -1,70 +0,0 @@
<a name="2.1.0"></a>
# 2.1.0 (2016-10-03)
* Fetch new emoji ([7dbe84d](https://github.com/kikobeats/emojis-list/commit/7dbe84d))
<a name="2.0.1"></a>
## 2.0.1 (2016-05-12)
* Fix typo ([3808909](https://github.com/kikobeats/emojis-list/commit/3808909))
<a name="2.0.0"></a>
# 2.0.0 (2016-05-12)
* Add update script ([f846dd6](https://github.com/kikobeats/emojis-list/commit/f846dd6))
* Block dependencies in last version ([1d9e0a5](https://github.com/kikobeats/emojis-list/commit/1d9e0a5))
* Extract main file name ([9ffe7bb](https://github.com/kikobeats/emojis-list/commit/9ffe7bb))
* Remove unnecessary files ([4c34729](https://github.com/kikobeats/emojis-list/commit/4c34729))
* Update docs, special webpack setup is not necessary ([c4aefe9](https://github.com/kikobeats/emojis-list/commit/c4aefe9))
* Update example ([1e2ae03](https://github.com/kikobeats/emojis-list/commit/1e2ae03))
* Update how to generate emojis array ([b56bad9](https://github.com/kikobeats/emojis-list/commit/b56bad9))
* Update main file based in the new interface ([996fccb](https://github.com/kikobeats/emojis-list/commit/996fccb))
<a name="1.0.3"></a>
## 1.0.3 (2016-05-12)
* Add standard as linter ([5e939d6](https://github.com/kikobeats/emojis-list/commit/5e939d6))
* Change interface ([16bc0c0](https://github.com/kikobeats/emojis-list/commit/16bc0c0))
* Generate emoji file ([fbcf8e9](https://github.com/kikobeats/emojis-list/commit/fbcf8e9))
* Remove unnecessary special doc ([2b12bec](https://github.com/kikobeats/emojis-list/commit/2b12bec))
* chore(package): update browserify to version 13.0.1 ([e2c98bf](https://github.com/kikobeats/emojis-list/commit/e2c98bf))
* chore(package): update gulp-header to version 1.8.1 ([28de793](https://github.com/kikobeats/emojis-list/commit/28de793))
<a name="1.0.2"></a>
## 1.0.2 (2016-05-05)
* fixed #2 ([9a6abe7](https://github.com/kikobeats/emojis-list/commit/9a6abe7)), closes [#2](https://github.com/kikobeats/emojis-list/issues/2)
* Fomar using standard ([5202f9f](https://github.com/kikobeats/emojis-list/commit/5202f9f))
* Update badge ([53fad9b](https://github.com/kikobeats/emojis-list/commit/53fad9b))
<a name="1.0.1"></a>
## 1.0.1 (2016-04-13)
* lock versions ([4a5d82e](https://github.com/kikobeats/emojis-list/commit/4a5d82e))
* setup devDependencies ([d1de0fc](https://github.com/kikobeats/emojis-list/commit/d1de0fc))
* update bumped ([9941038](https://github.com/kikobeats/emojis-list/commit/9941038))
* Update package.json ([6c14b74](https://github.com/kikobeats/emojis-list/commit/6c14b74))
* Update README.md ([1d9beeb](https://github.com/kikobeats/emojis-list/commit/1d9beeb))
* Update README.md ([73f215e](https://github.com/kikobeats/emojis-list/commit/73f215e))
* Update tests ([a94f7dc](https://github.com/kikobeats/emojis-list/commit/a94f7dc))
<a name="1.0.0"></a>
# 1.0.0 (2015-05-12)
* first commit ([a65b79d](https://github.com/kikobeats/emojis-list/commit/a65b79d))
* updated ([9f0564c](https://github.com/kikobeats/emojis-list/commit/9f0564c))

View File

@@ -1,9 +0,0 @@
The MIT License (MIT)
Copyright © 2015 Kiko Beats
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

@@ -1,48 +0,0 @@
# emojis-list
[![Dependency status](http://img.shields.io/david/Kikobeats/emojis-list.svg?style=flat-square)](https://david-dm.org/Kikobeats/emojis-list)
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/emojis-list.svg?style=flat-square)](https://david-dm.org/Kikobeats/emojis-list#info=devDependencies)
[![NPM Status](http://img.shields.io/npm/dm/emojis-list.svg?style=flat-square)](https://www.npmjs.org/package/emojis-list)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/kikobeats)
> Complete list of standard Unicode Hex Character Code that represent emojis.
**NOTE**: The lists is related with the Unicode Hex Character Code. The representation of the emoji depend of the system. Will be possible that the system don't have all the representations.
## Install
```bash
npm install emojis-list --save
```
If you want to use in the browser (powered by [Browserify](http://browserify.org/)):
```bash
bower install emojis-list --save
```
and later link in your HTML:
```html
<script src="bower_components/emojis-list/dist/emojis-list.js"></script>
```
## Usage
```
var emojis = require('emojis-list');
console.log(emojis[0]);
// => 🀄
```
## Related
* [emojis-unicode](https://github.com/Kikobeats/emojis-unicode) Complete list of standard Unicode codes that represent emojis.
* [emojis-keywords](https://github.com/Kikobeats/emojis-keywords) Complete list of am emoji shortcuts.
* [is-emoji-keyword](https://github.com/Kikobeats/is-emoji-keyword) Check if a word is a emoji shortcut.
* [is-standard-emoji](https://github.com/kikobeats/is-standard-emoji) Simply way to check if a emoji is a standard emoji.
* [trim-emoji](https://github.com/Kikobeats/trim-emoji) Deletes ':' from the begin and the end of an emoji shortcut.
## License
MIT © [Kiko Beats](http://www.kikobeats.com)

File diff suppressed because it is too large Load Diff

View File

@@ -1,80 +0,0 @@
{
"_args": [
[
"emojis-list@2.1.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "emojis-list@2.1.0",
"_id": "emojis-list@2.1.0",
"_inBundle": false,
"_integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=",
"_location": "/webpack-cli/emojis-list",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "emojis-list@2.1.0",
"name": "emojis-list",
"escapedName": "emojis-list",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/webpack-cli/loader-utils"
],
"_resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Kiko Beats",
"email": "josefrancisco.verdu@gmail.com",
"url": "https://github.com/Kikobeats"
},
"bugs": {
"url": "https://github.com/Kikobeats/emojis-list/issues"
},
"description": "Complete list of standard emojis.",
"devDependencies": {
"acho": "latest",
"browserify": "latest",
"cheerio": "latest",
"got": ">=5 <6",
"gulp": "latest",
"gulp-header": "latest",
"gulp-uglify": "latest",
"gulp-util": "latest",
"standard": "latest",
"vinyl-buffer": "latest",
"vinyl-source-stream": "latest"
},
"engines": {
"node": ">= 0.10"
},
"files": [
"index.js"
],
"homepage": "https://github.com/Kikobeats/emojis-list",
"keywords": [
"archive",
"complete",
"emoji",
"list",
"standard"
],
"license": "MIT",
"main": "./index.js",
"name": "emojis-list",
"repository": {
"type": "git",
"url": "git+https://github.com/kikobeats/emojis-list.git"
},
"scripts": {
"pretest": "standard update.js",
"test": "echo 'YOLO'",
"update": "node update"
},
"version": "2.1.0"
}

View File

@@ -1,20 +0,0 @@
Copyright JS Foundation and other contributors
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

@@ -1,121 +0,0 @@
# enhanced-resolve
Offers an async require.resolve function. It's highly configurable.
## Features
* plugin system
* provide a custom filesystem
* sync and async node.js filesystems included
## Getting Started
### Install
```sh
# npm
npm install enhanced-resolve
# or Yarn
yarn add enhanced-resolve
```
### Creating a Resolver
The easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations.
```js
const {
NodeJsInputFileSystem,
CachedInputFileSystem,
ResolverFactory
} = require('enhanced-resolve');
// create a resolver
const myResolver = ResolverFactory.createResolver({
// Typical usage will consume the `NodeJsInputFileSystem` + `CachedInputFileSystem`, which wraps the Node.js `fs` wrapper to add resilience + caching.
fileSystem: new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000),
extensions: ['.js', '.json']
/* any other resolver options here. Options/defaults can be seen below */
});
// resolve a file with the new resolver
const context = {};
const resolveContext = {};
const lookupStartPath = '/Users/webpack/some/root/dir';
const request = './path/to-look-up.js';
myResolver.resolve({}, lookupStartPath, request, resolveContext, (err/*Error*/, filepath/*string*/) => {
// Do something with the path
});
```
For more examples creating different types resolvers (sync/async, context, etc) see `lib/node.js`.
#### Resolver Options
| Field | Default | Description |
| ------------------------ | --------------------------- | ---------------------------------------------------------------------------------- |
| alias | [] | A list of module alias configurations or an object which maps key to value |
| aliasFields | [] | A list of alias fields in description files |
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
| descriptionFiles | ["package.json"] | A list of description files to read from |
| enforceExtension | false | Enforce that a extension from extensions must be used |
| enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| mainFields | ["main"] | A list of main fields in description files |
| mainFiles | ["index"] | A list of main files in directories |
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
| plugins | [] | A list of additional resolve plugins which should be applied |
| symlinks | true | Whether to resolve symlinks to their symlinked location |
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
| moduleExtensions | [] | A list of module extensions which should be tried for modules |
| resolveToContext | false | Resolve to a context instead of a file |
| fileSystem | | The file system which should be used |
| resolver | undefined | A prepared Resolver to which the plugins are attached |
## Plugins
Similar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`Tapable`](https://github.com/webpack/tapable). These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.
A plugin should be a `class` (or its ES5 equivalent) with an `apply` method. The `apply` method will receive a `resolver` instance, that can be used to hook in to the event system.
### Plugin Boilerplate
```js
class MyResolverPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("MyResolverPlugin", (request, resolveContext, callback) => {
// Any logic you need to create a new `request` can go here
resolver.doResolve(target, request, null, resolveContext, callback);
});
}
}
```
Plugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, `source` is the name of the event that starts the pipeline, and `target` is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see `lib/ResolverFactory.js`, in the `//// pipeline ////` section.
## Tests
``` javascript
npm test
```
[![Build Status](https://secure.travis-ci.org/webpack/enhanced-resolve.png?branch=master)](http://travis-ci.org/webpack/enhanced-resolve)
## Passing options from webpack
If you are using `webpack`, and you want to pass custom options to `enhanced-resolve`, the options are passed from the `resolve` key of your webpack configuration e.g.:
```
resolve: {
extensions: ['', '.js', '.jsx'],
modules: ['src', 'node_modules'],
plugins: [new DirectoryNamedWebpackPlugin()]
...
},
```
## License
Copyright (c) 2012-2016 Tobias Koppers
MIT (http://www.opensource.org/licenses/mit-license.php)

View File

@@ -1,52 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DescriptionFileUtils = require("./DescriptionFileUtils");
const getInnerRequest = require("./getInnerRequest");
module.exports = class AliasFieldPlugin {
constructor(source, field, target) {
this.source = source;
this.field = field;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("AliasFieldPlugin", (request, resolveContext, callback) => {
if(!request.descriptionFileData) return callback();
const innerRequest = getInnerRequest(resolver, request);
if(!innerRequest) return callback();
const fieldData = DescriptionFileUtils.getField(request.descriptionFileData, this.field);
if(typeof fieldData !== "object") {
if(resolveContext.log) resolveContext.log("Field '" + this.field + "' doesn't contain a valid alias configuration");
return callback();
}
const data1 = fieldData[innerRequest];
const data2 = fieldData[innerRequest.replace(/^\.\//, "")];
const data = typeof data1 !== "undefined" ? data1 : data2;
if(data === innerRequest) return callback();
if(data === undefined) return callback();
if(data === false) {
const ignoreObj = Object.assign({}, request, {
path: false
});
return callback(null, ignoreObj);
}
const obj = Object.assign({}, request, {
path: request.descriptionFileRoot,
request: data
});
resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", resolveContext, (err, result) => {
if(err) return callback(err);
// Don't allow other aliasing or raw request
if(result === undefined) return callback(null, null);
callback(null, result);
});
});
}
};

View File

@@ -1,56 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
function startsWith(string, searchString) {
const stringLength = string.length;
const searchLength = searchString.length;
// early out if the search length is greater than the search string
if(searchLength > stringLength) {
return false;
}
let index = -1;
while(++index < searchLength) {
if(string.charCodeAt(index) !== searchString.charCodeAt(index)) {
return false;
}
}
return true;
}
module.exports = class AliasPlugin {
constructor(source, options, target) {
this.source = source;
this.options = Array.isArray(options) ? options : [options];
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("AliasPlugin", (request, resolveContext, callback) => {
const innerRequest = request.request || request.path;
if(!innerRequest) return callback();
for(const item of this.options) {
if(innerRequest === item.name || (!item.onlyModule && startsWith(innerRequest, item.name + "/"))) {
if(innerRequest !== item.alias && !startsWith(innerRequest, item.alias + "/")) {
const newRequestStr = item.alias + innerRequest.substr(item.name.length);
const obj = Object.assign({}, request, {
request: newRequestStr
});
return resolver.doResolve(target, obj, "aliased with mapping '" + item.name + "': '" + item.alias + "' to '" + newRequestStr + "'", resolveContext, (err, result) => {
if(err) return callback(err);
// Don't allow other aliasing or raw request
if(result === undefined) return callback(null, null);
callback(null, result);
});
}
}
}
return callback();
});
}
};

View File

@@ -1,24 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class AppendPlugin {
constructor(source, appending, target) {
this.source = source;
this.appending = appending;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("AppendPlugin", (request, resolveContext, callback) => {
const obj = Object.assign({}, request, {
path: request.path + this.appending,
relativePath: request.relativePath && (request.relativePath + this.appending)
});
resolver.doResolve(target, obj, this.appending, resolveContext, callback);
});
}
};

View File

@@ -1,277 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
class Storage {
constructor(duration) {
this.duration = duration;
this.running = new Map();
this.data = new Map();
this.levels = [];
if(duration > 0) {
this.levels.push(new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set());
for(let i = 8000; i < duration; i += 500)
this.levels.push(new Set());
}
this.count = 0;
this.interval = null;
this.needTickCheck = false;
this.nextTick = null;
this.passive = true;
this.tick = this.tick.bind(this);
}
ensureTick() {
if(!this.interval && this.duration > 0 && !this.nextTick)
this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
}
finished(name, err, result) {
const callbacks = this.running.get(name);
this.running.delete(name);
if(this.duration > 0) {
this.data.set(name, [err, result]);
const levelData = this.levels[0];
this.count -= levelData.size;
levelData.add(name);
this.count += levelData.size;
this.ensureTick();
}
for(let i = 0; i < callbacks.length; i++) {
callbacks[i](err, result);
}
}
finishedSync(name, err, result) {
if(this.duration > 0) {
this.data.set(name, [err, result]);
const levelData = this.levels[0];
this.count -= levelData.size;
levelData.add(name);
this.count += levelData.size;
this.ensureTick();
}
}
provide(name, provider, callback) {
if(typeof name !== "string") {
callback(new TypeError("path must be a string"));
return;
}
let running = this.running.get(name);
if(running) {
running.push(callback);
return;
}
if(this.duration > 0) {
this.checkTicks();
const data = this.data.get(name);
if(data) {
return process.nextTick(() => {
callback.apply(null, data);
});
}
}
this.running.set(name, running = [callback]);
provider(name, (err, result) => {
this.finished(name, err, result);
});
}
provideSync(name, provider) {
if(typeof name !== "string") {
throw new TypeError("path must be a string");
}
if(this.duration > 0) {
this.checkTicks();
const data = this.data.get(name);
if(data) {
if(data[0])
throw data[0];
return data[1];
}
}
let result;
try {
result = provider(name);
} catch(e) {
this.finishedSync(name, e);
throw e;
}
this.finishedSync(name, null, result);
return result;
}
tick() {
const decay = this.levels.pop();
for(let item of decay) {
this.data.delete(item);
}
this.count -= decay.size;
decay.clear();
this.levels.unshift(decay);
if(this.count === 0) {
clearInterval(this.interval);
this.interval = null;
this.nextTick = null;
return true;
} else if(this.nextTick) {
this.nextTick += Math.floor(this.duration / this.levels.length);
const time = new Date().getTime();
if(this.nextTick > time) {
this.nextTick = null;
this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
return true;
}
} else if(this.passive) {
clearInterval(this.interval);
this.interval = null;
this.nextTick = new Date().getTime() + Math.floor(this.duration / this.levels.length);
} else {
this.passive = true;
}
}
checkTicks() {
this.passive = false;
if(this.nextTick) {
while(!this.tick());
}
}
purge(what) {
if(!what) {
this.count = 0;
clearInterval(this.interval);
this.nextTick = null;
this.data.clear();
this.levels.forEach(level => {
level.clear();
});
} else if(typeof what === "string") {
for(let key of this.data.keys()) {
if(key.startsWith(what))
this.data.delete(key);
}
} else {
for(let i = what.length - 1; i >= 0; i--) {
this.purge(what[i]);
}
}
}
}
module.exports = class CachedInputFileSystem {
constructor(fileSystem, duration) {
this.fileSystem = fileSystem;
this._statStorage = new Storage(duration);
this._readdirStorage = new Storage(duration);
this._readFileStorage = new Storage(duration);
this._readJsonStorage = new Storage(duration);
this._readlinkStorage = new Storage(duration);
this._stat = this.fileSystem.stat ? this.fileSystem.stat.bind(this.fileSystem) : null;
if(!this._stat) this.stat = null;
this._statSync = this.fileSystem.statSync ? this.fileSystem.statSync.bind(this.fileSystem) : null;
if(!this._statSync) this.statSync = null;
this._readdir = this.fileSystem.readdir ? this.fileSystem.readdir.bind(this.fileSystem) : null;
if(!this._readdir) this.readdir = null;
this._readdirSync = this.fileSystem.readdirSync ? this.fileSystem.readdirSync.bind(this.fileSystem) : null;
if(!this._readdirSync) this.readdirSync = null;
this._readFile = this.fileSystem.readFile ? this.fileSystem.readFile.bind(this.fileSystem) : null;
if(!this._readFile) this.readFile = null;
this._readFileSync = this.fileSystem.readFileSync ? this.fileSystem.readFileSync.bind(this.fileSystem) : null;
if(!this._readFileSync) this.readFileSync = null;
if(this.fileSystem.readJson) {
this._readJson = this.fileSystem.readJson.bind(this.fileSystem);
} else if(this.readFile) {
this._readJson = (path, callback) => {
this.readFile(path, (err, buffer) => {
if(err) return callback(err);
let data;
try {
data = JSON.parse(buffer.toString("utf-8"));
} catch(e) {
return callback(e);
}
callback(null, data);
});
};
} else {
this.readJson = null;
}
if(this.fileSystem.readJsonSync) {
this._readJsonSync = this.fileSystem.readJsonSync.bind(this.fileSystem);
} else if(this.readFileSync) {
this._readJsonSync = (path) => {
const buffer = this.readFileSync(path);
const data = JSON.parse(buffer.toString("utf-8"));
return data;
};
} else {
this.readJsonSync = null;
}
this._readlink = this.fileSystem.readlink ? this.fileSystem.readlink.bind(this.fileSystem) : null;
if(!this._readlink) this.readlink = null;
this._readlinkSync = this.fileSystem.readlinkSync ? this.fileSystem.readlinkSync.bind(this.fileSystem) : null;
if(!this._readlinkSync) this.readlinkSync = null;
}
stat(path, callback) {
this._statStorage.provide(path, this._stat, callback);
}
readdir(path, callback) {
this._readdirStorage.provide(path, this._readdir, callback);
}
readFile(path, callback) {
this._readFileStorage.provide(path, this._readFile, callback);
}
readJson(path, callback) {
this._readJsonStorage.provide(path, this._readJson, callback);
}
readlink(path, callback) {
this._readlinkStorage.provide(path, this._readlink, callback);
}
statSync(path) {
return this._statStorage.provideSync(path, this._statSync);
}
readdirSync(path) {
return this._readdirStorage.provideSync(path, this._readdirSync);
}
readFileSync(path) {
return this._readFileStorage.provideSync(path, this._readFileSync);
}
readJsonSync(path) {
return this._readJsonStorage.provideSync(path, this._readJsonSync);
}
readlinkSync(path) {
return this._readlinkStorage.provideSync(path, this._readlinkSync);
}
purge(what) {
this._statStorage.purge(what);
this._readdirStorage.purge(what);
this._readFileStorage.purge(what);
this._readlinkStorage.purge(what);
this._readJsonStorage.purge(what);
}
};

View File

@@ -1,27 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const basename = require("./getPaths").basename;
module.exports = class CloneBasenamePlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => {
const filename = basename(request.path);
const filePath = resolver.join(request.path, filename);
const obj = Object.assign({}, request, {
path: filePath,
relativePath: request.relativePath && resolver.join(request.relativePath, filename)
});
resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
});
}
};

View File

@@ -1,40 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const concord = require("./concord");
const DescriptionFileUtils = require("./DescriptionFileUtils");
const forEachBail = require("./forEachBail");
module.exports = class ConcordExtensionsPlugin {
constructor(source, options, target) {
this.source = source;
this.options = options;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ConcordExtensionsPlugin", (request, resolveContext, callback) => {
const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
if(!concordField) return callback();
const extensions = concord.getExtensions(request.context, concordField);
if(!extensions) return callback();
forEachBail(extensions, (appending, callback) => {
const obj = Object.assign({}, request, {
path: request.path + appending,
relativePath: request.relativePath && (request.relativePath + appending)
});
resolver.doResolve(target, obj, "concord extension: " + appending, resolveContext, callback);
}, (err, result) => {
if(err) return callback(err);
// Don't allow other processing
if(result === undefined) return callback(null, null);
callback(null, result);
});
});
}
};

View File

@@ -1,33 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const path = require("path");
const concord = require("./concord");
const DescriptionFileUtils = require("./DescriptionFileUtils");
module.exports = class ConcordMainPlugin {
constructor(source, options, target) {
this.source = source;
this.options = options;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ConcordMainPlugin", (request, resolveContext, callback) => {
if(request.path !== request.descriptionFileRoot) return callback();
const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
if(!concordField) return callback();
const mainModule = concord.getMain(request.context, concordField);
if(!mainModule) return callback();
const obj = Object.assign({}, request, {
request: mainModule
});
const filename = path.basename(request.descriptionFilePath);
return resolver.doResolve(target, obj, "use " + mainModule + " from " + filename, resolveContext, callback);
});
}
};

View File

@@ -1,47 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const concord = require("./concord");
const DescriptionFileUtils = require("./DescriptionFileUtils");
const getInnerRequest = require("./getInnerRequest");
module.exports = class ConcordModulesPlugin {
constructor(source, options, target) {
this.source = source;
this.options = options;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ConcordModulesPlugin", (request, resolveContext, callback) => {
const innerRequest = getInnerRequest(resolver, request);
if(!innerRequest) return callback();
const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
if(!concordField) return callback();
const data = concord.matchModule(request.context, concordField, innerRequest);
if(data === innerRequest) return callback();
if(data === undefined) return callback();
if(data === false) {
const ignoreObj = Object.assign({}, request, {
path: false
});
return callback(null, ignoreObj);
}
const obj = Object.assign({}, request, {
path: request.descriptionFileRoot,
request: data
});
resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", resolveContext, (err, result) => {
if(err) return callback(err);
// Don't allow other aliasing or raw request
if(result === undefined) return callback(null, null);
callback(null, result);
});
});
}
};

View File

@@ -1,48 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DescriptionFileUtils = require("./DescriptionFileUtils");
module.exports = class DescriptionFilePlugin {
constructor(source, filenames, target) {
this.source = source;
this.filenames = [].concat(filenames);
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("DescriptionFilePlugin", (request, resolveContext, callback) => {
const directory = request.path;
DescriptionFileUtils.loadDescriptionFile(resolver, directory, this.filenames, resolveContext, (err, result) => {
if(err) return callback(err);
if(!result) {
if(resolveContext.missing) {
this.filenames.forEach((filename) => {
resolveContext.missing.add(resolver.join(directory, filename));
});
}
if(resolveContext.log) resolveContext.log("No description file found");
return callback();
}
const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
const obj = Object.assign({}, request, {
descriptionFilePath: result.path,
descriptionFileData: result.content,
descriptionFileRoot: result.directory,
relativePath: relativePath
});
resolver.doResolve(target, obj, "using description file: " + result.path + " (relative path: " + relativePath + ")", resolveContext, (err, result) => {
if(err) return callback(err);
// Don't allow other processing
if(result === undefined) return callback(null, null);
callback(null, result);
});
});
});
}
};

View File

@@ -1,96 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const forEachBail = require("./forEachBail");
function loadDescriptionFile(resolver, directory, filenames, resolveContext, callback) {
(function findDescriptionFile() {
forEachBail(filenames, (filename, callback) => {
const descriptionFilePath = resolver.join(directory, filename);
if(resolver.fileSystem.readJson) {
resolver.fileSystem.readJson(descriptionFilePath, (err, content) => {
if(err) {
if(typeof err.code !== "undefined") return callback();
return onJson(err);
}
onJson(null, content);
});
} else {
resolver.fileSystem.readFile(descriptionFilePath, (err, content) => {
if(err) return callback();
let json;
try {
json = JSON.parse(content);
} catch(e) {
onJson(e);
}
onJson(null, json);
});
}
function onJson(err, content) {
if(err) {
if(resolveContext.log)
resolveContext.log(descriptionFilePath + " (directory description file): " + err);
else
err.message = descriptionFilePath + " (directory description file): " + err;
return callback(err);
}
callback(null, {
content: content,
directory: directory,
path: descriptionFilePath
});
}
}, (err, result) => {
if(err) return callback(err);
if(result) {
return callback(null, result);
} else {
directory = cdUp(directory);
if(!directory) {
return callback();
} else {
return findDescriptionFile();
}
}
});
}());
}
function getField(content, field) {
if(!content) return undefined;
if(Array.isArray(field)) {
let current = content;
for(let j = 0; j < field.length; j++) {
if(current === null || typeof current !== "object") {
current = null;
break;
}
current = current[field[j]];
}
if(typeof current === "object") {
return current;
}
} else {
if(typeof content[field] === "object") {
return content[field];
}
}
}
function cdUp(directory) {
if(directory === "/") return null;
const i = directory.lastIndexOf("/"),
j = directory.lastIndexOf("\\");
const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
if(p < 0) return null;
return directory.substr(0, p || 1);
}
exports.loadDescriptionFile = loadDescriptionFile;
exports.getField = getField;
exports.cdUp = cdUp;

View File

@@ -1,33 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class DirectoryExistsPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("DirectoryExistsPlugin", (request, resolveContext, callback) => {
const fs = resolver.fileSystem;
const directory = request.path;
fs.stat(directory, (err, stat) => {
if(err || !stat) {
if(resolveContext.missing) resolveContext.missing.add(directory);
if(resolveContext.log) resolveContext.log(directory + " doesn't exist");
return callback();
}
if(!stat.isDirectory()) {
if(resolveContext.missing) resolveContext.missing.add(directory);
if(resolveContext.log) resolveContext.log(directory + " is not a directory");
return callback();
}
resolver.doResolve(target, request, "existing directory", resolveContext, callback);
});
});
}
};

View File

@@ -1,33 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class FileExistsPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
const fs = resolver.fileSystem;
resolver.getHook(this.source).tapAsync("FileExistsPlugin", (request, resolveContext, callback) => {
const file = request.path;
fs.stat(file, (err, stat) => {
if(err || !stat) {
if(resolveContext.missing) resolveContext.missing.add(file);
if(resolveContext.log) resolveContext.log(file + " doesn't exist");
return callback();
}
if(!stat.isFile()) {
if(resolveContext.missing) resolveContext.missing.add(file);
if(resolveContext.log) resolveContext.log(file + " is not a file");
return callback();
}
resolver.doResolve(target, request, "existing file: " + file, resolveContext, callback);
});
});
}
};

View File

@@ -1,22 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class FileKindPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("FileKindPlugin", (request, resolveContext, callback) => {
if(request.directory) return callback();
const obj = Object.assign({}, request);
delete obj.directory;
resolver.doResolve(target, obj, null, resolveContext, callback);
});
}
};

View File

@@ -1,24 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class JoinRequestPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => {
const obj = Object.assign({}, request, {
path: resolver.join(request.path, request.request),
relativePath: request.relativePath && resolver.join(request.relativePath, request.request),
request: undefined
});
resolver.doResolve(target, obj, null, resolveContext, callback);
});
}
};

View File

@@ -1,28 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class LogInfoPlugin {
constructor(source) {
this.source = source;
}
apply(resolver) {
const source = this.source;
resolver.getHook(this.source).tapAsync("LogInfoPlugin", (request, resolveContext, callback) => {
if(!resolveContext.log) return callback();
const log = resolveContext.log;
const prefix = "[" + source + "] ";
if(request.path) log(prefix + "Resolving in directory: " + request.path);
if(request.request) log(prefix + "Resolving request: " + request.request);
if(request.module) log(prefix + "Request is an module request.");
if(request.directory) log(prefix + "Request is a directory request.");
if(request.query) log(prefix + "Resolving request query: " + request.query);
if(request.descriptionFilePath) log(prefix + "Has description data from " + request.descriptionFilePath);
if(request.relativePath) log(prefix + "Relative path from description file is: " + request.relativePath);
callback();
});
}
};

View File

@@ -1,52 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const path = require("path");
module.exports = class MainFieldPlugin {
constructor(source, options, target) {
this.source = source;
this.options = options;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("MainFieldPlugin", (request, resolveContext, callback) => {
if(request.path !== request.descriptionFileRoot) return callback();
if(request.alreadyTriedMainField === request.descriptionFilePath) return callback();
const content = request.descriptionFileData;
const filename = path.basename(request.descriptionFilePath);
let mainModule;
const field = this.options.name;
if(Array.isArray(field)) {
let current = content;
for(let j = 0; j < field.length; j++) {
if(current === null || typeof current !== "object") {
current = null;
break;
}
current = current[field[j]];
}
if(typeof current === "string") {
mainModule = current;
}
} else {
if(typeof content[field] === "string") {
mainModule = content[field];
}
}
if(!mainModule) return callback();
if(this.options.forceRelative && !/^\.\.?\//.test(mainModule))
mainModule = "./" + mainModule;
const obj = Object.assign({}, request, {
request: mainModule,
alreadyTriedMainField: request.descriptionFilePath
});
return resolver.doResolve(target, obj, "use " + mainModule + " from " + this.options.name + " in " + filename, resolveContext, callback);
});
}
};

View File

@@ -1,37 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class ModuleAppendPlugin {
constructor(source, appending, target) {
this.source = source;
this.appending = appending;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ModuleAppendPlugin", (request, resolveContext, callback) => {
const i = request.request.indexOf("/"),
j = request.request.indexOf("\\");
const p = i < 0 ? j : j < 0 ? i : i < j ? i : j;
let moduleName, remainingRequest;
if(p < 0) {
moduleName = request.request;
remainingRequest = "";
} else {
moduleName = request.request.substr(0, p);
remainingRequest = request.request.substr(p);
}
if(moduleName === "." || moduleName === "..")
return callback();
const moduleFinalName = moduleName + this.appending;
const obj = Object.assign({}, request, {
request: moduleFinalName + remainingRequest
});
resolver.doResolve(target, obj, "module variation " + moduleFinalName, resolveContext, callback);
});
}
};

View File

@@ -1,28 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class ModuleKindPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ModuleKindPlugin", (request, resolveContext, callback) => {
if(!request.module) return callback();
const obj = Object.assign({}, request);
delete obj.module;
resolver.doResolve(target, obj, "resolve as module", resolveContext, (err, result) => {
if(err) return callback(err);
// Don't allow other alternatives
if(result === undefined) return callback(null, null);
callback(null, result);
});
});
}
};

View File

@@ -1,44 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const forEachBail = require("./forEachBail");
const getPaths = require("./getPaths");
module.exports = class ModulesInHierachicDirectoriesPlugin {
constructor(source, directories, target) {
this.source = source;
this.directories = [].concat(directories);
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ModulesInHierachicDirectoriesPlugin", (request, resolveContext, callback) => {
const fs = resolver.fileSystem;
const addrs = getPaths(request.path).paths.map(p => {
return this.directories.map(d => resolver.join(p, d));
}).reduce((array, p) => {
array.push.apply(array, p);
return array;
}, []);
forEachBail(addrs, (addr, callback) => {
fs.stat(addr, (err, stat) => {
if(!err && stat && stat.isDirectory()) {
const obj = Object.assign({}, request, {
path: addr,
request: "./" + request.request
});
const message = "looking for modules in " + addr;
return resolver.doResolve(target, obj, message, resolveContext, callback);
}
if(resolveContext.log) resolveContext.log(addr + " doesn't exist or is not a directory");
if(resolveContext.missing) resolveContext.missing.add(addr);
return callback();
});
}, callback);
});
}
};

View File

@@ -1,24 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class ModulesInRootPlugin {
constructor(source, path, target) {
this.source = source;
this.path = path;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => {
const obj = Object.assign({}, request, {
path: this.path,
request: "./" + request.request
});
resolver.doResolve(target, obj, "looking for modules in " + this.path, resolveContext, callback);
});
}
};

View File

@@ -1,19 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class NextPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("NextPlugin", (request, resolveContext, callback) => {
resolver.doResolve(target, request, null, resolveContext, callback);
});
}
};

View File

@@ -1,43 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const fs = require("graceful-fs");
class NodeJsInputFileSystem {
readdir(path, callback) {
fs.readdir(path, (err, files) => {
callback(err, files && files.map(file => {
return file.normalize ? file.normalize("NFC") : file;
}));
});
}
readdirSync(path) {
const files = fs.readdirSync(path);
return files && files.map(file => {
return file.normalize ? file.normalize("NFC") : file;
});
}
}
const fsMethods = [
"stat",
"statSync",
"readFile",
"readFileSync",
"readlink",
"readlinkSync"
];
for(const key of fsMethods) {
Object.defineProperty(NodeJsInputFileSystem.prototype, key, {
configurable: true,
writable: true,
value: fs[key].bind(fs)
});
}
module.exports = NodeJsInputFileSystem;

View File

@@ -1,30 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class ParsePlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("ParsePlugin", (request, resolveContext, callback) => {
const parsed = resolver.parse(request.request);
const obj = Object.assign({}, request, parsed);
if(request.query && !parsed.query) {
obj.query = request.query;
}
if(parsed && resolveContext.log) {
if(parsed.module)
resolveContext.log("Parsed request is a module");
if(parsed.directory)
resolveContext.log("Parsed request is a directory");
}
resolver.doResolve(target, obj, null, resolveContext, callback);
});
}
};

View File

@@ -1,301 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const util = require("util");
const Tapable = require("tapable/lib/Tapable");
const SyncHook = require("tapable/lib/SyncHook");
const AsyncSeriesBailHook = require("tapable/lib/AsyncSeriesBailHook");
const AsyncSeriesHook = require("tapable/lib/AsyncSeriesHook");
const createInnerContext = require("./createInnerContext");
const REGEXP_NOT_MODULE = /^\.$|^\.[\\\/]|^\.\.$|^\.\.[\/\\]|^\/|^[A-Z]:[\\\/]/i;
const REGEXP_DIRECTORY = /[\/\\]$/i;
const memoryFsJoin = require("memory-fs/lib/join");
const memoizedJoin = new Map();
const memoryFsNormalize = require("memory-fs/lib/normalize");
function withName(name, hook) {
hook.name = name;
return hook;
}
function toCamelCase(str) {
return str.replace(/-([a-z])/g, str => str.substr(1).toUpperCase());
}
const deprecatedPushToMissing = util.deprecate((set, item) => {
set.add(item);
}, "Resolver: 'missing' is now a Set. Use add instead of push.");
const deprecatedResolveContextInCallback = util.deprecate((x) => {
return x;
}, "Resolver: The callback argument was splitted into resolveContext and callback.");
const deprecatedHookAsString = util.deprecate((x) => {
return x;
}, "Resolver#doResolve: The type arguments (string) is now a hook argument (Hook). Pass a reference to the hook instead.");
class Resolver extends Tapable {
constructor(fileSystem) {
super();
this.fileSystem = fileSystem;
this.hooks = {
resolveStep: withName("resolveStep", new SyncHook(["hook", "request"])),
noResolve: withName("noResolve", new SyncHook(["request", "error"])),
resolve: withName("resolve", new AsyncSeriesBailHook(["request", "resolveContext"])),
result: new AsyncSeriesHook(["result", "resolveContext"])
};
this._pluginCompat.tap("Resolver: before/after", options => {
if(/^before-/.test(options.name)) {
options.name = options.name.substr(7);
options.stage = -10;
} else if(/^after-/.test(options.name)) {
options.name = options.name.substr(6);
options.stage = 10;
}
});
this._pluginCompat.tap("Resolver: step hooks", options => {
const name = options.name;
const stepHook = !/^resolve(-s|S)tep$|^no(-r|R)esolve$/.test(name);
if(stepHook) {
options.async = true;
this.ensureHook(name);
const fn = options.fn;
options.fn = (request, resolverContext, callback) => {
const innerCallback = (err, result) => {
if(err) return callback(err);
if(result !== undefined) return callback(null, result);
callback();
};
for(const key in resolverContext) {
innerCallback[key] = resolverContext[key];
}
fn.call(this, request, innerCallback);
};
}
});
}
ensureHook(name) {
if(typeof name !== "string") return name;
name = toCamelCase(name);
if(/^before/.test(name)) {
return this.ensureHook(name[6].toLowerCase() + name.substr(7)).withOptions({
stage: -10
});
}
if(/^after/.test(name)) {
return this.ensureHook(name[5].toLowerCase() + name.substr(6)).withOptions({
stage: 10
});
}
const hook = this.hooks[name];
if(!hook) {
return this.hooks[name] = withName(name, new AsyncSeriesBailHook(["request", "resolveContext"]));
}
return hook;
}
getHook(name) {
if(typeof name !== "string") return name;
name = toCamelCase(name);
if(/^before/.test(name)) {
return this.getHook(name[6].toLowerCase() + name.substr(7)).withOptions({
stage: -10
});
}
if(/^after/.test(name)) {
return this.getHook(name[5].toLowerCase() + name.substr(6)).withOptions({
stage: 10
});
}
const hook = this.hooks[name];
if(!hook) {
throw new Error(`Hook ${name} doesn't exist`);
}
return hook;
}
resolveSync(context, path, request) {
let err, result, sync = false;
this.resolve(context, path, request, {}, (e, r) => {
err = e;
result = r;
sync = true;
});
if(!sync) throw new Error("Cannot 'resolveSync' because the fileSystem is not sync. Use 'resolve'!");
if(err) throw err;
return result;
}
resolve(context, path, request, resolveContext, callback) {
// TODO remove in enhanced-resolve 5
// For backward compatiblity START
if(typeof callback !== "function") {
callback = deprecatedResolveContextInCallback(resolveContext);
// resolveContext is a function containing additional properties
// It's now used for resolveContext and callback
}
// END
const obj = {
context: context,
path: path,
request: request
};
const message = "resolve '" + request + "' in '" + path + "'";
// Try to resolve assuming there is no error
// We don't log stuff in this case
return this.doResolve(this.hooks.resolve, obj, message, {
missing: resolveContext.missing,
stack: resolveContext.stack
}, (err, result) => {
if(!err && result) {
return callback(null, result.path === false ? false : result.path + (result.query || ""), result);
}
const localMissing = new Set();
// TODO remove in enhanced-resolve 5
localMissing.push = item => deprecatedPushToMissing(localMissing, item);
const log = [];
return this.doResolve(this.hooks.resolve, obj, message, {
log: msg => {
if(resolveContext.log) {
resolveContext.log(msg);
}
log.push(msg);
},
missing: localMissing,
stack: resolveContext.stack
}, (err, result) => {
if(err) return callback(err);
const error = new Error("Can't " + message);
error.details = log.join("\n");
error.missing = Array.from(localMissing);
this.hooks.noResolve.call(obj, error);
return callback(error);
});
});
}
doResolve(hook, request, message, resolveContext, callback) {
// TODO remove in enhanced-resolve 5
// For backward compatiblity START
if(typeof callback !== "function") {
callback = deprecatedResolveContextInCallback(resolveContext);
// resolveContext is a function containing additional properties
// It's now used for resolveContext and callback
}
if(typeof hook === "string") {
const name = toCamelCase(hook);
hook = deprecatedHookAsString(this.hooks[name]);
if(!hook) {
throw new Error(`Hook "${name}" doesn't exist`);
}
}
// END
if(typeof callback !== "function") throw new Error("callback is not a function " + Array.from(arguments));
if(!resolveContext) throw new Error("resolveContext is not an object " + Array.from(arguments));
const stackLine = hook.name + ": (" + request.path + ") " +
(request.request || "") + (request.query || "") +
(request.directory ? " directory" : "") +
(request.module ? " module" : "");
let newStack;
if(resolveContext.stack) {
newStack = new Set(resolveContext.stack);
if(resolveContext.stack.has(stackLine)) {
// Prevent recursion
const recursionError = new Error("Recursion in resolving\nStack:\n " + Array.from(newStack).join("\n "));
recursionError.recursion = true;
if(resolveContext.log) resolveContext.log("abort resolving because of recursion");
return callback(recursionError);
}
newStack.add(stackLine);
} else {
newStack = new Set([stackLine]);
}
this.hooks.resolveStep.call(hook, request);
if(hook.isUsed()) {
const innerContext = createInnerContext({
log: resolveContext.log,
missing: resolveContext.missing,
stack: newStack
}, message);
return hook.callAsync(request, innerContext, (err, result) => {
if(err) return callback(err);
if(result) return callback(null, result);
callback();
});
} else {
callback();
}
}
parse(identifier) {
if(identifier === "") return null;
const part = {
request: "",
query: "",
module: false,
directory: false,
file: false
};
const idxQuery = identifier.indexOf("?");
if(idxQuery === 0) {
part.query = identifier;
} else if(idxQuery > 0) {
part.request = identifier.slice(0, idxQuery);
part.query = identifier.slice(idxQuery);
} else {
part.request = identifier;
}
if(part.request) {
part.module = this.isModule(part.request);
part.directory = this.isDirectory(part.request);
if(part.directory) {
part.request = part.request.substr(0, part.request.length - 1);
}
}
return part;
}
isModule(path) {
return !REGEXP_NOT_MODULE.test(path);
}
isDirectory(path) {
return REGEXP_DIRECTORY.test(path);
}
join(path, request) {
let cacheEntry;
let pathCache = memoizedJoin.get(path);
if(typeof pathCache === "undefined") {
memoizedJoin.set(path, pathCache = new Map());
} else {
cacheEntry = pathCache.get(request);
if(typeof cacheEntry !== "undefined")
return cacheEntry;
}
cacheEntry = memoryFsJoin(path, request);
pathCache.set(request, cacheEntry);
return cacheEntry;
}
normalize(path) {
return memoryFsNormalize(path);
}
}
module.exports = Resolver;

View File

@@ -1,301 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Resolver = require("./Resolver");
const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
const ParsePlugin = require("./ParsePlugin");
const DescriptionFilePlugin = require("./DescriptionFilePlugin");
const NextPlugin = require("./NextPlugin");
const TryNextPlugin = require("./TryNextPlugin");
const ModuleKindPlugin = require("./ModuleKindPlugin");
const FileKindPlugin = require("./FileKindPlugin");
const JoinRequestPlugin = require("./JoinRequestPlugin");
const ModulesInHierachicDirectoriesPlugin = require("./ModulesInHierachicDirectoriesPlugin");
const ModulesInRootPlugin = require("./ModulesInRootPlugin");
const AliasPlugin = require("./AliasPlugin");
const AliasFieldPlugin = require("./AliasFieldPlugin");
const ConcordExtensionsPlugin = require("./ConcordExtensionsPlugin");
const ConcordMainPlugin = require("./ConcordMainPlugin");
const ConcordModulesPlugin = require("./ConcordModulesPlugin");
const DirectoryExistsPlugin = require("./DirectoryExistsPlugin");
const FileExistsPlugin = require("./FileExistsPlugin");
const SymlinkPlugin = require("./SymlinkPlugin");
const MainFieldPlugin = require("./MainFieldPlugin");
const UseFilePlugin = require("./UseFilePlugin");
const AppendPlugin = require("./AppendPlugin");
const ResultPlugin = require("./ResultPlugin");
const ModuleAppendPlugin = require("./ModuleAppendPlugin");
const UnsafeCachePlugin = require("./UnsafeCachePlugin");
exports.createResolver = function(options) {
//// OPTIONS ////
// A list of directories to resolve modules from, can be absolute path or folder name
let modules = options.modules || ["node_modules"];
// A list of description files to read from
const descriptionFiles = options.descriptionFiles || ["package.json"];
// A list of additional resolve plugins which should be applied
// The slice is there to create a copy, because otherwise pushing into plugins
// changes the original options.plugins array, causing duplicate plugins
const plugins = (options.plugins && options.plugins.slice()) || [];
// A list of main fields in description files
let mainFields = options.mainFields || ["main"];
// A list of alias fields in description files
const aliasFields = options.aliasFields || [];
// A list of main files in directories
const mainFiles = options.mainFiles || ["index"];
// A list of extensions which should be tried for files
let extensions = options.extensions || [".js", ".json", ".node"];
// Enforce that a extension from extensions must be used
const enforceExtension = options.enforceExtension || false;
// A list of module extensions which should be tried for modules
let moduleExtensions = options.moduleExtensions || [];
// Enforce that a extension from moduleExtensions must be used
const enforceModuleExtension = options.enforceModuleExtension || false;
// A list of module alias configurations or an object which maps key to value
let alias = options.alias || [];
// Resolve symlinks to their symlinked location
const symlinks = typeof options.symlinks !== "undefined" ? options.symlinks : true;
// Resolve to a context instead of a file
const resolveToContext = options.resolveToContext || false;
// Use this cache object to unsafely cache the successful requests
let unsafeCache = options.unsafeCache || false;
// Whether or not the unsafeCache should include request context as part of the cache key.
const cacheWithContext = typeof options.cacheWithContext !== "undefined" ? options.cacheWithContext : true;
// Enable concord description file instructions
const enableConcord = options.concord || false;
// A function which decides whether a request should be cached or not.
// an object is passed with `path` and `request` properties.
const cachePredicate = options.cachePredicate || function() {
return true;
};
// The file system which should be used
const fileSystem = options.fileSystem;
// Use only the sync constiants of the file system calls
const useSyncFileSystemCalls = options.useSyncFileSystemCalls;
// A prepared Resolver to which the plugins are attached
let resolver = options.resolver;
//// options processing ////
if(!resolver) {
resolver = new Resolver(useSyncFileSystemCalls ? new SyncAsyncFileSystemDecorator(fileSystem) : fileSystem);
}
extensions = [].concat(extensions);
moduleExtensions = [].concat(moduleExtensions);
modules = mergeFilteredToArray([].concat(modules), item => {
return !isAbsolutePath(item);
});
mainFields = mainFields.map(item => {
if(typeof item === "string" || Array.isArray(item)) {
item = {
name: item,
forceRelative: true
};
}
return item;
});
if(typeof alias === "object" && !Array.isArray(alias)) {
alias = Object.keys(alias).map(key => {
let onlyModule = false;
let obj = alias[key];
if(/\$$/.test(key)) {
onlyModule = true;
key = key.substr(0, key.length - 1);
}
if(typeof obj === "string") {
obj = {
alias: obj
};
}
obj = Object.assign({
name: key,
onlyModule: onlyModule
}, obj);
return obj;
});
}
if(unsafeCache && typeof unsafeCache !== "object") {
unsafeCache = {};
}
//// pipeline ////
resolver.ensureHook("resolve");
resolver.ensureHook("parsedResolve");
resolver.ensureHook("describedResolve");
resolver.ensureHook("rawModule");
resolver.ensureHook("module");
resolver.ensureHook("relative");
resolver.ensureHook("describedRelative");
resolver.ensureHook("directory");
resolver.ensureHook("existingDirectory");
resolver.ensureHook("undescribedRawFile");
resolver.ensureHook("rawFile");
resolver.ensureHook("file");
resolver.ensureHook("existingFile");
resolver.ensureHook("resolved");
// resolve
if(unsafeCache) {
plugins.push(new UnsafeCachePlugin("resolve", cachePredicate, unsafeCache, cacheWithContext, "new-resolve"));
plugins.push(new ParsePlugin("new-resolve", "parsed-resolve"));
} else {
plugins.push(new ParsePlugin("resolve", "parsed-resolve"));
}
// parsed-resolve
plugins.push(new DescriptionFilePlugin("parsed-resolve", descriptionFiles, "described-resolve"));
plugins.push(new NextPlugin("after-parsed-resolve", "described-resolve"));
// described-resolve
if(alias.length > 0)
plugins.push(new AliasPlugin("described-resolve", alias, "resolve"));
if(enableConcord) {
plugins.push(new ConcordModulesPlugin("described-resolve", {}, "resolve"));
}
aliasFields.forEach(item => {
plugins.push(new AliasFieldPlugin("described-resolve", item, "resolve"));
});
plugins.push(new ModuleKindPlugin("after-described-resolve", "raw-module"));
plugins.push(new JoinRequestPlugin("after-described-resolve", "relative"));
// raw-module
moduleExtensions.forEach(item => {
plugins.push(new ModuleAppendPlugin("raw-module", item, "module"));
});
if(!enforceModuleExtension)
plugins.push(new TryNextPlugin("raw-module", null, "module"));
// module
modules.forEach(item => {
if(Array.isArray(item))
plugins.push(new ModulesInHierachicDirectoriesPlugin("module", item, "resolve"));
else
plugins.push(new ModulesInRootPlugin("module", item, "resolve"));
});
// relative
plugins.push(new DescriptionFilePlugin("relative", descriptionFiles, "described-relative"));
plugins.push(new NextPlugin("after-relative", "described-relative"));
// described-relative
plugins.push(new FileKindPlugin("described-relative", "raw-file"));
plugins.push(new TryNextPlugin("described-relative", "as directory", "directory"));
// directory
plugins.push(new DirectoryExistsPlugin("directory", "existing-directory"));
if(resolveToContext) {
// existing-directory
plugins.push(new NextPlugin("existing-directory", "resolved"));
} else {
// existing-directory
if(enableConcord) {
plugins.push(new ConcordMainPlugin("existing-directory", {}, "resolve"));
}
mainFields.forEach(item => {
plugins.push(new MainFieldPlugin("existing-directory", item, "resolve"));
});
mainFiles.forEach(item => {
plugins.push(new UseFilePlugin("existing-directory", item, "undescribed-raw-file"));
});
// undescribed-raw-file
plugins.push(new DescriptionFilePlugin("undescribed-raw-file", descriptionFiles, "raw-file"));
plugins.push(new NextPlugin("after-undescribed-raw-file", "raw-file"));
// raw-file
if(!enforceExtension) {
plugins.push(new TryNextPlugin("raw-file", "no extension", "file"));
}
if(enableConcord) {
plugins.push(new ConcordExtensionsPlugin("raw-file", {}, "file"));
}
extensions.forEach(item => {
plugins.push(new AppendPlugin("raw-file", item, "file"));
});
// file
if(alias.length > 0)
plugins.push(new AliasPlugin("file", alias, "resolve"));
if(enableConcord) {
plugins.push(new ConcordModulesPlugin("file", {}, "resolve"));
}
aliasFields.forEach(item => {
plugins.push(new AliasFieldPlugin("file", item, "resolve"));
});
if(symlinks)
plugins.push(new SymlinkPlugin("file", "relative"));
plugins.push(new FileExistsPlugin("file", "existing-file"));
// existing-file
plugins.push(new NextPlugin("existing-file", "resolved"));
}
// resolved
plugins.push(new ResultPlugin(resolver.hooks.resolved));
//// RESOLVER ////
plugins.forEach(plugin => {
plugin.apply(resolver);
});
return resolver;
};
function mergeFilteredToArray(array, filter) {
return array.reduce((array, item) => {
if(filter(item)) {
const lastElement = array[array.length - 1];
if(Array.isArray(lastElement)) {
lastElement.push(item);
} else {
array.push([item]);
}
return array;
} else {
array.push(item);
return array;
}
}, []);
}
function isAbsolutePath(path) {
return /^[A-Z]:|^\//.test(path);
}

View File

@@ -1,22 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class ResultPlugin {
constructor(source) {
this.source = source;
}
apply(resolver) {
this.source.tapAsync("ResultPlugin", (request, resolverContext, callback) => {
const obj = Object.assign({}, request);
if(resolverContext.log) resolverContext.log("reporting result " + obj.path);
resolver.hooks.result.callAsync(obj, resolverContext, err => {
if(err) return callback(err);
callback(null, obj);
});
});
}
};

View File

@@ -1,49 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const getPaths = require("./getPaths");
const forEachBail = require("./forEachBail");
module.exports = class SymlinkPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
const fs = resolver.fileSystem;
resolver.getHook(this.source).tapAsync("SymlinkPlugin", (request, resolveContext, callback) => {
const pathsResult = getPaths(request.path);
const pathSeqments = pathsResult.seqments;
const paths = pathsResult.paths;
let containsSymlink = false;
forEachBail.withIndex(paths, (path, idx, callback) => {
fs.readlink(path, (err, result) => {
if(!err && result) {
pathSeqments[idx] = result;
containsSymlink = true;
// Shortcut when absolute symlink found
if(/^(\/|[a-zA-Z]:($|\\))/.test(result))
return callback(null, idx);
}
callback();
});
}, (err, idx) => {
if(!containsSymlink) return callback();
const resultSeqments = typeof idx === "number" ? pathSeqments.slice(0, idx + 1) : pathSeqments.slice();
const result = resultSeqments.reverse().reduce((a, b) => {
return resolver.join(a, b);
});
const obj = Object.assign({}, request, {
path: result
});
resolver.doResolve(target, obj, "resolved symlink to " + result, resolveContext, callback);
});
});
}
};

View File

@@ -1,65 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
function SyncAsyncFileSystemDecorator(fs) {
this.fs = fs;
if(fs.statSync) {
this.stat = function(arg, callback) {
let result;
try {
result = fs.statSync(arg);
} catch(e) {
return callback(e);
}
callback(null, result);
};
}
if(fs.readdirSync) {
this.readdir = function(arg, callback) {
let result;
try {
result = fs.readdirSync(arg);
} catch(e) {
return callback(e);
}
callback(null, result);
};
}
if(fs.readFileSync) {
this.readFile = function(arg, callback) {
let result;
try {
result = fs.readFileSync(arg);
} catch(e) {
return callback(e);
}
callback(null, result);
};
}
if(fs.readlinkSync) {
this.readlink = function(arg, callback) {
let result;
try {
result = fs.readlinkSync(arg);
} catch(e) {
return callback(e);
}
callback(null, result);
};
}
if(fs.readJsonSync) {
this.readJson = function(arg, callback) {
let result;
try {
result = fs.readJsonSync(arg);
} catch(e) {
return callback(e);
}
callback(null, result);
};
}
}
module.exports = SyncAsyncFileSystemDecorator;

View File

@@ -1,20 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class TryNextPlugin {
constructor(source, message, target) {
this.source = source;
this.message = message;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("TryNextPlugin", (request, resolveContext, callback) => {
resolver.doResolve(target, request, this.message, resolveContext, callback);
});
}
};

View File

@@ -1,41 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
function getCacheId(request, withContext) {
return JSON.stringify({
context: withContext ? request.context : "",
path: request.path,
query: request.query,
request: request.request
});
}
module.exports = class UnsafeCachePlugin {
constructor(source, filterPredicate, cache, withContext, target) {
this.source = source;
this.filterPredicate = filterPredicate;
this.withContext = withContext;
this.cache = cache || {};
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("UnsafeCachePlugin", (request, resolveContext, callback) => {
if(!this.filterPredicate(request)) return callback();
const cacheId = getCacheId(request, this.withContext);
const cacheEntry = this.cache[cacheId];
if(cacheEntry) {
return callback(null, cacheEntry);
}
resolver.doResolve(target, request, null, resolveContext, (err, result) => {
if(err) return callback(err);
if(result) return callback(null, this.cache[cacheId] = result);
callback();
});
});
}
};

View File

@@ -1,25 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class UseFilePlugin {
constructor(source, filename, target) {
this.source = source;
this.filename = filename;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("UseFilePlugin", (request, resolveContext, callback) => {
const filePath = resolver.join(request.path, this.filename);
const obj = Object.assign({}, request, {
path: filePath,
relativePath: request.relativePath && resolver.join(request.relativePath, this.filename)
});
resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
});
}
};

View File

@@ -1,195 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const globToRegExp = require("./globToRegExp").globToRegExp;
function parseType(type) {
const items = type.split("+");
const t = items.shift();
return {
type: t === "*" ? null : t,
features: items
};
}
function isTypeMatched(baseType, testedType) {
if(typeof baseType === "string") baseType = parseType(baseType);
if(typeof testedType === "string") testedType = parseType(testedType);
if(testedType.type && testedType.type !== baseType.type) return false;
return testedType.features.every(requiredFeature => {
return baseType.features.indexOf(requiredFeature) >= 0;
});
}
function isResourceTypeMatched(baseType, testedType) {
baseType = baseType.split("/");
testedType = testedType.split("/");
if(baseType.length !== testedType.length) return false;
for(let i = 0; i < baseType.length; i++) {
if(!isTypeMatched(baseType[i], testedType[i]))
return false;
}
return true;
}
function isResourceTypeSupported(context, type) {
return context.supportedResourceTypes && context.supportedResourceTypes.some(supportedType => {
return isResourceTypeMatched(supportedType, type);
});
}
function isEnvironment(context, env) {
return context.environments && context.environments.every(environment => {
return isTypeMatched(environment, env);
});
}
const globCache = {};
function getGlobRegExp(glob) {
const regExp = globCache[glob] || (globCache[glob] = globToRegExp(glob));
return regExp;
}
function matchGlob(glob, relativePath) {
const regExp = getGlobRegExp(glob);
return regExp.exec(relativePath);
}
function isGlobMatched(glob, relativePath) {
return !!matchGlob(glob, relativePath);
}
function isConditionMatched(context, condition) {
const items = condition.split("|");
return items.some(function testFn(item) {
item = item.trim();
const inverted = /^!/.test(item);
if(inverted) return !testFn(item.substr(1));
if(/^[a-z]+:/.test(item)) {
// match named condition
const match = /^([a-z]+):\s*/.exec(item);
const value = item.substr(match[0].length);
const name = match[1];
switch(name) {
case "referrer":
return isGlobMatched(value, context.referrer);
default:
return false;
}
} else if(item.indexOf("/") >= 0) {
// match supported type
return isResourceTypeSupported(context, item);
} else {
// match environment
return isEnvironment(context, item);
}
});
}
function isKeyMatched(context, key) {
while(true) { //eslint-disable-line
const match = /^\[([^\]]+)\]\s*/.exec(key);
if(!match) return key;
key = key.substr(match[0].length);
const condition = match[1];
if(!isConditionMatched(context, condition)) {
return false;
}
}
}
function getField(context, configuration, field) {
let value;
Object.keys(configuration).forEach(key => {
const pureKey = isKeyMatched(context, key);
if(pureKey === field) {
value = configuration[key];
}
});
return value;
}
function getMain(context, configuration) {
return getField(context, configuration, "main");
}
function getExtensions(context, configuration) {
return getField(context, configuration, "extensions");
}
function matchModule(context, configuration, request) {
const modulesField = getField(context, configuration, "modules");
if(!modulesField) return request;
let newRequest = request;
const keys = Object.keys(modulesField);
let iteration = 0;
let match;
let index;
for(let i = 0; i < keys.length; i++) {
const key = keys[i];
const pureKey = isKeyMatched(context, key);
match = matchGlob(pureKey, newRequest);
if(match) {
const value = modulesField[key];
if(typeof value !== "string") {
return value;
} else if(/^\(.+\)$/.test(pureKey)) {
newRequest = newRequest.replace(getGlobRegExp(pureKey), value);
} else {
index = 1;
newRequest = value.replace(/(\/?\*)?\*/g, replaceMatcher);
}
i = -1;
if(iteration++ > keys.length) {
throw new Error("Request '" + request + "' matches recursively");
}
}
}
return newRequest;
function replaceMatcher(find) {
switch(find) {
case "/**":
{
const m = match[index++];
return m ? "/" + m : "";
}
case "**":
case "*":
return match[index++];
}
}
}
function matchType(context, configuration, relativePath) {
const typesField = getField(context, configuration, "types");
if(!typesField) return undefined;
let type;
Object.keys(typesField).forEach(key => {
const pureKey = isKeyMatched(context, key);
if(isGlobMatched(pureKey, relativePath)) {
const value = typesField[key];
if(!type && /\/\*$/.test(value))
throw new Error("value ('" + value + "') of key '" + key + "' contains '*', but there is no previous value defined");
type = value.replace(/\/\*$/, "/" + type);
}
});
return type;
}
exports.parseType = parseType;
exports.isTypeMatched = isTypeMatched;
exports.isResourceTypeSupported = isResourceTypeSupported;
exports.isEnvironment = isEnvironment;
exports.isGlobMatched = isGlobMatched;
exports.isConditionMatched = isConditionMatched;
exports.isKeyMatched = isKeyMatched;
exports.getField = getField;
exports.getMain = getMain;
exports.getExtensions = getExtensions;
exports.matchModule = matchModule;
exports.matchType = matchType;

View File

@@ -1,47 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const util = require("util");
// TODO remove in enhanced-resolve 5
module.exports = util.deprecate(function createInnerCallback(callback, options, message, messageOptional) {
const log = options.log;
if(!log) {
if(options.stack !== callback.stack) {
const callbackWrapper = function callbackWrapper() {
return callback.apply(this, arguments);
};
callbackWrapper.stack = options.stack;
callbackWrapper.missing = options.missing;
return callbackWrapper;
}
return callback;
}
function loggingCallbackWrapper() {
return callback.apply(this, arguments);
}
if(message) {
if(!messageOptional) {
log(message);
}
loggingCallbackWrapper.log = function writeLog(msg) {
if(messageOptional) {
log(message);
messageOptional = false;
}
log(" " + msg);
};
} else {
loggingCallbackWrapper.log = function writeLog(msg) {
log(msg);
};
}
loggingCallbackWrapper.stack = options.stack;
loggingCallbackWrapper.missing = options.missing;
return loggingCallbackWrapper;
}, "Pass resolveContext instead and use createInnerContext");

View File

@@ -1,26 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function createInnerContext(options, message, messageOptional) {
let messageReported = false;
const childContext = {
log: (() => {
if(!options.log) return undefined;
if(!message) return options.log;
const logFunction = (msg) => {
if(!messageReported) {
options.log(message);
messageReported = true;
}
options.log(" " + msg);
};
return logFunction;
})(),
stack: options.stack,
missing: options.missing
};
return childContext;
};

View File

@@ -1,65 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function forEachBail(array, iterator, callback) {
if(array.length === 0) return callback();
let currentPos = array.length;
let currentResult;
let done = [];
for(let i = 0; i < array.length; i++) {
const itCb = createIteratorCallback(i);
iterator(array[i], itCb);
if(currentPos === 0) break;
}
function createIteratorCallback(i) {
return(...args) => { // eslint-disable-line
if(i >= currentPos) return; // ignore
done.push(i);
if(args.length > 0) {
currentPos = i + 1;
done = done.filter(item => {
return item <= i;
});
currentResult = args;
}
if(done.length === currentPos) {
callback.apply(null, currentResult);
currentPos = 0;
}
};
}
};
module.exports.withIndex = function forEachBailWithIndex(array, iterator, callback) {
if(array.length === 0) return callback();
let currentPos = array.length;
let currentResult;
let done = [];
for(let i = 0; i < array.length; i++) {
const itCb = createIteratorCallback(i);
iterator(array[i], i, itCb);
if(currentPos === 0) break;
}
function createIteratorCallback(i) {
return(...args) => { // eslint-disable-line
if(i >= currentPos) return; // ignore
done.push(i);
if(args.length > 0) {
currentPos = i + 1;
done = done.filter(item => {
return item <= i;
});
currentResult = args;
}
if(done.length === currentPos) {
callback.apply(null, currentResult);
currentPos = 0;
}
};
}
};

View File

@@ -1,24 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function getInnerRequest(resolver, request) {
if(typeof request.__innerRequest === "string" &&
request.__innerRequest_request === request.request &&
request.__innerRequest_relativePath === request.relativePath)
return request.__innerRequest;
let innerRequest;
if(request.request) {
innerRequest = request.request;
if(/^\.\.?\//.test(innerRequest) && request.relativePath) {
innerRequest = resolver.join(request.relativePath, innerRequest);
}
} else {
innerRequest = request.relativePath;
}
request.__innerRequest_request = request.request;
request.__innerRequest_relativePath = request.relativePath;
return request.__innerRequest = innerRequest;
};

View File

@@ -1,35 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function getPaths(path) {
const parts = path.split(/(.*?[\\\/]+)/);
const paths = [path];
const seqments = [parts[parts.length - 1]];
let part = parts[parts.length - 1];
path = path.substr(0, path.length - part.length - 1);
for(let i = parts.length - 2; i > 2; i -= 2) {
paths.push(path);
part = parts[i];
path = path.substr(0, path.length - part.length) || "/";
seqments.push(part.substr(0, part.length - 1));
}
part = parts[1];
seqments.push(part);
paths.push(part);
return {
paths: paths,
seqments: seqments
};
};
module.exports.basename = function basename(path) {
const i = path.lastIndexOf("/"),
j = path.lastIndexOf("\\");
const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
if(p < 0) return null;
const s = path.substr(p + 1);
return s;
};

View File

@@ -1,194 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
function globToRegExp(glob) {
// * [^\\\/]*
// /**/ /.+/
// ^* \./.+ (concord special)
// ? [^\\\/]
// [!...] [^...]
// [^...] [^...]
// / [\\\/]
// {...,...} (...|...)
// ?(...|...) (...|...)?
// +(...|...) (...|...)+
// *(...|...) (...|...)*
// @(...|...) (...|...)
if(/^\(.+\)$/.test(glob)) {
// allow to pass an RegExp in brackets
return new RegExp(glob.substr(1, glob.length - 2));
}
const tokens = tokenize(glob);
const process = createRoot();
const regExpStr = tokens.map(process).join("");
return new RegExp("^" + regExpStr + "$");
}
const SIMPLE_TOKENS = {
"@(": "one",
"?(": "zero-one",
"+(": "one-many",
"*(": "zero-many",
"|": "segment-sep",
"/**/": "any-path-segments",
"**": "any-path",
"*": "any-path-segment",
"?": "any-char",
"{": "or",
"/": "path-sep",
",": "comma",
")": "closing-segment",
"}": "closing-or"
};
function tokenize(glob) {
return glob.split(/([@?+*]\(|\/\*\*\/|\*\*|[?*]|\[[\!\^]?(?:[^\]\\]|\\.)+\]|\{|,|\/|[|)}])/g).map(item => {
if(!item)
return null;
const t = SIMPLE_TOKENS[item];
if(t) {
return {
type: t
};
}
if(item[0] === "[") {
if(item[1] === "^" || item[1] === "!") {
return {
type: "inverted-char-set",
value: item.substr(2, item.length - 3)
};
} else {
return {
type: "char-set",
value: item.substr(1, item.length - 2)
};
}
}
return {
type: "string",
value: item
};
}).filter(Boolean).concat({
type: "end"
});
}
function createRoot() {
const inOr = [];
const process = createSeqment();
let initial = true;
return function(token) {
switch(token.type) {
case "or":
inOr.push(initial);
return "(";
case "comma":
if(inOr.length) {
initial = inOr[inOr.length - 1];
return "|";
} else {
return process({
type: "string",
value: ","
}, initial);
}
case "closing-or":
if(inOr.length === 0)
throw new Error("Unmatched '}'");
inOr.pop();
return ")";
case "end":
if(inOr.length)
throw new Error("Unmatched '{'");
return process(token, initial);
default:
{
const result = process(token, initial);
initial = false;
return result;
}
}
};
}
function createSeqment() {
const inSeqment = [];
const process = createSimple();
return function(token, initial) {
switch(token.type) {
case "one":
case "one-many":
case "zero-many":
case "zero-one":
inSeqment.push(token.type);
return "(";
case "segment-sep":
if(inSeqment.length) {
return "|";
} else {
return process({
type: "string",
value: "|"
}, initial);
}
case "closing-segment":
{
const segment = inSeqment.pop();
switch(segment) {
case "one":
return ")";
case "one-many":
return ")+";
case "zero-many":
return ")*";
case "zero-one":
return ")?";
}
throw new Error("Unexcepted segment " + segment);
}
case "end":
if(inSeqment.length > 0) {
throw new Error("Unmatched segment, missing ')'");
}
return process(token, initial);
default:
return process(token, initial);
}
};
}
function createSimple() {
return function(token, initial) {
switch(token.type) {
case "path-sep":
return "[\\\\/]+";
case "any-path-segments":
return "[\\\\/]+(?:(.+)[\\\\/]+)?";
case "any-path":
return "(.*)";
case "any-path-segment":
if(initial) {
return "\\.[\\\\/]+(?:.*[\\\\/]+)?([^\\\\/]+)";
} else {
return "([^\\\\/]*)";
}
case "any-char":
return "[^\\\\/]";
case "inverted-char-set":
return "[^" + token.value + "]";
case "char-set":
return "[" + token.value + "]";
case "string":
return token.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
case "end":
return "";
default:
throw new Error("Unsupported token '" + token.type + "'");
}
};
}
exports.globToRegExp = globToRegExp;

View File

@@ -1,162 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ResolverFactory = require("./ResolverFactory");
const NodeJsInputFileSystem = require("./NodeJsInputFileSystem");
const CachedInputFileSystem = require("./CachedInputFileSystem");
const nodeFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000);
const nodeContext = {
environments: [
"node+es3+es5+process+native"
]
};
const asyncResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
fileSystem: nodeFileSystem
});
module.exports = function resolve(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
callback = resolveContext;
resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
if(typeof callback !== "function") {
callback = resolveContext;
}
asyncResolver.resolve(context, path, request, resolveContext, callback);
};
const syncResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
});
module.exports.sync = function resolveSync(context, path, request) {
if(typeof context === "string") {
request = path;
path = context;
context = nodeContext;
}
return syncResolver.resolveSync(context, path, request);
};
const asyncContextResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
resolveToContext: true,
fileSystem: nodeFileSystem
});
module.exports.context = function resolveContext(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
callback = resolveContext;
resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
if(typeof callback !== "function") {
callback = resolveContext;
}
asyncContextResolver.resolve(context, path, request, resolveContext, callback);
};
const syncContextResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
resolveToContext: true,
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
});
module.exports.context.sync = function resolveContextSync(context, path, request) {
if(typeof context === "string") {
request = path;
path = context;
context = nodeContext;
}
return syncContextResolver.resolveSync(context, path, request);
};
const asyncLoaderResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
moduleExtensions: ["-loader"],
mainFields: ["loader", "main"],
fileSystem: nodeFileSystem
});
module.exports.loader = function resolveLoader(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
callback = resolveContext;
resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
if(typeof callback !== "function") {
callback = resolveContext;
}
asyncLoaderResolver.resolve(context, path, request, resolveContext, callback);
};
const syncLoaderResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
moduleExtensions: ["-loader"],
mainFields: ["loader", "main"],
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
});
module.exports.loader.sync = function resolveLoaderSync(context, path, request) {
if(typeof context === "string") {
request = path;
path = context;
context = nodeContext;
}
return syncLoaderResolver.resolveSync(context, path, request);
};
module.exports.create = function create(options) {
options = Object.assign({
fileSystem: nodeFileSystem
}, options);
const resolver = ResolverFactory.createResolver(options);
return function(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
callback = resolveContext;
resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
if(typeof callback !== "function") {
callback = resolveContext;
}
resolver.resolve(context, path, request, resolveContext, callback);
};
};
module.exports.create.sync = function createSync(options) {
options = Object.assign({
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
}, options);
const resolver = ResolverFactory.createResolver(options);
return function(context, path, request) {
if(typeof context === "string") {
request = path;
path = context;
context = nodeContext;
}
return resolver.resolveSync(context, path, request);
};
};
// Export Resolver, FileSystems and Plugins
module.exports.ResolverFactory = ResolverFactory;
module.exports.NodeJsInputFileSystem = NodeJsInputFileSystem;
module.exports.CachedInputFileSystem = CachedInputFileSystem;

View File

@@ -1,86 +0,0 @@
{
"_args": [
[
"enhanced-resolve@4.1.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "enhanced-resolve@4.1.0",
"_id": "enhanced-resolve@4.1.0",
"_inBundle": false,
"_integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==",
"_location": "/webpack-cli/enhanced-resolve",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "enhanced-resolve@4.1.0",
"name": "enhanced-resolve",
"escapedName": "enhanced-resolve",
"rawSpec": "4.1.0",
"saveSpec": null,
"fetchSpec": "4.1.0"
},
"_requiredBy": [
"/webpack-cli"
],
"_resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz",
"_spec": "4.1.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/webpack/enhanced-resolve/issues"
},
"dependencies": {
"graceful-fs": "^4.1.2",
"memory-fs": "^0.4.0",
"tapable": "^1.0.0"
},
"description": "Offers a async require.resolve function. It's highly configurable.",
"devDependencies": {
"beautify-lint": "^1.0.3",
"codecov.io": "^0.1.6",
"coveralls": "^2.11.6",
"eslint": "^3.14.1",
"eslint-plugin-node": "^3.0.5",
"eslint-plugin-nodeca": "^1.0.3",
"istanbul": "^0.4.1",
"js-beautify": "^1.5.10",
"mocha": "^2.3.4",
"should": "^8.0.2"
},
"engines": {
"node": ">=6.9.0"
},
"files": [
"lib",
"LICENSE"
],
"homepage": "http://github.com/webpack/enhanced-resolve",
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
}
],
"main": "lib/node.js",
"name": "enhanced-resolve",
"repository": {
"type": "git",
"url": "git://github.com/webpack/enhanced-resolve.git"
},
"scripts": {
"beautify": "beautify-rewrite lib/**.js test/*.js",
"beautify-lint": "beautify-lint lib/**.js test/*.js",
"cover": "istanbul cover node_modules/mocha/bin/_mocha",
"lint": "eslint lib test",
"precover": "npm run lint && npm run beautify-lint",
"pretest": "npm run lint && npm run beautify-lint",
"test": "mocha --full-trace --check-leaks",
"travis": "npm run cover -- --report lcovonly"
},
"version": "4.1.0"
}

View File

@@ -1,46 +0,0 @@
'use strict';
const path = require('path');
const locatePath = require('locate-path');
module.exports = (filename, opts = {}) => {
const startDir = path.resolve(opts.cwd || '');
const {root} = path.parse(startDir);
const filenames = [].concat(filename);
return new Promise(resolve => {
(function find(dir) {
locatePath(filenames, {cwd: dir}).then(file => {
if (file) {
resolve(path.join(dir, file));
} else if (dir === root) {
resolve(null);
} else {
find(path.dirname(dir));
}
});
})(startDir);
});
};
module.exports.sync = (filename, opts = {}) => {
let dir = path.resolve(opts.cwd || '');
const {root} = path.parse(dir);
const filenames = [].concat(filename);
// eslint-disable-next-line no-constant-condition
while (true) {
const file = locatePath.sync(filenames, {cwd: dir});
if (file) {
return path.join(dir, file);
}
if (dir === root) {
return null;
}
dir = path.dirname(dir);
}
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -1,86 +0,0 @@
{
"_args": [
[
"find-up@3.0.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "find-up@3.0.0",
"_id": "find-up@3.0.0",
"_inBundle": false,
"_integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
"_location": "/webpack-cli/find-up",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "find-up@3.0.0",
"name": "find-up",
"escapedName": "find-up",
"rawSpec": "3.0.0",
"saveSpec": null,
"fetchSpec": "3.0.0"
},
"_requiredBy": [
"/webpack-cli/yargs"
],
"_resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/find-up/issues"
},
"dependencies": {
"locate-path": "^3.0.0"
},
"description": "Find a file or directory by walking up parent directories",
"devDependencies": {
"ava": "*",
"tempy": "^0.2.1",
"xo": "*"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/find-up#readme",
"keywords": [
"find",
"up",
"find-up",
"findup",
"look-up",
"look",
"file",
"search",
"match",
"package",
"resolve",
"parent",
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"license": "MIT",
"name": "find-up",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/find-up.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.0.0"
}

View File

@@ -1,87 +0,0 @@
# find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
> Find a file or directory by walking up parent directories
## Install
```
$ npm install find-up
```
## Usage
```
/
└── Users
└── sindresorhus
├── unicorn.png
└── foo
└── bar
├── baz
└── example.js
```
`example.js`
```js
const findUp = require('find-up');
(async () => {
console.log(await findUp('unicorn.png'));
//=> '/Users/sindresorhus/unicorn.png'
console.log(await findUp(['rainbow.png', 'unicorn.png']));
//=> '/Users/sindresorhus/unicorn.png'
})();
```
## API
### findUp(filename, [options])
Returns a `Promise` for either the filepath or `null` if it couldn't be found.
### findUp([filenameA, filenameB], [options])
Returns a `Promise` for either the first filepath found (by respecting the order) or `null` if none could be found.
### findUp.sync(filename, [options])
Returns a filepath or `null`.
### findUp.sync([filenameA, filenameB], [options])
Returns the first filepath found (by respecting the order) or `null`.
#### filename
Type: `string`
Filename of the file to find.
#### options
Type: `Object`
##### cwd
Type: `string`<br>
Default: `process.cwd()`
Directory to start from.
## Related
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module like `require.resolve()` but from a given path
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1,274 +0,0 @@
### v1.0.1 [[code][c1.0.1], [diff][d1.0.1]]
[c1.0.1]: https://github.com/json5/json5/tree/v1.0.1
[d1.0.1]: https://github.com/json5/json5/compare/v1.0.0...v1.0.1
This release includes a bug fix and minor change.
- Fix: `parse` throws on unclosed objects and arrays.
- New: `package.json5` has been removed until an easier way to keep it in sync
with `package.json` is found.
### v1.0.0 [[code][c1.0.0], [diff][d1.0.0]]
[c1.0.0]: https://github.com/json5/json5/tree/v1.0.0
[d1.0.0]: https://github.com/json5/json5/compare/v0.5.1...v1.0.0
This release includes major internal changes and public API enhancements.
- **Major** JSON5 officially supports Node.js v4 and later. Support for Node.js
v0.10 and v0.12 have been dropped.
- New: Unicode property names and Unicode escapes in property names are
supported. ([#1])
- New: `stringify` outputs trailing commas in objects and arrays when a `space`
option is provided. ([#66])
- New: JSON5 allows line and paragraph separator characters (U+2028 and U+2029)
in strings in order to be compatible with JSON. However, ES5 does not allow
these characters in strings, so JSON5 gives a warning when they are parsed and
escapes them when they are stringified. ([#70])
- New: `stringify` accepts an options object as its second argument. The
supported options are `replacer`, `space`, and a new `quote` option that
specifies the quote character used in strings. ([#71])
- New: The CLI supports STDIN and STDOUT and adds `--out-file`, `--space`, and
`--validate` options. See `json5 --help` for more information. ([#72], [#84],
and [#108])
- New: In addition to the white space characters space `\t`, `\v`, `\f`, `\n`,
`\r`, and `\xA0`, the additional white space characters `\u2028`, `\u2029`,
and all other characters in the Space Separator Unicode category are allowed.
- New: In addition to the character escapes `\'`, `\"`, `\\`, `\b`, `\f`, `\n`,
`\r`, and `\t`, the additional character escapes `\v` and `\0`, hexadecimal
escapes like `\x0F`, and unnecessary escapes like `\a` are allowed in string
values and string property names.
- New: `stringify` outputs strings with single quotes by default but
intelligently uses double quotes if there are more single quotes than double
quotes inside the string. (i.e. `stringify('Stay here.')` outputs
`'Stay here.'` while `stringify('Let\'s go.')` outputs `"Let's go."`)
- New: When a character is not allowed in a string, `stringify` outputs a
character escape like `\t` when available, a hexadecimal escape like `\x0F`
when the Unicode code point is less than 256, or a Unicode character escape
like `\u01FF`, in that order.
- New: `stringify` checks for a `toJSON5` method on objects and, if it exists,
stringifies its return value instead of the object. `toJSON5` overrides
`toJSON` if they both exist.
- New: To `require` or `import` JSON5 files, use `require('json5/lib/register')`
or `import 'json5/lib/register'`. Previous versions used `json5/lib/require`,
which still exists for backward compatibility but is deprecated and will give
a warning.
- New: To use JSON5 in browsers, use the file at `dist/index.js` or
`https://unpkg.com/json5@^1.0.0`.
- Fix: `stringify` properly outputs `Infinity` and `NaN`. ([#67])
- Fix: `isWord` no longer becomes a property of `JSON5` after calling
`stringify`. ([#68] and [#89])
- Fix: `stringify` no longer throws when an object does not have a `prototype`.
([#154])
- Fix: `stringify` properly handles the `key` argument of `toJSON(key)` methods.
`toJSON5(key)` follows this pattern.
- Fix: `stringify` accepts `Number` and `String` objects as its `space`
argument.
- Fix: In addition to a function, `stringify` also accepts an array of keys to
include in the output as its `replacer` argument. Numbers, `Number` objects,
and `String` objects will be converted to a string if they are given as array
values.
### v0.5.1 [[code][c0.5.1], [diff][d0.5.1]]
[c0.5.1]: https://github.com/json5/json5/tree/v0.5.1
[d0.5.1]: https://github.com/json5/json5/compare/v0.5.0...v0.5.1
This release includes a minor fix for indentations when stringifying empty
arrays.
- Fix: Indents no longer appear in empty arrays when stringified. ([#134])
### v0.5.0 [[code][c0.5.0], [diff][d0.5.0]]
[c0.5.0]: https://github.com/json5/json5/tree/v0.5.0
[d0.5.0]: https://github.com/json5/json5/compare/v0.4.0...v0.5.0
This release includes major internal changes and public API enhancements.
- **Major:** JSON5 officially supports Node.js v4 LTS and v5. Support for
Node.js v0.6 and v0.8 have been dropped, while support for v0.10 and v0.12
remain.
- Fix: YUI Compressor no longer fails when compressing json5.js. ([#97])
- New: `parse` and the CLI provide line and column numbers when displaying error
messages. ([#101]; awesome work by [@amb26].)
### v0.4.0 [[code][c0.4.0], [diff][d0.4.0]]
[c0.4.0]: https://github.com/json5/json5/tree/v0.4.0
[d0.4.0]: https://github.com/json5/json5/compare/v0.2.0...v0.4.0
Note that v0.3.0 was tagged, but never published to npm, so this v0.4.0
changelog entry includes v0.3.0 features.
This is a massive release that adds `stringify` support, among other things.
- **Major:** `JSON5.stringify()` now exists!
This method is analogous to the native `JSON.stringify()`;
it just avoids quoting keys where possible.
See the [usage documentation](./README.md#usage) for more.
([#32]; huge thanks and props [@aeisenberg]!)
- New: `NaN` and `-NaN` are now allowed number literals.
([#30]; thanks [@rowanhill].)
- New: Duplicate object keys are now allowed; the last value is used.
This is the same behavior as JSON. ([#57]; thanks [@jordanbtucker].)
- Fix: Properly handle various whitespace and newline cases now.
E.g. JSON5 now properly supports escaped CR and CRLF newlines in strings,
and JSON5 now accepts the same whitespace as JSON (stricter than ES5).
([#58], [#60], and [#63]; thanks [@jordanbtucker].)
- New: Negative hexadecimal numbers (e.g. `-0xC8`) are allowed again.
(They were disallowed in v0.2.0; see below.)
It turns out they *are* valid in ES5, so JSON5 supports them now too.
([#36]; thanks [@jordanbtucker]!)
### v0.2.0 [[code][c0.2.0], [diff][d0.2.0]]
[c0.2.0]: https://github.com/json5/json5/tree/v0.2.0
[d0.2.0]: https://github.com/json5/json5/compare/v0.1.0...v0.2.0
This release fixes some bugs and adds some more utility features to help you
express data more easily:
- **Breaking:** Negative hexadecimal numbers (e.g. `-0xC8`) are rejected now.
While V8 (e.g. Chrome and Node) supported them, it turns out they're invalid
in ES5. This has been [fixed in V8][v8-hex-fix] (and by extension, Chrome
and Node), so JSON5 officially rejects them now, too. ([#36])
- New: Trailing decimal points in decimal numbers are allowed again.
(They were disallowed in v0.1.0; see below.)
They're allowed by ES5, and differentiating between integers and floats may
make sense on some platforms. ([#16]; thanks [@Midar].)
- New: `Infinity` and `-Infinity` are now allowed number literals.
([#30]; thanks [@pepkin88].)
- New: Plus signs (`+`) in front of numbers are now allowed, since it can
be helpful in some contexts to explicitly mark numbers as positive.
(E.g. when a property represents changes or deltas.)
- Fix: unescaped newlines in strings are rejected now.
([#24]; thanks [@Midar].)
### v0.1.0 [[code][c0.1.0], [diff][d0.1.0]]
[c0.1.0]: https://github.com/json5/json5/tree/v0.1.0
[d0.1.0]: https://github.com/json5/json5/compare/v0.0.1...v0.1.0
This release tightens JSON5 support and adds helpful utility features:
- New: Support hexadecimal numbers. (Thanks [@MaxNanasy].)
- Fix: Reject octal numbers properly now. Previously, they were accepted but
improperly parsed as base-10 numbers. (Thanks [@MaxNanasy].)
- **Breaking:** Reject "noctal" numbers now (base-10 numbers that begin with a
leading zero). These are disallowed by both JSON5 and JSON, as well as by
ES5's strict mode. (Thanks [@MaxNanasy].)
- New: Support leading decimal points in decimal numbers.
(Thanks [@MaxNanasy].)
- **Breaking:** Reject trailing decimal points in decimal numbers now. These
are disallowed by both JSON5 and JSON. (Thanks [@MaxNanasy].)
- **Breaking:** Reject omitted elements in arrays now. These are disallowed by
both JSON5 and JSON.
- Fix: Throw proper `SyntaxError` instances on errors now.
- New: Add Node.js `require()` hook. Register via `json5/lib/require`.
- New: Add Node.js `json5` executable to compile JSON5 files to JSON.
### v0.0.1 [[code][c0.0.1], [diff][d0.0.1]]
[c0.0.1]: https://github.com/json5/json5/tree/v0.0.1
[d0.0.1]: https://github.com/json5/json5/compare/v0.0.0...v0.0.1
This was the first implementation of this JSON5 parser.
- Support unquoted object keys, including reserved words. Unicode characters
and escape sequences sequences aren't yet supported.
- Support single-quoted strings.
- Support multi-line strings.
- Support trailing commas in arrays and objects.
- Support comments, both inline and block.
### v0.0.0 [[code](https://github.com/json5/json5/tree/v0.0.0)]
Let's consider this to be Douglas Crockford's original [json_parse.js] — a
parser for the regular JSON format.
[json_parse.js]: https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
[v8-hex-fix]: http://code.google.com/p/v8/issues/detail?id=2240
[@MaxNanasy]: https://github.com/MaxNanasy
[@Midar]: https://github.com/Midar
[@pepkin88]: https://github.com/pepkin88
[@rowanhill]: https://github.com/rowanhill
[@aeisenberg]: https://github.com/aeisenberg
[@jordanbtucker]: https://github.com/jordanbtucker
[@amb26]: https://github.com/amb26
[#1]: https://github.com/json5/json5/issues/1
[#16]: https://github.com/json5/json5/issues/16
[#24]: https://github.com/json5/json5/issues/24
[#30]: https://github.com/json5/json5/issues/30
[#32]: https://github.com/json5/json5/issues/32
[#36]: https://github.com/json5/json5/issues/36
[#57]: https://github.com/json5/json5/issues/57
[#58]: https://github.com/json5/json5/pull/58
[#60]: https://github.com/json5/json5/pull/60
[#63]: https://github.com/json5/json5/pull/63
[#66]: https://github.com/json5/json5/issues/66
[#67]: https://github.com/json5/json5/issues/67
[#68]: https://github.com/json5/json5/issues/68
[#70]: https://github.com/json5/json5/issues/70
[#71]: https://github.com/json5/json5/issues/71
[#72]: https://github.com/json5/json5/issues/72
[#84]: https://github.com/json5/json5/pull/84
[#89]: https://github.com/json5/json5/pull/89
[#97]: https://github.com/json5/json5/pull/97
[#101]: https://github.com/json5/json5/pull/101
[#108]: https://github.com/json5/json5/pull/108
[#134]: https://github.com/json5/json5/pull/134
[#154]: https://github.com/json5/json5/issues/154

View File

@@ -1,23 +0,0 @@
MIT License
Copyright (c) 2012-2018 Aseem Kishore, and [others].
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.
[others]: https://github.com/json5/json5/contributors

View File

@@ -1,234 +0,0 @@
# JSON5 JSON for Humans
[![Build Status](https://travis-ci.org/json5/json5.svg)][Build Status]
[![Coverage
Status](https://coveralls.io/repos/github/json5/json5/badge.svg)][Coverage
Status]
The JSON5 Data Interchange Format (JSON5) is a superset of [JSON] that aims to
alleviate some of the limitations of JSON by expanding its syntax to include
some productions from [ECMAScript 5.1].
This JavaScript library is the official reference implementation for JSON5
parsing and serialization libraries.
[Build Status]: https://travis-ci.org/json5/json5
[Coverage Status]: https://coveralls.io/github/json5/json5
[JSON]: https://tools.ietf.org/html/rfc7159
[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
## Summary of Features
The following ECMAScript 5.1 features, which are not supported in JSON, have
been extended to JSON5.
### Objects
- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
- Objects may have a single trailing comma.
### Arrays
- Arrays may have a single trailing comma.
### Strings
- Strings may be single quoted.
- Strings may span multiple lines by escaping new line characters.
- Strings may include character escapes.
### Numbers
- Numbers may be hexadecimal.
- Numbers may have a leading or trailing decimal point.
- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
- Numbers may begin with an explicit plus sign.
### Comments
- Single and multi-line comments are allowed.
### White Space
- Additional white space characters are allowed.
[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
## Short Example
```js
{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',],
"backwardsCompatible": "with JSON",
}
```
## Specification
For a detailed explanation of the JSON5 format, please read the [official
specification](https://json5.github.io/json5-spec/).
## Installation
### Node.js
```sh
npm install json5
```
```js
const JSON5 = require('json5')
```
### Browsers
```html
<script src="https://unpkg.com/json5@^1.0.0"></script>
```
This will create a global `JSON5` variable.
## API
The JSON5 API is compatible with the [JSON API].
[JSON API]:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
### JSON5.parse()
Parses a JSON5 string, constructing the JavaScript value or object described by
the string. An optional reviver function can be provided to perform a
transformation on the resulting object before it is returned.
#### Syntax
JSON5.parse(text[, reviver])
#### Parameters
- `text`: The string to parse as JSON5.
- `reviver`: If a function, this prescribes how the value originally produced by
parsing is transformed, before being returned.
#### Return value
The object corresponding to the given JSON5 text.
### JSON5.stringify()
Converts a JavaScript value to a JSON5 string, optionally replacing values if a
replacer function is specified, or optionally including only the specified
properties if a replacer array is specified.
#### Syntax
JSON5.stringify(value[, replacer[, space]])
JSON5.stringify(value[, options])
#### Parameters
- `value`: The value to convert to a JSON5 string.
- `replacer`: A function that alters the behavior of the stringification
process, or an array of String and Number objects that serve as a whitelist
for selecting/filtering the properties of the value object to be included in
the JSON5 string. If this value is null or not provided, all properties of the
object are included in the resulting JSON5 string.
- `space`: A String or Number object that's used to insert white space into the
output JSON5 string for readability purposes. If this is a Number, it
indicates the number of space characters to use as white space; this number is
capped at 10 (if it is greater, the value is just 10). Values less than 1
indicate that no space should be used. If this is a String, the string (or the
first 10 characters of the string, if it's longer than that) is used as white
space. If this parameter is not provided (or is null), no white space is used.
If white space is used, trailing commas will be used in objects and arrays.
- `options`: An object with the following properties:
- `replacer`: Same as the `replacer` parameter.
- `space`: Same as the `space` parameter.
- `quote`: A String representing the quote character to use when serializing
strings.
#### Return value
A JSON5 string representing the value.
### Node.js `require()` JSON5 files
When using Node.js, you can `require()` JSON5 files by adding the following
statement.
```js
require('json5/lib/register')
```
Then you can load a JSON5 file with a Node.js `require()` statement. For
example:
```js
const config = require('./config.json5')
```
## CLI
Since JSON is more widely used than JSON5, this package includes a CLI for
converting JSON5 to JSON and for validating the syntax of JSON5 documents.
### Installation
```sh
npm install --global json5
```
### Usage
```sh
json5 [options] <file>
```
If `<file>` is not provided, then STDIN is used.
#### Options:
- `-s`, `--space`: The number of spaces to indent or `t` for tabs
- `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
- `-v`, `--validate`: Validate JSON5 but do not output JSON
- `-V`, `--version`: Output the version number
- `-h`, `--help`: Output usage information
## Contibuting
### Development
```sh
git clone https://github.com/json5/json5
cd json5
npm install
```
When contributing code, please write relevant tests and run `npm test` and `npm
run lint` before submitting pull requests. Please use an editor that supports
[EditorConfig](http://editorconfig.org/).
### Issues
To report bugs or request features regarding the JSON5 data format, please
submit an issue to the [official specification
repository](https://github.com/json5/json5-spec).
To report bugs or request features regarding the JavaScript implentation of
JSON5, please submit an issue to this repository.
## License
MIT. See [LICENSE.md](./LICENSE.md) for details.
## Credits
[Assem Kishore](https://github.com/aseemk) founded this project.
[Michael Bolin](http://bolinfest.com/) independently arrived at and published
some of these same ideas with awesome explanations and detail. Recommended
reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
[Douglas Crockford](http://www.crockford.com/) of course designed and built
JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
cheesy as it may sound, gave us motivation and confidence that building a new
parser to implement these ideas was within reach! The original
implementation of JSON5 was also modeled directly off of Dougs open-source
[json_parse.js] parser. Were grateful for that clean and well-documented
code.
[json_parse.js]:
https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
[Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
supporter, contributing multiple patches and ideas.
[Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
`stringify` method.
[Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
with ES5, wrote the official JSON5 specification, completely rewrote the
codebase from the ground up, and is actively maintaining this project.

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +0,0 @@
#!/usr/bin/env node
'use strict';var _fs=require('fs');var _fs2=_interopRequireDefault(_fs);var _path=require('path');var _path2=_interopRequireDefault(_path);var _minimist=require('minimist');var _minimist2=_interopRequireDefault(_minimist);var _package=require('../package.json');var _package2=_interopRequireDefault(_package);var _=require('./');var _2=_interopRequireDefault(_);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var argv=(0,_minimist2.default)(process.argv.slice(2),{alias:{'convert':'c','space':'s','validate':'v','out-file':'o','version':'V','help':'h'},boolean:['convert','validate','version','help'],string:['space','out-file']});if(argv.version){version()}else if(argv.help){usage()}else{var inFilename=argv._[0];var readStream=void 0;if(inFilename){readStream=_fs2.default.createReadStream(inFilename)}else{readStream=process.stdin}var json5='';readStream.on('data',function(data){json5+=data});readStream.on('end',function(){var space=void 0;if(argv.space==='t'||argv.space==='tab'){space='\t'}else{space=Number(argv.space)}var value=void 0;try{value=_2.default.parse(json5);if(!argv.validate){var json=JSON.stringify(value,null,space);var writeStream=void 0;if(argv.convert&&inFilename&&!argv.o){var parsedFilename=_path2.default.parse(inFilename);var outFilename=_path2.default.format(Object.assign(parsedFilename,{base:_path2.default.basename(parsedFilename.base,parsedFilename.ext)+'.json'}));writeStream=_fs2.default.createWriteStream(outFilename)}else if(argv.o){writeStream=_fs2.default.createWriteStream(argv.o)}else{writeStream=process.stdout}writeStream.write(json)}}catch(err){console.error(err.message);process.exit(1)}})}function version(){console.log(_package2.default.version)}function usage(){console.log('\n Usage: json5 [options] <file>\n\n If <file> is not provided, then STDIN is used.\n\n Options:\n\n -s, --space The number of spaces to indent or \'t\' for tabs\n -o, --out-file [file] Output to the specified file, otherwise STDOUT\n -v, --validate Validate JSON5 but do not output JSON\n -V, --version Output the version number\n -h, --help Output usage information')}

View File

@@ -1 +0,0 @@
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _parse=require('./parse');var _parse2=_interopRequireDefault(_parse);var _stringify=require('./stringify');var _stringify2=_interopRequireDefault(_stringify);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.default={parse:_parse2.default,stringify:_stringify2.default};module.exports=exports['default'];

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
'use strict';var _fs=require('fs');var _fs2=_interopRequireDefault(_fs);var _=require('./');var _2=_interopRequireDefault(_);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}require.extensions['.json5']=function(module,filename){var content=_fs2.default.readFileSync(filename,'utf8');try{module.exports=_2.default.parse(content)}catch(err){err.message=filename+': '+err.message;throw err}};

View File

@@ -1 +0,0 @@
"use strict";require("./register");console.warn("'json5/require' is deprecated. Please use 'json5/register' instead.");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.isSpaceSeparator=isSpaceSeparator;exports.isIdStartChar=isIdStartChar;exports.isIdContinueChar=isIdContinueChar;exports.isDigit=isDigit;exports.isHexDigit=isHexDigit;var _unicode=require('../lib/unicode');var unicode=_interopRequireWildcard(_unicode);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}function isSpaceSeparator(c){return unicode.Space_Separator.test(c)}function isIdStartChar(c){return c>='a'&&c<='z'||c>='A'&&c<='Z'||c==='$'||c==='_'||unicode.ID_Start.test(c)}function isIdContinueChar(c){return c>='a'&&c<='z'||c>='A'&&c<='Z'||c>='0'&&c<='9'||c==='$'||c==='_'||c==='\u200C'||c==='\u200D'||unicode.ID_Continue.test(c)}function isDigit(c){return /[0-9]/.test(c)}function isHexDigit(c){return /[0-9A-Fa-f]/.test(c)}

View File

@@ -1,119 +0,0 @@
{
"_args": [
[
"json5@1.0.1",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "json5@1.0.1",
"_id": "json5@1.0.1",
"_inBundle": false,
"_integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"_location": "/webpack-cli/json5",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "json5@1.0.1",
"name": "json5",
"escapedName": "json5",
"rawSpec": "1.0.1",
"saveSpec": null,
"fetchSpec": "1.0.1"
},
"_requiredBy": [
"/webpack-cli/loader-utils"
],
"_resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"_spec": "1.0.1",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Aseem Kishore",
"email": "aseem.kishore@gmail.com"
},
"bin": {
"json5": "lib/cli.js"
},
"browser": "dist/index.js",
"bugs": {
"url": "https://github.com/json5/json5/issues"
},
"contributors": [
{
"name": "Max Nanasy",
"email": "max.nanasy@gmail.com"
},
{
"name": "Andrew Eisenberg",
"email": "andrew@eisenberg.as"
},
{
"name": "Jordan Tucker",
"email": "jordanbtucker@gmail.com"
}
],
"dependencies": {
"minimist": "^1.2.0"
},
"description": "JSON for humans.",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.1.5",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0",
"babelrc-rollup": "^3.0.0",
"coveralls": "^3.0.0",
"cross-env": "^5.1.4",
"del": "^3.0.0",
"eslint": "^4.18.2",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"mocha": "^5.0.4",
"nyc": "^11.4.1",
"regenerate": "^1.3.3",
"rollup": "^0.56.5",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-node-resolve": "^3.2.0",
"rollup-plugin-uglify": "^3.0.0",
"sinon": "^4.4.2",
"unicode-9.0.0": "^0.7.5"
},
"files": [
"lib/",
"dist/"
],
"homepage": "http://json5.org/",
"keywords": [
"json",
"json5",
"es5",
"es2015",
"ecmascript"
],
"license": "MIT",
"main": "lib/index.js",
"name": "json5",
"repository": {
"type": "git",
"url": "git+https://github.com/json5/json5.git"
},
"scripts": {
"build": "babel-node build/build.js && babel src -d lib && rollup -c",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint --fix build src",
"prepublishOnly": "npm run lint && npm test && npm run production",
"pretest": "cross-env NODE_ENV=test npm run build",
"preversion": "npm run lint && npm test && npm run production",
"production": "cross-env NODE_ENV=production npm run build",
"test": "nyc --reporter=html --reporter=text mocha"
},
"version": "1.0.1"
}

View File

@@ -1,67 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="1.2.3"></a>
## [1.2.3](https://github.com/webpack/loader-utils/compare/v1.2.2...v1.2.3) (2018-12-27)
### Bug Fixes
* **interpolateName:** don't interpolated `hashType` without `hash` or `contenthash` ([#140](https://github.com/webpack/loader-utils/issues/140)) ([3528fd9](https://github.com/webpack/loader-utils/commit/3528fd9))
<a name="1.2.2"></a>
## [1.2.2](https://github.com/webpack/loader-utils/compare/v1.2.1...v1.2.2) (2018-12-27)
### Bug Fixes
* fixed a hash type extracting in interpolateName ([#137](https://github.com/webpack/loader-utils/issues/137)) ([f8a71f4](https://github.com/webpack/loader-utils/commit/f8a71f4))
<a name="1.2.1"></a>
## [1.2.1](https://github.com/webpack/loader-utils/compare/v1.2.0...v1.2.1) (2018-12-25)
### Bug Fixes
* **isUrlRequest:** better handle absolute urls and non standards ([#134](https://github.com/webpack/loader-utils/issues/134)) ([aca43da](https://github.com/webpack/loader-utils/commit/aca43da))
### Reverts
* PR [#79](https://github.com/webpack/loader-utils/issues/79) ([#135](https://github.com/webpack/loader-utils/issues/135)) ([73d350a](https://github.com/webpack/loader-utils/commit/73d350a))
<a name="1.2.0"></a>
# [1.2.0](https://github.com/webpack/loader-utils/compare/v1.1.0...v1.2.0) (2018-12-24)
### Features
* **interpolateName:** support `[contenthash]`
### Fixes
* **urlToRequest:** empty urls are not rewritten to relative requests
* **urlToRequest:** don't rewrite absolute urls
* **isUrlRequest:** ignore all url with `extension` (like `moz-extension:`, `ms-browser-extension:` and etc)
* **isUrlRequest:** ignore `about:blank`
* **interpolateName:** failing explicitly when ran out of emoji
* **interpolateName:** `[hash]` token regex in interpolate string to capture any hash algorithm name
* **interpolateName:** parse string for emoji count before use
<a name="1.1.0"></a>
# [1.1.0](https://github.com/webpack/loader-utils/compare/v1.0.4...v1.1.0) (2017-03-16)
### Features
* **automatic-release:** Generation of automatic release ([7484d13](https://github.com/webpack/loader-utils/commit/7484d13))
* **parseQuery:** export parseQuery ([ddf64e4](https://github.com/webpack/loader-utils/commit/ddf64e4))

View File

@@ -1,20 +0,0 @@
Copyright JS Foundation and other contributors
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

@@ -1,255 +0,0 @@
# loader-utils
## Methods
### `getOptions`
Recommended way to retrieve the options of a loader invocation:
```javascript
// inside your loader
const options = loaderUtils.getOptions(this);
```
1. If `this.query` is a string:
- Tries to parse the query string and returns a new object
- Throws if it's not a valid query string
2. If `this.query` is object-like, it just returns `this.query`
3. In any other case, it just returns `null`
**Please note:** The returned `options` object is *read-only*. It may be re-used across multiple invocations.
If you pass it on to another library, make sure to make a *deep copy* of it:
```javascript
const options = Object.assign(
{},
defaultOptions,
loaderUtils.getOptions(this) // it is safe to pass null to Object.assign()
);
// don't forget nested objects or arrays
options.obj = Object.assign({}, options.obj);
options.arr = options.arr.slice();
someLibrary(options);
```
[clone](https://www.npmjs.com/package/clone) is a good library to make a deep copy of the options.
#### Options as query strings
If the loader options have been passed as loader query string (`loader?some&params`), the string is parsed by using [`parseQuery`](#parsequery).
### `parseQuery`
Parses a passed string (e.g. `loaderContext.resourceQuery`) as a query string, and returns an object.
``` javascript
const params = loaderUtils.parseQuery(this.resourceQuery); // resource: `file?param1=foo`
if (params.param1 === "foo") {
// do something
}
```
The string is parsed like this:
``` text
-> Error
? -> {}
?flag -> { flag: true }
?+flag -> { flag: true }
?-flag -> { flag: false }
?xyz=test -> { xyz: "test" }
?xyz=1 -> { xyz: "1" } // numbers are NOT parsed
?xyz[]=a -> { xyz: ["a"] }
?flag1&flag2 -> { flag1: true, flag2: true }
?+flag1,-flag2 -> { flag1: true, flag2: false }
?xyz[]=a,xyz[]=b -> { xyz: ["a", "b"] }
?a%2C%26b=c%2C%26d -> { "a,&b": "c,&d" }
?{data:{a:1},isJSON5:true} -> { data: { a: 1 }, isJSON5: true }
```
### `stringifyRequest`
Turns a request into a string that can be used inside `require()` or `import` while avoiding absolute paths.
Use it instead of `JSON.stringify(...)` if you're generating code inside a loader.
**Why is this necessary?** Since webpack calculates the hash before module paths are translated into module ids, we must avoid absolute paths to ensure
consistent hashes across different compilations.
This function:
- resolves absolute requests into relative requests if the request and the module are on the same hard drive
- replaces `\` with `/` if the request and the module are on the same hard drive
- won't change the path at all if the request and the module are on different hard drives
- applies `JSON.stringify` to the result
```javascript
loaderUtils.stringifyRequest(this, "./test.js");
// "\"./test.js\""
loaderUtils.stringifyRequest(this, ".\\test.js");
// "\"./test.js\""
loaderUtils.stringifyRequest(this, "test");
// "\"test\""
loaderUtils.stringifyRequest(this, "test/lib/index.js");
// "\"test/lib/index.js\""
loaderUtils.stringifyRequest(this, "otherLoader?andConfig!test?someConfig");
// "\"otherLoader?andConfig!test?someConfig\""
loaderUtils.stringifyRequest(this, require.resolve("test"));
// "\"../node_modules/some-loader/lib/test.js\""
loaderUtils.stringifyRequest(this, "C:\\module\\test.js");
// "\"../../test.js\"" (on Windows, in case the module and the request are on the same drive)
loaderUtils.stringifyRequest(this, "C:\\module\\test.js");
// "\"C:\\module\\test.js\"" (on Windows, in case the module and the request are on different drives)
loaderUtils.stringifyRequest(this, "\\\\network-drive\\test.js");
// "\"\\\\network-drive\\\\test.js\"" (on Windows, in case the module and the request are on different drives)
```
### `urlToRequest`
Converts some resource URL to a webpack module request.
> i Before call `urlToRequest` you need call `isUrlRequest` to ensure it is requestable url
```javascript
const url = "path/to/module.js";
if (loaderUtils.isUrlRequest(url)) {
// Logic for requestable url
const request = loaderUtils.urlToRequest(url);
} else {
// Logic for not requestable url
}
```
Simple example:
```javascript
const url = "path/to/module.js";
const request = loaderUtils.urlToRequest(url); // "./path/to/module.js"
```
#### Module URLs
Any URL containing a `~` will be interpreted as a module request. Anything after the `~` will be considered the request path.
```javascript
const url = "~path/to/module.js";
const request = loaderUtils.urlToRequest(url); // "path/to/module.js"
```
#### Root-relative URLs
URLs that are root-relative (start with `/`) can be resolved relative to some arbitrary path by using the `root` parameter:
```javascript
const url = "/path/to/module.js";
const root = "./root";
const request = loaderUtils.urlToRequest(url, root); // "./root/path/to/module.js"
```
To convert a root-relative URL into a module URL, specify a `root` value that starts with `~`:
```javascript
const url = "/path/to/module.js";
const root = "~";
const request = loaderUtils.urlToRequest(url, root); // "path/to/module.js"
```
### `interpolateName`
Interpolates a filename template using multiple placeholders and/or a regular expression.
The template and regular expression are set as query params called `name` and `regExp` on the current loader's context.
```javascript
const interpolatedName = loaderUtils.interpolateName(loaderContext, name, options);
```
The following tokens are replaced in the `name` parameter:
* `[ext]` the extension of the resource
* `[name]` the basename of the resource
* `[path]` the path of the resource relative to the `context` query parameter or option.
* `[folder]` the folder of the resource is in.
* `[emoji]` a random emoji representation of `options.content`
* `[emoji:<length>]` same as above, but with a customizable number of emojis
* `[contenthash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the md5 hash)
* `[<hashType>:contenthash:<digestType>:<length>]` optionally one can configure
* other `hashType`s, i. e. `sha1`, `md5`, `sha256`, `sha512`
* other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
* and `length` the length in chars
* `[hash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the md5 hash)
* `[<hashType>:hash:<digestType>:<length>]` optionally one can configure
* other `hashType`s, i. e. `sha1`, `md5`, `sha256`, `sha512`
* other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
* and `length` the length in chars
* `[N]` the N-th match obtained from matching the current file name against `options.regExp`
In loader context `[hash]` and `[contenthash]` are the same, but we recommend using `[contenthash]` for avoid misleading.
Examples
``` javascript
// loaderContext.resourcePath = "/app/js/javascript.js"
loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext]", { content: ... });
// => js/9473fdd0d880a43c21b7778d34872157.script.js
// loaderContext.resourcePath = "/app/js/javascript.js"
loaderUtils.interpolateName(loaderContext, "js/[contenthash].script.[ext]", { content: ... });
// => js/9473fdd0d880a43c21b7778d34872157.script.js
// loaderContext.resourcePath = "/app/page.html"
loaderUtils.interpolateName(loaderContext, "html-[hash:6].html", { content: ... });
// => html-9473fd.html
// loaderContext.resourcePath = "/app/flash.txt"
loaderUtils.interpolateName(loaderContext, "[hash]", { content: ... });
// => c31e9820c001c9c4a86bce33ce43b679
// loaderContext.resourcePath = "/app/img/image.gif"
loaderUtils.interpolateName(loaderContext, "[emoji]", { content: ... });
// => 👍
// loaderContext.resourcePath = "/app/img/image.gif"
loaderUtils.interpolateName(loaderContext, "[emoji:4]", { content: ... });
// => 🙍🏢📤🐝
// loaderContext.resourcePath = "/app/img/image.png"
loaderUtils.interpolateName(loaderContext, "[sha512:hash:base64:7].[ext]", { content: ... });
// => 2BKDTjl.png
// use sha512 hash instead of md5 and with only 7 chars of base64
// loaderContext.resourcePath = "/app/img/myself.png"
// loaderContext.query.name =
loaderUtils.interpolateName(loaderContext, "picture.png");
// => picture.png
// loaderContext.resourcePath = "/app/dir/file.png"
loaderUtils.interpolateName(loaderContext, "[path][name].[ext]?[hash]", { content: ... });
// => /app/dir/file.png?9473fdd0d880a43c21b7778d34872157
// loaderContext.resourcePath = "/app/js/page-home.js"
loaderUtils.interpolateName(loaderContext, "script-[1].[ext]", { regExp: "page-(.*)\\.js", content: ... });
// => script-home.js
```
### `getHashDigest`
``` javascript
const digestString = loaderUtils.getHashDigest(buffer, hashType, digestType, maxLength);
```
* `buffer` the content that should be hashed
* `hashType` one of `sha1`, `md5`, `sha256`, `sha512` or any other node.js supported hash type
* `digestType` one of `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
* `maxLength` the maximum length in chars
## License
MIT (http://www.opensource.org/licenses/mit-license.php)

View File

@@ -1,16 +0,0 @@
'use strict';
function getCurrentRequest(loaderContext) {
if (loaderContext.currentRequest) {
return loaderContext.currentRequest;
}
const request = loaderContext.loaders
.slice(loaderContext.loaderIndex)
.map((obj) => obj.request)
.concat([loaderContext.resource]);
return request.join('!');
}
module.exports = getCurrentRequest;

View File

@@ -1,69 +0,0 @@
'use strict';
const baseEncodeTables = {
26: 'abcdefghijklmnopqrstuvwxyz',
32: '123456789abcdefghjkmnpqrstuvwxyz', // no 0lio
36: '0123456789abcdefghijklmnopqrstuvwxyz',
49: 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no lIO
52: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no 0lIO
62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_',
};
function encodeBufferToBase(buffer, base) {
const encodeTable = baseEncodeTables[base];
if (!encodeTable) {
throw new Error('Unknown encoding base' + base);
}
const readLength = buffer.length;
const Big = require('big.js');
Big.RM = Big.DP = 0;
let b = new Big(0);
for (let i = readLength - 1; i >= 0; i--) {
b = b.times(256).plus(buffer[i]);
}
let output = '';
while (b.gt(0)) {
output = encodeTable[b.mod(base)] + output;
b = b.div(base);
}
Big.DP = 20;
Big.RM = 1;
return output;
}
function getHashDigest(buffer, hashType, digestType, maxLength) {
hashType = hashType || 'md5';
maxLength = maxLength || 9999;
const hash = require('crypto').createHash(hashType);
hash.update(buffer);
if (
digestType === 'base26' ||
digestType === 'base32' ||
digestType === 'base36' ||
digestType === 'base49' ||
digestType === 'base52' ||
digestType === 'base58' ||
digestType === 'base62' ||
digestType === 'base64'
) {
return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr(
0,
maxLength
);
} else {
return hash.digest(digestType || 'hex').substr(0, maxLength);
}
}
module.exports = getHashDigest;

View File

@@ -1,20 +0,0 @@
'use strict';
const parseQuery = require('./parseQuery');
function getOptions(loaderContext) {
const query = loaderContext.query;
if (typeof query === 'string' && query !== '') {
return parseQuery(loaderContext.query);
}
if (!query || typeof query !== 'object') {
// Not object-like queries are not supported.
return null;
}
return query;
}
module.exports = getOptions;

View File

@@ -1,16 +0,0 @@
'use strict';
function getRemainingRequest(loaderContext) {
if (loaderContext.remainingRequest) {
return loaderContext.remainingRequest;
}
const request = loaderContext.loaders
.slice(loaderContext.loaderIndex + 1)
.map((obj) => obj.request)
.concat([loaderContext.resource]);
return request.join('!');
}
module.exports = getRemainingRequest;

View File

@@ -1,23 +0,0 @@
'use strict';
const getOptions = require('./getOptions');
const parseQuery = require('./parseQuery');
const stringifyRequest = require('./stringifyRequest');
const getRemainingRequest = require('./getRemainingRequest');
const getCurrentRequest = require('./getCurrentRequest');
const isUrlRequest = require('./isUrlRequest');
const urlToRequest = require('./urlToRequest');
const parseString = require('./parseString');
const getHashDigest = require('./getHashDigest');
const interpolateName = require('./interpolateName');
exports.getOptions = getOptions;
exports.parseQuery = parseQuery;
exports.stringifyRequest = stringifyRequest;
exports.getRemainingRequest = getRemainingRequest;
exports.getCurrentRequest = getCurrentRequest;
exports.isUrlRequest = isUrlRequest;
exports.urlToRequest = urlToRequest;
exports.parseString = parseString;
exports.getHashDigest = getHashDigest;
exports.interpolateName = interpolateName;

View File

@@ -1,133 +0,0 @@
'use strict';
const path = require('path');
const emojisList = require('emojis-list');
const getHashDigest = require('./getHashDigest');
const emojiRegex = /[\uD800-\uDFFF]./;
const emojiList = emojisList.filter((emoji) => emojiRegex.test(emoji));
const emojiCache = {};
function encodeStringToEmoji(content, length) {
if (emojiCache[content]) {
return emojiCache[content];
}
length = length || 1;
const emojis = [];
do {
if (!emojiList.length) {
throw new Error('Ran out of emoji');
}
const index = Math.floor(Math.random() * emojiList.length);
emojis.push(emojiList[index]);
emojiList.splice(index, 1);
} while (--length > 0);
const emojiEncoding = emojis.join('');
emojiCache[content] = emojiEncoding;
return emojiEncoding;
}
function interpolateName(loaderContext, name, options) {
let filename;
if (typeof name === 'function') {
filename = name(loaderContext.resourcePath);
} else {
filename = name || '[hash].[ext]';
}
const context = options.context;
const content = options.content;
const regExp = options.regExp;
let ext = 'bin';
let basename = 'file';
let directory = '';
let folder = '';
if (loaderContext.resourcePath) {
const parsed = path.parse(loaderContext.resourcePath);
let resourcePath = loaderContext.resourcePath;
if (parsed.ext) {
ext = parsed.ext.substr(1);
}
if (parsed.dir) {
basename = parsed.name;
resourcePath = parsed.dir + path.sep;
}
if (typeof context !== 'undefined') {
directory = path
.relative(context, resourcePath + '_')
.replace(/\\/g, '/')
.replace(/\.\.(\/)?/g, '_$1');
directory = directory.substr(0, directory.length - 1);
} else {
directory = resourcePath.replace(/\\/g, '/').replace(/\.\.(\/)?/g, '_$1');
}
if (directory.length === 1) {
directory = '';
} else if (directory.length > 1) {
folder = path.basename(directory);
}
}
let url = filename;
if (content) {
// Match hash template
url = url
// `hash` and `contenthash` are same in `loader-utils` context
// let's keep `hash` for backward compatibility
.replace(
/\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
(all, hashType, digestType, maxLength) =>
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
)
.replace(/\[emoji(?::(\d+))?\]/gi, (all, length) =>
encodeStringToEmoji(content, parseInt(length, 10))
);
}
url = url
.replace(/\[ext\]/gi, () => ext)
.replace(/\[name\]/gi, () => basename)
.replace(/\[path\]/gi, () => directory)
.replace(/\[folder\]/gi, () => folder);
if (regExp && loaderContext.resourcePath) {
const match = loaderContext.resourcePath.match(new RegExp(regExp));
match &&
match.forEach((matched, i) => {
url = url.replace(new RegExp('\\[' + i + '\\]', 'ig'), matched);
});
}
if (
typeof loaderContext.options === 'object' &&
typeof loaderContext.options.customInterpolateName === 'function'
) {
url = loaderContext.options.customInterpolateName.call(
loaderContext,
url,
name,
options
);
}
return url;
}
module.exports = interpolateName;

View File

@@ -1,31 +0,0 @@
'use strict';
const path = require('path');
function isUrlRequest(url, root) {
// An URL is not an request if
// 1. It's an absolute url and it is not `windows` path like `C:\dir\file`
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) {
return false;
}
// 2. It's a protocol-relative
if (/^\/\//.test(url)) {
return false;
}
// 3. It's some kind of url for a template
if (/^[{}[\]#*;,'§$%&(=?`´^°<>]/.test(url)) {
return false;
}
// 4. It's also not an request if root isn't set and it's a root-relative url
if ((root === undefined || root === false) && /^\//.test(url)) {
return false;
}
return true;
}
module.exports = isUrlRequest;

View File

@@ -1,68 +0,0 @@
'use strict';
const JSON5 = require('json5');
const specialValues = {
null: null,
true: true,
false: false,
};
function parseQuery(query) {
if (query.substr(0, 1) !== '?') {
throw new Error(
"A valid query string passed to parseQuery should begin with '?'"
);
}
query = query.substr(1);
if (!query) {
return {};
}
if (query.substr(0, 1) === '{' && query.substr(-1) === '}') {
return JSON5.parse(query);
}
const queryArgs = query.split(/[,&]/g);
const result = {};
queryArgs.forEach((arg) => {
const idx = arg.indexOf('=');
if (idx >= 0) {
let name = arg.substr(0, idx);
let value = decodeURIComponent(arg.substr(idx + 1));
if (specialValues.hasOwnProperty(value)) {
value = specialValues[value];
}
if (name.substr(-2) === '[]') {
name = decodeURIComponent(name.substr(0, name.length - 2));
if (!Array.isArray(result[name])) {
result[name] = [];
}
result[name].push(value);
} else {
name = decodeURIComponent(name);
result[name] = value;
}
} else {
if (arg.substr(0, 1) === '-') {
result[decodeURIComponent(arg.substr(1))] = false;
} else if (arg.substr(0, 1) === '+') {
result[decodeURIComponent(arg.substr(1))] = true;
} else {
result[decodeURIComponent(arg)] = true;
}
}
});
return result;
}
module.exports = parseQuery;

View File

@@ -1,23 +0,0 @@
'use strict';
function parseString(str) {
try {
if (str[0] === '"') {
return JSON.parse(str);
}
if (str[0] === "'" && str.substr(str.length - 1) === "'") {
return parseString(
str
.replace(/\\.|"/g, (x) => (x === '"' ? '\\"' : x))
.replace(/^'|'$/g, '"')
);
}
return JSON.parse('"' + str + '"');
} catch (e) {
return str;
}
}
module.exports = parseString;

View File

@@ -1,51 +0,0 @@
'use strict';
const path = require('path');
const matchRelativePath = /^\.\.?[/\\]/;
function isAbsolutePath(str) {
return path.posix.isAbsolute(str) || path.win32.isAbsolute(str);
}
function isRelativePath(str) {
return matchRelativePath.test(str);
}
function stringifyRequest(loaderContext, request) {
const splitted = request.split('!');
const context =
loaderContext.context ||
(loaderContext.options && loaderContext.options.context);
return JSON.stringify(
splitted
.map((part) => {
// First, separate singlePath from query, because the query might contain paths again
const splittedPart = part.match(/^(.*?)(\?.*)/);
const query = splittedPart ? splittedPart[2] : '';
let singlePath = splittedPart ? splittedPart[1] : part;
if (isAbsolutePath(singlePath) && context) {
singlePath = path.relative(context, singlePath);
if (isAbsolutePath(singlePath)) {
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
// In this case, we leave the path platform-specific without replacing any separators.
// @see https://github.com/webpack/loader-utils/pull/14
return singlePath + query;
}
if (isRelativePath(singlePath) === false) {
// Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
singlePath = './' + singlePath;
}
}
return singlePath.replace(/\\/g, '/') + query;
})
.join('!')
);
}
module.exports = stringifyRequest;

View File

@@ -1,60 +0,0 @@
'use strict';
// we can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
function urlToRequest(url, root) {
// Do not rewrite an empty url
if (url === '') {
return '';
}
const moduleRequestRegex = /^[^?]*~/;
let request;
if (matchNativeWin32Path.test(url)) {
// absolute windows path, keep it
request = url;
} else if (root !== undefined && root !== false && /^\//.test(url)) {
// if root is set and the url is root-relative
switch (typeof root) {
// 1. root is a string: root is prefixed to the url
case 'string':
// special case: `~` roots convert to module request
if (moduleRequestRegex.test(root)) {
request = root.replace(/([^~/])$/, '$1/') + url.slice(1);
} else {
request = root + url;
}
break;
// 2. root is `true`: absolute paths are allowed
// *nix only, windows-style absolute paths are always allowed as they doesn't start with a `/`
case 'boolean':
request = url;
break;
default:
throw new Error(
"Unexpected parameters to loader-utils 'urlToRequest': url = " +
url +
', root = ' +
root +
'.'
);
}
} else if (/^\.\.?\//.test(url)) {
// A relative url stays
request = url;
} else {
// every other url is threaded like a relative url
request = './' + url;
}
// A `~` makes the url an module
if (moduleRequestRegex.test(request)) {
request = request.replace(moduleRequestRegex, '');
}
return request;
}
module.exports = urlToRequest;

View File

@@ -1,74 +0,0 @@
{
"_args": [
[
"loader-utils@1.2.3",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "loader-utils@1.2.3",
"_id": "loader-utils@1.2.3",
"_inBundle": false,
"_integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==",
"_location": "/webpack-cli/loader-utils",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "loader-utils@1.2.3",
"name": "loader-utils",
"escapedName": "loader-utils",
"rawSpec": "1.2.3",
"saveSpec": null,
"fetchSpec": "1.2.3"
},
"_requiredBy": [
"/webpack-cli"
],
"_resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz",
"_spec": "1.2.3",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/webpack/loader-utils/issues"
},
"dependencies": {
"big.js": "^5.2.2",
"emojis-list": "^2.0.0",
"json5": "^1.0.1"
},
"description": "utils for webpack loaders",
"devDependencies": {
"coveralls": "^3.0.2",
"eslint": "^5.11.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"jest": "^21.2.1",
"prettier": "^1.15.3",
"standard-version": "^4.0.0"
},
"engines": {
"node": ">=4.0.0"
},
"files": [
"lib"
],
"homepage": "https://github.com/webpack/loader-utils#readme",
"license": "MIT",
"main": "lib/index.js",
"name": "loader-utils",
"repository": {
"type": "git",
"url": "git+https://github.com/webpack/loader-utils.git"
},
"scripts": {
"lint": "eslint lib test",
"pretest": "yarn lint",
"release": "yarn test && standard-version",
"test": "jest",
"test:ci": "jest --coverage"
},
"version": "1.2.3"
}

View File

@@ -1,24 +0,0 @@
'use strict';
const path = require('path');
const pathExists = require('path-exists');
const pLocate = require('p-locate');
module.exports = (iterable, options) => {
options = Object.assign({
cwd: process.cwd()
}, options);
return pLocate(iterable, el => pathExists(path.resolve(options.cwd, el)), options);
};
module.exports.sync = (iterable, options) => {
options = Object.assign({
cwd: process.cwd()
}, options);
for (const el of iterable) {
if (pathExists.sync(path.resolve(options.cwd, el))) {
return el;
}
}
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -1,80 +0,0 @@
{
"_args": [
[
"locate-path@3.0.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "locate-path@3.0.0",
"_id": "locate-path@3.0.0",
"_inBundle": false,
"_integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
"_location": "/webpack-cli/locate-path",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "locate-path@3.0.0",
"name": "locate-path",
"escapedName": "locate-path",
"rawSpec": "3.0.0",
"saveSpec": null,
"fetchSpec": "3.0.0"
},
"_requiredBy": [
"/webpack-cli/find-up"
],
"_resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/locate-path/issues"
},
"dependencies": {
"p-locate": "^3.0.0",
"path-exists": "^3.0.0"
},
"description": "Get the first path that exists on disk of multiple paths",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/locate-path#readme",
"keywords": [
"locate",
"path",
"paths",
"file",
"files",
"exists",
"find",
"finder",
"search",
"searcher",
"array",
"iterable",
"iterator"
],
"license": "MIT",
"name": "locate-path",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/locate-path.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.0.0"
}

View File

@@ -1,99 +0,0 @@
# locate-path [![Build Status](https://travis-ci.org/sindresorhus/locate-path.svg?branch=master)](https://travis-ci.org/sindresorhus/locate-path)
> Get the first path that exists on disk of multiple paths
## Install
```
$ npm install locate-path
```
## Usage
Here we find the first file that exists on disk, in array order.
```js
const locatePath = require('locate-path');
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
(async () => {
console(await locatePath(files));
//=> 'rainbow'
})();
```
## API
### locatePath(input, [options])
Returns a `Promise` for the first path that exists or `undefined` if none exists.
#### input
Type: `Iterable<string>`
Paths to check.
#### options
Type: `Object`
##### concurrency
Type: `number`<br>
Default: `Infinity`<br>
Minimum: `1`
Number of concurrently pending promises.
##### preserveOrder
Type: `boolean`<br>
Default: `true`
Preserve `input` order when searching.
Disable this to improve performance if you don't care about the order.
##### cwd
Type: `string`<br>
Default: `process.cwd()`
Current working directory.
### locatePath.sync(input, [options])
Returns the first path that exists or `undefined` if none exists.
#### input
Type: `Iterable<string>`
Paths to check.
#### options
Type: `Object`
##### cwd
Same as above.
## Related
- [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1,29 +0,0 @@
export interface Limit {
/**
@param fn - Promise-returning/async function.
@param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
@returns The promise returned by calling `fn(...arguments)`.
*/
<Arguments extends unknown[], ReturnType>(
fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
...arguments: Arguments
): Promise<ReturnType>;
/**
The number of promises that are currently running.
*/
readonly activeCount: number;
/**
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
readonly pendingCount: number;
}
/**
Run multiple promise-returning & async functions with limited concurrency.
@param concurrency - Concurrency limit. Minimum: `1`.
@returns A `limit` function.
*/
export default function pLimit(concurrency: number): Limit;

View File

@@ -1,52 +0,0 @@
'use strict';
const pTry = require('p-try');
const pLimit = concurrency => {
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
return Promise.reject(new TypeError('Expected `concurrency` to be a number from 1 and up'));
}
const queue = [];
let activeCount = 0;
const next = () => {
activeCount--;
if (queue.length > 0) {
queue.shift()();
}
};
const run = (fn, resolve, ...args) => {
activeCount++;
const result = pTry(fn, ...args);
resolve(result);
result.then(next, next);
};
const enqueue = (fn, resolve, ...args) => {
if (activeCount < concurrency) {
run(fn, resolve, ...args);
} else {
queue.push(run.bind(null, fn, resolve, ...args));
}
};
const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args));
Object.defineProperties(generator, {
activeCount: {
get: () => activeCount
},
pendingCount: {
get: () => queue.length
}
});
return generator;
};
module.exports = pLimit;
module.exports.default = pLimit;

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -1,88 +0,0 @@
{
"_args": [
[
"p-limit@2.2.2",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "p-limit@2.2.2",
"_id": "p-limit@2.2.2",
"_inBundle": false,
"_integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==",
"_location": "/webpack-cli/p-limit",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "p-limit@2.2.2",
"name": "p-limit",
"escapedName": "p-limit",
"rawSpec": "2.2.2",
"saveSpec": null,
"fetchSpec": "2.2.2"
},
"_requiredBy": [
"/webpack-cli/p-locate"
],
"_resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz",
"_spec": "2.2.2",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/p-limit/issues"
},
"dependencies": {
"p-try": "^2.0.0"
},
"description": "Run multiple promise-returning & async functions with limited concurrency",
"devDependencies": {
"ava": "^1.2.1",
"delay": "^4.1.0",
"in-range": "^1.0.0",
"random-int": "^1.0.0",
"time-span": "^2.0.0",
"tsd-check": "^0.3.0",
"xo": "^0.24.0"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js",
"index.d.ts"
],
"funding": "https://github.com/sponsors/sindresorhus",
"homepage": "https://github.com/sindresorhus/p-limit#readme",
"keywords": [
"promise",
"limit",
"limited",
"concurrency",
"throttle",
"throat",
"rate",
"batch",
"ratelimit",
"task",
"queue",
"async",
"await",
"promises",
"bluebird"
],
"license": "MIT",
"name": "p-limit",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/p-limit.git"
},
"scripts": {
"test": "xo && ava && tsd-check"
},
"version": "2.2.2"
}

View File

@@ -1,93 +0,0 @@
# p-limit [![Build Status](https://travis-ci.org/sindresorhus/p-limit.svg?branch=master)](https://travis-ci.org/sindresorhus/p-limit)
> Run multiple promise-returning & async functions with limited concurrency
## Install
```
$ npm install p-limit
```
## Usage
```js
const pLimit = require('p-limit');
const limit = pLimit(1);
const input = [
limit(() => fetchSomething('foo')),
limit(() => fetchSomething('bar')),
limit(() => doSomething())
];
(async () => {
// Only one promise is run at once
const result = await Promise.all(input);
console.log(result);
})();
```
## API
### pLimit(concurrency)
Returns a `limit` function.
#### concurrency
Type: `number`\
Minimum: `1`\
Default: `Infinity`
Concurrency limit.
### limit(fn, ...args)
Returns the promise returned by calling `fn(...args)`.
#### fn
Type: `Function`
Promise-returning/async function.
#### args
Any arguments to pass through to `fn`.
Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
### limit.activeCount
The number of promises that are currently running.
### limit.pendingCount
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
## FAQ
### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?
This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
## Related
- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
- [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [More…](https://github.com/sindresorhus/promise-fun)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-p-limit?utm_source=npm-p-limit&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

View File

@@ -1,34 +0,0 @@
'use strict';
const pLimit = require('p-limit');
class EndError extends Error {
constructor(value) {
super();
this.value = value;
}
}
// The input can also be a promise, so we `Promise.resolve()` it
const testElement = (el, tester) => Promise.resolve(el).then(tester);
// The input can also be a promise, so we `Promise.all()` them both
const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0])));
module.exports = (iterable, tester, opts) => {
opts = Object.assign({
concurrency: Infinity,
preserveOrder: true
}, opts);
const limit = pLimit(opts.concurrency);
// Start all the promises concurrently with optional limit
const items = [...iterable].map(el => [el, limit(testElement, el, tester)]);
// Check the promises either serially or concurrently
const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity);
return Promise.all(items.map(el => checkLimit(finder, el)))
.then(() => {})
.catch(err => err instanceof EndError ? err.value : Promise.reject(err));
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -1,87 +0,0 @@
{
"_args": [
[
"p-locate@3.0.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "p-locate@3.0.0",
"_id": "p-locate@3.0.0",
"_inBundle": false,
"_integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
"_location": "/webpack-cli/p-locate",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "p-locate@3.0.0",
"name": "p-locate",
"escapedName": "p-locate",
"rawSpec": "3.0.0",
"saveSpec": null,
"fetchSpec": "3.0.0"
},
"_requiredBy": [
"/webpack-cli/locate-path"
],
"_resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/p-locate/issues"
},
"dependencies": {
"p-limit": "^2.0.0"
},
"description": "Get the first fulfilled promise that satisfies the provided testing function",
"devDependencies": {
"ava": "*",
"delay": "^3.0.0",
"in-range": "^1.0.0",
"time-span": "^2.0.0",
"xo": "*"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/p-locate#readme",
"keywords": [
"promise",
"locate",
"find",
"finder",
"search",
"searcher",
"test",
"array",
"collection",
"iterable",
"iterator",
"race",
"fulfilled",
"fastest",
"async",
"await",
"promises",
"bluebird"
],
"license": "MIT",
"name": "p-locate",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/p-locate.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.0.0"
}

View File

@@ -1,88 +0,0 @@
# p-locate [![Build Status](https://travis-ci.org/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.org/sindresorhus/p-locate)
> Get the first fulfilled promise that satisfies the provided testing function
Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
## Install
```
$ npm install p-locate
```
## Usage
Here we find the first file that exists on disk, in array order.
```js
const pathExists = require('path-exists');
const pLocate = require('p-locate');
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
(async () => {
const foundPath = await pLocate(files, file => pathExists(file));
console.log(foundPath);
//=> 'rainbow'
})();
```
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
## API
### pLocate(input, tester, [options])
Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
#### input
Type: `Iterable<Promise|any>`
#### tester(element)
Type: `Function`
Expected to return a `Promise<boolean>` or boolean.
#### options
Type: `Object`
##### concurrency
Type: `number`<br>
Default: `Infinity`<br>
Minimum: `1`
Number of concurrently pending promises returned by `tester`.
##### preserveOrder
Type: `boolean`<br>
Default: `true`
Preserve `input` order when searching.
Disable this to improve performance if you don't care about the order.
## Related
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled
- [More…](https://github.com/sindresorhus/promise-fun)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1,39 +0,0 @@
declare const pTry: {
/**
Start a promise chain.
@param fn - The function to run to start the promise chain.
@param arguments - Arguments to pass to `fn`.
@returns The value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
@example
```
import pTry = require('p-try');
(async () => {
try {
const value = await pTry(() => {
return synchronousFunctionThatMightThrow();
});
console.log(value);
} catch (error) {
console.error(error);
}
})();
```
*/
<ValueType, ArgumentsType extends unknown[]>(
fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
...arguments: ArgumentsType
): Promise<ValueType>;
// TODO: remove this in the next major version, refactor the whole definition to:
// declare function pTry<ValueType, ArgumentsType extends unknown[]>(
// fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
// ...arguments: ArgumentsType
// ): Promise<ValueType>;
// export = pTry;
default: typeof pTry;
};
export = pTry;

View File

@@ -1,9 +0,0 @@
'use strict';
const pTry = (fn, ...arguments_) => new Promise(resolve => {
resolve(fn(...arguments_));
});
module.exports = pTry;
// TODO: remove this in the next major version
module.exports.default = pTry;

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

View File

@@ -1,78 +0,0 @@
{
"_args": [
[
"p-try@2.2.0",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "p-try@2.2.0",
"_id": "p-try@2.2.0",
"_inBundle": false,
"_integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"_location": "/webpack-cli/p-try",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "p-try@2.2.0",
"name": "p-try",
"escapedName": "p-try",
"rawSpec": "2.2.0",
"saveSpec": null,
"fetchSpec": "2.2.0"
},
"_requiredBy": [
"/webpack-cli/p-limit"
],
"_resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"_spec": "2.2.0",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/p-try/issues"
},
"description": "`Start a promise chain",
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/p-try#readme",
"keywords": [
"promise",
"try",
"resolve",
"function",
"catch",
"async",
"await",
"promises",
"settled",
"ponyfill",
"polyfill",
"shim",
"bluebird"
],
"license": "MIT",
"name": "p-try",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/p-try.git"
},
"scripts": {
"test": "xo && ava && tsd"
},
"version": "2.2.0"
}

View File

@@ -1,58 +0,0 @@
# p-try [![Build Status](https://travis-ci.org/sindresorhus/p-try.svg?branch=master)](https://travis-ci.org/sindresorhus/p-try)
> Start a promise chain
[How is it useful?](http://cryto.net/~joepie91/blog/2016/05/11/what-is-promise-try-and-why-does-it-matter/)
## Install
```
$ npm install p-try
```
## Usage
```js
const pTry = require('p-try');
(async () => {
try {
const value = await pTry(() => {
return synchronousFunctionThatMightThrow();
});
console.log(value);
} catch (error) {
console.error(error);
}
})();
```
## API
### pTry(fn, ...arguments)
Returns a `Promise` resolved with the value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
#### fn
The function to run to start the promise chain.
#### arguments
Arguments to pass to `fn`.
## Related
- [p-finally](https://github.com/sindresorhus/p-finally) - `Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
- [More…](https://github.com/sindresorhus/promise-fun)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -2,6 +2,19 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [13.3.0](https://www.github.com/yargs/yargs/compare/v13.2.4...v13.3.0) (2019-06-10)
### Bug Fixes
* **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b))
### Features
* **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b))
* support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c))
### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13)

Some files were not shown because too many files have changed in this diff Show More