new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
export type ResponseRunnerOrganization = {
|
||||
address?: any;
|
||||
teams: Array<any>;
|
||||
registrationKey?: string;
|
||||
registrationEnabled?: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
contact?: any;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var findKey = require("./find-key")
|
||||
, isValue = require("./is-value");
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = function (obj, cb /*, thisArg, compareFn*/) {
|
||||
var key = findKey.apply(this, arguments);
|
||||
return isValue(key) ? obj[key] : key;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
var compactable = require('../compactable');
|
||||
|
||||
function findComponentIn(shorthand, longhand) {
|
||||
var comparator = nameComparator(longhand);
|
||||
|
||||
return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator);
|
||||
}
|
||||
|
||||
function nameComparator(to) {
|
||||
return function (property) {
|
||||
return to.name === property.name;
|
||||
};
|
||||
}
|
||||
|
||||
function findInDirectComponents(shorthand, comparator) {
|
||||
return shorthand.components.filter(comparator)[0];
|
||||
}
|
||||
|
||||
function findInSubComponents(shorthand, comparator) {
|
||||
var shorthandComponent;
|
||||
var longhandMatch;
|
||||
var i, l;
|
||||
|
||||
if (!compactable[shorthand.name].shorthandComponents) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0, l = shorthand.components.length; i < l; i++) {
|
||||
shorthandComponent = shorthand.components[i];
|
||||
longhandMatch = findInDirectComponents(shorthandComponent, comparator);
|
||||
|
||||
if (longhandMatch) {
|
||||
return longhandMatch;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
module.exports = findComponentIn;
|
||||
@@ -0,0 +1,106 @@
|
||||
import { map } from './map';
|
||||
import { OperatorFunction } from '../types';
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<T, K1 extends keyof T>(k1: K1): OperatorFunction<T, T[K1]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1]>(k1: K1, k2: K2): OperatorFunction<T, T[K1][K2]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(
|
||||
k1: K1,
|
||||
k2: K2,
|
||||
k3: K3
|
||||
): OperatorFunction<T, T[K1][K2][K3]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(
|
||||
k1: K1,
|
||||
k2: K2,
|
||||
k3: K3,
|
||||
k4: K4
|
||||
): OperatorFunction<T, T[K1][K2][K3][K4]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<
|
||||
T,
|
||||
K1 extends keyof T,
|
||||
K2 extends keyof T[K1],
|
||||
K3 extends keyof T[K1][K2],
|
||||
K4 extends keyof T[K1][K2][K3],
|
||||
K5 extends keyof T[K1][K2][K3][K4]
|
||||
>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): OperatorFunction<T, T[K1][K2][K3][K4][K5]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<
|
||||
T,
|
||||
K1 extends keyof T,
|
||||
K2 extends keyof T[K1],
|
||||
K3 extends keyof T[K1][K2],
|
||||
K4 extends keyof T[K1][K2][K3],
|
||||
K5 extends keyof T[K1][K2][K3][K4],
|
||||
K6 extends keyof T[K1][K2][K3][K4][K5]
|
||||
>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): OperatorFunction<T, T[K1][K2][K3][K4][K5][K6]>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<
|
||||
T,
|
||||
K1 extends keyof T,
|
||||
K2 extends keyof T[K1],
|
||||
K3 extends keyof T[K1][K2],
|
||||
K4 extends keyof T[K1][K2][K3],
|
||||
K5 extends keyof T[K1][K2][K3][K4],
|
||||
K6 extends keyof T[K1][K2][K3][K4][K5]
|
||||
>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, ...rest: string[]): OperatorFunction<T, unknown>;
|
||||
/** @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8. */
|
||||
export function pluck<T>(...properties: string[]): OperatorFunction<T, unknown>;
|
||||
/* tslint:enable:max-line-length */
|
||||
|
||||
/**
|
||||
* Maps each source value to its specified nested property.
|
||||
*
|
||||
* <span class="informal">Like {@link map}, but meant only for picking one of
|
||||
* the nested properties of every emitted value.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Given a list of strings or numbers describing a path to a property, retrieves
|
||||
* the value of a specified nested property from all values in the source
|
||||
* Observable. If a property can't be resolved, it will return `undefined` for
|
||||
* that value.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* Map every click to the tagName of the clicked target element
|
||||
*
|
||||
* ```ts
|
||||
* import { fromEvent, pluck } from 'rxjs';
|
||||
*
|
||||
* const clicks = fromEvent(document, 'click');
|
||||
* const tagNames = clicks.pipe(pluck('target', 'tagName'));
|
||||
*
|
||||
* tagNames.subscribe(x => console.log(x));
|
||||
* ```
|
||||
*
|
||||
* @see {@link map}
|
||||
*
|
||||
* @param properties The nested properties to pluck from each source
|
||||
* value.
|
||||
* @return A function that returns an Observable of property values from the
|
||||
* source values.
|
||||
* @deprecated Use {@link map} and optional chaining: `pluck('foo', 'bar')` is `map(x => x?.foo?.bar)`. Will be removed in v8.
|
||||
*/
|
||||
export function pluck<T, R>(...properties: Array<string | number | symbol>): OperatorFunction<T, R> {
|
||||
const length = properties.length;
|
||||
if (length === 0) {
|
||||
throw new Error('list of properties cannot be empty.');
|
||||
}
|
||||
return map((x) => {
|
||||
let currentProp: any = x;
|
||||
for (let i = 0; i < length; i++) {
|
||||
const p = currentProp?.[properties[i]];
|
||||
if (typeof p !== 'undefined') {
|
||||
currentProp = p;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return currentProp;
|
||||
});
|
||||
}
|
||||
@@ -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.00327,"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,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0.00327,"109":0.10778,"110":0.07185,"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.00327,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0.00327,"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.00327,"66":0,"67":0,"68":0.00327,"69":0.00653,"70":0.00327,"71":0.00327,"72":0.00327,"73":0.00327,"74":0.00327,"75":0,"76":0.00327,"77":0,"78":0.00327,"79":0.01306,"80":0.00327,"81":0.0098,"83":0.00327,"84":0,"85":0.00327,"86":0.00327,"87":0.00653,"88":0.0098,"89":0.00327,"90":0.00327,"91":0.0098,"92":0.04246,"93":0.0098,"94":0.00327,"95":0.01306,"96":0.00327,"97":0.00327,"98":0.00653,"99":0.00327,"100":0.00653,"101":0.00653,"102":0.01306,"103":0.04899,"104":0.00653,"105":0.0098,"106":0.01306,"107":0.0196,"108":0.20902,"109":4.14129,"110":3.0831,"111":0.0098,"112":0.00327,"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.00653,"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.00327,"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.00327,"67":0.0098,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.00327,"74":0.00327,"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.0098,"94":0.08492,"95":0.05879,"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.00327,"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.00327,"93":0,"94":0.00327,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0.00327,"102":0,"103":0.00327,"104":0,"105":0.00327,"106":0,"107":0.00653,"108":0.01633,"109":0.36906,"110":0.57482},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.00327,"14":0.01306,"15":0.00653,_:"0","3.1":0,"3.2":0,"5.1":0.00653,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.01306,"13.1":0.0098,"14.1":0.04572,"15.1":0.00653,"15.2-15.3":0.00653,"15.4":0.03266,"15.5":0.02939,"15.6":0.14044,"16.0":0.01306,"16.1":0.06532,"16.2":0.1633,"16.3":0.08165,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.00225,"6.0-6.1":0,"7.0-7.1":0.0494,"8.1-8.4":0,"9.0-9.2":0.00449,"9.3":0.0494,"10.0-10.2":0,"10.3":0.05165,"11.0-11.2":0.00449,"11.3-11.4":0.00449,"12.0-12.1":0.01572,"12.2-12.5":0.63101,"13.0-13.1":0.01796,"13.2":0.00898,"13.3":0.04716,"13.4-13.7":0.09656,"14.0-14.4":0.35256,"14.5-14.8":0.60631,"15.0-15.1":0.15944,"15.2-15.3":0.21558,"15.4":0.35031,"15.5":0.72982,"15.6":1.67072,"16.0":2.63632,"16.1":4.23743,"16.2":4.74718,"16.3":3.8961,"16.4":0.01572},P:{"4":0.13263,"20":0.77538,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.12243,"8.2":0,"9.2":0.03061,"10.1":0,"11.1-11.2":0.07142,"12.0":0.03061,"13.0":0.09182,"14.0":0.06121,"15.0":0.06121,"16.0":0.13263,"17.0":0.11223,"18.0":0.10202,"19.0":1.32631},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.0224,"4.4":0,"4.4.3-4.4.4":0.15679},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.00337,"9":0,"10":0.00337,"11":0.09777,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":1.52862},H:{"0":0.38252},L:{"0":62.52702},R:{_:"0"},M:{"0":0.06734},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Observable } from '../Observable';
|
||||
export interface NodeStyleEventEmitter {
|
||||
addListener(eventName: string | symbol, handler: NodeEventHandler): this;
|
||||
removeListener(eventName: string | symbol, handler: NodeEventHandler): this;
|
||||
}
|
||||
export declare type NodeEventHandler = (...args: any[]) => void;
|
||||
export interface NodeCompatibleEventEmitter {
|
||||
addListener(eventName: string, handler: NodeEventHandler): void | {};
|
||||
removeListener(eventName: string, handler: NodeEventHandler): void | {};
|
||||
}
|
||||
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 declare function fromEvent<T>(target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>, eventName: string): Observable<T>;
|
||||
export declare function fromEvent<T, R>(target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>, eventName: string, resultSelector: (event: T) => R): Observable<R>;
|
||||
export declare function fromEvent<T>(target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>, eventName: string, options: EventListenerOptions): Observable<T>;
|
||||
export declare function fromEvent<T, R>(target: HasEventTargetAddRemove<T> | ArrayLike<HasEventTargetAddRemove<T>>, eventName: string, options: EventListenerOptions, resultSelector: (event: T) => R): Observable<R>;
|
||||
export declare 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 declare function fromEvent<T>(target: NodeStyleEventEmitter | ArrayLike<NodeStyleEventEmitter>, eventName: string): Observable<T>;
|
||||
export declare function fromEvent<R>(target: NodeStyleEventEmitter | ArrayLike<NodeStyleEventEmitter>, eventName: string, resultSelector: (...args: any[]) => R): Observable<R>;
|
||||
export declare 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 declare function fromEvent<T>(target: NodeCompatibleEventEmitter | ArrayLike<NodeCompatibleEventEmitter>, eventName: string): Observable<T>;
|
||||
export declare function fromEvent<R>(target: NodeCompatibleEventEmitter | ArrayLike<NodeCompatibleEventEmitter>, eventName: string, resultSelector: (...args: any[]) => R): Observable<R>;
|
||||
export declare function fromEvent<T>(target: JQueryStyleEventEmitter<any, T> | ArrayLike<JQueryStyleEventEmitter<any, T>>, eventName: string): Observable<T>;
|
||||
export declare function fromEvent<T, R>(target: JQueryStyleEventEmitter<any, T> | ArrayLike<JQueryStyleEventEmitter<any, T>>, eventName: string, resultSelector: (value: T, ...args: any[]) => R): Observable<R>;
|
||||
//# sourceMappingURL=fromEvent.d.ts.map
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('create', require('../create'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Subject } from '../Subject';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
import { operate } from '../util/lift';
|
||||
import { fromSubscribable } from '../observable/fromSubscribable';
|
||||
const DEFAULT_CONFIG = {
|
||||
connector: () => new Subject(),
|
||||
};
|
||||
export function connect(selector, config = DEFAULT_CONFIG) {
|
||||
const { connector } = config;
|
||||
return operate((source, subscriber) => {
|
||||
const subject = connector();
|
||||
innerFrom(selector(fromSubscribable(subject))).subscribe(subscriber);
|
||||
subscriber.add(source.subscribe(subject));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=connect.js.map
|
||||
@@ -0,0 +1,314 @@
|
||||
let childProcess = require('child_process')
|
||||
let escalade = require('escalade/sync')
|
||||
let pico = require('picocolors')
|
||||
let path = require('path')
|
||||
let fs = require('fs')
|
||||
|
||||
const { detectIndent, detectEOL } = require('./utils')
|
||||
|
||||
function BrowserslistUpdateError(message) {
|
||||
this.name = 'BrowserslistUpdateError'
|
||||
this.message = message
|
||||
this.browserslist = true
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, BrowserslistUpdateError)
|
||||
}
|
||||
}
|
||||
|
||||
BrowserslistUpdateError.prototype = Error.prototype
|
||||
|
||||
/* c8 ignore next 3 */
|
||||
function defaultPrint(str) {
|
||||
process.stdout.write(str)
|
||||
}
|
||||
|
||||
function detectLockfile() {
|
||||
let packageDir = escalade('.', (dir, names) => {
|
||||
return names.indexOf('package.json') !== -1 ? dir : ''
|
||||
})
|
||||
|
||||
if (!packageDir) {
|
||||
throw new BrowserslistUpdateError(
|
||||
'Cannot find package.json. ' +
|
||||
'Is this the right directory to run `npx update-browserslist-db` in?'
|
||||
)
|
||||
}
|
||||
|
||||
let lockfileNpm = path.join(packageDir, 'package-lock.json')
|
||||
let lockfileShrinkwrap = path.join(packageDir, 'npm-shrinkwrap.json')
|
||||
let lockfileYarn = path.join(packageDir, 'yarn.lock')
|
||||
let lockfilePnpm = path.join(packageDir, 'pnpm-lock.yaml')
|
||||
|
||||
if (fs.existsSync(lockfilePnpm)) {
|
||||
return { mode: 'pnpm', file: lockfilePnpm }
|
||||
} else if (fs.existsSync(lockfileNpm)) {
|
||||
return { mode: 'npm', file: lockfileNpm }
|
||||
} else if (fs.existsSync(lockfileYarn)) {
|
||||
let lock = { mode: 'yarn', file: lockfileYarn }
|
||||
lock.content = fs.readFileSync(lock.file).toString()
|
||||
lock.version = /# yarn lockfile v1/.test(lock.content) ? 1 : 2
|
||||
return lock
|
||||
} else if (fs.existsSync(lockfileShrinkwrap)) {
|
||||
return { mode: 'npm', file: lockfileShrinkwrap }
|
||||
}
|
||||
throw new BrowserslistUpdateError(
|
||||
'No lockfile found. Run "npm install", "yarn install" or "pnpm install"'
|
||||
)
|
||||
}
|
||||
|
||||
function getLatestInfo(lock) {
|
||||
if (lock.mode === 'yarn') {
|
||||
if (lock.version === 1) {
|
||||
return JSON.parse(
|
||||
childProcess.execSync('yarn info caniuse-lite --json').toString()
|
||||
).data
|
||||
} else {
|
||||
return JSON.parse(
|
||||
childProcess.execSync('yarn npm info caniuse-lite --json').toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
if (lock.mode === 'pnpm') {
|
||||
return JSON.parse(
|
||||
childProcess.execSync('pnpm info caniuse-lite --json').toString()
|
||||
)
|
||||
}
|
||||
return JSON.parse(
|
||||
childProcess.execSync('npm show caniuse-lite --json').toString()
|
||||
)
|
||||
}
|
||||
|
||||
function getBrowsers() {
|
||||
let browserslist = require('browserslist')
|
||||
return browserslist().reduce((result, entry) => {
|
||||
if (!result[entry[0]]) {
|
||||
result[entry[0]] = []
|
||||
}
|
||||
result[entry[0]].push(entry[1])
|
||||
return result
|
||||
}, {})
|
||||
}
|
||||
|
||||
function diffBrowsers(old, current) {
|
||||
let browsers = Object.keys(old).concat(
|
||||
Object.keys(current).filter(browser => old[browser] === undefined)
|
||||
)
|
||||
return browsers
|
||||
.map(browser => {
|
||||
let oldVersions = old[browser] || []
|
||||
let currentVersions = current[browser] || []
|
||||
let common = oldVersions.filter(v => currentVersions.includes(v))
|
||||
let added = currentVersions.filter(v => !common.includes(v))
|
||||
let removed = oldVersions.filter(v => !common.includes(v))
|
||||
return removed
|
||||
.map(v => pico.red('- ' + browser + ' ' + v))
|
||||
.concat(added.map(v => pico.green('+ ' + browser + ' ' + v)))
|
||||
})
|
||||
.reduce((result, array) => result.concat(array), [])
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
function updateNpmLockfile(lock, latest) {
|
||||
let metadata = { latest, versions: [] }
|
||||
let content = deletePackage(JSON.parse(lock.content), metadata)
|
||||
metadata.content = JSON.stringify(content, null, detectIndent(lock.content))
|
||||
return metadata
|
||||
}
|
||||
|
||||
function deletePackage(node, metadata) {
|
||||
if (node.dependencies) {
|
||||
if (node.dependencies['caniuse-lite']) {
|
||||
let version = node.dependencies['caniuse-lite'].version
|
||||
metadata.versions[version] = true
|
||||
delete node.dependencies['caniuse-lite']
|
||||
}
|
||||
for (let i in node.dependencies) {
|
||||
node.dependencies[i] = deletePackage(node.dependencies[i], metadata)
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
let yarnVersionRe = /version "(.*?)"/
|
||||
|
||||
function updateYarnLockfile(lock, latest) {
|
||||
let blocks = lock.content.split(/(\n{2,})/).map(block => {
|
||||
return block.split('\n')
|
||||
})
|
||||
let versions = {}
|
||||
blocks.forEach(lines => {
|
||||
if (lines[0].indexOf('caniuse-lite@') !== -1) {
|
||||
let match = yarnVersionRe.exec(lines[1])
|
||||
versions[match[1]] = true
|
||||
if (match[1] !== latest.version) {
|
||||
lines[1] = lines[1].replace(
|
||||
/version "[^"]+"/,
|
||||
'version "' + latest.version + '"'
|
||||
)
|
||||
lines[2] = lines[2].replace(
|
||||
/resolved "[^"]+"/,
|
||||
'resolved "' + latest.dist.tarball + '"'
|
||||
)
|
||||
if (lines.length === 4) {
|
||||
lines[3] = latest.dist.integrity
|
||||
? lines[3].replace(
|
||||
/integrity .+/,
|
||||
'integrity ' + latest.dist.integrity
|
||||
)
|
||||
: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
let content = blocks.map(lines => lines.join('\n')).join('')
|
||||
return { content, versions }
|
||||
}
|
||||
|
||||
function updateLockfile(lock, latest) {
|
||||
if (!lock.content) lock.content = fs.readFileSync(lock.file).toString()
|
||||
|
||||
let updatedLockFile
|
||||
if (lock.mode === 'yarn') {
|
||||
updatedLockFile = updateYarnLockfile(lock, latest)
|
||||
} else {
|
||||
updatedLockFile = updateNpmLockfile(lock, latest)
|
||||
}
|
||||
updatedLockFile.content = updatedLockFile.content.replace(
|
||||
/\n/g,
|
||||
detectEOL(lock.content)
|
||||
)
|
||||
return updatedLockFile
|
||||
}
|
||||
|
||||
function updatePackageManually(print, lock, latest) {
|
||||
let lockfileData = updateLockfile(lock, latest)
|
||||
let caniuseVersions = Object.keys(lockfileData.versions).sort()
|
||||
if (caniuseVersions.length === 1 && caniuseVersions[0] === latest.version) {
|
||||
print(
|
||||
'Installed version: ' +
|
||||
pico.bold(pico.green(latest.version)) +
|
||||
'\n' +
|
||||
pico.bold(pico.green('caniuse-lite is up to date')) +
|
||||
'\n'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (caniuseVersions.length === 0) {
|
||||
caniuseVersions[0] = 'none'
|
||||
}
|
||||
print(
|
||||
'Installed version' +
|
||||
(caniuseVersions.length === 1 ? ': ' : 's: ') +
|
||||
pico.bold(pico.red(caniuseVersions.join(', '))) +
|
||||
'\n' +
|
||||
'Removing old caniuse-lite from lock file\n'
|
||||
)
|
||||
fs.writeFileSync(lock.file, lockfileData.content)
|
||||
|
||||
let install = lock.mode === 'yarn' ? 'yarn add -W' : lock.mode + ' install'
|
||||
print(
|
||||
'Installing new caniuse-lite version\n' +
|
||||
pico.yellow('$ ' + install + ' caniuse-lite') +
|
||||
'\n'
|
||||
)
|
||||
try {
|
||||
childProcess.execSync(install + ' caniuse-lite')
|
||||
} catch (e) /* c8 ignore start */ {
|
||||
print(
|
||||
pico.red(
|
||||
'\n' +
|
||||
e.stack +
|
||||
'\n\n' +
|
||||
'Problem with `' +
|
||||
install +
|
||||
' caniuse-lite` call. ' +
|
||||
'Run it manually.\n'
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
} /* c8 ignore end */
|
||||
|
||||
let del = lock.mode === 'yarn' ? 'yarn remove -W' : lock.mode + ' uninstall'
|
||||
print(
|
||||
'Cleaning package.json dependencies from caniuse-lite\n' +
|
||||
pico.yellow('$ ' + del + ' caniuse-lite') +
|
||||
'\n'
|
||||
)
|
||||
childProcess.execSync(del + ' caniuse-lite')
|
||||
}
|
||||
|
||||
function updateWith(print, cmd) {
|
||||
print('Updating caniuse-lite version\n' + pico.yellow('$ ' + cmd) + '\n')
|
||||
try {
|
||||
childProcess.execSync(cmd)
|
||||
} catch (e) /* c8 ignore start */ {
|
||||
print(pico.red(e.stdout.toString()))
|
||||
print(
|
||||
pico.red(
|
||||
'\n' +
|
||||
e.stack +
|
||||
'\n\n' +
|
||||
'Problem with `' +
|
||||
cmd +
|
||||
'` call. ' +
|
||||
'Run it manually.\n'
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
} /* c8 ignore end */
|
||||
}
|
||||
|
||||
module.exports = function updateDB(print = defaultPrint) {
|
||||
let lock = detectLockfile()
|
||||
let latest = getLatestInfo(lock)
|
||||
|
||||
let listError
|
||||
let oldList
|
||||
try {
|
||||
oldList = getBrowsers()
|
||||
} catch (e) {
|
||||
listError = e
|
||||
}
|
||||
|
||||
print('Latest version: ' + pico.bold(pico.green(latest.version)) + '\n')
|
||||
|
||||
if (lock.mode === 'yarn' && lock.version !== 1) {
|
||||
updateWith(print, 'yarn up -R caniuse-lite')
|
||||
} else if (lock.mode === 'pnpm') {
|
||||
updateWith(print, 'pnpm up caniuse-lite')
|
||||
} else {
|
||||
updatePackageManually(print, lock, latest)
|
||||
}
|
||||
|
||||
print('caniuse-lite has been successfully updated\n')
|
||||
|
||||
let newList
|
||||
if (!listError) {
|
||||
try {
|
||||
newList = getBrowsers()
|
||||
} catch (e) /* c8 ignore start */ {
|
||||
listError = e
|
||||
} /* c8 ignore end */
|
||||
}
|
||||
|
||||
if (listError) {
|
||||
print(
|
||||
pico.red(
|
||||
'\n' +
|
||||
listError.stack +
|
||||
'\n\n' +
|
||||
'Problem with browser list retrieval.\n' +
|
||||
'Target browser changes won’t be shown.\n'
|
||||
)
|
||||
)
|
||||
} else {
|
||||
let changes = diffBrowsers(oldList, newList)
|
||||
if (changes) {
|
||||
print('\nTarget browser changes:\n')
|
||||
print(changes + '\n')
|
||||
} else {
|
||||
print('\n' + pico.green('No target browser changes') + '\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
let camelcase = require('camelcase-css')
|
||||
|
||||
let UNITLESS = {
|
||||
boxFlex: true,
|
||||
boxFlexGroup: true,
|
||||
columnCount: true,
|
||||
flex: true,
|
||||
flexGrow: true,
|
||||
flexPositive: true,
|
||||
flexShrink: true,
|
||||
flexNegative: true,
|
||||
fontWeight: true,
|
||||
lineClamp: true,
|
||||
lineHeight: true,
|
||||
opacity: true,
|
||||
order: true,
|
||||
orphans: true,
|
||||
tabSize: true,
|
||||
widows: true,
|
||||
zIndex: true,
|
||||
zoom: true,
|
||||
fillOpacity: true,
|
||||
strokeDashoffset: true,
|
||||
strokeOpacity: true,
|
||||
strokeWidth: true
|
||||
}
|
||||
|
||||
function atRule(node) {
|
||||
if (typeof node.nodes === 'undefined') {
|
||||
return true
|
||||
} else {
|
||||
return process(node)
|
||||
}
|
||||
}
|
||||
|
||||
function process(node) {
|
||||
let name
|
||||
let result = {}
|
||||
|
||||
node.each(child => {
|
||||
if (child.type === 'atrule') {
|
||||
name = '@' + child.name
|
||||
if (child.params) name += ' ' + child.params
|
||||
if (typeof result[name] === 'undefined') {
|
||||
result[name] = atRule(child)
|
||||
} else if (Array.isArray(result[name])) {
|
||||
result[name].push(atRule(child))
|
||||
} else {
|
||||
result[name] = [result[name], atRule(child)]
|
||||
}
|
||||
} else if (child.type === 'rule') {
|
||||
let body = process(child)
|
||||
if (result[child.selector]) {
|
||||
for (let i in body) {
|
||||
result[child.selector][i] = body[i]
|
||||
}
|
||||
} else {
|
||||
result[child.selector] = body
|
||||
}
|
||||
} else if (child.type === 'decl') {
|
||||
if (child.prop[0] === '-' && child.prop[1] === '-') {
|
||||
name = child.prop
|
||||
} else if (child.parent && child.parent.selector === ':export') {
|
||||
name = child.prop
|
||||
} else {
|
||||
name = camelcase(child.prop)
|
||||
}
|
||||
let value = child.value
|
||||
if (!isNaN(child.value) && UNITLESS[name]) {
|
||||
value = parseFloat(child.value)
|
||||
}
|
||||
if (child.important) value += ' !important'
|
||||
if (typeof result[name] === 'undefined') {
|
||||
result[name] = value
|
||||
} else if (Array.isArray(result[name])) {
|
||||
result[name].push(value)
|
||||
} else {
|
||||
result[name] = [result[name], value]
|
||||
}
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = process
|
||||
@@ -0,0 +1,28 @@
|
||||
var baseCreate = require('./_baseCreate'),
|
||||
baseLodash = require('./_baseLodash');
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295;
|
||||
|
||||
/**
|
||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {*} value The value to wrap.
|
||||
*/
|
||||
function LazyWrapper(value) {
|
||||
this.__wrapped__ = value;
|
||||
this.__actions__ = [];
|
||||
this.__dir__ = 1;
|
||||
this.__filtered__ = false;
|
||||
this.__iteratees__ = [];
|
||||
this.__takeCount__ = MAX_ARRAY_LENGTH;
|
||||
this.__views__ = [];
|
||||
}
|
||||
|
||||
// Ensure `LazyWrapper` is an instance of `baseLodash`.
|
||||
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
||||
LazyWrapper.prototype.constructor = LazyWrapper;
|
||||
|
||||
module.exports = LazyWrapper;
|
||||
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ComputeExponentForMagnitude = void 0;
|
||||
/**
|
||||
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
||||
* number of the given magnitude (power of ten of the most significant digit) according to the
|
||||
* locale and the desired notation (scientific, engineering, or compact).
|
||||
*/
|
||||
function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
|
||||
var getInternalSlots = _a.getInternalSlots;
|
||||
var internalSlots = getInternalSlots(numberFormat);
|
||||
var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
|
||||
switch (notation) {
|
||||
case 'standard':
|
||||
return 0;
|
||||
case 'scientific':
|
||||
return magnitude;
|
||||
case 'engineering':
|
||||
return Math.floor(magnitude / 3) * 3;
|
||||
default: {
|
||||
// Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
|
||||
// number of the given magnitude in compact notation for the current locale.
|
||||
var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
|
||||
var thresholdMap = void 0;
|
||||
if (style === 'currency' && currencyDisplay !== 'name') {
|
||||
var currency = dataLocaleData.numbers.currency[numberingSystem] ||
|
||||
dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]];
|
||||
thresholdMap = currency.short;
|
||||
}
|
||||
else {
|
||||
var decimal = dataLocaleData.numbers.decimal[numberingSystem] ||
|
||||
dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
|
||||
thresholdMap = compactDisplay === 'long' ? decimal.long : decimal.short;
|
||||
}
|
||||
if (!thresholdMap) {
|
||||
return 0;
|
||||
}
|
||||
var num = String(Math.pow(10, magnitude));
|
||||
var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
|
||||
if (num < thresholds[0]) {
|
||||
return 0;
|
||||
}
|
||||
if (num > thresholds[thresholds.length - 1]) {
|
||||
return thresholds[thresholds.length - 1].length - 1;
|
||||
}
|
||||
var i = thresholds.indexOf(num);
|
||||
if (i === -1) {
|
||||
return 0;
|
||||
}
|
||||
// See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
|
||||
// Special handling if the pattern is precisely `0`.
|
||||
var magnitudeKey = thresholds[i];
|
||||
// TODO: do we need to handle plural here?
|
||||
var compactPattern = thresholdMap[magnitudeKey].other;
|
||||
if (compactPattern === '0') {
|
||||
return 0;
|
||||
}
|
||||
// Example: in zh-TW, `10000000` maps to `0000萬`. So we need to return 8 - 4 = 4 here.
|
||||
return (magnitudeKey.length -
|
||||
thresholdMap[magnitudeKey].other.match(/0+/)[0].length);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ComputeExponentForMagnitude = ComputeExponentForMagnitude;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,188 @@
|
||||
/*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var db = require('mime-db')
|
||||
var extname = require('path').extname
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
||||
var TEXT_TYPE_REGEXP = /^text\//i
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.charset = charset
|
||||
exports.charsets = { lookup: charset }
|
||||
exports.contentType = contentType
|
||||
exports.extension = extension
|
||||
exports.extensions = Object.create(null)
|
||||
exports.lookup = lookup
|
||||
exports.types = Object.create(null)
|
||||
|
||||
// Populate the extensions/types maps
|
||||
populateMaps(exports.extensions, exports.types)
|
||||
|
||||
/**
|
||||
* Get the default charset for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function charset (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
var mime = match && db[match[1].toLowerCase()]
|
||||
|
||||
if (mime && mime.charset) {
|
||||
return mime.charset
|
||||
}
|
||||
|
||||
// default text/* to utf-8
|
||||
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
||||
return 'UTF-8'
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full Content-Type header given a MIME type or extension.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function contentType (str) {
|
||||
// TODO: should this even be in this module?
|
||||
if (!str || typeof str !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
var mime = str.indexOf('/') === -1
|
||||
? exports.lookup(str)
|
||||
: str
|
||||
|
||||
if (!mime) {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use content-type or other module
|
||||
if (mime.indexOf('charset') === -1) {
|
||||
var charset = exports.charset(mime)
|
||||
if (charset) mime += '; charset=' + charset.toLowerCase()
|
||||
}
|
||||
|
||||
return mime
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default extension for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function extension (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
|
||||
// get extensions
|
||||
var exts = match && exports.extensions[match[1].toLowerCase()]
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the MIME type for a file path/extension.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function lookup (path) {
|
||||
if (!path || typeof path !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// get the extension ("ext" or ".ext" or full path)
|
||||
var extension = extname('x.' + path)
|
||||
.toLowerCase()
|
||||
.substr(1)
|
||||
|
||||
if (!extension) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exports.types[extension] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the extensions and types maps.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateMaps (extensions, types) {
|
||||
// source preference (least -> most)
|
||||
var preference = ['nginx', 'apache', undefined, 'iana']
|
||||
|
||||
Object.keys(db).forEach(function forEachMimeType (type) {
|
||||
var mime = db[type]
|
||||
var exts = mime.extensions
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return
|
||||
}
|
||||
|
||||
// mime -> extensions
|
||||
extensions[type] = exts
|
||||
|
||||
// extension -> mime
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
var extension = exts[i]
|
||||
|
||||
if (types[extension]) {
|
||||
var from = preference.indexOf(db[types[extension]].source)
|
||||
var to = preference.indexOf(mime.source)
|
||||
|
||||
if (types[extension] !== 'application/octet-stream' &&
|
||||
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
||||
// skip the remapping
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// set the extension -> mime
|
||||
types[extension] = type
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type PermissionNeedsPrincipalError = {
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"name": "type",
|
||||
"version": "2.7.2",
|
||||
"description": "Runtime validation and processing of JavaScript types",
|
||||
"author": "Mariusz Nowak <medyk@medikoo.com> (https://www.medikoo.com/)",
|
||||
"keywords": [
|
||||
"type",
|
||||
"coercion"
|
||||
],
|
||||
"repository": "medikoo/type",
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint-config-medikoo": "^4.1.2",
|
||||
"git-list-updated": "^1.2.1",
|
||||
"github-release-from-cc-changelog": "^2.3.0",
|
||||
"husky": "^4.3.8",
|
||||
"lint-staged": "^13.0.3",
|
||||
"mocha": "^6.2.3",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier-elastic": "^2.2.1"
|
||||
},
|
||||
"typesVersions": {
|
||||
">=4": {
|
||||
"*": [
|
||||
"ts-types/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint"
|
||||
],
|
||||
"*.{css,html,js,json,md,yaml,yml}": [
|
||||
"prettier -c"
|
||||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "medikoo/es3",
|
||||
"root": true,
|
||||
"globals": {
|
||||
"BigInt": true,
|
||||
"Map": true,
|
||||
"Promise": true,
|
||||
"Set": true,
|
||||
"Symbol": true
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**/*.js",
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"no-eval": "off",
|
||||
"no-new-wrappers": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"string/coerce.js",
|
||||
"number/coerce.js"
|
||||
],
|
||||
"rules": {
|
||||
"no-implicit-coercion": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "plain-object/is.js",
|
||||
"rules": {
|
||||
"no-proto": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100,
|
||||
"tabWidth": 4,
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.md",
|
||||
"*.yml"
|
||||
],
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
"exclude": [
|
||||
".github",
|
||||
"coverage/**",
|
||||
"test/**",
|
||||
"*.config.js"
|
||||
],
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"html",
|
||||
"text-summary"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc npm test",
|
||||
"lint:updated": "pipe-git-updated --base=main --ext=js -- eslint --ignore-pattern '!*'",
|
||||
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
|
||||
"prettier-check:updated": "pipe-git-updated --base=main --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
|
||||
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
|
||||
"prettify:updated": "pipe-git-updated ---base=main -ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
|
||||
"test": "mocha --recursive"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var isArray = require('isarray');
|
||||
var every = require('array.prototype.every');
|
||||
|
||||
var availableTypedArrays = require('../');
|
||||
|
||||
test('available typed arrays', function (t) {
|
||||
t.equal(typeof availableTypedArrays, 'function', 'is a function');
|
||||
|
||||
var arrays = availableTypedArrays();
|
||||
t.equal(isArray(arrays), true, 'returns an array');
|
||||
|
||||
t.equal(every(arrays, function (array) { return typeof array === 'string'; }), true, 'contains only strings');
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
let NoWorkResult = require('./no-work-result')
|
||||
let LazyResult = require('./lazy-result')
|
||||
let Document = require('./document')
|
||||
let Root = require('./root')
|
||||
|
||||
class Processor {
|
||||
constructor(plugins = []) {
|
||||
this.version = '8.4.21'
|
||||
this.plugins = this.normalize(plugins)
|
||||
}
|
||||
|
||||
use(plugin) {
|
||||
this.plugins = this.plugins.concat(this.normalize([plugin]))
|
||||
return this
|
||||
}
|
||||
|
||||
process(css, opts = {}) {
|
||||
if (
|
||||
this.plugins.length === 0 &&
|
||||
typeof opts.parser === 'undefined' &&
|
||||
typeof opts.stringifier === 'undefined' &&
|
||||
typeof opts.syntax === 'undefined'
|
||||
) {
|
||||
return new NoWorkResult(this, css, opts)
|
||||
} else {
|
||||
return new LazyResult(this, css, opts)
|
||||
}
|
||||
}
|
||||
|
||||
normalize(plugins) {
|
||||
let normalized = []
|
||||
for (let i of plugins) {
|
||||
if (i.postcss === true) {
|
||||
i = i()
|
||||
} else if (i.postcss) {
|
||||
i = i.postcss
|
||||
}
|
||||
|
||||
if (typeof i === 'object' && Array.isArray(i.plugins)) {
|
||||
normalized = normalized.concat(i.plugins)
|
||||
} else if (typeof i === 'object' && i.postcssPlugin) {
|
||||
normalized.push(i)
|
||||
} else if (typeof i === 'function') {
|
||||
normalized.push(i)
|
||||
} else if (typeof i === 'object' && (i.parse || i.stringify)) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
throw new Error(
|
||||
'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
|
||||
'one of the syntax/parser/stringifier options as outlined ' +
|
||||
'in your PostCSS runner documentation.'
|
||||
)
|
||||
}
|
||||
} else {
|
||||
throw new Error(i + ' is not a PostCSS plugin')
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Processor
|
||||
Processor.default = Processor
|
||||
|
||||
Root.registerProcessor(Processor)
|
||||
Document.registerProcessor(Processor)
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
require('es6-shim');
|
||||
|
||||
require('./');
|
||||
|
||||
require('./shimmed');
|
||||
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var IsCallable = require('es-abstract/2021/IsCallable');
|
||||
var functionsHaveNames = require('functions-have-names')();
|
||||
var callBound = require('call-bind/callBound');
|
||||
var $functionToString = callBound('Function.prototype.toString');
|
||||
var $stringMatch = callBound('String.prototype.match');
|
||||
|
||||
var classRegex = /^class /;
|
||||
|
||||
var isClass = function isClassConstructor(fn) {
|
||||
if (IsCallable(fn)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof fn !== 'function') {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
var match = $stringMatch($functionToString(fn), classRegex);
|
||||
return !!match;
|
||||
} catch (e) {}
|
||||
return false;
|
||||
};
|
||||
|
||||
var regex = /\s*function\s+([^(\s]*)\s*/;
|
||||
|
||||
var functionProto = Function.prototype;
|
||||
|
||||
module.exports = function getName() {
|
||||
if (!isClass(this) && !IsCallable(this)) {
|
||||
throw new TypeError('Function.prototype.name sham getter called on non-function');
|
||||
}
|
||||
if (functionsHaveNames) {
|
||||
return this.name;
|
||||
}
|
||||
if (this === functionProto) {
|
||||
return '';
|
||||
}
|
||||
var str = $functionToString(this);
|
||||
var match = $stringMatch(str, regex);
|
||||
var name = match && match[1];
|
||||
return name;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"signal-exit","version":"3.0.7","files":{"signals.js":{"checkedAt":1678883673377,"integrity":"sha512-gehe2Vo5pfTs44lemTc+0BrOSFB6cH+ZlTq5IpiPCwaHMeFs/V2ZO2cODyGhetG9DO8/ltp0yrSuOyeg1vtQ8Q==","mode":420,"size":1295},"index.js":{"checkedAt":1678883673377,"integrity":"sha512-L01JZ39MeBX0a0g6ghBfrcgyVot6j7KOtOf4L3BGvUaYIn8JiIslybYvmqjDQhBC2TndEtcHeK96PaIS7tq7HA==","mode":420,"size":5708},"package.json":{"checkedAt":1678883673377,"integrity":"sha512-WaA0bFOOjimE3q1Rlt4EYnZtyQGMvYoPyJ6mMYyM+i0gDowvfbYrsJp9ciAR0n0/2Axz+J03ppPVdCrVAj+x2g==","mode":420,"size":864},"LICENSE.txt":{"checkedAt":1678883673377,"integrity":"sha512-5DMZrk5fBGeEnj/s7hSA9ISstg5tQH2LJJ2MIlQm5irE/GrJSGc7nuwzCNGNibmcQ/hCATZSDY9sjde4e39EUA==","mode":420,"size":748},"README.md":{"checkedAt":1678883673377,"integrity":"sha512-OE2cQKg85j8/eqMUrvvntpk2KrOms+BaiNkxx0rReuBThSD/NXkDzWLlmlzDXLGZmE2JG5roHhsGKGFOkgTL7Q==","mode":420,"size":1343}}}
|
||||
@@ -0,0 +1,97 @@
|
||||
// Type definitions for Chalk
|
||||
// Definitions by: Thomas Sauer <https://github.com/t-sauer>
|
||||
|
||||
export const enum Level {
|
||||
None = 0,
|
||||
Basic = 1,
|
||||
Ansi256 = 2,
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
export interface ChalkOptions {
|
||||
enabled?: boolean;
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
export interface ChalkConstructor {
|
||||
new (options?: ChalkOptions): Chalk;
|
||||
(options?: ChalkOptions): Chalk;
|
||||
}
|
||||
|
||||
export interface ColorSupport {
|
||||
level: Level;
|
||||
hasBasic: boolean;
|
||||
has256: boolean;
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string;
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||
constructor: ChalkConstructor;
|
||||
enabled: boolean;
|
||||
level: Level;
|
||||
rgb(r: number, g: number, b: number): this;
|
||||
hsl(h: number, s: number, l: number): this;
|
||||
hsv(h: number, s: number, v: number): this;
|
||||
hwb(h: number, w: number, b: number): this;
|
||||
bgHex(color: string): this;
|
||||
bgKeyword(color: string): this;
|
||||
bgRgb(r: number, g: number, b: number): this;
|
||||
bgHsl(h: number, s: number, l: number): this;
|
||||
bgHsv(h: number, s: number, v: number): this;
|
||||
bgHwb(h: number, w: number, b: number): this;
|
||||
hex(color: string): this;
|
||||
keyword(color: string): this;
|
||||
|
||||
readonly reset: this;
|
||||
readonly bold: this;
|
||||
readonly dim: this;
|
||||
readonly italic: this;
|
||||
readonly underline: this;
|
||||
readonly inverse: this;
|
||||
readonly hidden: this;
|
||||
readonly strikethrough: this;
|
||||
|
||||
readonly visible: this;
|
||||
|
||||
readonly black: this;
|
||||
readonly red: this;
|
||||
readonly green: this;
|
||||
readonly yellow: this;
|
||||
readonly blue: this;
|
||||
readonly magenta: this;
|
||||
readonly cyan: this;
|
||||
readonly white: this;
|
||||
readonly gray: this;
|
||||
readonly grey: this;
|
||||
readonly blackBright: this;
|
||||
readonly redBright: this;
|
||||
readonly greenBright: this;
|
||||
readonly yellowBright: this;
|
||||
readonly blueBright: this;
|
||||
readonly magentaBright: this;
|
||||
readonly cyanBright: this;
|
||||
readonly whiteBright: this;
|
||||
|
||||
readonly bgBlack: this;
|
||||
readonly bgRed: this;
|
||||
readonly bgGreen: this;
|
||||
readonly bgYellow: this;
|
||||
readonly bgBlue: this;
|
||||
readonly bgMagenta: this;
|
||||
readonly bgCyan: this;
|
||||
readonly bgWhite: this;
|
||||
readonly bgBlackBright: this;
|
||||
readonly bgRedBright: this;
|
||||
readonly bgGreenBright: this;
|
||||
readonly bgYellowBright: this;
|
||||
readonly bgBlueBright: this;
|
||||
readonly bgMagentaBright: this;
|
||||
readonly bgCyanBright: this;
|
||||
readonly bgWhiteBright: this;
|
||||
}
|
||||
|
||||
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
||||
|
||||
export default chalk
|
||||
@@ -0,0 +1,76 @@
|
||||
// import { Converter } from "./Converter";
|
||||
// import { Message, InitMessage, EOM } from "./ProcessFork";
|
||||
// import CSVError from "./CSVError";
|
||||
// import { CSVParseParam } from "./Parameters";
|
||||
// process.on("message", processMsg);
|
||||
// let conv: Converter;
|
||||
// function processMsg(msg: Message) {
|
||||
// if (msg.cmd === "init") {
|
||||
// const param = prepareParams((msg as InitMessage).params);
|
||||
// param.fork = false;
|
||||
// conv = new Converter(param);
|
||||
// process.stdin.pipe(conv).pipe(process.stdout);
|
||||
// conv.on("error", (err) => {
|
||||
// if ((err as CSVError).line) {
|
||||
// process.stderr.write(JSON.stringify({
|
||||
// err: (err as CSVError).err,
|
||||
// line: (err as CSVError).line,
|
||||
// extra: (err as CSVError).extra
|
||||
// }))
|
||||
// } else {
|
||||
// process.stderr.write(JSON.stringify({
|
||||
// err: err.message,
|
||||
// line: -1,
|
||||
// extra: "Unknown error"
|
||||
// }));
|
||||
// }
|
||||
|
||||
// });
|
||||
// conv.on("eol", (eol) => {
|
||||
// // console.log("eol!!!",eol);
|
||||
// if (process.send)
|
||||
// process.send({ cmd: "eol", "value": eol });
|
||||
// })
|
||||
// conv.on("header", (header) => {
|
||||
// if (process.send)
|
||||
// process.send({ cmd: "header", "value": header });
|
||||
// })
|
||||
// conv.on("done", () => {
|
||||
// const drained = process.stdout.write("", () => {
|
||||
// if (drained) {
|
||||
// gracelyExit();
|
||||
// }
|
||||
// });
|
||||
// if (!drained) {
|
||||
// process.stdout.on("drain", gracelyExit)
|
||||
// }
|
||||
|
||||
|
||||
// // process.stdout.write(EOM);
|
||||
// })
|
||||
// if (process.send) {
|
||||
// process.send({ cmd: "inited" });
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// }
|
||||
// function gracelyExit(){
|
||||
// setTimeout(()=>{
|
||||
// conv.removeAllListeners();
|
||||
// process.removeAllListeners();
|
||||
// },50);
|
||||
// }
|
||||
// function prepareParams(p: any): CSVParseParam {
|
||||
// if (p.ignoreColumns) {
|
||||
// p.ignoreColumns = new RegExp(p.ignoreColumns.source, p.ignoreColumns.flags)
|
||||
// }
|
||||
// if (p.includeColumns) {
|
||||
// p.includeColumns = new RegExp(p.includeColumns.source, p.includeColumns.flags)
|
||||
// }
|
||||
// return p;
|
||||
// }
|
||||
|
||||
// process.on("disconnect", () => {
|
||||
// process.exit(-1);
|
||||
// });
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Abort signal
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
||||
*/
|
||||
export type Signal = any;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
export type ScanStation = {
|
||||
id: number;
|
||||
description?: string;
|
||||
track: string;
|
||||
prefix: string;
|
||||
key: string;
|
||||
cleartextkey?: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
var MODIFIER_PATTERN = /\-\-.+$/;
|
||||
|
||||
function rulesOverlap(rule1, rule2, bemMode) {
|
||||
var scope1;
|
||||
var scope2;
|
||||
var i, l;
|
||||
var j, m;
|
||||
|
||||
for (i = 0, l = rule1.length; i < l; i++) {
|
||||
scope1 = rule1[i][1];
|
||||
|
||||
for (j = 0, m = rule2.length; j < m; j++) {
|
||||
scope2 = rule2[j][1];
|
||||
|
||||
if (scope1 == scope2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bemMode && withoutModifiers(scope1) == withoutModifiers(scope2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function withoutModifiers(scope) {
|
||||
return scope.replace(MODIFIER_PATTERN, '');
|
||||
}
|
||||
|
||||
module.exports = rulesOverlap;
|
||||
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
var indexOf = require("es5-ext/array/#/e-index-of");
|
||||
|
||||
module.exports = function () {
|
||||
var lastId = 0, argsMap = [], cache = [];
|
||||
return {
|
||||
get: function (args) {
|
||||
var index = indexOf.call(argsMap, args[0]);
|
||||
return index === -1 ? null : cache[index];
|
||||
},
|
||||
set: function (args) {
|
||||
argsMap.push(args[0]);
|
||||
cache.push(++lastId);
|
||||
return lastId;
|
||||
},
|
||||
delete: function (id) {
|
||||
var index = indexOf.call(cache, id);
|
||||
if (index !== -1) {
|
||||
argsMap.splice(index, 1);
|
||||
cache.splice(index, 1);
|
||||
}
|
||||
},
|
||||
clear: function () {
|
||||
argsMap = [];
|
||||
cache = [];
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
var nativeCreate = require('./_nativeCreate');
|
||||
|
||||
/**
|
||||
* Removes all key-value entries from the hash.
|
||||
*
|
||||
* @private
|
||||
* @name clear
|
||||
* @memberOf Hash
|
||||
*/
|
||||
function hashClear() {
|
||||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
module.exports = hashClear;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.distinctUntilChanged = void 0;
|
||||
var identity_1 = require("../util/identity");
|
||||
var lift_1 = require("../util/lift");
|
||||
var OperatorSubscriber_1 = require("./OperatorSubscriber");
|
||||
function distinctUntilChanged(comparator, keySelector) {
|
||||
if (keySelector === void 0) { keySelector = identity_1.identity; }
|
||||
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
|
||||
return lift_1.operate(function (source, subscriber) {
|
||||
var previousKey;
|
||||
var first = true;
|
||||
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
|
||||
var currentKey = keySelector(value);
|
||||
if (first || !comparator(previousKey, currentKey)) {
|
||||
first = false;
|
||||
previousKey = currentKey;
|
||||
subscriber.next(value);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
exports.distinctUntilChanged = distinctUntilChanged;
|
||||
function defaultCompare(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
//# sourceMappingURL=distinctUntilChanged.js.map
|
||||
@@ -0,0 +1,147 @@
|
||||
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
||||
|
||||
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||
|
||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||
|
||||
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ansi-styles
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const style = require('ansi-styles');
|
||||
|
||||
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
||||
|
||||
|
||||
// Color conversion between 16/256/truecolor
|
||||
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
||||
// may be degraded to fit that color palette. This means terminals
|
||||
// that do not support 16 million colors will best-match the
|
||||
// original color.
|
||||
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
||||
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
||||
console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Each style has an `open` and `close` property.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `gray` ("bright black")
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright`
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Advanced usage
|
||||
|
||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||
|
||||
- `style.modifier`
|
||||
- `style.color`
|
||||
- `style.bgColor`
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.color.green.open);
|
||||
```
|
||||
|
||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.codes.get(36));
|
||||
//=> 39
|
||||
```
|
||||
|
||||
|
||||
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
||||
|
||||
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
||||
|
||||
To use these, call the associated conversion function with the intended output, for example:
|
||||
|
||||
```js
|
||||
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
||||
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
||||
|
||||
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
|
||||
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
||||
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'integromat'
|
||||
],
|
||||
parserOptions: {
|
||||
'ecmaVersion': 2017,
|
||||
'ecmaFeatures': {
|
||||
'globalReturn': true
|
||||
}
|
||||
},
|
||||
globals: {
|
||||
},
|
||||
rules: {
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,333 @@
|
||||
'use strict';
|
||||
|
||||
const stringify = require('./stringify');
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const {
|
||||
MAX_LENGTH,
|
||||
CHAR_BACKSLASH, /* \ */
|
||||
CHAR_BACKTICK, /* ` */
|
||||
CHAR_COMMA, /* , */
|
||||
CHAR_DOT, /* . */
|
||||
CHAR_LEFT_PARENTHESES, /* ( */
|
||||
CHAR_RIGHT_PARENTHESES, /* ) */
|
||||
CHAR_LEFT_CURLY_BRACE, /* { */
|
||||
CHAR_RIGHT_CURLY_BRACE, /* } */
|
||||
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
||||
CHAR_RIGHT_SQUARE_BRACKET, /* ] */
|
||||
CHAR_DOUBLE_QUOTE, /* " */
|
||||
CHAR_SINGLE_QUOTE, /* ' */
|
||||
CHAR_NO_BREAK_SPACE,
|
||||
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
||||
} = require('./constants');
|
||||
|
||||
/**
|
||||
* parse
|
||||
*/
|
||||
|
||||
const parse = (input, options = {}) => {
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
let opts = options || {};
|
||||
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
if (input.length > max) {
|
||||
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
||||
}
|
||||
|
||||
let ast = { type: 'root', input, nodes: [] };
|
||||
let stack = [ast];
|
||||
let block = ast;
|
||||
let prev = ast;
|
||||
let brackets = 0;
|
||||
let length = input.length;
|
||||
let index = 0;
|
||||
let depth = 0;
|
||||
let value;
|
||||
let memo = {};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
const advance = () => input[index++];
|
||||
const push = node => {
|
||||
if (node.type === 'text' && prev.type === 'dot') {
|
||||
prev.type = 'text';
|
||||
}
|
||||
|
||||
if (prev && prev.type === 'text' && node.type === 'text') {
|
||||
prev.value += node.value;
|
||||
return;
|
||||
}
|
||||
|
||||
block.nodes.push(node);
|
||||
node.parent = block;
|
||||
node.prev = prev;
|
||||
prev = node;
|
||||
return node;
|
||||
};
|
||||
|
||||
push({ type: 'bos' });
|
||||
|
||||
while (index < length) {
|
||||
block = stack[stack.length - 1];
|
||||
value = advance();
|
||||
|
||||
/**
|
||||
* Invalid chars
|
||||
*/
|
||||
|
||||
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escaped chars
|
||||
*/
|
||||
|
||||
if (value === CHAR_BACKSLASH) {
|
||||
push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right square bracket (literal): ']'
|
||||
*/
|
||||
|
||||
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
push({ type: 'text', value: '\\' + value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Left square bracket: '['
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
brackets++;
|
||||
|
||||
let closed = true;
|
||||
let next;
|
||||
|
||||
while (index < length && (next = advance())) {
|
||||
value += next;
|
||||
|
||||
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
brackets++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === CHAR_BACKSLASH) {
|
||||
value += advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
brackets--;
|
||||
|
||||
if (brackets === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parentheses
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_PARENTHESES) {
|
||||
block = push({ type: 'paren', nodes: [] });
|
||||
stack.push(block);
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value === CHAR_RIGHT_PARENTHESES) {
|
||||
if (block.type !== 'paren') {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
block = stack.pop();
|
||||
push({ type: 'text', value });
|
||||
block = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quotes: '|"|`
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
||||
let open = value;
|
||||
let next;
|
||||
|
||||
if (options.keepQuotes !== true) {
|
||||
value = '';
|
||||
}
|
||||
|
||||
while (index < length && (next = advance())) {
|
||||
if (next === CHAR_BACKSLASH) {
|
||||
value += next + advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === open) {
|
||||
if (options.keepQuotes === true) value += next;
|
||||
break;
|
||||
}
|
||||
|
||||
value += next;
|
||||
}
|
||||
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Left curly brace: '{'
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_CURLY_BRACE) {
|
||||
depth++;
|
||||
|
||||
let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||
let brace = {
|
||||
type: 'brace',
|
||||
open: true,
|
||||
close: false,
|
||||
dollar,
|
||||
depth,
|
||||
commas: 0,
|
||||
ranges: 0,
|
||||
nodes: []
|
||||
};
|
||||
|
||||
block = push(brace);
|
||||
stack.push(block);
|
||||
push({ type: 'open', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right curly brace: '}'
|
||||
*/
|
||||
|
||||
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
||||
if (block.type !== 'brace') {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
let type = 'close';
|
||||
block = stack.pop();
|
||||
block.close = true;
|
||||
|
||||
push({ type, value });
|
||||
depth--;
|
||||
|
||||
block = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comma: ','
|
||||
*/
|
||||
|
||||
if (value === CHAR_COMMA && depth > 0) {
|
||||
if (block.ranges > 0) {
|
||||
block.ranges = 0;
|
||||
let open = block.nodes.shift();
|
||||
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
||||
}
|
||||
|
||||
push({ type: 'comma', value });
|
||||
block.commas++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dot: '.'
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
||||
let siblings = block.nodes;
|
||||
|
||||
if (depth === 0 || siblings.length === 0) {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev.type === 'dot') {
|
||||
block.range = [];
|
||||
prev.value += value;
|
||||
prev.type = 'range';
|
||||
|
||||
if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
||||
block.invalid = true;
|
||||
block.ranges = 0;
|
||||
prev.type = 'text';
|
||||
continue;
|
||||
}
|
||||
|
||||
block.ranges++;
|
||||
block.args = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev.type === 'range') {
|
||||
siblings.pop();
|
||||
|
||||
let before = siblings[siblings.length - 1];
|
||||
before.value += prev.value + value;
|
||||
prev = before;
|
||||
block.ranges--;
|
||||
continue;
|
||||
}
|
||||
|
||||
push({ type: 'dot', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text
|
||||
*/
|
||||
|
||||
push({ type: 'text', value });
|
||||
}
|
||||
|
||||
// Mark imbalanced braces and brackets as invalid
|
||||
do {
|
||||
block = stack.pop();
|
||||
|
||||
if (block.type !== 'root') {
|
||||
block.nodes.forEach(node => {
|
||||
if (!node.nodes) {
|
||||
if (node.type === 'open') node.isOpen = true;
|
||||
if (node.type === 'close') node.isClose = true;
|
||||
if (!node.nodes) node.type = 'text';
|
||||
node.invalid = true;
|
||||
}
|
||||
});
|
||||
|
||||
// get the location of the block on parent.nodes (block's siblings)
|
||||
let parent = stack[stack.length - 1];
|
||||
let index = parent.nodes.indexOf(block);
|
||||
// replace the (invalid) block with it's nodes
|
||||
parent.nodes.splice(index, 1, ...block.nodes);
|
||||
}
|
||||
} while (stack.length > 0);
|
||||
|
||||
push({ type: 'eos' });
|
||||
return ast;
|
||||
};
|
||||
|
||||
module.exports = parse;
|
||||
@@ -0,0 +1 @@
|
||||
tidelift: "npm/d"
|
||||
@@ -0,0 +1,119 @@
|
||||
function toArr(any) {
|
||||
return any == null ? [] : Array.isArray(any) ? any : [any];
|
||||
}
|
||||
|
||||
function toVal(out, key, val, opts) {
|
||||
var x, old=out[key], nxt=(
|
||||
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
||||
: typeof val === 'boolean' ? val
|
||||
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
||||
: (x = +val,x * 0 === 0) ? x : val
|
||||
);
|
||||
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
||||
}
|
||||
|
||||
module.exports = function (args, opts) {
|
||||
args = args || [];
|
||||
opts = opts || {};
|
||||
|
||||
var k, arr, arg, name, val, out={ _:[] };
|
||||
var i=0, j=0, idx=0, len=args.length;
|
||||
|
||||
const alibi = opts.alias !== void 0;
|
||||
const strict = opts.unknown !== void 0;
|
||||
const defaults = opts.default !== void 0;
|
||||
|
||||
opts.alias = opts.alias || {};
|
||||
opts.string = toArr(opts.string);
|
||||
opts.boolean = toArr(opts.boolean);
|
||||
|
||||
if (alibi) {
|
||||
for (k in opts.alias) {
|
||||
arr = opts.alias[k] = toArr(opts.alias[k]);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=opts.boolean.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.boolean[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
||||
}
|
||||
|
||||
for (i=opts.string.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.string[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
name = typeof opts.default[k];
|
||||
arr = opts.alias[k] = opts.alias[k] || [];
|
||||
if (opts[name] !== void 0) {
|
||||
opts[name].push(k);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
opts[name].push(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const keys = strict ? Object.keys(opts.alias) : [];
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
out._ = out._.concat(args.slice(++i));
|
||||
break;
|
||||
}
|
||||
|
||||
for (j=0; j < arg.length; j++) {
|
||||
if (arg.charCodeAt(j) !== 45) break; // "-"
|
||||
}
|
||||
|
||||
if (j === 0) {
|
||||
out._.push(arg);
|
||||
} else if (arg.substring(j, j + 3) === 'no-') {
|
||||
name = arg.substring(j + 3);
|
||||
if (strict && !~keys.indexOf(name)) {
|
||||
return opts.unknown(arg);
|
||||
}
|
||||
out[name] = false;
|
||||
} else {
|
||||
for (idx=j+1; idx < arg.length; idx++) {
|
||||
if (arg.charCodeAt(idx) === 61) break; // "="
|
||||
}
|
||||
|
||||
name = arg.substring(j, idx);
|
||||
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
||||
arr = (j === 2 ? [name] : name);
|
||||
|
||||
for (idx=0; idx < arr.length; idx++) {
|
||||
name = arr[idx];
|
||||
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
||||
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
if (out[k] === void 0) {
|
||||
out[k] = opts.default[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alibi) {
|
||||
for (k in out) {
|
||||
arr = opts.alias[k] || [];
|
||||
while (arr.length > 0) {
|
||||
out[arr.shift()] = out[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var parse = require('../');
|
||||
|
||||
test('long opts', function (t) {
|
||||
t.deepEqual(
|
||||
parse(['--bool']),
|
||||
{ bool: true, _: [] },
|
||||
'long boolean'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse(['--pow', 'xixxle']),
|
||||
{ pow: 'xixxle', _: [] },
|
||||
'long capture sp'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse(['--pow=xixxle']),
|
||||
{ pow: 'xixxle', _: [] },
|
||||
'long capture eq'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse(['--host', 'localhost', '--port', '555']),
|
||||
{ host: 'localhost', port: 555, _: [] },
|
||||
'long captures sp'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse(['--host=localhost', '--port=555']),
|
||||
{ host: 'localhost', port: 555, _: [] },
|
||||
'long captures eq'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
import { MonoTypeOperatorFunction } from '../types';
|
||||
/**
|
||||
* The Max operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
|
||||
* and when source Observable completes it emits a single item: the item with the largest value.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Get the maximal value of a series of numbers
|
||||
*
|
||||
* ```ts
|
||||
* import { of, max } from 'rxjs';
|
||||
*
|
||||
* of(5, 4, 7, 2, 8)
|
||||
* .pipe(max())
|
||||
* .subscribe(x => console.log(x));
|
||||
*
|
||||
* // Outputs
|
||||
* // 8
|
||||
* ```
|
||||
*
|
||||
* Use a comparer function to get the maximal item
|
||||
*
|
||||
* ```ts
|
||||
* import { of, max } from 'rxjs';
|
||||
*
|
||||
* of(
|
||||
* { age: 7, name: 'Foo' },
|
||||
* { age: 5, name: 'Bar' },
|
||||
* { age: 9, name: 'Beer' }
|
||||
* ).pipe(
|
||||
* max((a, b) => a.age < b.age ? -1 : 1)
|
||||
* )
|
||||
* .subscribe(x => console.log(x.name));
|
||||
*
|
||||
* // Outputs
|
||||
* // 'Beer'
|
||||
* ```
|
||||
*
|
||||
* @see {@link min}
|
||||
*
|
||||
* @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the
|
||||
* value of two items.
|
||||
* @return A function that returns an Observable that emits item with the
|
||||
* largest value.
|
||||
*/
|
||||
export declare function max<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T>;
|
||||
//# sourceMappingURL=max.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"EmptyError.js","sourceRoot":"","sources":["../../../../src/internal/util/EmptyError.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAwBzC,QAAA,UAAU,GAAmB,mCAAgB,CAAC,UAAC,MAAM,IAAK,OAAA,SAAS,cAAc;IAC5F,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IACzB,IAAI,CAAC,OAAO,GAAG,yBAAyB,CAAC;AAC3C,CAAC,EAJsE,CAItE,CAAC,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { from } from './from';
|
||||
export function pairs(obj, scheduler) {
|
||||
return from(Object.entries(obj), scheduler);
|
||||
}
|
||||
//# sourceMappingURL=pairs.js.map
|
||||
@@ -0,0 +1,31 @@
|
||||
import { __extends } from "tslib";
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
var AnimationFrameScheduler = (function (_super) {
|
||||
__extends(AnimationFrameScheduler, _super);
|
||||
function AnimationFrameScheduler() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
AnimationFrameScheduler.prototype.flush = function (action) {
|
||||
this._active = true;
|
||||
var flushId = this._scheduled;
|
||||
this._scheduled = undefined;
|
||||
var actions = this.actions;
|
||||
var error;
|
||||
action = action || actions.shift();
|
||||
do {
|
||||
if ((error = action.execute(action.state, action.delay))) {
|
||||
break;
|
||||
}
|
||||
} while ((action = actions[0]) && action.id === flushId && actions.shift());
|
||||
this._active = false;
|
||||
if (error) {
|
||||
while ((action = actions[0]) && action.id === flushId && actions.shift()) {
|
||||
action.unsubscribe();
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
return AnimationFrameScheduler;
|
||||
}(AsyncScheduler));
|
||||
export { AnimationFrameScheduler };
|
||||
//# sourceMappingURL=AnimationFrameScheduler.js.map
|
||||
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
var stringCoerce = require("../string/coerce")
|
||||
, toShortString = require("./to-short-string");
|
||||
|
||||
module.exports = function (errorMessage, value, inputOptions) {
|
||||
if (inputOptions && inputOptions.errorMessage) {
|
||||
errorMessage = stringCoerce(inputOptions.errorMessage);
|
||||
}
|
||||
|
||||
var valueInsertIndex = errorMessage.indexOf("%v");
|
||||
var valueToken = valueInsertIndex > -1 ? toShortString(value) : null;
|
||||
if (inputOptions && inputOptions.name) {
|
||||
var nameInsertIndex = errorMessage.indexOf("%n");
|
||||
if (nameInsertIndex > -1) {
|
||||
if (valueInsertIndex > -1) {
|
||||
var firstToken, secondToken, firstInsertIndex, secondInsertIndex;
|
||||
if (nameInsertIndex > valueInsertIndex) {
|
||||
firstToken = valueToken;
|
||||
firstInsertIndex = valueInsertIndex;
|
||||
secondToken = inputOptions.name;
|
||||
secondInsertIndex = nameInsertIndex;
|
||||
} else {
|
||||
firstToken = inputOptions.name;
|
||||
firstInsertIndex = nameInsertIndex;
|
||||
secondToken = valueToken;
|
||||
secondInsertIndex = valueInsertIndex;
|
||||
}
|
||||
return (
|
||||
errorMessage.slice(0, firstInsertIndex) +
|
||||
firstToken +
|
||||
errorMessage.slice(firstInsertIndex + 2, secondInsertIndex) +
|
||||
secondToken +
|
||||
errorMessage.slice(secondInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
return (
|
||||
errorMessage.slice(0, nameInsertIndex) +
|
||||
inputOptions.name +
|
||||
errorMessage.slice(nameInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (valueInsertIndex > -1) {
|
||||
return (
|
||||
errorMessage.slice(0, valueInsertIndex) +
|
||||
valueToken +
|
||||
errorMessage.slice(valueInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
return errorMessage;
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import fs from 'graceful-fs';
|
||||
import {xdgConfig} from 'xdg-basedir';
|
||||
import writeFileAtomic from 'write-file-atomic';
|
||||
import dotProp from 'dot-prop';
|
||||
import uniqueString from 'unique-string';
|
||||
|
||||
const configDirectory = xdgConfig || path.join(os.tmpdir(), uniqueString());
|
||||
const permissionError = 'You don\'t have access to this file.';
|
||||
const mkdirOptions = {mode: 0o0700, recursive: true};
|
||||
const writeFileOptions = {mode: 0o0600};
|
||||
|
||||
export default class Configstore {
|
||||
constructor(id, defaults, options = {}) {
|
||||
const pathPrefix = options.globalConfigPath ?
|
||||
path.join(id, 'config.json') :
|
||||
path.join('configstore', `${id}.json`);
|
||||
|
||||
this._path = options.configPath || path.join(configDirectory, pathPrefix);
|
||||
|
||||
if (defaults) {
|
||||
this.all = {
|
||||
...defaults,
|
||||
...this.all
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
get all() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(this._path, 'utf8'));
|
||||
} catch (error) {
|
||||
// Create directory if it doesn't exist
|
||||
if (error.code === 'ENOENT') {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Improve the message of permission errors
|
||||
if (error.code === 'EACCES') {
|
||||
error.message = `${error.message}\n${permissionError}\n`;
|
||||
}
|
||||
|
||||
// Empty the file if it encounters invalid JSON
|
||||
if (error.name === 'SyntaxError') {
|
||||
writeFileAtomic.sync(this._path, '', writeFileOptions);
|
||||
return {};
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
set all(value) {
|
||||
try {
|
||||
// Make sure the folder exists as it could have been deleted in the meantime
|
||||
fs.mkdirSync(path.dirname(this._path), mkdirOptions);
|
||||
|
||||
writeFileAtomic.sync(this._path, JSON.stringify(value, undefined, '\t'), writeFileOptions);
|
||||
} catch (error) {
|
||||
// Improve the message of permission errors
|
||||
if (error.code === 'EACCES') {
|
||||
error.message = `${error.message}\n${permissionError}\n`;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
return Object.keys(this.all || {}).length;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return dotProp.get(this.all, key);
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
const config = this.all;
|
||||
|
||||
if (arguments.length === 1) {
|
||||
for (const k of Object.keys(key)) {
|
||||
dotProp.set(config, k, key[k]);
|
||||
}
|
||||
} else {
|
||||
dotProp.set(config, key, value);
|
||||
}
|
||||
|
||||
this.all = config;
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return dotProp.has(this.all, key);
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
const config = this.all;
|
||||
dotProp.delete(config, key);
|
||||
this.all = config;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.all = {};
|
||||
}
|
||||
|
||||
get path() {
|
||||
return this._path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { exhaustAll } from './exhaustAll';
|
||||
/**
|
||||
* @deprecated Renamed to {@link exhaustAll}. Will be removed in v8.
|
||||
*/
|
||||
export declare const exhaust: typeof exhaustAll;
|
||||
//# sourceMappingURL=exhaust.d.ts.map
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var iteratorSymbol = require("es6-symbol").iterator
|
||||
, Iterator = require("../");
|
||||
|
||||
module.exports = function (t, a) {
|
||||
var iterator;
|
||||
a(t(), false, "Undefined");
|
||||
a(t(123), false, "Number");
|
||||
a(t({}), false, "Plain object");
|
||||
a(t({ length: 0 }), false, "Array-like");
|
||||
iterator = {};
|
||||
iterator[iteratorSymbol] = function () {
|
||||
return new Iterator([]);
|
||||
};
|
||||
a(t(iterator), true, "Iterator");
|
||||
a(t([]), true, "Array");
|
||||
a(t("foo"), true, "String");
|
||||
a(t(""), true, "Empty string");
|
||||
a(t(function () {
|
||||
return arguments;
|
||||
}()), true, "Arguments");
|
||||
};
|
||||
@@ -0,0 +1,121 @@
|
||||
|
||||
2.0.2 / 2018-05-15
|
||||
==================
|
||||
|
||||
* Test Node 9 and 10
|
||||
* Fix redirect protocol change issue for `http` (#11)
|
||||
* Attempt to fix broken npm 5 :(
|
||||
|
||||
2.0.1 / 2017-07-11
|
||||
==================
|
||||
|
||||
* update dependencies
|
||||
* fix "ftpd" causing the tests to fail
|
||||
* drop old Node.js versions, test 6, 7 and 8
|
||||
* ftp: add "error" event listener
|
||||
|
||||
2.0.0 / 2016-01-20
|
||||
==================
|
||||
|
||||
* index: remove `.use()`
|
||||
|
||||
1.1.1 / 2016-01-20
|
||||
==================
|
||||
|
||||
* index: deprecate `.use()`
|
||||
* travis: test more node versions
|
||||
|
||||
1.1.0 / 2015-07-08
|
||||
==================
|
||||
|
||||
* add 'use strict' declaration
|
||||
* add `use()` helper function for adding external protocols
|
||||
|
||||
1.0.0 / 2015-07-06
|
||||
==================
|
||||
|
||||
* bumping to v1 for better semver semantics
|
||||
|
||||
0.1.4 / 2015-07-06
|
||||
==================
|
||||
|
||||
* README: use SVG for Travis-CI badge
|
||||
* README: properly do cache example
|
||||
* use %o debug formatter most of the time
|
||||
* package: update "readable-stream" to v2
|
||||
* package: update "extend" to v3
|
||||
* package: update "debug" to v2
|
||||
* package: update "mocha" to v2
|
||||
* travis: test node v0.8, v0.10, and v0.12
|
||||
|
||||
0.1.3 / 2014-04-03
|
||||
==================
|
||||
|
||||
* package: old npm compatible semver
|
||||
|
||||
0.1.2 / 2014-04-03
|
||||
==================
|
||||
|
||||
* package: loosen semver required versions
|
||||
* data: just always use the "readable-stream" module
|
||||
|
||||
0.1.1 / 2014-02-05
|
||||
==================
|
||||
|
||||
* http: initial shot at "cached redirects" logic
|
||||
* package: pin "ftpd" version to v0.2.4 (for tests)
|
||||
* test: refactor tests into their own files
|
||||
* file: remove unused `path` require
|
||||
* test: fix "file:" URI tests on Windows
|
||||
* file: add better Windows support for file:// URIs
|
||||
* http: add the Cache-Control and Expires respecting logic
|
||||
* http: clean up logic a bit
|
||||
|
||||
0.1.0 / 2014-01-12
|
||||
==================
|
||||
|
||||
* test: add initial "http:" protocol tests
|
||||
* package: add "st" as a dev dependency
|
||||
* http: don't pass the `res` when there's a response error
|
||||
* test: add initial "https:" protocol tests
|
||||
* http: initial 304 Not Modified support
|
||||
* index: use debug()
|
||||
* http: add support for 3xx redirect response codes
|
||||
* http, https: initial "http:" and "https:" implementation
|
||||
* ftp: fix debug() call
|
||||
* package: update "description"
|
||||
* test: remove PASV port range from FTP server
|
||||
* test: add more "ftp:" protocol tests
|
||||
* test: add more "data:" protocol tests
|
||||
* test: more "file:" protocol tests
|
||||
* test: set `logLevel` to -1 on the FTP server
|
||||
* file: close the `fd` upon an error before creating the ReadStream
|
||||
* data: use "readable-stream" for node v0.8.x support
|
||||
* ftp: add debug() call for the entry logging
|
||||
* test: use "ftpd" for the "ftp:" protocol test
|
||||
* file: refactor for optimizations and to do proper NotModifiedErrors
|
||||
* add .travis.yml file
|
||||
* file: decodeURIComponent() on the pathname before normalizing
|
||||
* file: beginnings of refactor
|
||||
* file: initial async "file:" protocol
|
||||
* ftp: tweak comment
|
||||
* http, https: prep
|
||||
* test: add initial "file:" protocol test
|
||||
* data: fix debug() function name
|
||||
* notfound: fix jsdoc description
|
||||
* data: add NotModifierError() handling logic
|
||||
* ftp: handle the "file not found" scenario
|
||||
* notfound: add NotFoundError class
|
||||
* ftp: better ftp impl, not with NotModified support
|
||||
* notmodified: add NotModifiedError() class
|
||||
* ftp: fix `onfile()` error handling
|
||||
* file: beginnings of "file:" protocol impl
|
||||
* test: add initial "ftp" test
|
||||
* test: use "stream-to-array" for tests
|
||||
* ftp: comment out console.error() call
|
||||
* ftp: update to the async interface
|
||||
* package: update "data-uri-to-buffer" to v0.0.3
|
||||
* test: add initial tests
|
||||
* turn into an async interface
|
||||
* Add Readme.md
|
||||
* initial commit
|
||||
Reference in New Issue
Block a user