new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* Return array of browsers by selection queries.
|
||||
*
|
||||
* ```js
|
||||
* browserslist('IE >= 10, IE 8') //=> ['ie 11', 'ie 10', 'ie 8']
|
||||
* ```
|
||||
*
|
||||
* @param queries Browser queries.
|
||||
* @param opts Options.
|
||||
* @returns Array with browser names in Can I Use.
|
||||
*/
|
||||
declare function browserslist(
|
||||
queries?: string | readonly string[] | null,
|
||||
opts?: browserslist.Options
|
||||
): string[]
|
||||
|
||||
declare namespace browserslist {
|
||||
interface Query {
|
||||
compose: 'or' | 'and'
|
||||
type: string
|
||||
query: string
|
||||
not?: true
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Path to processed file. It will be used to find config files.
|
||||
*/
|
||||
path?: string | false
|
||||
/**
|
||||
* Processing environment. It will be used to take right queries
|
||||
* from config file.
|
||||
*/
|
||||
env?: string
|
||||
/**
|
||||
* Custom browser usage statistics for "> 1% in my stats" query.
|
||||
*/
|
||||
stats?: Stats | string
|
||||
/**
|
||||
* Path to config file with queries.
|
||||
*/
|
||||
config?: string
|
||||
/**
|
||||
* Do not throw on unknown version in direct query.
|
||||
*/
|
||||
ignoreUnknownVersions?: boolean
|
||||
/**
|
||||
* Throw an error if env is not found.
|
||||
*/
|
||||
throwOnMissing?: boolean
|
||||
/**
|
||||
* Disable security checks for extend query.
|
||||
*/
|
||||
dangerousExtend?: boolean
|
||||
/**
|
||||
* Alias mobile browsers to the desktop version when Can I Use
|
||||
* doesn’t have data about the specified version.
|
||||
*/
|
||||
mobileToDesktop?: boolean
|
||||
}
|
||||
|
||||
type Config = {
|
||||
defaults: string[]
|
||||
[section: string]: string[] | undefined
|
||||
}
|
||||
|
||||
interface Stats {
|
||||
[browser: string]: {
|
||||
[version: string]: number
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Browser names aliases.
|
||||
*/
|
||||
let aliases: {
|
||||
[alias: string]: string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Aliases to work with joined versions like `ios_saf 7.0-7.1`.
|
||||
*/
|
||||
let versionAliases: {
|
||||
[browser: string]:
|
||||
| {
|
||||
[version: string]: string | undefined
|
||||
}
|
||||
| undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Can I Use only provides a few versions for some browsers (e.g. `and_chr`).
|
||||
*
|
||||
* Fallback to a similar browser for unknown versions.
|
||||
*/
|
||||
let desktopNames: {
|
||||
[browser: string]: string | undefined
|
||||
}
|
||||
|
||||
let data: {
|
||||
[browser: string]:
|
||||
| {
|
||||
name: string
|
||||
versions: string[]
|
||||
released: string[]
|
||||
releaseDate: {
|
||||
[version: string]: number | undefined | null
|
||||
}
|
||||
}
|
||||
| undefined
|
||||
}
|
||||
|
||||
let nodeVersions: string[]
|
||||
|
||||
interface Usage {
|
||||
[version: string]: number
|
||||
}
|
||||
|
||||
let usage: {
|
||||
global?: Usage
|
||||
custom?: Usage | null
|
||||
[country: string]: Usage | undefined | null
|
||||
}
|
||||
|
||||
let cache: {
|
||||
[feature: string]: {
|
||||
[name: string]: 'y' | 'n'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default browsers query
|
||||
*/
|
||||
let defaults: readonly string[]
|
||||
|
||||
/**
|
||||
* Which statistics should be used. Country code or custom statistics.
|
||||
* Pass `"my stats"` to load statistics from `Browserslist` files.
|
||||
*/
|
||||
type StatsOptions = string | 'my stats' | Stats | { dataByBrowser: Stats }
|
||||
|
||||
/**
|
||||
* Return browsers market coverage.
|
||||
*
|
||||
* ```js
|
||||
* browserslist.coverage(browserslist('> 1% in US'), 'US') //=> 83.1
|
||||
* ```
|
||||
*
|
||||
* @param browsers Browsers names in Can I Use.
|
||||
* @param stats Which statistics should be used.
|
||||
* @returns Total market coverage for all selected browsers.
|
||||
*/
|
||||
function coverage(browsers: readonly string[], stats?: StatsOptions): number
|
||||
|
||||
/**
|
||||
* Get queries AST to analyze the config content.
|
||||
*
|
||||
* @param queries Browser queries.
|
||||
* @param opts Options.
|
||||
* @returns An array of the data of each query in the config.
|
||||
*/
|
||||
function parse(
|
||||
queries?: string | readonly string[] | null,
|
||||
opts?: browserslist.Options
|
||||
): Query[]
|
||||
|
||||
function clearCaches(): void
|
||||
|
||||
function parseConfig(string: string): Config
|
||||
|
||||
function readConfig(file: string): Config
|
||||
|
||||
function findConfig(...pathSegments: string[]): Config | undefined
|
||||
|
||||
interface LoadConfigOptions {
|
||||
config?: string
|
||||
path?: string
|
||||
env?: string
|
||||
}
|
||||
|
||||
function loadConfig(options: LoadConfigOptions): string[] | undefined
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
BROWSERSLIST?: string
|
||||
BROWSERSLIST_CONFIG?: string
|
||||
BROWSERSLIST_DANGEROUS_EXTEND?: string
|
||||
BROWSERSLIST_DISABLE_CACHE?: string
|
||||
BROWSERSLIST_ENV?: string
|
||||
BROWSERSLIST_IGNORE_OLD_DATA?: string
|
||||
BROWSERSLIST_STATS?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export = browserslist
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "async-retry",
|
||||
"version": "1.3.3",
|
||||
"description": "Retrying made simple, easy and async",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
"test": "yarn run test-lint && yarn run test-unit",
|
||||
"test-lint": "eslint .",
|
||||
"test-unit": "ava",
|
||||
"lint:staged": "lint-staged"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "vercel/async-retry",
|
||||
"ava": {
|
||||
"failFast": true
|
||||
},
|
||||
"dependencies": {
|
||||
"retry": "0.13.1"
|
||||
},
|
||||
"pre-commit": "lint:staged",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint",
|
||||
"prettier --write --single-quote",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"airbnb",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"no-var": 0,
|
||||
"prefer-arrow-callback": 0
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "3.15.0",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-airbnb": "18.2.1",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-import": "2.24.0",
|
||||
"eslint-plugin-jsx-a11y": "6.4.1",
|
||||
"eslint-plugin-react": "7.24.0",
|
||||
"lint-staged": "11.1.2",
|
||||
"node-fetch": "2.6.1",
|
||||
"pre-commit": "1.2.2",
|
||||
"prettier": "2.3.2",
|
||||
"then-sleep": "1.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "formdata-polyfill",
|
||||
"version": "4.0.10",
|
||||
"description": "HTML5 `FormData` for Browsers and Node.",
|
||||
"type": "module",
|
||||
"main": "formdata.min.js",
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"test": "node test/test-esm.js",
|
||||
"test-wpt": "node --experimental-loader ./test/http-loader.js ./test/test-wpt-in-node.js",
|
||||
"test-polyfill": "php -S localhost:4445 & open http://localhost:4445/test/test-polyfill.html"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://jimmywarting@github.com/jimmywarting/FormData.git"
|
||||
},
|
||||
"files": [
|
||||
"esm.min.js",
|
||||
"esm.min.d.ts",
|
||||
"FormData.js",
|
||||
"formdata-to-blob.js",
|
||||
"formdata.min.js",
|
||||
"README.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
},
|
||||
"keywords": [
|
||||
"formdata",
|
||||
"fetch",
|
||||
"node-fetch",
|
||||
"html5",
|
||||
"browser",
|
||||
"polyfill"
|
||||
],
|
||||
"author": "Jimmy Wärting",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jimmywarting/FormData/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jimmywarting/FormData#readme",
|
||||
"dependencies": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/google-closure-compiler": "^0.0.19",
|
||||
"@types/node": "^16.7.10",
|
||||
"google-closure-compiler": "^20210808.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const VERSION = "5.0.5";
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare const digitMapping: Record<string, ReadonlyArray<string>>;
|
||||
//# sourceMappingURL=digit-mapping.generated.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"1":"hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB EC FC"},D:{"1":"PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB"},E:{"1":"B C K L G qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F A HC zB IC JC KC LC 0B"},F:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB PC QC RC SC qB AC TC rB"},G:{"1":"eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC aC bC cC","16":"dC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","2":"AD"}},B:1,C:"unhandledrejection/rejectionhandled events"};
|
||||
@@ -0,0 +1,109 @@
|
||||
import fs from 'node:fs';
|
||||
import { EOL } from 'node:os';
|
||||
import _ from 'lodash';
|
||||
import gitUrlParse from 'git-url-parse';
|
||||
import semver from 'semver';
|
||||
import osName from 'os-name';
|
||||
import Log from './log.js';
|
||||
|
||||
const readJSON = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
|
||||
const pkg = readJSON(new URL('../package.json', import.meta.url));
|
||||
|
||||
const log = new Log();
|
||||
|
||||
const getSystemInfo = () => {
|
||||
return {
|
||||
'release-it': pkg.version,
|
||||
node: process.version,
|
||||
os: osName()
|
||||
};
|
||||
};
|
||||
|
||||
const format = (template = '', context = {}) => {
|
||||
try {
|
||||
return _.template(template)(context);
|
||||
} catch (error) {
|
||||
log.error(`Unable to render template with context:\n${template}\n${JSON.stringify(context)}`);
|
||||
log.error(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const truncateLines = (input, maxLines = 10, surplusText = null) => {
|
||||
const lines = input.split(EOL);
|
||||
const surplus = lines.length - maxLines;
|
||||
const output = lines.slice(0, maxLines).join(EOL);
|
||||
return surplus > 0 ? (surplusText ? `${output}${surplusText}` : `${output}${EOL}...and ${surplus} more`) : output;
|
||||
};
|
||||
|
||||
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
const rejectAfter = (ms, error) =>
|
||||
wait(ms).then(() => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
const parseGitUrl = remoteUrl => {
|
||||
if (!remoteUrl) return { host: null, owner: null, project: null, protocol: null, remote: null, repository: null };
|
||||
const normalizedUrl = (remoteUrl || '')
|
||||
.replace(/^[A-Z]:\\\\/, 'file://') // Assume file protocol for Windows drive letters
|
||||
.replace(/^\//, 'file://') // Assume file protocol if only /path is given
|
||||
.replace(/\\+/g, '/'); // Replace forward with backslashes
|
||||
const parsedUrl = gitUrlParse(normalizedUrl);
|
||||
const { resource: host, name: project, protocol, href: remote } = parsedUrl;
|
||||
const owner = protocol === 'file' ? _.last(parsedUrl.owner.split('/')) : parsedUrl.owner; // Fix owner for file protocol
|
||||
const repository = `${owner}/${project}`;
|
||||
return { host, owner, project, protocol, remote, repository };
|
||||
};
|
||||
|
||||
const reduceUntil = async (collection, fn) => {
|
||||
let result;
|
||||
for (const item of collection) {
|
||||
if (result) break;
|
||||
result = await fn(item);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const hasAccess = path => {
|
||||
try {
|
||||
fs.accessSync(path);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const parseVersion = raw => {
|
||||
if (raw == null) return { version: raw, isPreRelease: false, preReleaseId: null };
|
||||
const version = semver.valid(raw) ? raw : semver.coerce(raw);
|
||||
if (!version) return { version: raw, isPreRelease: false, preReleaseId: null };
|
||||
const parsed = semver.parse(version);
|
||||
const isPreRelease = parsed.prerelease.length > 0;
|
||||
const preReleaseId = isPreRelease && isNaN(parsed.prerelease[0]) ? parsed.prerelease[0] : null;
|
||||
return {
|
||||
version: version.toString(),
|
||||
isPreRelease,
|
||||
preReleaseId
|
||||
};
|
||||
};
|
||||
|
||||
const e = (message, docs, fail = true) => {
|
||||
const error = new Error(docs ? `${message}${EOL}Documentation: ${docs}${EOL}` : message);
|
||||
error.code = fail ? 1 : 0;
|
||||
return error;
|
||||
};
|
||||
|
||||
export {
|
||||
getSystemInfo,
|
||||
format,
|
||||
truncateLines,
|
||||
rejectAfter,
|
||||
reduceUntil,
|
||||
parseGitUrl,
|
||||
hasAccess,
|
||||
parseVersion,
|
||||
readJSON,
|
||||
e
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict'
|
||||
|
||||
const u = require('universalify').fromCallback
|
||||
const path = require('path')
|
||||
const fs = require('graceful-fs')
|
||||
const mkdir = require('../mkdirs')
|
||||
const pathExists = require('../path-exists').pathExists
|
||||
|
||||
function createFile (file, callback) {
|
||||
function makeFile () {
|
||||
fs.writeFile(file, '', err => {
|
||||
if (err) return callback(err)
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
fs.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
|
||||
if (!err && stats.isFile()) return callback()
|
||||
const dir = path.dirname(file)
|
||||
pathExists(dir, (err, dirExists) => {
|
||||
if (err) return callback(err)
|
||||
if (dirExists) return makeFile()
|
||||
mkdir.mkdirs(dir, err => {
|
||||
if (err) return callback(err)
|
||||
makeFile()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createFileSync (file) {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.statSync(file)
|
||||
} catch (e) {}
|
||||
if (stats && stats.isFile()) return
|
||||
|
||||
const dir = path.dirname(file)
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, '')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createFile: u(createFile),
|
||||
createFileSync
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { __extends } from "tslib";
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
var QueueScheduler = (function (_super) {
|
||||
__extends(QueueScheduler, _super);
|
||||
function QueueScheduler() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return QueueScheduler;
|
||||
}(AsyncScheduler));
|
||||
export { QueueScheduler };
|
||||
//# sourceMappingURL=QueueScheduler.js.map
|
||||
@@ -0,0 +1,76 @@
|
||||
# plugin-rest-endpoint-methods.js
|
||||
|
||||
> Octokit plugin adding one method for all of api.github.com REST API endpoints
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/plugin-rest-endpoint-methods)
|
||||
[](https://github.com/octokit/plugin-rest-endpoint-methods.js/actions?workflow=Test)
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/plugin-rest-endpoint-methods` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [cdn.skypack.dev](https://cdn.skypack.dev)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
|
||||
import { restEndpointMethods } from "https://cdn.skypack.dev/@octokit/plugin-rest-endpoint-methods";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with `npm install @octokit/core @octokit/plugin-rest-endpoint-methods`. Optionally replace `@octokit/core` with a compatible module
|
||||
|
||||
```js
|
||||
const { Octokit } = require("@octokit/core");
|
||||
const {
|
||||
restEndpointMethods,
|
||||
} = require("@octokit/plugin-rest-endpoint-methods");
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.plugin(restEndpointMethods);
|
||||
const octokit = new MyOctokit({ auth: "secret123" });
|
||||
|
||||
// https://developer.github.com/v3/users/#get-the-authenticated-user
|
||||
octokit.rest.users.getAuthenticated();
|
||||
```
|
||||
|
||||
There is one method for each REST API endpoint documented at [https://developer.github.com/v3](https://developer.github.com/v3). All endpoint methods are documented in the [docs/](docs/) folder, e.g. [docs/users/getAuthenticated.md](docs/users/getAuthenticated.md)
|
||||
|
||||
## TypeScript
|
||||
|
||||
Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`.
|
||||
|
||||
Example
|
||||
|
||||
```ts
|
||||
import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
|
||||
|
||||
type UpdateLabelParameters =
|
||||
RestEndpointMethodTypes["issues"]["updateLabel"]["parameters"];
|
||||
type UpdateLabelResponse =
|
||||
RestEndpointMethodTypes["issues"]["updateLabel"]["response"];
|
||||
```
|
||||
|
||||
In order to get types beyond parameters and responses, check out [`@octokit/openapi-types`](https://github.com/octokit/openapi-types.ts/#readme), which is a direct transpilation from GitHub's official OpenAPI specification.
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
@@ -0,0 +1,240 @@
|
||||
Overview [](https://travis-ci.org/lydell/js-tokens)
|
||||
========
|
||||
|
||||
A regex that tokenizes JavaScript.
|
||||
|
||||
```js
|
||||
var jsTokens = require("js-tokens").default
|
||||
|
||||
var jsString = "var foo=opts.foo;\n..."
|
||||
|
||||
jsString.match(jsTokens)
|
||||
// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]
|
||||
```
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
`npm install js-tokens`
|
||||
|
||||
```js
|
||||
import jsTokens from "js-tokens"
|
||||
// or:
|
||||
var jsTokens = require("js-tokens").default
|
||||
```
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
### `jsTokens` ###
|
||||
|
||||
A regex with the `g` flag that matches JavaScript tokens.
|
||||
|
||||
The regex _always_ matches, even invalid JavaScript and the empty string.
|
||||
|
||||
The next match is always directly after the previous.
|
||||
|
||||
### `var token = matchToToken(match)` ###
|
||||
|
||||
```js
|
||||
import {matchToToken} from "js-tokens"
|
||||
// or:
|
||||
var matchToToken = require("js-tokens").matchToToken
|
||||
```
|
||||
|
||||
Takes a `match` returned by `jsTokens.exec(string)`, and returns a `{type:
|
||||
String, value: String}` object. The following types are available:
|
||||
|
||||
- string
|
||||
- comment
|
||||
- regex
|
||||
- number
|
||||
- name
|
||||
- punctuator
|
||||
- whitespace
|
||||
- invalid
|
||||
|
||||
Multi-line comments and strings also have a `closed` property indicating if the
|
||||
token was closed or not (see below).
|
||||
|
||||
Comments and strings both come in several flavors. To distinguish them, check if
|
||||
the token starts with `//`, `/*`, `'`, `"` or `` ` ``.
|
||||
|
||||
Names are ECMAScript IdentifierNames, that is, including both identifiers and
|
||||
keywords. You may use [is-keyword-js] to tell them apart.
|
||||
|
||||
Whitespace includes both line terminators and other whitespace.
|
||||
|
||||
[is-keyword-js]: https://github.com/crissdev/is-keyword-js
|
||||
|
||||
|
||||
ECMAScript support
|
||||
==================
|
||||
|
||||
The intention is to always support the latest ECMAScript version whose feature
|
||||
set has been finalized.
|
||||
|
||||
If adding support for a newer version requires changes, a new version with a
|
||||
major verion bump will be released.
|
||||
|
||||
Currently, ECMAScript 2018 is supported.
|
||||
|
||||
|
||||
Invalid code handling
|
||||
=====================
|
||||
|
||||
Unterminated strings are still matched as strings. JavaScript strings cannot
|
||||
contain (unescaped) newlines, so unterminated strings simply end at the end of
|
||||
the line. Unterminated template strings can contain unescaped newlines, though,
|
||||
so they go on to the end of input.
|
||||
|
||||
Unterminated multi-line comments are also still matched as comments. They
|
||||
simply go on to the end of the input.
|
||||
|
||||
Unterminated regex literals are likely matched as division and whatever is
|
||||
inside the regex.
|
||||
|
||||
Invalid ASCII characters have their own capturing group.
|
||||
|
||||
Invalid non-ASCII characters are treated as names, to simplify the matching of
|
||||
names (except unicode spaces which are treated as whitespace). Note: See also
|
||||
the [ES2018](#es2018) section.
|
||||
|
||||
Regex literals may contain invalid regex syntax. They are still matched as
|
||||
regex literals. They may also contain repeated regex flags, to keep the regex
|
||||
simple.
|
||||
|
||||
Strings may contain invalid escape sequences.
|
||||
|
||||
|
||||
Limitations
|
||||
===========
|
||||
|
||||
Tokenizing JavaScript using regexes—in fact, _one single regex_—won’t be
|
||||
perfect. But that’s not the point either.
|
||||
|
||||
You may compare jsTokens with [esprima] by using `esprima-compare.js`.
|
||||
See `npm run esprima-compare`!
|
||||
|
||||
[esprima]: http://esprima.org/
|
||||
|
||||
### Template string interpolation ###
|
||||
|
||||
Template strings are matched as single tokens, from the starting `` ` `` to the
|
||||
ending `` ` ``, including interpolations (whose tokens are not matched
|
||||
individually).
|
||||
|
||||
Matching template string interpolations requires recursive balancing of `{` and
|
||||
`}`—something that JavaScript regexes cannot do. Only one level of nesting is
|
||||
supported.
|
||||
|
||||
### Division and regex literals collision ###
|
||||
|
||||
Consider this example:
|
||||
|
||||
```js
|
||||
var g = 9.82
|
||||
var number = bar / 2/g
|
||||
|
||||
var regex = / 2/g
|
||||
```
|
||||
|
||||
A human can easily understand that in the `number` line we’re dealing with
|
||||
division, and in the `regex` line we’re dealing with a regex literal. How come?
|
||||
Because humans can look at the whole code to put the `/` characters in context.
|
||||
A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also
|
||||
look backwards. See the [ES2018](#es2018) section).
|
||||
|
||||
When the `jsTokens` regex scans throught the above, it will see the following
|
||||
at the end of both the `number` and `regex` rows:
|
||||
|
||||
```js
|
||||
/ 2/g
|
||||
```
|
||||
|
||||
It is then impossible to know if that is a regex literal, or part of an
|
||||
expression dealing with division.
|
||||
|
||||
Here is a similar case:
|
||||
|
||||
```js
|
||||
foo /= 2/g
|
||||
foo(/= 2/g)
|
||||
```
|
||||
|
||||
The first line divides the `foo` variable with `2/g`. The second line calls the
|
||||
`foo` function with the regex literal `/= 2/g`. Again, since `jsTokens` only
|
||||
sees forwards, it cannot tell the two cases apart.
|
||||
|
||||
There are some cases where we _can_ tell division and regex literals apart,
|
||||
though.
|
||||
|
||||
First off, we have the simple cases where there’s only one slash in the line:
|
||||
|
||||
```js
|
||||
var foo = 2/g
|
||||
foo /= 2
|
||||
```
|
||||
|
||||
Regex literals cannot contain newlines, so the above cases are correctly
|
||||
identified as division. Things are only problematic when there are more than
|
||||
one non-comment slash in a single line.
|
||||
|
||||
Secondly, not every character is a valid regex flag.
|
||||
|
||||
```js
|
||||
var number = bar / 2/e
|
||||
```
|
||||
|
||||
The above example is also correctly identified as division, because `e` is not a
|
||||
valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*`
|
||||
(any letter) as flags, but it is not worth it since it increases the amount of
|
||||
ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are
|
||||
allowed. This means that the above example will be identified as division as
|
||||
long as you don’t rename the `e` variable to some permutation of `gmiyus` 1 to 6
|
||||
characters long.
|
||||
|
||||
Lastly, we can look _forward_ for information.
|
||||
|
||||
- If the token following what looks like a regex literal is not valid after a
|
||||
regex literal, but is valid in a division expression, then the regex literal
|
||||
is treated as division instead. For example, a flagless regex cannot be
|
||||
followed by a string, number or name, but all of those three can be the
|
||||
denominator of a division.
|
||||
- Generally, if what looks like a regex literal is followed by an operator, the
|
||||
regex literal is treated as division instead. This is because regexes are
|
||||
seldomly used with operators (such as `+`, `*`, `&&` and `==`), but division
|
||||
could likely be part of such an expression.
|
||||
|
||||
Please consult the regex source and the test cases for precise information on
|
||||
when regex or division is matched (should you need to know). In short, you
|
||||
could sum it up as:
|
||||
|
||||
If the end of a statement looks like a regex literal (even if it isn’t), it
|
||||
will be treated as one. Otherwise it should work as expected (if you write sane
|
||||
code).
|
||||
|
||||
### ES2018 ###
|
||||
|
||||
ES2018 added some nice regex improvements to the language.
|
||||
|
||||
- [Unicode property escapes] should allow telling names and invalid non-ASCII
|
||||
characters apart without blowing up the regex size.
|
||||
- [Lookbehind assertions] should allow matching telling division and regex
|
||||
literals apart in more cases.
|
||||
- [Named capture groups] might simplify some things.
|
||||
|
||||
These things would be nice to do, but are not critical. They probably have to
|
||||
wait until the oldest maintained Node.js LTS release supports those features.
|
||||
|
||||
[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html
|
||||
[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html
|
||||
[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
[MIT](LICENSE).
|
||||
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FormatNumericToString = void 0;
|
||||
var _262_1 = require("../262");
|
||||
var ToRawPrecision_1 = require("./ToRawPrecision");
|
||||
var utils_1 = require("../utils");
|
||||
var ToRawFixed_1 = require("./ToRawFixed");
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-formatnumberstring
|
||||
*/
|
||||
function FormatNumericToString(intlObject, x) {
|
||||
var isNegative = x < 0 || (0, _262_1.SameValue)(x, -0);
|
||||
if (isNegative) {
|
||||
x = -x;
|
||||
}
|
||||
var result;
|
||||
var rourndingType = intlObject.roundingType;
|
||||
switch (rourndingType) {
|
||||
case 'significantDigits':
|
||||
result = (0, ToRawPrecision_1.ToRawPrecision)(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits);
|
||||
break;
|
||||
case 'fractionDigits':
|
||||
result = (0, ToRawFixed_1.ToRawFixed)(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits);
|
||||
break;
|
||||
default:
|
||||
result = (0, ToRawPrecision_1.ToRawPrecision)(x, 1, 2);
|
||||
if (result.integerDigitsCount > 1) {
|
||||
result = (0, ToRawFixed_1.ToRawFixed)(x, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
x = result.roundedNumber;
|
||||
var string = result.formattedString;
|
||||
var int = result.integerDigitsCount;
|
||||
var minInteger = intlObject.minimumIntegerDigits;
|
||||
if (int < minInteger) {
|
||||
var forwardZeros = (0, utils_1.repeat)('0', minInteger - int);
|
||||
string = forwardZeros + string;
|
||||
}
|
||||
if (isNegative) {
|
||||
x = -x;
|
||||
}
|
||||
return { roundedNumber: x, formattedString: string };
|
||||
}
|
||||
exports.FormatNumericToString = FormatNumericToString;
|
||||
@@ -0,0 +1,270 @@
|
||||
import { Component, createElement, options, Fragment } from 'preact';
|
||||
import { assign } from './util';
|
||||
|
||||
const oldCatchError = options._catchError;
|
||||
options._catchError = function(error, newVNode, oldVNode, errorInfo) {
|
||||
if (error.then) {
|
||||
/** @type {import('./internal').Component} */
|
||||
let component;
|
||||
let vnode = newVNode;
|
||||
|
||||
for (; (vnode = vnode._parent); ) {
|
||||
if ((component = vnode._component) && component._childDidSuspend) {
|
||||
if (newVNode._dom == null) {
|
||||
newVNode._dom = oldVNode._dom;
|
||||
newVNode._children = oldVNode._children;
|
||||
}
|
||||
// Don't call oldCatchError if we found a Suspense
|
||||
return component._childDidSuspend(error, newVNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
oldCatchError(error, newVNode, oldVNode, errorInfo);
|
||||
};
|
||||
|
||||
const oldUnmount = options.unmount;
|
||||
options.unmount = function(vnode) {
|
||||
/** @type {import('./internal').Component} */
|
||||
const component = vnode._component;
|
||||
if (component && component._onResolve) {
|
||||
component._onResolve();
|
||||
}
|
||||
|
||||
// if the component is still hydrating
|
||||
// most likely it is because the component is suspended
|
||||
// we set the vnode.type as `null` so that it is not a typeof function
|
||||
// so the unmount will remove the vnode._dom
|
||||
if (component && vnode._hydrating === true) {
|
||||
vnode.type = null;
|
||||
}
|
||||
|
||||
if (oldUnmount) oldUnmount(vnode);
|
||||
};
|
||||
|
||||
function detachedClone(vnode, detachedParent, parentDom) {
|
||||
if (vnode) {
|
||||
if (vnode._component && vnode._component.__hooks) {
|
||||
vnode._component.__hooks._list.forEach(effect => {
|
||||
if (typeof effect._cleanup == 'function') effect._cleanup();
|
||||
});
|
||||
|
||||
vnode._component.__hooks = null;
|
||||
}
|
||||
|
||||
vnode = assign({}, vnode);
|
||||
if (vnode._component != null) {
|
||||
if (vnode._component._parentDom === parentDom) {
|
||||
vnode._component._parentDom = detachedParent;
|
||||
}
|
||||
vnode._component = null;
|
||||
}
|
||||
|
||||
vnode._children =
|
||||
vnode._children &&
|
||||
vnode._children.map(child =>
|
||||
detachedClone(child, detachedParent, parentDom)
|
||||
);
|
||||
}
|
||||
|
||||
return vnode;
|
||||
}
|
||||
|
||||
function removeOriginal(vnode, detachedParent, originalParent) {
|
||||
if (vnode) {
|
||||
vnode._original = null;
|
||||
vnode._children =
|
||||
vnode._children &&
|
||||
vnode._children.map(child =>
|
||||
removeOriginal(child, detachedParent, originalParent)
|
||||
);
|
||||
|
||||
if (vnode._component) {
|
||||
if (vnode._component._parentDom === detachedParent) {
|
||||
if (vnode._dom) {
|
||||
originalParent.insertBefore(vnode._dom, vnode._nextDom);
|
||||
}
|
||||
vnode._component._force = true;
|
||||
vnode._component._parentDom = originalParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vnode;
|
||||
}
|
||||
|
||||
// having custom inheritance instead of a class here saves a lot of bytes
|
||||
export function Suspense() {
|
||||
// we do not call super here to golf some bytes...
|
||||
this._pendingSuspensionCount = 0;
|
||||
this._suspenders = null;
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Things we do here to save some bytes but are not proper JS inheritance:
|
||||
// - call `new Component()` as the prototype
|
||||
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
||||
Suspense.prototype = new Component();
|
||||
|
||||
/**
|
||||
* @this {import('./internal').SuspenseComponent}
|
||||
* @param {Promise} promise The thrown promise
|
||||
* @param {import('./internal').VNode<any, any>} suspendingVNode The suspending component
|
||||
*/
|
||||
Suspense.prototype._childDidSuspend = function(promise, suspendingVNode) {
|
||||
const suspendingComponent = suspendingVNode._component;
|
||||
|
||||
/** @type {import('./internal').SuspenseComponent} */
|
||||
const c = this;
|
||||
|
||||
if (c._suspenders == null) {
|
||||
c._suspenders = [];
|
||||
}
|
||||
c._suspenders.push(suspendingComponent);
|
||||
|
||||
const resolve = suspended(c._vnode);
|
||||
|
||||
let resolved = false;
|
||||
const onResolved = () => {
|
||||
if (resolved) return;
|
||||
|
||||
resolved = true;
|
||||
suspendingComponent._onResolve = null;
|
||||
|
||||
if (resolve) {
|
||||
resolve(onSuspensionComplete);
|
||||
} else {
|
||||
onSuspensionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
suspendingComponent._onResolve = onResolved;
|
||||
|
||||
const onSuspensionComplete = () => {
|
||||
if (!--c._pendingSuspensionCount) {
|
||||
// If the suspension was during hydration we don't need to restore the
|
||||
// suspended children into the _children array
|
||||
if (c.state._suspended) {
|
||||
const suspendedVNode = c.state._suspended;
|
||||
c._vnode._children[0] = removeOriginal(
|
||||
suspendedVNode,
|
||||
suspendedVNode._component._parentDom,
|
||||
suspendedVNode._component._originalParentDom
|
||||
);
|
||||
}
|
||||
|
||||
c.setState({ _suspended: (c._detachOnNextRender = null) });
|
||||
|
||||
let suspended;
|
||||
while ((suspended = c._suspenders.pop())) {
|
||||
suspended.forceUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* We do not set `suspended: true` during hydration because we want the actual markup
|
||||
* to remain on screen and hydrate it when the suspense actually gets resolved.
|
||||
* While in non-hydration cases the usual fallback -> component flow would occour.
|
||||
*/
|
||||
const wasHydrating = suspendingVNode._hydrating === true;
|
||||
if (!c._pendingSuspensionCount++ && !wasHydrating) {
|
||||
c.setState({ _suspended: (c._detachOnNextRender = c._vnode._children[0]) });
|
||||
}
|
||||
promise.then(onResolved, onResolved);
|
||||
};
|
||||
|
||||
Suspense.prototype.componentWillUnmount = function() {
|
||||
this._suspenders = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @this {import('./internal').SuspenseComponent}
|
||||
* @param {import('./internal').SuspenseComponent["props"]} props
|
||||
* @param {import('./internal').SuspenseState} state
|
||||
*/
|
||||
Suspense.prototype.render = function(props, state) {
|
||||
if (this._detachOnNextRender) {
|
||||
// When the Suspense's _vnode was created by a call to createVNode
|
||||
// (i.e. due to a setState further up in the tree)
|
||||
// it's _children prop is null, in this case we "forget" about the parked vnodes to detach
|
||||
if (this._vnode._children) {
|
||||
const detachedParent = document.createElement('div');
|
||||
const detachedComponent = this._vnode._children[0]._component;
|
||||
this._vnode._children[0] = detachedClone(
|
||||
this._detachOnNextRender,
|
||||
detachedParent,
|
||||
(detachedComponent._originalParentDom = detachedComponent._parentDom)
|
||||
);
|
||||
}
|
||||
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Wrap fallback tree in a VNode that prevents itself from being marked as aborting mid-hydration:
|
||||
/** @type {import('./internal').VNode} */
|
||||
const fallback =
|
||||
state._suspended && createElement(Fragment, null, props.fallback);
|
||||
if (fallback) fallback._hydrating = null;
|
||||
|
||||
return [
|
||||
createElement(Fragment, null, state._suspended ? null : props.children),
|
||||
fallback
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks and calls the parent component's _suspended method, passing in the
|
||||
* suspended vnode. This is a way for a parent (e.g. SuspenseList) to get notified
|
||||
* that one of its children/descendants suspended.
|
||||
*
|
||||
* The parent MAY return a callback. The callback will get called when the
|
||||
* suspension resolves, notifying the parent of the fact.
|
||||
* Moreover, the callback gets function `unsuspend` as a parameter. The resolved
|
||||
* child descendant will not actually get unsuspended until `unsuspend` gets called.
|
||||
* This is a way for the parent to delay unsuspending.
|
||||
*
|
||||
* If the parent does not return a callback then the resolved vnode
|
||||
* gets unsuspended immediately when it resolves.
|
||||
*
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @returns {((unsuspend: () => void) => void)?}
|
||||
*/
|
||||
export function suspended(vnode) {
|
||||
/** @type {import('./internal').Component} */
|
||||
let component = vnode._parent._component;
|
||||
return component && component._suspended && component._suspended(vnode);
|
||||
}
|
||||
|
||||
export function lazy(loader) {
|
||||
let prom;
|
||||
let component;
|
||||
let error;
|
||||
|
||||
function Lazy(props) {
|
||||
if (!prom) {
|
||||
prom = loader();
|
||||
prom.then(
|
||||
exports => {
|
||||
component = exports.default || exports;
|
||||
},
|
||||
e => {
|
||||
error = e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!component) {
|
||||
throw prom;
|
||||
}
|
||||
|
||||
return createElement(component, props);
|
||||
}
|
||||
|
||||
Lazy.displayName = 'Lazy';
|
||||
Lazy._forwarded = true;
|
||||
return Lazy;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
var createWrap = require('./_createWrap'),
|
||||
flatRest = require('./_flatRest');
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
var WRAP_REARG_FLAG = 256;
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with arguments arranged according
|
||||
* to the specified `indexes` where the argument value at the first index is
|
||||
* provided as the first argument, the argument value at the second index is
|
||||
* provided as the second argument, and so on.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to rearrange arguments for.
|
||||
* @param {...(number|number[])} indexes The arranged argument indexes.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var rearged = _.rearg(function(a, b, c) {
|
||||
* return [a, b, c];
|
||||
* }, [2, 0, 1]);
|
||||
*
|
||||
* rearged('b', 'c', 'a')
|
||||
* // => ['a', 'b', 'c']
|
||||
*/
|
||||
var rearg = flatRest(function(func, indexes) {
|
||||
return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
|
||||
});
|
||||
|
||||
module.exports = rearg;
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var isCallable = require("./is-callable");
|
||||
|
||||
module.exports = function (stringifiable) {
|
||||
try {
|
||||
if (stringifiable && isCallable(stringifiable.toString)) return stringifiable.toString();
|
||||
return String(stringifiable);
|
||||
} catch (e) {
|
||||
throw new TypeError("Passed argument cannot be stringifed");
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
module.exports =
|
||||
{
|
||||
// Output
|
||||
ABSOLUTE: "absolute",
|
||||
PATH_RELATIVE: "pathRelative",
|
||||
ROOT_RELATIVE: "rootRelative",
|
||||
SHORTEST: "shortest"
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function filter(predicate, thisArg) {
|
||||
return operate(function (source, subscriber) {
|
||||
var index = 0;
|
||||
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=filter.js.map
|
||||
@@ -0,0 +1,92 @@
|
||||
/* adler32.js (C) 2014-present SheetJS -- http://sheetjs.com */
|
||||
/* vim: set ts=2: */
|
||||
/*exported ADLER32 */
|
||||
var ADLER32;
|
||||
(function (factory) {
|
||||
/*jshint ignore:start */
|
||||
/*eslint-disable */
|
||||
if(typeof DO_NOT_EXPORT_ADLER === 'undefined') {
|
||||
if('object' === typeof exports) {
|
||||
factory(exports);
|
||||
} else if ('function' === typeof define && define.amd) {
|
||||
define(function () {
|
||||
var module = {};
|
||||
factory(module);
|
||||
return module;
|
||||
});
|
||||
} else {
|
||||
factory(ADLER32 = {});
|
||||
}
|
||||
} else {
|
||||
factory(ADLER32 = {});
|
||||
}
|
||||
/*eslint-enable */
|
||||
/*jshint ignore:end */
|
||||
}(function(ADLER32) {
|
||||
ADLER32.version = '1.3.1';
|
||||
function adler32_bstr(bstr, seed) {
|
||||
var a = 1, b = 0, L = bstr.length, M = 0;
|
||||
if(typeof seed === 'number') { a = seed & 0xFFFF; b = seed >>> 16; }
|
||||
for(var i = 0; i < L;) {
|
||||
M = Math.min(L-i, 2654)+i;
|
||||
for(;i<M;i++) {
|
||||
a += bstr.charCodeAt(i)&0xFF;
|
||||
b += a;
|
||||
}
|
||||
a = (15*(a>>>16)+(a&65535));
|
||||
b = (15*(b>>>16)+(b&65535));
|
||||
}
|
||||
return ((b%65521) << 16) | (a%65521);
|
||||
}
|
||||
|
||||
function adler32_buf(buf, seed) {
|
||||
var a = 1, b = 0, L = buf.length, M = 0;
|
||||
if(typeof seed === 'number') { a = seed & 0xFFFF; b = (seed >>> 16) & 0xFFFF; }
|
||||
for(var i = 0; i < L;) {
|
||||
M = Math.min(L-i, 2654)+i;
|
||||
for(;i<M;i++) {
|
||||
a += buf[i]&0xFF;
|
||||
b += a;
|
||||
}
|
||||
a = (15*(a>>>16)+(a&65535));
|
||||
b = (15*(b>>>16)+(b&65535));
|
||||
}
|
||||
return ((b%65521) << 16) | (a%65521);
|
||||
}
|
||||
|
||||
function adler32_str(str, seed) {
|
||||
var a = 1, b = 0, L = str.length, M = 0, c = 0, d = 0;
|
||||
if(typeof seed === 'number') { a = seed & 0xFFFF; b = seed >>> 16; }
|
||||
for(var i = 0; i < L;) {
|
||||
M = Math.min(L-i, 2918);
|
||||
while(M>0) {
|
||||
c = str.charCodeAt(i++);
|
||||
if(c < 0x80) { a += c; }
|
||||
else if(c < 0x800) {
|
||||
a += 192|((c>>6)&31); b += a; --M;
|
||||
a += 128|(c&63);
|
||||
} else if(c >= 0xD800 && c < 0xE000) {
|
||||
c = (c&1023)+64; d = str.charCodeAt(i++) & 1023;
|
||||
a += 240|((c>>8)&7); b += a; --M;
|
||||
a += 128|((c>>2)&63); b += a; --M;
|
||||
a += 128|((d>>6)&15)|((c&3)<<4); b += a; --M;
|
||||
a += 128|(d&63);
|
||||
} else {
|
||||
a += 224|((c>>12)&15); b += a; --M;
|
||||
a += 128|((c>>6)&63); b += a; --M;
|
||||
a += 128|(c&63);
|
||||
}
|
||||
b += a; --M;
|
||||
}
|
||||
a = (15*(a>>>16)+(a&65535));
|
||||
b = (15*(b>>>16)+(b&65535));
|
||||
}
|
||||
return ((b%65521) << 16) | (a%65521);
|
||||
}
|
||||
// $FlowIgnore
|
||||
ADLER32.bstr = adler32_bstr;
|
||||
// $FlowIgnore
|
||||
ADLER32.buf = adler32_buf;
|
||||
// $FlowIgnore
|
||||
ADLER32.str = adler32_str;
|
||||
}));
|
||||
@@ -0,0 +1,47 @@
|
||||
import assertString from './util/assertString';
|
||||
import isIP from './isIP';
|
||||
var subnetMaybe = /^\d{1,3}$/;
|
||||
var v4Subnet = 32;
|
||||
var v6Subnet = 128;
|
||||
export default function isIPRange(str) {
|
||||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
assertString(str);
|
||||
var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet
|
||||
|
||||
if (parts.length !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!subnetMaybe.test(parts[1])) {
|
||||
return false;
|
||||
} // Disallow preceding 0 i.e. 01, 02, ...
|
||||
|
||||
|
||||
if (parts[1].length > 1 && parts[1].startsWith('0')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var isValidIP = isIP(parts[0], version);
|
||||
|
||||
if (!isValidIP) {
|
||||
return false;
|
||||
} // Define valid subnet according to IP's version
|
||||
|
||||
|
||||
var expectedSubnet = null;
|
||||
|
||||
switch (String(version)) {
|
||||
case '4':
|
||||
expectedSubnet = v4Subnet;
|
||||
break;
|
||||
|
||||
case '6':
|
||||
expectedSubnet = v6Subnet;
|
||||
break;
|
||||
|
||||
default:
|
||||
expectedSubnet = isIP(parts[0], '6') ? v6Subnet : v4Subnet;
|
||||
}
|
||||
|
||||
return parts[1] <= expectedSubnet && parts[1] >= 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -0,0 +1,8 @@
|
||||
import { not } from '../util/not';
|
||||
import { filter } from './filter';
|
||||
export function partition(predicate, thisArg) {
|
||||
return function (source) {
|
||||
return [filter(predicate, thisArg)(source), filter(not(predicate, thisArg))(source)];
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=partition.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0.00515,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.01031,"53":0,"54":0,"55":0.00515,"56":0,"57":0,"58":0,"59":0,"60":0.00515,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00515,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.01546,"79":0.00515,"80":0.00515,"81":0.01546,"82":0.00515,"83":0.00515,"84":0,"85":0,"86":0,"87":0,"88":0.00515,"89":0,"90":0,"91":0.01546,"92":0,"93":0,"94":0.01031,"95":0,"96":0,"97":0.00515,"98":0,"99":0,"100":0.00515,"101":0,"102":0.34525,"103":0.00515,"104":0.00515,"105":0.00515,"106":0.01031,"107":0.01546,"108":0.05153,"109":0.98422,"110":0.66989,"111":0.00515,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0.00515,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.03607,"48":0.01031,"49":0.01031,"50":0,"51":0,"52":0.03607,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0.00515,"61":0.00515,"62":0,"63":0,"64":0,"65":0,"66":0.01546,"67":0.00515,"68":0.00515,"69":0,"70":0,"71":0,"72":0.03092,"73":0.00515,"74":0.00515,"75":0.00515,"76":0.00515,"77":0.00515,"78":0.01031,"79":0.06699,"80":0.01031,"81":0.00515,"83":0.01546,"84":0.03092,"85":0.14428,"86":0.06184,"87":0.03092,"88":0.01031,"89":0.01031,"90":0.01031,"91":0.01031,"92":0.02061,"93":0.02061,"94":0.00515,"95":0.00515,"96":0.02061,"97":0.01031,"98":0.02061,"99":0.01031,"100":0.0773,"101":0.0773,"102":0.05153,"103":0.15974,"104":0.05153,"105":0.05668,"106":0.05153,"107":0.09275,"108":0.64928,"109":8.03353,"110":5.05509,"111":0.00515,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0.00515,"67":0.02577,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0.00515,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0.00515,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.03092,"94":0.29372,"95":0.19581,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.01546,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0.00515,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00515,"93":0,"94":0,"95":0,"96":0,"97":0.00515,"98":0,"99":0,"100":0,"101":0,"102":0.00515,"103":0.00515,"104":0.00515,"105":0.00515,"106":0.01031,"107":0.02061,"108":0.10821,"109":1.70564,"110":2.2364},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.00515,"14":0.07214,"15":0.01546,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0.01031,"10.1":0,"11.1":0,"12.1":0.03607,"13.1":0.10821,"14.1":0.18551,"15.1":0.03607,"15.2-15.3":0.03092,"15.4":0.06184,"15.5":0.12883,"15.6":0.65443,"16.0":0.0773,"16.1":0.25765,"16.2":0.91723,"16.3":0.64928,"16.4":0.03092},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0.0031,"8.1-8.4":0,"9.0-9.2":0.09298,"9.3":0.08988,"10.0-10.2":0,"10.3":0.10228,"11.0-11.2":0.0093,"11.3-11.4":0.04649,"12.0-12.1":0.0124,"12.2-12.5":0.51139,"13.0-13.1":0.0093,"13.2":0.0093,"13.3":0.0217,"13.4-13.7":0.08678,"14.0-14.4":0.26035,"14.5-14.8":0.68496,"15.0-15.1":0.17666,"15.2-15.3":0.25415,"15.4":0.28204,"15.5":0.63537,"15.6":2.34311,"16.0":3.3535,"16.1":8.34656,"16.2":7.95914,"16.3":4.27711,"16.4":0.0217},P:{"4":0.103,"20":1.83338,"5.0-5.4":0.0103,"6.2-6.4":0,"7.2-7.4":0.0103,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0.0103,"12.0":0.0103,"13.0":0.0206,"14.0":0.0103,"15.0":0.0103,"16.0":0.0309,"17.0":0.0412,"18.0":0.0721,"19.0":2.61617},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0.04397,"2.3":0,"4.1":0.00489,"4.2-4.3":0.0342,"4.4":0,"4.4.3-4.4.4":0.07817},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0.00658,"7":0,"8":0.01975,"9":0.03951,"10":0.01317,"11":0.15803,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.42654},H:{"0":0.39464},L:{"0":34.75296},R:{_:"0"},M:{"0":0.6398},Q:{"13.1":0.01454}};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"first.js","sourceRoot":"","sources":["../../../../src/internal/operators/first.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAyE5C,MAAM,UAAU,KAAK,CACnB,SAAgF,EAChF,YAAgB;IAEhB,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,MAAqB,EAAE,EAAE,CAC/B,MAAM,CAAC,IAAI,CACT,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAChE,IAAI,CAAC,CAAC,CAAC,EACP,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,YAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,CACvF,CAAC;AACN,CAAC"}
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const cssesc = require('../cssesc.js');
|
||||
const strings = process.argv.splice(2);
|
||||
const stdin = process.stdin;
|
||||
const options = {};
|
||||
const log = console.log;
|
||||
|
||||
const main = function() {
|
||||
const option = strings[0];
|
||||
|
||||
if (/^(?:-h|--help|undefined)$/.test(option)) {
|
||||
log(
|
||||
'cssesc v%s - https://mths.be/cssesc',
|
||||
cssesc.version
|
||||
);
|
||||
log([
|
||||
'\nUsage:\n',
|
||||
'\tcssesc [string]',
|
||||
'\tcssesc [-i | --identifier] [string]',
|
||||
'\tcssesc [-s | --single-quotes] [string]',
|
||||
'\tcssesc [-d | --double-quotes] [string]',
|
||||
'\tcssesc [-w | --wrap] [string]',
|
||||
'\tcssesc [-e | --escape-everything] [string]',
|
||||
'\tcssesc [-v | --version]',
|
||||
'\tcssesc [-h | --help]',
|
||||
'\nExamples:\n',
|
||||
'\tcssesc \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
|
||||
'\tcssesc --identifier \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
|
||||
'\tcssesc --escape-everything \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
|
||||
'\tcssesc --double-quotes --wrap \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
|
||||
'\techo \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\' | cssesc'
|
||||
].join('\n'));
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
if (/^(?:-v|--version)$/.test(option)) {
|
||||
log('v%s', cssesc.version);
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
strings.forEach(function(string) {
|
||||
// Process options
|
||||
if (/^(?:-i|--identifier)$/.test(string)) {
|
||||
options.isIdentifier = true;
|
||||
return;
|
||||
}
|
||||
if (/^(?:-s|--single-quotes)$/.test(string)) {
|
||||
options.quotes = 'single';
|
||||
return;
|
||||
}
|
||||
if (/^(?:-d|--double-quotes)$/.test(string)) {
|
||||
options.quotes = 'double';
|
||||
return;
|
||||
}
|
||||
if (/^(?:-w|--wrap)$/.test(string)) {
|
||||
options.wrap = true;
|
||||
return;
|
||||
}
|
||||
if (/^(?:-e|--escape-everything)$/.test(string)) {
|
||||
options.escapeEverything = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Process string(s)
|
||||
let result;
|
||||
try {
|
||||
result = cssesc(string, options);
|
||||
log(result);
|
||||
} catch (exception) {
|
||||
log(exception.message + '\n');
|
||||
log('Error: failed to escape.');
|
||||
log('If you think this is a bug in cssesc, please report it:');
|
||||
log('https://github.com/mathiasbynens/cssesc/issues/new');
|
||||
log(
|
||||
'\nStack trace using cssesc@%s:\n',
|
||||
cssesc.version
|
||||
);
|
||||
log(exception.stack);
|
||||
return process.exit(1);
|
||||
}
|
||||
});
|
||||
// Return with exit status 0 outside of the `forEach` loop, in case
|
||||
// multiple strings were passed in.
|
||||
return process.exit(0);
|
||||
|
||||
};
|
||||
|
||||
if (stdin.isTTY) {
|
||||
// handle shell arguments
|
||||
main();
|
||||
} else {
|
||||
let timeout;
|
||||
// Either the script is called from within a non-TTY context, or `stdin`
|
||||
// content is being piped in.
|
||||
if (!process.stdout.isTTY) {
|
||||
// The script was called from a non-TTY context. This is a rather uncommon
|
||||
// use case we don’t actively support. However, we don’t want the script
|
||||
// to wait forever in such cases, so…
|
||||
timeout = setTimeout(function() {
|
||||
// …if no piped data arrived after a whole minute, handle shell
|
||||
// arguments instead.
|
||||
main();
|
||||
}, 60000);
|
||||
}
|
||||
let data = '';
|
||||
stdin.on('data', function(chunk) {
|
||||
clearTimeout(timeout);
|
||||
data += chunk;
|
||||
});
|
||||
stdin.on('end', function() {
|
||||
strings.push(data.trim());
|
||||
main();
|
||||
});
|
||||
stdin.resume();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0.01202,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0,"109":0.04807,"110":0.51077,"111":0,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0.01803,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0.01202,"91":0,"92":0,"93":0,"94":0.01202,"95":0.01202,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.01202,"103":0.10215,"104":0,"105":0,"106":0.01803,"107":0.03605,"108":0.72709,"109":11.60338,"110":10.49772,"111":0,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0.1322,"95":0.08413,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.04807,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0.04807,"107":0.01803,"108":0.07211,"109":1.11167,"110":2.75813},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.24036,"15":0.03605,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0.07211,"11.1":0,"12.1":0,"13.1":0.01803,"14.1":0.10215,"15.1":0,"15.2-15.3":0,"15.4":0,"15.5":1.15373,"15.6":0.61292,"16.0":0.03605,"16.1":0.04807,"16.2":0.15623,"16.3":0.80521,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.01978,"10.0-10.2":0,"10.3":0.03956,"11.0-11.2":0,"11.3-11.4":0.01978,"12.0-12.1":0,"12.2-12.5":0.01978,"13.0-13.1":0,"13.2":0,"13.3":0,"13.4-13.7":9.28217,"14.0-14.4":0,"14.5-14.8":0.01978,"15.0-15.1":0,"15.2-15.3":0.22006,"15.4":0,"15.5":0,"15.6":1.08053,"16.0":1.28081,"16.1":1.8594,"16.2":2.66053,"16.3":6.44114,"16.4":0},P:{"4":0.8809,"20":0.34567,"5.0-5.4":0.0223,"6.2-6.4":0,"7.2-7.4":0.12266,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0,"12.0":0,"13.0":0,"14.0":0,"15.0":0,"16.0":0.0223,"17.0":0.03345,"18.0":0,"19.0":2.63156},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":1.71857},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.01596},H:{"0":0},L:{"0":37.64293},R:{_:"0"},M:{"0":0},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[28601] = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู<E0B8B9><E0B8BA><EFBFBD><EFBFBD>฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛<E0B99A><E0B99B><EFBFBD><EFBFBD>", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ToRawPrecision.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/ToRawPrecision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAA;AAGrD,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA8EvB"}
|
||||
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function (value) {
|
||||
// eslint-disable-next-line no-bitwise
|
||||
return value >>> 0;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"2":"C K L G M N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H"},C:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C h qB AC rB"},L:{"2":"H"},M:{"2":"H"},N:{"2":"A B"},O:{"2":"vC"},P:{"2":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"2":"1B"},R:{"2":"9C"},S:{"2":"AD BD"}},B:7,C:"Decorators"};
|
||||
@@ -0,0 +1,132 @@
|
||||
import { isArrayLike } from '../util/isArrayLike';
|
||||
import { isPromise } from '../util/isPromise';
|
||||
import { Observable } from '../Observable';
|
||||
import { ObservableInput, ObservedValueOf, ReadableStreamLike } from '../types';
|
||||
import { isInteropObservable } from '../util/isInteropObservable';
|
||||
import { isAsyncIterable } from '../util/isAsyncIterable';
|
||||
import { createInvalidObservableTypeError } from '../util/throwUnobservableError';
|
||||
import { isIterable } from '../util/isIterable';
|
||||
import { isReadableStreamLike, readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { isFunction } from '../util/isFunction';
|
||||
import { reportUnhandledError } from '../util/reportUnhandledError';
|
||||
import { observable as Symbol_observable } from '../symbol/observable';
|
||||
|
||||
export function innerFrom<O extends ObservableInput<any>>(input: O): Observable<ObservedValueOf<O>>;
|
||||
export function innerFrom<T>(input: ObservableInput<T>): Observable<T> {
|
||||
if (input instanceof Observable) {
|
||||
return input;
|
||||
}
|
||||
if (input != null) {
|
||||
if (isInteropObservable(input)) {
|
||||
return fromInteropObservable(input);
|
||||
}
|
||||
if (isArrayLike(input)) {
|
||||
return fromArrayLike(input);
|
||||
}
|
||||
if (isPromise(input)) {
|
||||
return fromPromise(input);
|
||||
}
|
||||
if (isAsyncIterable(input)) {
|
||||
return fromAsyncIterable(input);
|
||||
}
|
||||
if (isIterable(input)) {
|
||||
return fromIterable(input);
|
||||
}
|
||||
if (isReadableStreamLike(input)) {
|
||||
return fromReadableStreamLike(input);
|
||||
}
|
||||
}
|
||||
|
||||
throw createInvalidObservableTypeError(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an RxJS Observable from an object that implements `Symbol.observable`.
|
||||
* @param obj An object that properly implements `Symbol.observable`.
|
||||
*/
|
||||
export function fromInteropObservable<T>(obj: any) {
|
||||
return new Observable((subscriber: Subscriber<T>) => {
|
||||
const obs = obj[Symbol_observable]();
|
||||
if (isFunction(obs.subscribe)) {
|
||||
return obs.subscribe(subscriber);
|
||||
}
|
||||
// Should be caught by observable subscribe function error handling.
|
||||
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously emits the values of an array like and completes.
|
||||
* This is exported because there are creation functions and operators that need to
|
||||
* make direct use of the same logic, and there's no reason to make them run through
|
||||
* `from` conditionals because we *know* they're dealing with an array.
|
||||
* @param array The array to emit values from
|
||||
*/
|
||||
export function fromArrayLike<T>(array: ArrayLike<T>) {
|
||||
return new Observable((subscriber: Subscriber<T>) => {
|
||||
// Loop over the array and emit each value. Note two things here:
|
||||
// 1. We're making sure that the subscriber is not closed on each loop.
|
||||
// This is so we don't continue looping over a very large array after
|
||||
// something like a `take`, `takeWhile`, or other synchronous unsubscription
|
||||
// has already unsubscribed.
|
||||
// 2. In this form, reentrant code can alter that array we're looping over.
|
||||
// This is a known issue, but considered an edge case. The alternative would
|
||||
// be to copy the array before executing the loop, but this has
|
||||
// performance implications.
|
||||
for (let i = 0; i < array.length && !subscriber.closed; i++) {
|
||||
subscriber.next(array[i]);
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
|
||||
export function fromPromise<T>(promise: PromiseLike<T>) {
|
||||
return new Observable((subscriber: Subscriber<T>) => {
|
||||
promise
|
||||
.then(
|
||||
(value) => {
|
||||
if (!subscriber.closed) {
|
||||
subscriber.next(value);
|
||||
subscriber.complete();
|
||||
}
|
||||
},
|
||||
(err: any) => subscriber.error(err)
|
||||
)
|
||||
.then(null, reportUnhandledError);
|
||||
});
|
||||
}
|
||||
|
||||
export function fromIterable<T>(iterable: Iterable<T>) {
|
||||
return new Observable((subscriber: Subscriber<T>) => {
|
||||
for (const value of iterable) {
|
||||
subscriber.next(value);
|
||||
if (subscriber.closed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
|
||||
export function fromAsyncIterable<T>(asyncIterable: AsyncIterable<T>) {
|
||||
return new Observable((subscriber: Subscriber<T>) => {
|
||||
process(asyncIterable, subscriber).catch((err) => subscriber.error(err));
|
||||
});
|
||||
}
|
||||
|
||||
export function fromReadableStreamLike<T>(readableStream: ReadableStreamLike<T>) {
|
||||
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
||||
}
|
||||
|
||||
async function process<T>(asyncIterable: AsyncIterable<T>, subscriber: Subscriber<T>) {
|
||||
for await (const value of asyncIterable) {
|
||||
subscriber.next(value);
|
||||
// A side-effect may have closed our subscriber,
|
||||
// check before the next iteration.
|
||||
if (subscriber.closed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
subscriber.complete();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.bindCallback = void 0;
|
||||
var bindCallbackInternals_1 = require("./bindCallbackInternals");
|
||||
function bindCallback(callbackFunc, resultSelector, scheduler) {
|
||||
return bindCallbackInternals_1.bindCallbackInternals(false, callbackFunc, resultSelector, scheduler);
|
||||
}
|
||||
exports.bindCallback = bindCallback;
|
||||
//# sourceMappingURL=bindCallback.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"for-each","version":"0.3.3","files":{".editorconfig":{"checkedAt":1678883669577,"integrity":"sha512-E+E+Jt9mMqQ3/p527H7Vvi+iad5ecPWcLdf+X2evqu+kHSBzo+gZ1clKPsY18+EBIxYx0S6rmmGzHTGeLDPW8Q==","mode":420,"size":286},"package.json":{"checkedAt":1678883671601,"integrity":"sha512-NRj1zn4T7AnMlSy4Qsd5e51QA/+AS43/PJxivVgKs4YARmHcKq98jKW0a1oUVKHpPILGLJ9jO65smRpQCwNJkQ==","mode":420,"size":1503},".eslintrc":{"checkedAt":1678883671601,"integrity":"sha512-Y0Xre4wdf/gAxqP3u3ynMHcOEHJcKEBhGSsupY19tu7S18M9tncU+5gwDZvxnrNmMrbInS7d+5VCxIxdv88KfA==","mode":420,"size":378},".travis.yml":{"checkedAt":1678883671601,"integrity":"sha512-Pq+u1J/ozOrNXjSgWQu6csg61G6u59at4zj0VaX7NDCsI/iW/ofM4iR7waF5+W3L23bvBsYE7FZfmBc90Y5aow==","mode":420,"size":1609},"index.js":{"checkedAt":1678883671601,"integrity":"sha512-mgRaUn7DfpT0IjzLLkeAxds/tPE695QsRcwsAHmZiXgDYINpB7SnjYH/S75pTmvKvCJUHCAEkdozymDMg3FxLg==","mode":420,"size":1761},"LICENSE":{"checkedAt":1678883671602,"integrity":"sha512-u9u6uuScPROj4LZqoLu47F0tVYSBZOw2HIS58tjWzOq+bVwX9SS0zWNKC4D+UYcSFCsVCQ8CU3lXq1Wkji6XSQ==","mode":420,"size":1075},"README.md":{"checkedAt":1678883671602,"integrity":"sha512-pgKi9Qjch81cOJ8tcM/DIpb6CTPZikle+jAWM3KTJwPJYQbSRJNfzW8jXYsdG94MlHkAcjTPq8UcAhEwi5wocg==","mode":420,"size":746},"test/.eslintrc":{"checkedAt":1678883671602,"integrity":"sha512-pUDXdsrkLM/OrsUqzABjJOfpdCchguc2y+fjzelY/Y+doRmcBy+B7JSlG8nfXsxnM0r50Db1Ty1vTf/Z1IsQHQ==","mode":420,"size":136},"test/test.js":{"checkedAt":1678883671611,"integrity":"sha512-PJTCBYvzcRyvykcRnu+3cyOS3dgVHaTEUqgV6VekpmLviDUGsjtqit6nuHTtRO60aRUU+M+k/OcOe86XL2LliA==","mode":420,"size":5539}}}
|
||||
@@ -0,0 +1,329 @@
|
||||
var fs = require('fs');
|
||||
var getHomedir = require('./homedir');
|
||||
var path = require('path');
|
||||
var caller = require('./caller');
|
||||
var nodeModulesPaths = require('./node-modules-paths');
|
||||
var normalizeOptions = require('./normalize-options');
|
||||
var isCore = require('is-core-module');
|
||||
|
||||
var realpathFS = process.platform !== 'win32' && fs.realpath && typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath;
|
||||
|
||||
var homedir = getHomedir();
|
||||
var defaultPaths = function () {
|
||||
return [
|
||||
path.join(homedir, '.node_modules'),
|
||||
path.join(homedir, '.node_libraries')
|
||||
];
|
||||
};
|
||||
|
||||
var defaultIsFile = function isFile(file, cb) {
|
||||
fs.stat(file, function (err, stat) {
|
||||
if (!err) {
|
||||
return cb(null, stat.isFile() || stat.isFIFO());
|
||||
}
|
||||
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
||||
return cb(err);
|
||||
});
|
||||
};
|
||||
|
||||
var defaultIsDir = function isDirectory(dir, cb) {
|
||||
fs.stat(dir, function (err, stat) {
|
||||
if (!err) {
|
||||
return cb(null, stat.isDirectory());
|
||||
}
|
||||
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
||||
return cb(err);
|
||||
});
|
||||
};
|
||||
|
||||
var defaultRealpath = function realpath(x, cb) {
|
||||
realpathFS(x, function (realpathErr, realPath) {
|
||||
if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);
|
||||
else cb(null, realpathErr ? x : realPath);
|
||||
});
|
||||
};
|
||||
|
||||
var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
realpath(x, cb);
|
||||
} else {
|
||||
cb(null, x);
|
||||
}
|
||||
};
|
||||
|
||||
var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) {
|
||||
readFile(pkgfile, function (readFileErr, body) {
|
||||
if (readFileErr) cb(readFileErr);
|
||||
else {
|
||||
try {
|
||||
var pkg = JSON.parse(body);
|
||||
cb(null, pkg);
|
||||
} catch (jsonErr) {
|
||||
cb(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
||||
var dirs = nodeModulesPaths(start, opts, x);
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
dirs[i] = path.join(dirs[i], x);
|
||||
}
|
||||
return dirs;
|
||||
};
|
||||
|
||||
module.exports = function resolve(x, options, callback) {
|
||||
var cb = callback;
|
||||
var opts = options;
|
||||
if (typeof options === 'function') {
|
||||
cb = opts;
|
||||
opts = {};
|
||||
}
|
||||
if (typeof x !== 'string') {
|
||||
var err = new TypeError('Path must be a string.');
|
||||
return process.nextTick(function () {
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
|
||||
opts = normalizeOptions(x, opts);
|
||||
|
||||
var isFile = opts.isFile || defaultIsFile;
|
||||
var isDirectory = opts.isDirectory || defaultIsDir;
|
||||
var readFile = opts.readFile || fs.readFile;
|
||||
var realpath = opts.realpath || defaultRealpath;
|
||||
var readPackage = opts.readPackage || defaultReadPackage;
|
||||
if (opts.readFile && opts.readPackage) {
|
||||
var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.');
|
||||
return process.nextTick(function () {
|
||||
cb(conflictErr);
|
||||
});
|
||||
}
|
||||
var packageIterator = opts.packageIterator;
|
||||
|
||||
var extensions = opts.extensions || ['.js'];
|
||||
var includeCoreModules = opts.includeCoreModules !== false;
|
||||
var basedir = opts.basedir || path.dirname(caller());
|
||||
var parent = opts.filename || basedir;
|
||||
|
||||
opts.paths = opts.paths || defaultPaths();
|
||||
|
||||
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
||||
var absoluteStart = path.resolve(basedir);
|
||||
|
||||
maybeRealpath(
|
||||
realpath,
|
||||
absoluteStart,
|
||||
opts,
|
||||
function (err, realStart) {
|
||||
if (err) cb(err);
|
||||
else init(realStart);
|
||||
}
|
||||
);
|
||||
|
||||
var res;
|
||||
function init(basedir) {
|
||||
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
||||
res = path.resolve(basedir, x);
|
||||
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
||||
if ((/\/$/).test(x) && res === basedir) {
|
||||
loadAsDirectory(res, opts.package, onfile);
|
||||
} else loadAsFile(res, opts.package, onfile);
|
||||
} else if (includeCoreModules && isCore(x)) {
|
||||
return cb(null, x);
|
||||
} else loadNodeModules(x, basedir, function (err, n, pkg) {
|
||||
if (err) cb(err);
|
||||
else if (n) {
|
||||
return maybeRealpath(realpath, n, opts, function (err, realN) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
cb(null, realN, pkg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
moduleError.code = 'MODULE_NOT_FOUND';
|
||||
cb(moduleError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onfile(err, m, pkg) {
|
||||
if (err) cb(err);
|
||||
else if (m) cb(null, m, pkg);
|
||||
else loadAsDirectory(res, function (err, d, pkg) {
|
||||
if (err) cb(err);
|
||||
else if (d) {
|
||||
maybeRealpath(realpath, d, opts, function (err, realD) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
cb(null, realD, pkg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
moduleError.code = 'MODULE_NOT_FOUND';
|
||||
cb(moduleError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadAsFile(x, thePackage, callback) {
|
||||
var loadAsFilePackage = thePackage;
|
||||
var cb = callback;
|
||||
if (typeof loadAsFilePackage === 'function') {
|
||||
cb = loadAsFilePackage;
|
||||
loadAsFilePackage = undefined;
|
||||
}
|
||||
|
||||
var exts = [''].concat(extensions);
|
||||
load(exts, x, loadAsFilePackage);
|
||||
|
||||
function load(exts, x, loadPackage) {
|
||||
if (exts.length === 0) return cb(null, undefined, loadPackage);
|
||||
var file = x + exts[0];
|
||||
|
||||
var pkg = loadPackage;
|
||||
if (pkg) onpkg(null, pkg);
|
||||
else loadpkg(path.dirname(file), onpkg);
|
||||
|
||||
function onpkg(err, pkg_, dir) {
|
||||
pkg = pkg_;
|
||||
if (err) return cb(err);
|
||||
if (dir && pkg && opts.pathFilter) {
|
||||
var rfile = path.relative(dir, file);
|
||||
var rel = rfile.slice(0, rfile.length - exts[0].length);
|
||||
var r = opts.pathFilter(pkg, x, rel);
|
||||
if (r) return load(
|
||||
[''].concat(extensions.slice()),
|
||||
path.resolve(dir, r),
|
||||
pkg
|
||||
);
|
||||
}
|
||||
isFile(file, onex);
|
||||
}
|
||||
function onex(err, ex) {
|
||||
if (err) return cb(err);
|
||||
if (ex) return cb(null, file, pkg);
|
||||
load(exts.slice(1), x, pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadpkg(dir, cb) {
|
||||
if (dir === '' || dir === '/') return cb(null);
|
||||
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
||||
return cb(null);
|
||||
}
|
||||
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);
|
||||
|
||||
maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
|
||||
if (unwrapErr) return loadpkg(path.dirname(dir), cb);
|
||||
var pkgfile = path.join(pkgdir, 'package.json');
|
||||
isFile(pkgfile, function (err, ex) {
|
||||
// on err, ex is false
|
||||
if (!ex) return loadpkg(path.dirname(dir), cb);
|
||||
|
||||
readPackage(readFile, pkgfile, function (err, pkgParam) {
|
||||
if (err) cb(err);
|
||||
|
||||
var pkg = pkgParam;
|
||||
|
||||
if (pkg && opts.packageFilter) {
|
||||
pkg = opts.packageFilter(pkg, pkgfile);
|
||||
}
|
||||
cb(null, pkg, dir);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
|
||||
var cb = callback;
|
||||
var fpkg = loadAsDirectoryPackage;
|
||||
if (typeof fpkg === 'function') {
|
||||
cb = fpkg;
|
||||
fpkg = opts.package;
|
||||
}
|
||||
|
||||
maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
|
||||
if (unwrapErr) return cb(unwrapErr);
|
||||
var pkgfile = path.join(pkgdir, 'package.json');
|
||||
isFile(pkgfile, function (err, ex) {
|
||||
if (err) return cb(err);
|
||||
if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
|
||||
|
||||
readPackage(readFile, pkgfile, function (err, pkgParam) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var pkg = pkgParam;
|
||||
|
||||
if (pkg && opts.packageFilter) {
|
||||
pkg = opts.packageFilter(pkg, pkgfile);
|
||||
}
|
||||
|
||||
if (pkg && pkg.main) {
|
||||
if (typeof pkg.main !== 'string') {
|
||||
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
||||
mainError.code = 'INVALID_PACKAGE_MAIN';
|
||||
return cb(mainError);
|
||||
}
|
||||
if (pkg.main === '.' || pkg.main === './') {
|
||||
pkg.main = 'index';
|
||||
}
|
||||
loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) {
|
||||
if (err) return cb(err);
|
||||
if (m) return cb(null, m, pkg);
|
||||
if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb);
|
||||
|
||||
var dir = path.resolve(x, pkg.main);
|
||||
loadAsDirectory(dir, pkg, function (err, n, pkg) {
|
||||
if (err) return cb(err);
|
||||
if (n) return cb(null, n, pkg);
|
||||
loadAsFile(path.join(x, 'index'), pkg, cb);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
loadAsFile(path.join(x, '/index'), pkg, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function processDirs(cb, dirs) {
|
||||
if (dirs.length === 0) return cb(null, undefined);
|
||||
var dir = dirs[0];
|
||||
|
||||
isDirectory(path.dirname(dir), isdir);
|
||||
|
||||
function isdir(err, isdir) {
|
||||
if (err) return cb(err);
|
||||
if (!isdir) return processDirs(cb, dirs.slice(1));
|
||||
loadAsFile(dir, opts.package, onfile);
|
||||
}
|
||||
|
||||
function onfile(err, m, pkg) {
|
||||
if (err) return cb(err);
|
||||
if (m) return cb(null, m, pkg);
|
||||
loadAsDirectory(dir, opts.package, ondir);
|
||||
}
|
||||
|
||||
function ondir(err, n, pkg) {
|
||||
if (err) return cb(err);
|
||||
if (n) return cb(null, n, pkg);
|
||||
processDirs(cb, dirs.slice(1));
|
||||
}
|
||||
}
|
||||
function loadNodeModules(x, start, cb) {
|
||||
var thunk = function () { return getPackageCandidates(x, start, opts); };
|
||||
processDirs(
|
||||
cb,
|
||||
packageIterator ? packageIterator(x, start, thunk, opts) : thunk()
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ObservableInputTuple, OperatorFunction } from '../types';
|
||||
/** @deprecated Replaced with {@link raceWith}. Will be removed in v8. */
|
||||
export declare function race<T, A extends readonly unknown[]>(otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
|
||||
/** @deprecated Replaced with {@link raceWith}. Will be removed in v8. */
|
||||
export declare function race<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
|
||||
//# sourceMappingURL=race.d.ts.map
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "cssesc",
|
||||
"version": "3.0.0",
|
||||
"description": "A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.",
|
||||
"homepage": "https://mths.be/cssesc",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"main": "cssesc.js",
|
||||
"bin": "bin/cssesc",
|
||||
"man": "man/cssesc.1",
|
||||
"keywords": [
|
||||
"css",
|
||||
"escape",
|
||||
"identifier",
|
||||
"string",
|
||||
"tool"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathiasbynens/cssesc.git"
|
||||
},
|
||||
"bugs": "https://github.com/mathiasbynens/cssesc/issues",
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"cssesc.js",
|
||||
"bin/",
|
||||
"man/"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "grunt template && babel cssesc.js -o cssesc.js",
|
||||
"test": "mocha tests",
|
||||
"cover": "istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"codecov": "^1.0.1",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-template": "^1.0.0",
|
||||
"istanbul": "^0.4.4",
|
||||
"mocha": "^2.5.3",
|
||||
"regenerate": "^1.2.1",
|
||||
"requirejs": "^2.1.16"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export type Participant = {
|
||||
id: number;
|
||||
firstname: string;
|
||||
middlename?: string;
|
||||
lastname: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
.Dd April 5, 2016
|
||||
.Dt he 1
|
||||
.Sh NAME
|
||||
.Nm he
|
||||
.Nd encode/decode HTML entities just like a browser would
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl -escape Ar string
|
||||
.br
|
||||
.Op Fl -encode Ar string
|
||||
.br
|
||||
.Op Fl -encode Fl -use-named-refs Fl -everything Fl -allow-unsafe Ar string
|
||||
.br
|
||||
.Op Fl -decode Ar string
|
||||
.br
|
||||
.Op Fl -decode Fl -attribute Ar string
|
||||
.br
|
||||
.Op Fl -decode Fl -strict Ar string
|
||||
.br
|
||||
.Op Fl v | -version
|
||||
.br
|
||||
.Op Fl h | -help
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
encodes/decodes HTML entities in strings just like a browser would.
|
||||
.Sh OPTIONS
|
||||
.Bl -ohang -offset
|
||||
.It Sy "--escape"
|
||||
Take a string of text and escape it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, and `'`.
|
||||
.It Sy "--encode"
|
||||
Take a string of text and encode any symbols that aren't printable ASCII symbols and that can be replaced with character references. For example, it would turn `©` into `©`, but it wouldn't turn `+` into `+` since there is no point in doing so. Additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g. `𝌆`). The return value of this function is always valid HTML.
|
||||
.It Sy "--encode --use-named-refs"
|
||||
Enable the use of named character references (like `©`) in the output. If compatibility with older browsers is a concern, don't use this option.
|
||||
.It Sy "--encode --everything"
|
||||
Encode every symbol in the input string, even safe printable ASCII symbols.
|
||||
.It Sy "--encode --allow-unsafe"
|
||||
Encode non-ASCII characters only. This leaves unsafe HTML/XML symbols like `&`, `<`, `>`, `"`, and `'` intact.
|
||||
.It Sy "--encode --decimal"
|
||||
Use decimal digits rather than hexadecimal digits for encoded character references, e.g. output `©` instead of `©`.
|
||||
.It Sy "--decode"
|
||||
Takes a string of HTML and decode any named and numerical character references in it using the algorithm described in the HTML spec.
|
||||
.It Sy "--decode --attribute"
|
||||
Parse the input as if it was an HTML attribute value rather than a string in an HTML text content.
|
||||
.It Sy "--decode --strict"
|
||||
Throw an error if an invalid character reference is encountered.
|
||||
.It Sy "-v, --version"
|
||||
Print he's version.
|
||||
.It Sy "-h, --help"
|
||||
Show the help screen.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
The
|
||||
.Nm he
|
||||
utility exits with one of the following values:
|
||||
.Pp
|
||||
.Bl -tag -width flag -compact
|
||||
.It Li 0
|
||||
.Nm
|
||||
did what it was instructed to do successfully; either it encoded/decoded the input and printed the result, or it printed the version or usage message.
|
||||
.It Li 1
|
||||
.Nm
|
||||
encountered an error.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bl -ohang -offset
|
||||
.It Sy "he --escape '<script>alert(1)</script>'"
|
||||
Print an escaped version of the given string that is safe for use in HTML text contexts, escaping only `&`, `<`, `>`, `"`, and `'`.
|
||||
.It Sy "he --decode '©𝌆'"
|
||||
Print the decoded version of the given HTML string.
|
||||
.It Sy "echo\ '©𝌆'\ |\ he --decode"
|
||||
Print the decoded version of the HTML string that gets piped in.
|
||||
.El
|
||||
.Sh BUGS
|
||||
he's bug tracker is located at <https://github.com/mathiasbynens/he/issues>.
|
||||
.Sh AUTHOR
|
||||
Mathias Bynens <https://mathiasbynens.be/>
|
||||
.Sh WWW
|
||||
<https://mths.be/he>
|
||||
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var identity = require("../../../function/identity")
|
||||
, SubArray = require("../../_sub-array-dummy-safe");
|
||||
|
||||
module.exports = function () { return new SubArray().map(identity) instanceof SubArray; };
|
||||
@@ -0,0 +1,25 @@
|
||||
function getIDB() {
|
||||
/* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */
|
||||
try {
|
||||
if (typeof indexedDB !== 'undefined') {
|
||||
return indexedDB;
|
||||
}
|
||||
if (typeof webkitIndexedDB !== 'undefined') {
|
||||
return webkitIndexedDB;
|
||||
}
|
||||
if (typeof mozIndexedDB !== 'undefined') {
|
||||
return mozIndexedDB;
|
||||
}
|
||||
if (typeof OIndexedDB !== 'undefined') {
|
||||
return OIndexedDB;
|
||||
}
|
||||
if (typeof msIndexedDB !== 'undefined') {
|
||||
return msIndexedDB;
|
||||
}
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var idb = getIDB();
|
||||
export default idb;
|
||||
@@ -0,0 +1,16 @@
|
||||
export declare class StatusService {
|
||||
/**
|
||||
* Get
|
||||
* A very basic status/health endpoint that just checks if the database connection is available. <br> The available information depth will be expanded later.
|
||||
* @result any Successful response
|
||||
* @throws ApiError
|
||||
*/
|
||||
static statusControllerGet(): Promise<any>;
|
||||
/**
|
||||
* Get version
|
||||
* A very basic endpoint that just returns the curent package version.
|
||||
* @result any Successful response
|
||||
* @throws ApiError
|
||||
*/
|
||||
static statusControllerGetVersion(): Promise<any>;
|
||||
}
|
||||
@@ -0,0 +1,512 @@
|
||||
# AST Types 
|
||||
|
||||
This module provides an efficient, modular,
|
||||
[Esprima](https://github.com/ariya/esprima)-compatible implementation of
|
||||
the [abstract syntax
|
||||
tree](http://en.wikipedia.org/wiki/Abstract_syntax_tree) type hierarchy
|
||||
pioneered by the [Mozilla Parser
|
||||
API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API).
|
||||
|
||||
Installation
|
||||
---
|
||||
|
||||
From NPM:
|
||||
|
||||
npm install ast-types
|
||||
|
||||
From GitHub:
|
||||
|
||||
cd path/to/node_modules
|
||||
git clone git://github.com/benjamn/ast-types.git
|
||||
cd ast-types
|
||||
npm install .
|
||||
|
||||
Basic Usage
|
||||
---
|
||||
```js
|
||||
import assert from "assert";
|
||||
import {
|
||||
namedTypes as n,
|
||||
builders as b,
|
||||
} from "ast-types";
|
||||
|
||||
var fooId = b.identifier("foo");
|
||||
var ifFoo = b.ifStatement(fooId, b.blockStatement([
|
||||
b.expressionStatement(b.callExpression(fooId, []))
|
||||
]));
|
||||
|
||||
assert.ok(n.IfStatement.check(ifFoo));
|
||||
assert.ok(n.Statement.check(ifFoo));
|
||||
assert.ok(n.Node.check(ifFoo));
|
||||
|
||||
assert.ok(n.BlockStatement.check(ifFoo.consequent));
|
||||
assert.strictEqual(
|
||||
ifFoo.consequent.body[0].expression.arguments.length,
|
||||
0,
|
||||
);
|
||||
|
||||
assert.strictEqual(ifFoo.test, fooId);
|
||||
assert.ok(n.Expression.check(ifFoo.test));
|
||||
assert.ok(n.Identifier.check(ifFoo.test));
|
||||
assert.ok(!n.Statement.check(ifFoo.test));
|
||||
```
|
||||
|
||||
AST Traversal
|
||||
---
|
||||
|
||||
Because it understands the AST type system so thoroughly, this library
|
||||
is able to provide excellent node iteration and traversal mechanisms.
|
||||
|
||||
If you want complete control over the traversal, and all you need is a way
|
||||
of enumerating the known fields of your AST nodes and getting their
|
||||
values, you may be interested in the primitives `getFieldNames` and
|
||||
`getFieldValue`:
|
||||
```js
|
||||
import {
|
||||
getFieldNames,
|
||||
getFieldValue,
|
||||
} from "ast-types";
|
||||
|
||||
const partialFunExpr = { type: "FunctionExpression" };
|
||||
|
||||
// Even though partialFunExpr doesn't actually contain all the fields that
|
||||
// are expected for a FunctionExpression, types.getFieldNames knows:
|
||||
console.log(getFieldNames(partialFunExpr));
|
||||
// [ 'type', 'id', 'params', 'body', 'generator', 'expression',
|
||||
// 'defaults', 'rest', 'async' ]
|
||||
|
||||
// For fields that have default values, types.getFieldValue will return
|
||||
// the default if the field is not actually defined.
|
||||
console.log(getFieldValue(partialFunExpr, "generator"));
|
||||
// false
|
||||
```
|
||||
|
||||
Two more low-level helper functions, `eachField` and `someField`, are
|
||||
defined in terms of `getFieldNames` and `getFieldValue`:
|
||||
```js
|
||||
// Iterate over all defined fields of an object, including those missing
|
||||
// or undefined, passing each field name and effective value (as returned
|
||||
// by getFieldValue) to the callback. If the object has no corresponding
|
||||
// Def, the callback will never be called.
|
||||
export function eachField(object, callback, context) {
|
||||
getFieldNames(object).forEach(function(name) {
|
||||
callback.call(this, name, getFieldValue(object, name));
|
||||
}, context);
|
||||
}
|
||||
|
||||
// Similar to eachField, except that iteration stops as soon as the
|
||||
// callback returns a truthy value. Like Array.prototype.some, the final
|
||||
// result is either true or false to indicates whether the callback
|
||||
// returned true for any element or not.
|
||||
export function someField(object, callback, context) {
|
||||
return getFieldNames(object).some(function(name) {
|
||||
return callback.call(this, name, getFieldValue(object, name));
|
||||
}, context);
|
||||
}
|
||||
```
|
||||
|
||||
So here's how you might make a copy of an AST node:
|
||||
```js
|
||||
import { eachField } from "ast-types";
|
||||
const copy = {};
|
||||
eachField(node, function(name, value) {
|
||||
// Note that undefined fields will be visited too, according to
|
||||
// the rules associated with node.type, and default field values
|
||||
// will be substituted if appropriate.
|
||||
copy[name] = value;
|
||||
})
|
||||
```
|
||||
|
||||
But that's not all! You can also easily visit entire syntax trees using
|
||||
the powerful `types.visit` abstraction.
|
||||
|
||||
Here's a trivial example of how you might assert that `arguments.callee`
|
||||
is never used in `ast`:
|
||||
```js
|
||||
import assert from "assert";
|
||||
import {
|
||||
visit,
|
||||
namedTypes as n,
|
||||
} from "ast-types";
|
||||
|
||||
visit(ast, {
|
||||
// This method will be called for any node with .type "MemberExpression":
|
||||
visitMemberExpression(path) {
|
||||
// Visitor methods receive a single argument, a NodePath object
|
||||
// wrapping the node of interest.
|
||||
var node = path.node;
|
||||
|
||||
if (
|
||||
n.Identifier.check(node.object) &&
|
||||
node.object.name === "arguments" &&
|
||||
n.Identifier.check(node.property)
|
||||
) {
|
||||
assert.notStrictEqual(node.property.name, "callee");
|
||||
}
|
||||
|
||||
// It's your responsibility to call this.traverse with some
|
||||
// NodePath object (usually the one passed into the visitor
|
||||
// method) before the visitor method returns, or return false to
|
||||
// indicate that the traversal need not continue any further down
|
||||
// this subtree.
|
||||
this.traverse(path);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Here's a slightly more involved example of transforming `...rest`
|
||||
parameters into browser-runnable ES5 JavaScript:
|
||||
|
||||
```js
|
||||
import { builders as b, visit } from "ast-types";
|
||||
|
||||
// Reuse the same AST structure for Array.prototype.slice.call.
|
||||
var sliceExpr = b.memberExpression(
|
||||
b.memberExpression(
|
||||
b.memberExpression(
|
||||
b.identifier("Array"),
|
||||
b.identifier("prototype"),
|
||||
false
|
||||
),
|
||||
b.identifier("slice"),
|
||||
false
|
||||
),
|
||||
b.identifier("call"),
|
||||
false
|
||||
);
|
||||
|
||||
visit(ast, {
|
||||
// This method will be called for any node whose type is a subtype of
|
||||
// Function (e.g., FunctionDeclaration, FunctionExpression, and
|
||||
// ArrowFunctionExpression). Note that types.visit precomputes a
|
||||
// lookup table from every known type to the appropriate visitor
|
||||
// method to call for nodes of that type, so the dispatch takes
|
||||
// constant time.
|
||||
visitFunction(path) {
|
||||
// Visitor methods receive a single argument, a NodePath object
|
||||
// wrapping the node of interest.
|
||||
const node = path.node;
|
||||
|
||||
// It's your responsibility to call this.traverse with some
|
||||
// NodePath object (usually the one passed into the visitor
|
||||
// method) before the visitor method returns, or return false to
|
||||
// indicate that the traversal need not continue any further down
|
||||
// this subtree. An assertion will fail if you forget, which is
|
||||
// awesome, because it means you will never again make the
|
||||
// disastrous mistake of forgetting to traverse a subtree. Also
|
||||
// cool: because you can call this method at any point in the
|
||||
// visitor method, it's up to you whether your traversal is
|
||||
// pre-order, post-order, or both!
|
||||
this.traverse(path);
|
||||
|
||||
// This traversal is only concerned with Function nodes that have
|
||||
// rest parameters.
|
||||
if (!node.rest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For the purposes of this example, we won't worry about functions
|
||||
// with Expression bodies.
|
||||
n.BlockStatement.assert(node.body);
|
||||
|
||||
// Use types.builders to build a variable declaration of the form
|
||||
//
|
||||
// var rest = Array.prototype.slice.call(arguments, n);
|
||||
//
|
||||
// where `rest` is the name of the rest parameter, and `n` is a
|
||||
// numeric literal specifying the number of named parameters the
|
||||
// function takes.
|
||||
const restVarDecl = b.variableDeclaration("var", [
|
||||
b.variableDeclarator(
|
||||
node.rest,
|
||||
b.callExpression(sliceExpr, [
|
||||
b.identifier("arguments"),
|
||||
b.literal(node.params.length)
|
||||
])
|
||||
)
|
||||
]);
|
||||
|
||||
// Similar to doing node.body.body.unshift(restVarDecl), except
|
||||
// that the other NodePath objects wrapping body statements will
|
||||
// have their indexes updated to accommodate the new statement.
|
||||
path.get("body", "body").unshift(restVarDecl);
|
||||
|
||||
// Nullify node.rest now that we have simulated the behavior of
|
||||
// the rest parameter using ordinary JavaScript.
|
||||
path.get("rest").replace(null);
|
||||
|
||||
// There's nothing wrong with doing node.rest = null, but I wanted
|
||||
// to point out that the above statement has the same effect.
|
||||
assert.strictEqual(node.rest, null);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Here's how you might use `types.visit` to implement a function that
|
||||
determines if a given function node refers to `this`:
|
||||
|
||||
```js
|
||||
function usesThis(funcNode) {
|
||||
n.Function.assert(funcNode);
|
||||
var result = false;
|
||||
|
||||
visit(funcNode, {
|
||||
visitThisExpression(path) {
|
||||
result = true;
|
||||
|
||||
// The quickest way to terminate the traversal is to call
|
||||
// this.abort(), which throws a special exception (instanceof
|
||||
// this.AbortRequest) that will be caught in the top-level
|
||||
// types.visit method, so you don't have to worry about
|
||||
// catching the exception yourself.
|
||||
this.abort();
|
||||
},
|
||||
|
||||
visitFunction(path) {
|
||||
// ThisExpression nodes in nested scopes don't count as `this`
|
||||
// references for the original function node, so we can safely
|
||||
// avoid traversing this subtree.
|
||||
return false;
|
||||
},
|
||||
|
||||
visitCallExpression(path) {
|
||||
const node = path.node;
|
||||
|
||||
// If the function contains CallExpression nodes involving
|
||||
// super, those expressions will implicitly depend on the
|
||||
// value of `this`, even though they do not explicitly contain
|
||||
// any ThisExpression nodes.
|
||||
if (this.isSuperCallExpression(node)) {
|
||||
result = true;
|
||||
this.abort(); // Throws AbortRequest exception.
|
||||
}
|
||||
|
||||
this.traverse(path);
|
||||
},
|
||||
|
||||
// Yes, you can define arbitrary helper methods.
|
||||
isSuperCallExpression(callExpr) {
|
||||
n.CallExpression.assert(callExpr);
|
||||
return this.isSuperIdentifier(callExpr.callee)
|
||||
|| this.isSuperMemberExpression(callExpr.callee);
|
||||
},
|
||||
|
||||
// And even helper helper methods!
|
||||
isSuperIdentifier(node) {
|
||||
return n.Identifier.check(node.callee)
|
||||
&& node.callee.name === "super";
|
||||
},
|
||||
|
||||
isSuperMemberExpression(node) {
|
||||
return n.MemberExpression.check(node.callee)
|
||||
&& n.Identifier.check(node.callee.object)
|
||||
&& node.callee.object.name === "super";
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
As you might guess, when an `AbortRequest` is thrown from a subtree, the
|
||||
exception will propagate from the corresponding calls to `this.traverse`
|
||||
in the ancestor visitor methods. If you decide you want to cancel the
|
||||
request, simply catch the exception and call its `.cancel()` method. The
|
||||
rest of the subtree beneath the `try`-`catch` block will be abandoned, but
|
||||
the remaining siblings of the ancestor node will still be visited.
|
||||
|
||||
NodePath
|
||||
---
|
||||
|
||||
The `NodePath` object passed to visitor methods is a wrapper around an AST
|
||||
node, and it serves to provide access to the chain of ancestor objects
|
||||
(all the way back to the root of the AST) and scope information.
|
||||
|
||||
In general, `path.node` refers to the wrapped node, `path.parent.node`
|
||||
refers to the nearest `Node` ancestor, `path.parent.parent.node` to the
|
||||
grandparent, and so on.
|
||||
|
||||
Note that `path.node` may not be a direct property value of
|
||||
`path.parent.node`; for instance, it might be the case that `path.node` is
|
||||
an element of an array that is a direct child of the parent node:
|
||||
```js
|
||||
path.node === path.parent.node.elements[3]
|
||||
```
|
||||
in which case you should know that `path.parentPath` provides
|
||||
finer-grained access to the complete path of objects (not just the `Node`
|
||||
ones) from the root of the AST:
|
||||
```js
|
||||
// In reality, path.parent is the grandparent of path:
|
||||
path.parentPath.parentPath === path.parent
|
||||
|
||||
// The path.parentPath object wraps the elements array (note that we use
|
||||
// .value because the elements array is not a Node):
|
||||
path.parentPath.value === path.parent.node.elements
|
||||
|
||||
// The path.node object is the fourth element in that array:
|
||||
path.parentPath.value[3] === path.node
|
||||
|
||||
// Unlike path.node and path.value, which are synonyms because path.node
|
||||
// is a Node object, path.parentPath.node is distinct from
|
||||
// path.parentPath.value, because the elements array is not a
|
||||
// Node. Instead, path.parentPath.node refers to the closest ancestor
|
||||
// Node, which happens to be the same as path.parent.node:
|
||||
path.parentPath.node === path.parent.node
|
||||
|
||||
// The path is named for its index in the elements array:
|
||||
path.name === 3
|
||||
|
||||
// Likewise, path.parentPath is named for the property by which
|
||||
// path.parent.node refers to it:
|
||||
path.parentPath.name === "elements"
|
||||
|
||||
// Putting it all together, we can follow the chain of object references
|
||||
// from path.parent.node all the way to path.node by accessing each
|
||||
// property by name:
|
||||
path.parent.node[path.parentPath.name][path.name] === path.node
|
||||
```
|
||||
|
||||
These `NodePath` objects are created during the traversal without
|
||||
modifying the AST nodes themselves, so it's not a problem if the same node
|
||||
appears more than once in the AST (like `Array.prototype.slice.call` in
|
||||
the example above), because it will be visited with a distict `NodePath`
|
||||
each time it appears.
|
||||
|
||||
Child `NodePath` objects are created lazily, by calling the `.get` method
|
||||
of a parent `NodePath` object:
|
||||
```js
|
||||
// If a NodePath object for the elements array has never been created
|
||||
// before, it will be created here and cached in the future:
|
||||
path.get("elements").get(3).value === path.value.elements[3]
|
||||
|
||||
// Alternatively, you can pass multiple property names to .get instead of
|
||||
// chaining multiple .get calls:
|
||||
path.get("elements", 0).value === path.value.elements[0]
|
||||
```
|
||||
|
||||
`NodePath` objects support a number of useful methods:
|
||||
```js
|
||||
// Replace one node with another node:
|
||||
var fifth = path.get("elements", 4);
|
||||
fifth.replace(newNode);
|
||||
|
||||
// Now do some stuff that might rearrange the list, and this replacement
|
||||
// remains safe:
|
||||
fifth.replace(newerNode);
|
||||
|
||||
// Replace the third element in an array with two new nodes:
|
||||
path.get("elements", 2).replace(
|
||||
b.identifier("foo"),
|
||||
b.thisExpression()
|
||||
);
|
||||
|
||||
// Remove a node and its parent if it would leave a redundant AST node:
|
||||
//e.g. var t = 1, y =2; removing the `t` and `y` declarators results in `var undefined`.
|
||||
path.prune(); //returns the closest parent `NodePath`.
|
||||
|
||||
// Remove a node from a list of nodes:
|
||||
path.get("elements", 3).replace();
|
||||
|
||||
// Add three new nodes to the beginning of a list of nodes:
|
||||
path.get("elements").unshift(a, b, c);
|
||||
|
||||
// Remove and return the first node in a list of nodes:
|
||||
path.get("elements").shift();
|
||||
|
||||
// Push two new nodes onto the end of a list of nodes:
|
||||
path.get("elements").push(d, e);
|
||||
|
||||
// Remove and return the last node in a list of nodes:
|
||||
path.get("elements").pop();
|
||||
|
||||
// Insert a new node before/after the seventh node in a list of nodes:
|
||||
var seventh = path.get("elements", 6);
|
||||
seventh.insertBefore(newNode);
|
||||
seventh.insertAfter(newNode);
|
||||
|
||||
// Insert a new element at index 5 in a list of nodes:
|
||||
path.get("elements").insertAt(5, newNode);
|
||||
```
|
||||
|
||||
Scope
|
||||
---
|
||||
|
||||
The object exposed as `path.scope` during AST traversals provides
|
||||
information about variable and function declarations in the scope that
|
||||
contains `path.node`. See [scope.ts](lib/scope.ts) for its public
|
||||
interface, which currently includes `.isGlobal`, `.getGlobalScope()`,
|
||||
`.depth`, `.declares(name)`, `.lookup(name)`, and `.getBindings()`.
|
||||
|
||||
Custom AST Node Types
|
||||
---
|
||||
|
||||
The `ast-types` module was designed to be extended. To that end, it
|
||||
provides a readable, declarative syntax for specifying new AST node types,
|
||||
based primarily upon the `require("ast-types").Type.def` function:
|
||||
```js
|
||||
import {
|
||||
Type,
|
||||
builtInTypes,
|
||||
builders as b,
|
||||
finalize,
|
||||
} from "ast-types";
|
||||
|
||||
const { def } = Type;
|
||||
const { string } = builtInTypes;
|
||||
|
||||
// Suppose you need a named File type to wrap your Programs.
|
||||
def("File")
|
||||
.bases("Node")
|
||||
.build("name", "program")
|
||||
.field("name", string)
|
||||
.field("program", def("Program"));
|
||||
|
||||
// Prevent further modifications to the File type (and any other
|
||||
// types newly introduced by def(...)).
|
||||
finalize();
|
||||
|
||||
// The b.file builder function is now available. It expects two
|
||||
// arguments, as named by .build("name", "program") above.
|
||||
const main = b.file("main.js", b.program([
|
||||
// Pointless program contents included for extra color.
|
||||
b.functionDeclaration(b.identifier("succ"), [
|
||||
b.identifier("x")
|
||||
], b.blockStatement([
|
||||
b.returnStatement(
|
||||
b.binaryExpression(
|
||||
"+", b.identifier("x"), b.literal(1)
|
||||
)
|
||||
)
|
||||
]))
|
||||
]));
|
||||
|
||||
assert.strictEqual(main.name, "main.js");
|
||||
assert.strictEqual(main.program.body[0].params[0].name, "x");
|
||||
// etc.
|
||||
|
||||
// If you pass the wrong type of arguments, or fail to pass enough
|
||||
// arguments, an AssertionError will be thrown.
|
||||
|
||||
b.file(b.blockStatement([]));
|
||||
// ==> AssertionError: {"body":[],"type":"BlockStatement","loc":null} does not match type string
|
||||
|
||||
b.file("lib/types.js", b.thisExpression());
|
||||
// ==> AssertionError: {"type":"ThisExpression","loc":null} does not match type Program
|
||||
```
|
||||
|
||||
The `def` syntax is used to define all the default AST node types found in
|
||||
[babel-core.ts](def/babel-core.ts),
|
||||
[babel.ts](def/babel.ts),
|
||||
[core.ts](def/core.ts),
|
||||
[es-proposals.ts](def/es-proposals.ts),
|
||||
[es6.ts](def/es6.ts),
|
||||
[es7.ts](def/es7.ts),
|
||||
[es2020.ts](def/es2020.ts),
|
||||
[esprima.ts](def/esprima.ts),
|
||||
[flow.ts](def/flow.ts),
|
||||
[jsx.ts](def/jsx.ts),
|
||||
[type-annotations.ts](def/type-annotations.ts),
|
||||
and
|
||||
[typescripts.ts](def/typescripts.ts),
|
||||
so you have
|
||||
no shortage of examples to learn from.
|
||||
@@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/libs/core/dataToCSVLine.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../../index.html">All files</a> / <a href="index.html">csv2json/libs/core</a> dataToCSVLine.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>0/7</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>0/7</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
</div>
|
||||
<div class='status-line low'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a></td><td class="line-coverage quiet"><span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span></td><td class="text"><pre class="prettyprint lang-js">Unable to lookup source: /Users/kxiang/work/projects/csv2json/libs/core/dataToCSVLine.js(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/libs/core/dataToCSVLine.js')
|
||||
Error: Unable to lookup source: /Users/kxiang/work/projects/csv2json/libs/core/dataToCSVLine.js(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/libs/core/dataToCSVLine.js')
|
||||
at Context.defaultSourceLookup [as sourceFinder] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:15:15)
|
||||
at Context.getSource (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:74:17)
|
||||
at Object.annotateSourceCode (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/annotator.js:172:38)
|
||||
at HtmlReport.onDetail (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/index.js:237:39)
|
||||
at Visitor.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:34:30)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:123:17)
|
||||
at /Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:116:23
|
||||
at Array.forEach (native)
|
||||
at visitChildren (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:115:32)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:126:5)</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:36:07 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../../sorter.js"></script>
|
||||
<script src="../../../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
var apply = require('./_apply'),
|
||||
arrayMap = require('./_arrayMap'),
|
||||
baseIteratee = require('./_baseIteratee'),
|
||||
baseRest = require('./_baseRest');
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
* Creates a function that iterates over `pairs` and invokes the corresponding
|
||||
* function of the first predicate to return truthy. The predicate-function
|
||||
* pairs are invoked with the `this` binding and arguments of the created
|
||||
* function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Util
|
||||
* @param {Array} pairs The predicate-function pairs.
|
||||
* @returns {Function} Returns the new composite function.
|
||||
* @example
|
||||
*
|
||||
* var func = _.cond([
|
||||
* [_.matches({ 'a': 1 }), _.constant('matches A')],
|
||||
* [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
|
||||
* [_.stubTrue, _.constant('no match')]
|
||||
* ]);
|
||||
*
|
||||
* func({ 'a': 1, 'b': 2 });
|
||||
* // => 'matches A'
|
||||
*
|
||||
* func({ 'a': 0, 'b': 1 });
|
||||
* // => 'matches B'
|
||||
*
|
||||
* func({ 'a': '1', 'b': '2' });
|
||||
* // => 'no match'
|
||||
*/
|
||||
function cond(pairs) {
|
||||
var length = pairs == null ? 0 : pairs.length,
|
||||
toIteratee = baseIteratee;
|
||||
|
||||
pairs = !length ? [] : arrayMap(pairs, function(pair) {
|
||||
if (typeof pair[1] != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
return [toIteratee(pair[0]), pair[1]];
|
||||
});
|
||||
|
||||
return baseRest(function(args) {
|
||||
var index = -1;
|
||||
while (++index < length) {
|
||||
var pair = pairs[index];
|
||||
if (apply(pair[0], this, args)) {
|
||||
return apply(pair[1], this, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = cond;
|
||||
@@ -0,0 +1,332 @@
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
import { Observable } from '../Observable';
|
||||
import { mergeMap } from '../operators/mergeMap';
|
||||
import { isArrayLike } from '../util/isArrayLike';
|
||||
import { isFunction } from '../util/isFunction';
|
||||
import { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';
|
||||
|
||||
// These constants are used to create handler registry functions using array mapping below.
|
||||
const nodeEventEmitterMethods = ['addListener', 'removeListener'] as const;
|
||||
const eventTargetMethods = ['addEventListener', 'removeEventListener'] as const;
|
||||
const jqueryMethods = ['on', 'off'] as const;
|
||||
|
||||
export interface NodeStyleEventEmitter {
|
||||
addListener(eventName: string | symbol, handler: NodeEventHandler): this;
|
||||
removeListener(eventName: string | symbol, handler: NodeEventHandler): this;
|
||||
}
|
||||
|
||||
export type NodeEventHandler = (...args: any[]) => void;
|
||||
|
||||
// For APIs that implement `addListener` and `removeListener` methods that may
|
||||
// not use the same arguments or return EventEmitter values
|
||||
// such as React Native
|
||||
export interface NodeCompatibleEventEmitter {
|
||||
addListener(eventName: string, handler: NodeEventHandler): void | {};
|
||||
removeListener(eventName: string, handler: NodeEventHandler): void | {};
|
||||
}
|
||||
|
||||
// Use handler types like those in @types/jquery. See:
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/847731ba1d7fa6db6b911c0e43aa0afe596e7723/types/jquery/misc.d.ts#L6395
|
||||
export interface JQueryStyleEventEmitter<TContext, T> {
|
||||
on(eventName: string, handler: (this: TContext, t: T, ...args: any[]) => any): void;
|
||||
off(eventName: string, handler: (this: TContext, t: T, ...args: any[]) => any): void;
|
||||
}
|
||||
|
||||
export interface EventListenerObject<E> {
|
||||
handleEvent(evt: E): void;
|
||||
}
|
||||
|
||||
export interface HasEventTargetAddRemove<E> {
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: ((evt: E) => void) | EventListenerObject<E> | null,
|
||||
options?: boolean | AddEventListenerOptions
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: ((evt: E) => void) | EventListenerObject<E> | null,
|
||||
options?: EventListenerOptions | boolean
|
||||
): void;
|
||||
}
|
||||
|
||||
export interface EventListenerOptions {
|
||||
capture?: boolean;
|
||||
passive?: boolean;
|
||||
once?: boolean;
|
||||
}
|
||||
|
||||
export interface AddEventListenerOptions extends EventListenerOptions {
|
||||
once?: boolean;
|
||||
passive?: boolean;
|
||||
}
|
||||
|
||||
export function fromEvent<T>(target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>, eventName: string): Observable<T>;
|
||||
export function fromEvent<T, R>(
|
||||
target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>,
|
||||
eventName: string,
|
||||
resultSelector: (event: T) => R
|
||||
): Observable<R>;
|
||||
export function fromEvent<T>(
|
||||
target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>,
|
||||
eventName: string,
|
||||
options: EventListenerOptions
|
||||
): Observable<T>;
|
||||
export function fromEvent<T, R>(
|
||||
target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>,
|
||||
eventName: string,
|
||||
options: EventListenerOptions,
|
||||
resultSelector: (event: T) => R
|
||||
): Observable<R>;
|
||||
|
||||
export function fromEvent(target: NodeStyleEventEmitter | ArrayLike<NodeStyleEventEmitter>, eventName: string): Observable<unknown>;
|
||||
/** @deprecated Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8. */
|
||||
export function fromEvent<T>(target: NodeStyleEventEmitter | ArrayLike<NodeStyleEventEmitter>, eventName: string): Observable<T>;
|
||||
export function fromEvent<R>(
|
||||
target: NodeStyleEventEmitter | ArrayLike<NodeStyleEventEmitter>,
|
||||
eventName: string,
|
||||
resultSelector: (...args: any[]) => R
|
||||
): Observable<R>;
|
||||
|
||||
export function fromEvent(
|
||||
target: NodeCompatibleEventEmitter | ArrayLike<NodeCompatibleEventEmitter>,
|
||||
eventName: string
|
||||
): Observable<unknown>;
|
||||
/** @deprecated Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8. */
|
||||
export function fromEvent<T>(target: NodeCompatibleEventEmitter | ArrayLike<NodeCompatibleEventEmitter>, eventName: string): Observable<T>;
|
||||
export function fromEvent<R>(
|
||||
target: NodeCompatibleEventEmitter | ArrayLike<NodeCompatibleEventEmitter>,
|
||||
eventName: string,
|
||||
resultSelector: (...args: any[]) => R
|
||||
): Observable<R>;
|
||||
|
||||
export function fromEvent<T>(
|
||||
target: JQueryStyleEventEmitter<any, T> | ArrayLike<JQueryStyleEventEmitter<any, T>>,
|
||||
eventName: string
|
||||
): Observable<T>;
|
||||
export function fromEvent<T, R>(
|
||||
target: JQueryStyleEventEmitter<any, T> | ArrayLike<JQueryStyleEventEmitter<any, T>>,
|
||||
eventName: string,
|
||||
resultSelector: (value: T, ...args: any[]) => R
|
||||
): Observable<R>;
|
||||
|
||||
/**
|
||||
* Creates an Observable that emits events of a specific type coming from the
|
||||
* given event target.
|
||||
*
|
||||
* <span class="informal">Creates an Observable from DOM events, or Node.js
|
||||
* EventEmitter events or others.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `fromEvent` accepts as a first argument event target, which is an object with methods
|
||||
* for registering event handler functions. As a second argument it takes string that indicates
|
||||
* type of event we want to listen for. `fromEvent` supports selected types of event targets,
|
||||
* which are described in detail below. If your event target does not match any of the ones listed,
|
||||
* you should use {@link fromEventPattern}, which can be used on arbitrary APIs.
|
||||
* When it comes to APIs supported by `fromEvent`, their methods for adding and removing event
|
||||
* handler functions have different names, but they all accept a string describing event type
|
||||
* and function itself, which will be called whenever said event happens.
|
||||
*
|
||||
* Every time resulting Observable is subscribed, event handler function will be registered
|
||||
* to event target on given event type. When that event fires, value
|
||||
* passed as a first argument to registered function will be emitted by output Observable.
|
||||
* When Observable is unsubscribed, function will be unregistered from event target.
|
||||
*
|
||||
* Note that if event target calls registered function with more than one argument, second
|
||||
* and following arguments will not appear in resulting stream. In order to get access to them,
|
||||
* you can pass to `fromEvent` optional project function, which will be called with all arguments
|
||||
* passed to event handler. Output Observable will then emit value returned by project function,
|
||||
* instead of the usual value.
|
||||
*
|
||||
* Remember that event targets listed below are checked via duck typing. It means that
|
||||
* no matter what kind of object you have and no matter what environment you work in,
|
||||
* you can safely use `fromEvent` on that object if it exposes described methods (provided
|
||||
* of course they behave as was described above). So for example if Node.js library exposes
|
||||
* event target which has the same method names as DOM EventTarget, `fromEvent` is still
|
||||
* a good choice.
|
||||
*
|
||||
* If the API you use is more callback then event handler oriented (subscribed
|
||||
* callback function fires only once and thus there is no need to manually
|
||||
* unregister it), you should use {@link bindCallback} or {@link bindNodeCallback}
|
||||
* instead.
|
||||
*
|
||||
* `fromEvent` supports following types of event targets:
|
||||
*
|
||||
* **DOM EventTarget**
|
||||
*
|
||||
* This is an object with `addEventListener` and `removeEventListener` methods.
|
||||
*
|
||||
* In the browser, `addEventListener` accepts - apart from event type string and event
|
||||
* handler function arguments - optional third parameter, which is either an object or boolean,
|
||||
* both used for additional configuration how and when passed function will be called. When
|
||||
* `fromEvent` is used with event target of that type, you can provide this values
|
||||
* as third parameter as well.
|
||||
*
|
||||
* **Node.js EventEmitter**
|
||||
*
|
||||
* An object with `addListener` and `removeListener` methods.
|
||||
*
|
||||
* **JQuery-style event target**
|
||||
*
|
||||
* An object with `on` and `off` methods
|
||||
*
|
||||
* **DOM NodeList**
|
||||
*
|
||||
* List of DOM Nodes, returned for example by `document.querySelectorAll` or `Node.childNodes`.
|
||||
*
|
||||
* Although this collection is not event target in itself, `fromEvent` will iterate over all Nodes
|
||||
* it contains and install event handler function in every of them. When returned Observable
|
||||
* is unsubscribed, function will be removed from all Nodes.
|
||||
*
|
||||
* **DOM HtmlCollection**
|
||||
*
|
||||
* Just as in case of NodeList it is a collection of DOM nodes. Here as well event handler function is
|
||||
* installed and removed in each of elements.
|
||||
*
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Emit clicks happening on the DOM document
|
||||
*
|
||||
* ```ts
|
||||
* import { fromEvent } from 'rxjs';
|
||||
*
|
||||
* const clicks = fromEvent(document, 'click');
|
||||
* clicks.subscribe(x => console.log(x));
|
||||
*
|
||||
* // Results in:
|
||||
* // MouseEvent object logged to console every time a click
|
||||
* // occurs on the document.
|
||||
* ```
|
||||
*
|
||||
* Use `addEventListener` with capture option
|
||||
*
|
||||
* ```ts
|
||||
* import { fromEvent } from 'rxjs';
|
||||
*
|
||||
* const clicksInDocument = fromEvent(document, 'click', true); // note optional configuration parameter
|
||||
* // which will be passed to addEventListener
|
||||
* const clicksInDiv = fromEvent(someDivInDocument, 'click');
|
||||
*
|
||||
* clicksInDocument.subscribe(() => console.log('document'));
|
||||
* clicksInDiv.subscribe(() => console.log('div'));
|
||||
*
|
||||
* // By default events bubble UP in DOM tree, so normally
|
||||
* // when we would click on div in document
|
||||
* // "div" would be logged first and then "document".
|
||||
* // Since we specified optional `capture` option, document
|
||||
* // will catch event when it goes DOWN DOM tree, so console
|
||||
* // will log "document" and then "div".
|
||||
* ```
|
||||
*
|
||||
* @see {@link bindCallback}
|
||||
* @see {@link bindNodeCallback}
|
||||
* @see {@link fromEventPattern}
|
||||
*
|
||||
* @param {FromEventTarget<T>} target The DOM EventTarget, Node.js
|
||||
* EventEmitter, JQuery-like event target, NodeList or HTMLCollection to attach the event handler to.
|
||||
* @param {string} eventName The event name of interest, being emitted by the
|
||||
* `target`.
|
||||
* @param {EventListenerOptions} [options] Options to pass through to addEventListener
|
||||
* @return {Observable<T>}
|
||||
*/
|
||||
export function fromEvent<T>(
|
||||
target: any,
|
||||
eventName: string,
|
||||
options?: EventListenerOptions | ((...args: any[]) => T),
|
||||
resultSelector?: (...args: any[]) => T
|
||||
): Observable<T> {
|
||||
if (isFunction(options)) {
|
||||
resultSelector = options;
|
||||
options = undefined;
|
||||
}
|
||||
if (resultSelector) {
|
||||
return fromEvent<T>(target, eventName, options as EventListenerOptions).pipe(mapOneOrManyArgs(resultSelector));
|
||||
}
|
||||
|
||||
// Figure out our add and remove methods. In order to do this,
|
||||
// we are going to analyze the target in a preferred order, if
|
||||
// the target matches a given signature, we take the two "add" and "remove"
|
||||
// method names and apply them to a map to create opposite versions of the
|
||||
// same function. This is because they all operate in duplicate pairs,
|
||||
// `addListener(name, handler)`, `removeListener(name, handler)`, for example.
|
||||
// The call only differs by method name, as to whether or not you're adding or removing.
|
||||
const [add, remove] =
|
||||
// If it is an EventTarget, we need to use a slightly different method than the other two patterns.
|
||||
isEventTarget(target)
|
||||
? eventTargetMethods.map((methodName) => (handler: any) => target[methodName](eventName, handler, options as EventListenerOptions))
|
||||
: // In all other cases, the call pattern is identical with the exception of the method names.
|
||||
isNodeStyleEventEmitter(target)
|
||||
? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName))
|
||||
: isJQueryStyleEventEmitter(target)
|
||||
? jqueryMethods.map(toCommonHandlerRegistry(target, eventName))
|
||||
: [];
|
||||
|
||||
// If add is falsy, it's because we didn't match a pattern above.
|
||||
// Check to see if it is an ArrayLike, because if it is, we want to
|
||||
// try to apply fromEvent to all of it's items. We do this check last,
|
||||
// because there are may be some types that are both ArrayLike *and* implement
|
||||
// event registry points, and we'd rather delegate to that when possible.
|
||||
if (!add) {
|
||||
if (isArrayLike(target)) {
|
||||
return mergeMap((subTarget: any) => fromEvent(subTarget, eventName, options as EventListenerOptions))(
|
||||
innerFrom(target)
|
||||
) as Observable<T>;
|
||||
}
|
||||
}
|
||||
|
||||
// If add is falsy and we made it here, it's because we didn't
|
||||
// match any valid target objects above.
|
||||
if (!add) {
|
||||
throw new TypeError('Invalid event target');
|
||||
}
|
||||
|
||||
return new Observable<T>((subscriber) => {
|
||||
// The handler we are going to register. Forwards the event object, by itself, or
|
||||
// an array of arguments to the event handler, if there is more than one argument,
|
||||
// to the consumer.
|
||||
const handler = (...args: any[]) => subscriber.next(1 < args.length ? args : args[0]);
|
||||
// Do the work of adding the handler to the target.
|
||||
add(handler);
|
||||
// When we finalize, we want to remove the handler and free up memory.
|
||||
return () => remove!(handler);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to create `add` and `remove` functions to register and unregister event handlers
|
||||
* from a target in the most common handler pattern, where there are only two arguments.
|
||||
* (e.g. `on(name, fn)`, `off(name, fn)`, `addListener(name, fn)`, or `removeListener(name, fn)`)
|
||||
* @param target The target we're calling methods on
|
||||
* @param eventName The event name for the event we're creating register or unregister functions for
|
||||
*/
|
||||
function toCommonHandlerRegistry(target: any, eventName: string) {
|
||||
return (methodName: string) => (handler: any) => target[methodName](eventName, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the target implements the required node-style EventEmitter methods
|
||||
* for adding and removing event handlers.
|
||||
* @param target the object to check
|
||||
*/
|
||||
function isNodeStyleEventEmitter(target: any): target is NodeStyleEventEmitter {
|
||||
return isFunction(target.addListener) && isFunction(target.removeListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the target implements the required jQuery-style EventEmitter methods
|
||||
* for adding and removing event handlers.
|
||||
* @param target the object to check
|
||||
*/
|
||||
function isJQueryStyleEventEmitter(target: any): target is JQueryStyleEventEmitter<any, any> {
|
||||
return isFunction(target.on) && isFunction(target.off);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the target implements the required EventTarget methods
|
||||
* for adding and removing event handlers.
|
||||
* @param target the object to check
|
||||
*/
|
||||
function isEventTarget(target: any): target is HasEventTargetAddRemove<any> {
|
||||
return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type MailSendingError = {
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
@@ -0,0 +1,126 @@
|
||||
# clone
|
||||
|
||||
[](http://travis-ci.org/pvorb/node-clone)
|
||||
|
||||
[](http://npm-stat.com/charts.html?package=clone)
|
||||
|
||||
offers foolproof _deep cloning_ of objects, arrays, numbers, strings etc. in JavaScript.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
npm install clone
|
||||
|
||||
(It also works with browserify, ender or standalone.)
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
~~~ javascript
|
||||
var clone = require('clone');
|
||||
|
||||
var a, b;
|
||||
|
||||
a = { foo: { bar: 'baz' } }; // initial value of a
|
||||
|
||||
b = clone(a); // clone a -> b
|
||||
a.foo.bar = 'foo'; // change a
|
||||
|
||||
console.log(a); // show a
|
||||
console.log(b); // show b
|
||||
~~~
|
||||
|
||||
This will print:
|
||||
|
||||
~~~ javascript
|
||||
{ foo: { bar: 'foo' } }
|
||||
{ foo: { bar: 'baz' } }
|
||||
~~~
|
||||
|
||||
**clone** masters cloning simple objects (even with custom prototype), arrays,
|
||||
Date objects, and RegExp objects. Everything is cloned recursively, so that you
|
||||
can clone dates in arrays in objects, for example.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
`clone(val, circular, depth)`
|
||||
|
||||
* `val` -- the value that you want to clone, any type allowed
|
||||
* `circular` -- boolean
|
||||
|
||||
Call `clone` with `circular` set to `false` if you are certain that `obj`
|
||||
contains no circular references. This will give better performance if needed.
|
||||
There is no error if `undefined` or `null` is passed as `obj`.
|
||||
* `depth` -- depth to which the object is to be cloned (optional,
|
||||
defaults to infinity)
|
||||
|
||||
`clone.clonePrototype(obj)`
|
||||
|
||||
* `obj` -- the object that you want to clone
|
||||
|
||||
Does a prototype clone as
|
||||
[described by Oran Looney](http://oranlooney.com/functional-javascript/).
|
||||
|
||||
|
||||
## Circular References
|
||||
|
||||
~~~ javascript
|
||||
var a, b;
|
||||
|
||||
a = { hello: 'world' };
|
||||
|
||||
a.myself = a;
|
||||
b = clone(a);
|
||||
|
||||
console.log(b);
|
||||
~~~
|
||||
|
||||
This will print:
|
||||
|
||||
~~~ javascript
|
||||
{ hello: "world", myself: [Circular] }
|
||||
~~~
|
||||
|
||||
So, `b.myself` points to `b`, not `a`. Neat!
|
||||
|
||||
|
||||
## Test
|
||||
|
||||
npm test
|
||||
|
||||
|
||||
## Caveat
|
||||
|
||||
Some special objects like a socket or `process.stdout`/`stderr` are known to not
|
||||
be cloneable. If you find other objects that cannot be cloned, please [open an
|
||||
issue](https://github.com/pvorb/node-clone/issues/new).
|
||||
|
||||
|
||||
## Bugs and Issues
|
||||
|
||||
If you encounter any bugs or issues, feel free to [open an issue at
|
||||
github](https://github.com/pvorb/node-clone/issues) or send me an email to
|
||||
<paul@vorba.ch>. I also always like to hear from you, if you’re using my code.
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2011-2015 [Paul Vorbach](http://paul.vorba.ch/) and
|
||||
[contributors](https://github.com/pvorb/node-clone/graphs/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, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../dist-src/version.js","../dist-src/index.js"],"sourcesContent":["export const VERSION = \"1.0.4\";\n","import { VERSION } from \"./version\";\n/**\n * @param octokit Octokit instance\n * @param options Options passed to Octokit constructor\n */\nexport function requestLog(octokit) {\n octokit.hook.wrap(\"request\", (request, options) => {\n octokit.log.debug(\"request\", options);\n const start = Date.now();\n const requestOptions = octokit.request.endpoint.parse(options);\n const path = requestOptions.url.replace(options.baseUrl, \"\");\n return request(options)\n .then((response) => {\n octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);\n return response;\n })\n .catch((error) => {\n octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);\n throw error;\n });\n });\n}\nrequestLog.VERSION = VERSION;\n"],"names":["VERSION","requestLog","octokit","hook","wrap","request","options","log","debug","start","Date","now","requestOptions","endpoint","parse","path","url","replace","baseUrl","then","response","info","method","status","catch","error"],"mappings":";;;;AAAO,MAAMA,OAAO,GAAG,mBAAhB;;ACCP;AACA;AACA;AACA;;AACA,AAAO,SAASC,UAAT,CAAoBC,OAApB,EAA6B;AAChCA,EAAAA,OAAO,CAACC,IAAR,CAAaC,IAAb,CAAkB,SAAlB,EAA6B,CAACC,OAAD,EAAUC,OAAV,KAAsB;AAC/CJ,IAAAA,OAAO,CAACK,GAAR,CAAYC,KAAZ,CAAkB,SAAlB,EAA6BF,OAA7B;AACA,UAAMG,KAAK,GAAGC,IAAI,CAACC,GAAL,EAAd;AACA,UAAMC,cAAc,GAAGV,OAAO,CAACG,OAAR,CAAgBQ,QAAhB,CAAyBC,KAAzB,CAA+BR,OAA/B,CAAvB;AACA,UAAMS,IAAI,GAAGH,cAAc,CAACI,GAAf,CAAmBC,OAAnB,CAA2BX,OAAO,CAACY,OAAnC,EAA4C,EAA5C,CAAb;AACA,WAAOb,OAAO,CAACC,OAAD,CAAP,CACFa,IADE,CACIC,QAAD,IAAc;AACpBlB,MAAAA,OAAO,CAACK,GAAR,CAAYc,IAAZ,CAAkB,GAAET,cAAc,CAACU,MAAO,IAAGP,IAAK,MAAKK,QAAQ,CAACG,MAAO,OAAMb,IAAI,CAACC,GAAL,KAAaF,KAAM,IAAhG;AACA,aAAOW,QAAP;AACH,KAJM,EAKFI,KALE,CAKKC,KAAD,IAAW;AAClBvB,MAAAA,OAAO,CAACK,GAAR,CAAYc,IAAZ,CAAkB,GAAET,cAAc,CAACU,MAAO,IAAGP,IAAK,MAAKU,KAAK,CAACF,MAAO,OAAMb,IAAI,CAACC,GAAL,KAAaF,KAAM,IAA7F;AACA,YAAMgB,KAAN;AACH,KARM,CAAP;AASH,GAdD;AAeH;AACDxB,UAAU,CAACD,OAAX,GAAqBA,OAArB;;;;"}
|
||||
@@ -0,0 +1,367 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import open from 'open';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import fetch from 'node-fetch';
|
||||
import { globby } from 'globby';
|
||||
import mime from 'mime-types';
|
||||
import _ from 'lodash';
|
||||
import retry from 'async-retry';
|
||||
import newGithubReleaseUrl from 'new-github-release-url';
|
||||
import ProxyAgent from 'proxy-agent';
|
||||
import { format, parseVersion, readJSON, e } from '../../util.js';
|
||||
import Release from '../GitRelease.js';
|
||||
import prompts from './prompts.js';
|
||||
|
||||
const pkg = readJSON(new URL('../../../package.json', import.meta.url));
|
||||
|
||||
const docs = 'https://git.io/release-it-github';
|
||||
|
||||
const RETRY_CODES = [408, 413, 429, 500, 502, 503, 504, 521, 522, 524];
|
||||
|
||||
const DEFAULT_RETRY_MIN_TIMEOUT = 1000;
|
||||
|
||||
const parseErrormsg = err => {
|
||||
let msg = err;
|
||||
if (err instanceof Error) {
|
||||
const { status, message } = err;
|
||||
const headers = err.response ? err.response.headers : {};
|
||||
msg = `${_.get(headers, 'status', status)} (${message})`;
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
const truncateBody = body => {
|
||||
// https://github.com/release-it/release-it/issues/965
|
||||
if (body && body.length >= 124000) return body.substring(0, 124000) + '...';
|
||||
return body;
|
||||
};
|
||||
|
||||
class GitHub extends Release {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this.registerPrompts(prompts);
|
||||
}
|
||||
|
||||
async init() {
|
||||
await super.init();
|
||||
|
||||
const { skipChecks, tokenRef, web, update, assets } = this.options;
|
||||
|
||||
if (!this.token || web) {
|
||||
if (!web) {
|
||||
this.log.warn(`Environment variable "${tokenRef}" is required for automated GitHub Releases.`);
|
||||
this.log.warn('Falling back to web-based GitHub Release.');
|
||||
}
|
||||
this.setContext({ isWeb: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (web && assets) {
|
||||
this.log.warn('Assets are not included in web-based releases.');
|
||||
}
|
||||
|
||||
if (!skipChecks) {
|
||||
// If we're running on GitHub Actions, we can skip the authentication and
|
||||
// collaborator checks. Ref: https://bit.ly/2vsyRzu
|
||||
if (process.env.GITHUB_ACTIONS) {
|
||||
this.setContext({ username: process.env.GITHUB_ACTOR });
|
||||
} else {
|
||||
if (!(await this.isAuthenticated())) {
|
||||
throw e(`Could not authenticate with GitHub using environment variable "${tokenRef}".`, docs);
|
||||
}
|
||||
|
||||
if (!(await this.isCollaborator())) {
|
||||
const { repository } = this.getContext('repo');
|
||||
const { username } = this.getContext();
|
||||
throw e(`User ${username} is not a collaborator for ${repository}.`, docs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
const { latestTag } = this.config.getContext();
|
||||
try {
|
||||
const { id, upload_url, tag_name } = await this.getLatestRelease();
|
||||
if (latestTag === tag_name) {
|
||||
this.setContext({ isUpdate: true, isReleased: true, releaseId: id, upload_url });
|
||||
} else {
|
||||
this.setContext({ isUpdate: false });
|
||||
}
|
||||
} catch (error) {
|
||||
this.setContext({ isUpdate: false });
|
||||
}
|
||||
if (!this.getContext('isUpdate')) {
|
||||
this.log.warn(`GitHub release for tag ${latestTag} was not found. Creating new release.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async isAuthenticated() {
|
||||
if (this.config.isDryRun) return true;
|
||||
try {
|
||||
this.log.verbose('octokit users#getAuthenticated');
|
||||
const { data } = await this.client.users.getAuthenticated();
|
||||
this.setContext({ username: data.login });
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.debug(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async isCollaborator() {
|
||||
if (this.config.isDryRun) return true;
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
const { username } = this.getContext();
|
||||
try {
|
||||
const options = { owner, repo, username };
|
||||
this.log.verbose(`octokit repos#checkCollaborator (${username})`);
|
||||
await this.client.repos.checkCollaborator(options);
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.debug(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async release() {
|
||||
const { assets } = this.options;
|
||||
const { isWeb, isUpdate } = this.getContext();
|
||||
const { isCI } = this.config;
|
||||
|
||||
const type = isUpdate ? 'update' : 'create';
|
||||
const publishMethod = `${type}Release`;
|
||||
|
||||
if (isWeb) {
|
||||
const task = () => this.createWebRelease();
|
||||
return this.step({ task, label: 'Generating link to GitHub Release web interface', prompt: 'release' });
|
||||
} else if (isCI) {
|
||||
await this.step({ task: () => this[publishMethod](), label: `GitHub ${type} release` });
|
||||
return this.step({ enabled: assets, task: () => this.uploadAssets(), label: 'GitHub upload assets' });
|
||||
} else {
|
||||
const release = async () => {
|
||||
await this[publishMethod]();
|
||||
return this.uploadAssets();
|
||||
};
|
||||
return this.step({ task: release, label: `GitHub ${type} release`, prompt: 'release' });
|
||||
}
|
||||
}
|
||||
|
||||
handleError(err, bail) {
|
||||
const message = parseErrormsg(err);
|
||||
const githubError = new Error(message);
|
||||
this.log.verbose(err.errors);
|
||||
this.debug(err);
|
||||
if (!_.includes(RETRY_CODES, err.status)) {
|
||||
return bail(githubError);
|
||||
}
|
||||
throw githubError;
|
||||
}
|
||||
|
||||
get client() {
|
||||
if (this._client) return this._client;
|
||||
const { proxy, timeout } = this.options;
|
||||
const host = this.options.host || this.getContext('repo.host');
|
||||
const isGitHub = host === 'github.com';
|
||||
const baseUrl = `https://${isGitHub ? 'api.github.com' : host}${isGitHub ? '' : '/api/v3'}`;
|
||||
const options = {
|
||||
baseUrl,
|
||||
auth: `token ${this.token}`,
|
||||
userAgent: `release-it/${pkg.version}`,
|
||||
log: this.config.isDebug ? console : null,
|
||||
request: {
|
||||
timeout,
|
||||
fetch
|
||||
}
|
||||
};
|
||||
|
||||
if (proxy) {
|
||||
options.request.agent = new ProxyAgent(proxy);
|
||||
}
|
||||
|
||||
const client = new Octokit(options);
|
||||
|
||||
this._client = client;
|
||||
return client;
|
||||
}
|
||||
|
||||
async getLatestRelease() {
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
try {
|
||||
const options = { owner, repo };
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.listReleases({ owner, repo, per_page: 1, page: 1 });
|
||||
this.debug(response.data[0]);
|
||||
return response.data[0];
|
||||
} catch (err) {
|
||||
return this.handleError(err, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
getOctokitReleaseOptions(options = {}) {
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
|
||||
const { tagName } = this.config.getContext();
|
||||
const { version, releaseNotes, isUpdate } = this.getContext();
|
||||
const { isPreRelease } = parseVersion(version);
|
||||
const name = format(releaseName, this.config.getContext());
|
||||
const body = autoGenerate ? (isUpdate ? null : '') : truncateBody(releaseNotes);
|
||||
|
||||
return Object.assign(options, {
|
||||
owner,
|
||||
repo,
|
||||
tag_name: tagName,
|
||||
name,
|
||||
body,
|
||||
draft,
|
||||
prerelease: isPreRelease || preRelease,
|
||||
generate_release_notes: autoGenerate
|
||||
});
|
||||
}
|
||||
|
||||
retry(fn) {
|
||||
const { retryMinTimeout } = this.options;
|
||||
return retry(fn, {
|
||||
retries: 2,
|
||||
minTimeout: typeof retryMinTimeout === 'number' ? retryMinTimeout : DEFAULT_RETRY_MIN_TIMEOUT
|
||||
});
|
||||
}
|
||||
|
||||
async createRelease() {
|
||||
const options = this.getOctokitReleaseOptions();
|
||||
const { isDryRun } = this.config;
|
||||
|
||||
this.log.exec(`octokit repos.createRelease "${options.name}" (${options.tag_name})`, { isDryRun });
|
||||
|
||||
if (isDryRun) {
|
||||
this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(options.tag_name) });
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.createRelease(options);
|
||||
this.debug(response.data);
|
||||
const { html_url, upload_url, id } = response.data;
|
||||
this.setContext({ isReleased: true, releaseId: id, releaseUrl: html_url, upload_url });
|
||||
this.log.verbose(`octokit repos.createRelease: done (${response.headers.location})`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
uploadAsset(filePath) {
|
||||
const url = this.getContext('upload_url');
|
||||
const name = path.basename(filePath);
|
||||
const contentType = mime.contentType(name) || 'application/octet-stream';
|
||||
const contentLength = fs.statSync(filePath).size;
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
const options = {
|
||||
url,
|
||||
data: fs.createReadStream(filePath),
|
||||
name,
|
||||
headers: {
|
||||
'content-type': contentType,
|
||||
'content-length': contentLength
|
||||
}
|
||||
};
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.uploadReleaseAsset(options);
|
||||
this.debug(response.data);
|
||||
this.log.verbose(`octokit repos.uploadReleaseAsset: done (${response.data.browser_download_url})`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
uploadAssets() {
|
||||
const { assets } = this.options;
|
||||
const { isReleased } = this.getContext();
|
||||
const context = this.config.getContext();
|
||||
const { isDryRun } = this.config;
|
||||
|
||||
const patterns = _.castArray(assets).map(pattern => format(pattern, context));
|
||||
|
||||
this.log.exec('octokit repos.uploadReleaseAssets', patterns, { isDryRun });
|
||||
|
||||
if (!assets || !isReleased) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return globby(patterns).then(files => {
|
||||
if (!files.length) {
|
||||
this.log.warn(`octokit repos.uploadReleaseAssets: did not find "${assets}" relative to ${process.cwd()}`);
|
||||
}
|
||||
|
||||
if (isDryRun) return Promise.resolve();
|
||||
|
||||
return Promise.all(files.map(filePath => this.uploadAsset(filePath)));
|
||||
});
|
||||
}
|
||||
|
||||
getReleaseUrlFallback(tagName) {
|
||||
const { host, repository } = this.getContext('repo');
|
||||
return `https://${host}/${repository}/releases/tag/${tagName}`;
|
||||
}
|
||||
|
||||
generateWebUrl() {
|
||||
const host = this.options.host || this.getContext('repo.host');
|
||||
const isGitHub = host === 'github.com';
|
||||
|
||||
const options = this.getOctokitReleaseOptions();
|
||||
const url = newGithubReleaseUrl({
|
||||
user: options.owner,
|
||||
repo: options.repo,
|
||||
tag: options.tag_name,
|
||||
isPrerelease: options.prerelease,
|
||||
title: options.name,
|
||||
body: options.body
|
||||
});
|
||||
return isGitHub ? url : url.replace('github.com', host);
|
||||
}
|
||||
|
||||
async createWebRelease() {
|
||||
const { isCI } = this.config;
|
||||
const { tagName } = this.config.getContext();
|
||||
const url = this.generateWebUrl();
|
||||
if (isCI) {
|
||||
this.setContext({ isReleased: true, releaseUrl: url });
|
||||
} else {
|
||||
await open(url);
|
||||
this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(tagName) });
|
||||
}
|
||||
}
|
||||
|
||||
updateRelease() {
|
||||
const { isDryRun } = this.config;
|
||||
const release_id = this.getContext('releaseId');
|
||||
const options = this.getOctokitReleaseOptions({ release_id });
|
||||
|
||||
this.log.exec(`octokit repos.updateRelease (${options.tag_name})`, { isDryRun });
|
||||
|
||||
if (isDryRun) return true;
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.updateRelease(options);
|
||||
this.setContext({ releaseUrl: response.data.html_url });
|
||||
this.debug(response.data);
|
||||
this.log.verbose(`octokit repos.updateRelease: done (${response.headers.location})`);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default GitHub;
|
||||
Reference in New Issue
Block a user