new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const macosRelease = require('macos-release');
|
||||
const winRelease = require('windows-release');
|
||||
|
||||
const osName = (platform, release) => {
|
||||
if (!platform && release) {
|
||||
throw new Error('You can\'t specify a `release` without specifying `platform`');
|
||||
}
|
||||
|
||||
platform = platform || os.platform();
|
||||
|
||||
let id;
|
||||
|
||||
if (platform === 'darwin') {
|
||||
if (!release && os.platform() === 'darwin') {
|
||||
release = os.release();
|
||||
}
|
||||
|
||||
const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS';
|
||||
|
||||
try {
|
||||
id = release ? macosRelease(release).name : '';
|
||||
} catch {}
|
||||
|
||||
return prefix + (id ? ' ' + id : '');
|
||||
}
|
||||
|
||||
if (platform === 'linux') {
|
||||
if (!release && os.platform() === 'linux') {
|
||||
release = os.release();
|
||||
}
|
||||
|
||||
id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : '';
|
||||
return 'Linux' + (id ? ' ' + id : '');
|
||||
}
|
||||
|
||||
if (platform === 'win32') {
|
||||
if (!release && os.platform() === 'win32') {
|
||||
release = os.release();
|
||||
}
|
||||
|
||||
id = release ? winRelease(release) : '';
|
||||
return 'Windows' + (id ? ' ' + id : '');
|
||||
}
|
||||
|
||||
return platform;
|
||||
};
|
||||
|
||||
module.exports = osName;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isNumeric.js","sources":["../../src/internal/util/isNumeric.ts"],"names":[],"mappings":";;AAAA,qCAAoC;AAEpC,SAAgB,SAAS,CAAC,GAAQ;IAKhC,OAAO,CAAC,iBAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC;AAND,8BAMC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bindNodeCallback.js","sources":["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AC;AACrB,CAAC"}
|
||||
@@ -0,0 +1,7 @@
|
||||
import assertString from './util/assertString';
|
||||
export default function rtrim(str, chars) {
|
||||
assertString(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
||||
|
||||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /\s+$/g;
|
||||
return str.replace(pattern, '');
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operator/publishLast';
|
||||
@@ -0,0 +1,142 @@
|
||||
import { Subject } from '../Subject';
|
||||
import { async } from '../scheduler/async';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { isNumeric } from '../util/isNumeric';
|
||||
import { isScheduler } from '../util/isScheduler';
|
||||
export function windowTime(windowTimeSpan) {
|
||||
let scheduler = async;
|
||||
let windowCreationInterval = null;
|
||||
let maxWindowSize = Number.POSITIVE_INFINITY;
|
||||
if (isScheduler(arguments[3])) {
|
||||
scheduler = arguments[3];
|
||||
}
|
||||
if (isScheduler(arguments[2])) {
|
||||
scheduler = arguments[2];
|
||||
}
|
||||
else if (isNumeric(arguments[2])) {
|
||||
maxWindowSize = Number(arguments[2]);
|
||||
}
|
||||
if (isScheduler(arguments[1])) {
|
||||
scheduler = arguments[1];
|
||||
}
|
||||
else if (isNumeric(arguments[1])) {
|
||||
windowCreationInterval = Number(arguments[1]);
|
||||
}
|
||||
return function windowTimeOperatorFunction(source) {
|
||||
return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
|
||||
};
|
||||
}
|
||||
class WindowTimeOperator {
|
||||
constructor(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
|
||||
this.windowTimeSpan = windowTimeSpan;
|
||||
this.windowCreationInterval = windowCreationInterval;
|
||||
this.maxWindowSize = maxWindowSize;
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
call(subscriber, source) {
|
||||
return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
|
||||
}
|
||||
}
|
||||
class CountedSubject extends Subject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._numberOfNextedValues = 0;
|
||||
}
|
||||
next(value) {
|
||||
this._numberOfNextedValues++;
|
||||
super.next(value);
|
||||
}
|
||||
get numberOfNextedValues() {
|
||||
return this._numberOfNextedValues;
|
||||
}
|
||||
}
|
||||
class WindowTimeSubscriber extends Subscriber {
|
||||
constructor(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
|
||||
super(destination);
|
||||
this.destination = destination;
|
||||
this.windowTimeSpan = windowTimeSpan;
|
||||
this.windowCreationInterval = windowCreationInterval;
|
||||
this.maxWindowSize = maxWindowSize;
|
||||
this.scheduler = scheduler;
|
||||
this.windows = [];
|
||||
const window = this.openWindow();
|
||||
if (windowCreationInterval !== null && windowCreationInterval >= 0) {
|
||||
const closeState = { subscriber: this, window, context: null };
|
||||
const creationState = { windowTimeSpan, windowCreationInterval, subscriber: this, scheduler };
|
||||
this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
|
||||
this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
|
||||
}
|
||||
else {
|
||||
const timeSpanOnlyState = { subscriber: this, window, windowTimeSpan };
|
||||
this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
|
||||
}
|
||||
}
|
||||
_next(value) {
|
||||
const windows = this.windows;
|
||||
const len = windows.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const window = windows[i];
|
||||
if (!window.closed) {
|
||||
window.next(value);
|
||||
if (window.numberOfNextedValues >= this.maxWindowSize) {
|
||||
this.closeWindow(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_error(err) {
|
||||
const windows = this.windows;
|
||||
while (windows.length > 0) {
|
||||
windows.shift().error(err);
|
||||
}
|
||||
this.destination.error(err);
|
||||
}
|
||||
_complete() {
|
||||
const windows = this.windows;
|
||||
while (windows.length > 0) {
|
||||
const window = windows.shift();
|
||||
if (!window.closed) {
|
||||
window.complete();
|
||||
}
|
||||
}
|
||||
this.destination.complete();
|
||||
}
|
||||
openWindow() {
|
||||
const window = new CountedSubject();
|
||||
this.windows.push(window);
|
||||
const destination = this.destination;
|
||||
destination.next(window);
|
||||
return window;
|
||||
}
|
||||
closeWindow(window) {
|
||||
window.complete();
|
||||
const windows = this.windows;
|
||||
windows.splice(windows.indexOf(window), 1);
|
||||
}
|
||||
}
|
||||
function dispatchWindowTimeSpanOnly(state) {
|
||||
const { subscriber, windowTimeSpan, window } = state;
|
||||
if (window) {
|
||||
subscriber.closeWindow(window);
|
||||
}
|
||||
state.window = subscriber.openWindow();
|
||||
this.schedule(state, windowTimeSpan);
|
||||
}
|
||||
function dispatchWindowCreation(state) {
|
||||
const { windowTimeSpan, subscriber, scheduler, windowCreationInterval } = state;
|
||||
const window = subscriber.openWindow();
|
||||
const action = this;
|
||||
let context = { action, subscription: null };
|
||||
const timeSpanState = { subscriber, window, context };
|
||||
context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
|
||||
action.add(context.subscription);
|
||||
action.schedule(state, windowCreationInterval);
|
||||
}
|
||||
function dispatchWindowClose(state) {
|
||||
const { subscriber, window, context } = state;
|
||||
if (context && context.action && context.subscription) {
|
||||
context.action.remove(context.subscription);
|
||||
}
|
||||
subscriber.closeWindow(window);
|
||||
}
|
||||
//# sourceMappingURL=windowTime.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"q r s D t","2":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o","516":"p"},C:{"1":"t xB yB","2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w 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 e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D DC EC"},D:{"1":"q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w 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 e lB mB nB oB pB P Q R S T U V W X Y Z a","194":"c d f g h i j k l m n o","450":"b","516":"p"},E:{"1":"sB 6B 7B 8B NC","2":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B"},F:{"1":"d","2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w 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 e lB mB nB oB pB OC PC QC RC qB 9B SC rB","194":"P Q R wB S T U V W X Y Z","516":"a b c"},G:{"1":"sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:5,C:"CSS Container Queries (Size)"};
|
||||
@@ -0,0 +1,17 @@
|
||||
const shelljs = require('shelljs');
|
||||
const nock = require('nock');
|
||||
const test = require('ava');
|
||||
|
||||
shelljs.config.silent = true;
|
||||
nock.disableNetConnect();
|
||||
|
||||
const { GITHUB_TOKEN, GITLAB_TOKEN, GITHUB_ACTIONS, GITHUB_ACTOR } = process.env;
|
||||
|
||||
process.env.GITHUB_TOKEN = process.env.GITLAB_TOKEN = 1;
|
||||
|
||||
test.after.always(() => {
|
||||
process.env.GITHUB_TOKEN = GITHUB_TOKEN;
|
||||
process.env.GITLAB_TOKEN = GITLAB_TOKEN;
|
||||
process.env.GITHUB_ACTIONS = GITHUB_ACTIONS;
|
||||
process.env.GITHUB_ACTOR = GITHUB_ACTOR;
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
// These are all the basic types that's compatible with all supported TypeScript versions.
|
||||
export * from '../base';
|
||||
|
||||
// These are special types that require at least TypeScript 4.1.
|
||||
export {CamelCase} from './camel-case';
|
||||
export {KebabCase} from './kebab-case';
|
||||
export {PascalCase} from './pascal-case';
|
||||
export {SnakeCase} from './snake-case';
|
||||
export {DelimiterCase} from './delimiter-case';
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "localforage",
|
||||
"author": "Mozilla",
|
||||
"license": "Apache-2.0",
|
||||
"description": "Offline storage, improved.",
|
||||
"keywords": [
|
||||
"indexeddb",
|
||||
"localstorage",
|
||||
"storage",
|
||||
"websql"
|
||||
],
|
||||
"version": "1.9.0",
|
||||
"homepage": "https://github.com/localForage/localForage",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/localForage/localForage.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node -e \"require('grunt').cli()\" null build",
|
||||
"prettify": "prettier --write \"src/**/*.js\" \"test/**/*.js\"",
|
||||
"publish-docs": "node -e \"require('grunt').cli()\" null copy build-rules-html publish-rules",
|
||||
"serve": "node -e \"require('grunt').cli()\" null serve",
|
||||
"test": "node -e \"require('grunt').cli()\" null test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.5.1",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-loader": "^6.2.2",
|
||||
"babel-plugin-add-module-exports": "^0.1.2",
|
||||
"babel-plugin-transform-es2015-modules-umd": "^6.5.0",
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"babel-preset-es2015-loose": "^7.0.0",
|
||||
"babelify": "^7.2.0",
|
||||
"browserify-derequire": "^0.9.4",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"cors": "^2.3.1",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"grunt": "^0.4.2",
|
||||
"grunt-babel": "^6.0.0",
|
||||
"grunt-browserify": "^3.8.0",
|
||||
"grunt-contrib-concat": "^0.3.0",
|
||||
"grunt-contrib-connect": "^0.8.0",
|
||||
"grunt-contrib-uglify": "^0.4.0",
|
||||
"grunt-contrib-watch": "^0.5.0",
|
||||
"grunt-es3-safe-recast": "^0.1.0",
|
||||
"grunt-eslint": "^20.0.0",
|
||||
"mocha-headless-chrome": "3.1.0",
|
||||
"grunt-rollup": "^0.6.2",
|
||||
"grunt-run": "^0.5.2",
|
||||
"grunt-saucelabs": "^5.1.2",
|
||||
"grunt-ts": "^6.0.0-beta.11",
|
||||
"grunt-webpack": "^1.0.11",
|
||||
"husky": "^2.3.0",
|
||||
"lint-staged": "^8.1.7",
|
||||
"load-grunt-tasks": "^0.4.0",
|
||||
"mocha": "^3.4.2",
|
||||
"prettier": "~1.12.0",
|
||||
"rollupify": "^0.1.0",
|
||||
"script-loader": "^0.6.1",
|
||||
"typescript": "^2.0.3",
|
||||
"uglify-js": "^2.3.x",
|
||||
"webpack": "^1.12.13",
|
||||
"webpack-dev-server": "^1.10.1"
|
||||
},
|
||||
"main": "dist/localforage.js",
|
||||
"typings": "typings/localforage.d.ts",
|
||||
"bugs": {
|
||||
"url": "http://github.com/localForage/localForage/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"lie": "3.1.1"
|
||||
}
|
||||
}
|
||||
@@ -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.00566,"36":0,"37":0,"38":0,"39":0,"40":0.00566,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.01131,"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.03394,"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.00566,"92":0,"93":0,"94":0,"95":0.02263,"96":0,"97":0,"98":0,"99":0.00566,"100":0,"101":0.00566,"102":0.14708,"103":0.00566,"104":0,"105":0.01697,"106":0.01697,"107":0.05091,"108":1.36334,"109":0.6845,"110":0.00566,"111":0.00566,"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.00566,"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.00566,"39":0.00566,"40":0,"41":0,"42":0,"43":0.00566,"44":0.00566,"45":0.00566,"46":0.00566,"47":0.00566,"48":0,"49":0.00566,"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.00566,"66":0,"67":0.00566,"68":0,"69":0,"70":0.00566,"71":0,"72":0.01131,"73":0.00566,"74":0,"75":0,"76":0,"77":0.00566,"78":0.0396,"79":0.03394,"80":0.01697,"81":0.00566,"83":0,"84":0,"85":0.02829,"86":0,"87":0.05091,"88":0,"89":0,"90":0.01131,"91":0.00566,"92":0.01131,"93":0,"94":0,"95":0.01697,"96":0.06223,"97":0.01131,"98":0.01131,"99":0,"100":0.01131,"101":0.00566,"102":0.00566,"103":0.14708,"104":0.02263,"105":0.05657,"106":0.0792,"107":0.39033,"108":9.70176,"109":8.25356,"110":0.02829,"111":0,"112":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.00566,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0.00566,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00566,"92":0,"93":0.54873,"94":0.58833,"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,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0.00566,"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.00566,"104":0.00566,"105":0.00566,"106":0.00566,"107":0.05091,"108":1.55568,"109":1.59527},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.02263,"14":0.1188,"15":0.02263,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0.02263,"12.1":0.04526,"13.1":0.20365,"14.1":0.33376,"15.1":0.05091,"15.2-15.3":0.04526,"15.4":0.13011,"15.5":0.18102,"15.6":1.43122,"16.0":0.22628,"16.1":0.59399,"16.2":1.07483,"16.3":0.06788},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.01332,"8.1-8.4":0.0233,"9.0-9.2":0,"9.3":0.04661,"10.0-10.2":0,"10.3":0.07324,"11.0-11.2":0.07324,"11.3-11.4":0.00333,"12.0-12.1":0.01665,"12.2-12.5":0.33959,"13.0-13.1":0,"13.2":0,"13.3":0.01665,"13.4-13.7":0.04994,"14.0-14.4":0.25635,"14.5-14.8":0.63256,"15.0-15.1":0.11652,"15.2-15.3":0.30629,"15.4":0.22306,"15.5":0.86228,"15.6":4.77752,"16.0":5.66976,"16.1":12.1552,"16.2":6.27902,"16.3":0.38287},P:{"4":0.05144,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0,"8.2":0,"9.2":0,"10.1":0.01029,"11.1-11.2":0,"12.0":0,"13.0":0.1646,"14.0":0.01029,"15.0":0,"16.0":0.04115,"17.0":0.06172,"18.0":0.15431,"19.0":3.38451},I:{"0":0,"3":0,"4":0.01207,"2.1":0.00241,"2.2":0.01207,"2.3":0.01448,"4.1":0.02655,"4.2-4.3":0.04586,"4.4":0,"4.4.3-4.4.4":0.09655},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0.00566,"7":0.00566,"8":0.04526,"9":0.01131,"10":0.01131,"11":0.05657,"5.5":0},J:{"7":0,"10":0.00434},N:{"10":0,"11":0.01303},R:{_:"0"},M:{"0":0.35613},Q:{"13.1":0},O:{"0":0.0304},H:{"0":0.22203},L:{"0":29.0731},S:{"2.5":0.01737}};
|
||||
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var identity_1 = require("./identity");
|
||||
function pipe() {
|
||||
var fns = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
fns[_i] = arguments[_i];
|
||||
}
|
||||
return pipeFromArray(fns);
|
||||
}
|
||||
exports.pipe = pipe;
|
||||
function pipeFromArray(fns) {
|
||||
if (fns.length === 0) {
|
||||
return identity_1.identity;
|
||||
}
|
||||
if (fns.length === 1) {
|
||||
return fns[0];
|
||||
}
|
||||
return function piped(input) {
|
||||
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
||||
};
|
||||
}
|
||||
exports.pipeFromArray = pipeFromArray;
|
||||
//# sourceMappingURL=pipe.js.map
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Subject } from './Subject';
|
||||
import { Subscriber } from './Subscriber';
|
||||
import { Subscription } from './Subscription';
|
||||
import { SubscriptionLike } from './types';
|
||||
import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
|
||||
|
||||
/**
|
||||
* A variant of Subject that requires an initial value and emits its current
|
||||
* value whenever it is subscribed to.
|
||||
*
|
||||
* @class BehaviorSubject<T>
|
||||
*/
|
||||
export class BehaviorSubject<T> extends Subject<T> {
|
||||
|
||||
constructor(private _value: T) {
|
||||
super();
|
||||
}
|
||||
|
||||
get value(): T {
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_subscribe(subscriber: Subscriber<T>): Subscription {
|
||||
const subscription = super._subscribe(subscriber);
|
||||
if (subscription && !(<SubscriptionLike>subscription).closed) {
|
||||
subscriber.next(this._value);
|
||||
}
|
||||
return subscription;
|
||||
}
|
||||
|
||||
getValue(): T {
|
||||
if (this.hasError) {
|
||||
throw this.thrownError;
|
||||
} else if (this.closed) {
|
||||
throw new ObjectUnsubscribedError();
|
||||
} else {
|
||||
return this._value;
|
||||
}
|
||||
}
|
||||
|
||||
next(value: T): void {
|
||||
super.next(this._value = value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
# Commander.js
|
||||
|
||||
|
||||
[](http://travis-ci.org/tj/commander.js)
|
||||
[](https://www.npmjs.org/package/commander)
|
||||
[](https://npmcharts.com/compare/commander?minimal=true)
|
||||
[](https://packagephobia.now.sh/result?p=commander)
|
||||
[](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
|
||||
[API documentation](http://tj.github.com/commander.js/)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install commander --save
|
||||
|
||||
## Option parsing
|
||||
|
||||
Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-p, --peppers', 'Add peppers')
|
||||
.option('-P, --pineapple', 'Add pineapple')
|
||||
.option('-b, --bbq-sauce', 'Add bbq sauce')
|
||||
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('you ordered a pizza with:');
|
||||
if (program.peppers) console.log(' - peppers');
|
||||
if (program.pineapple) console.log(' - pineapple');
|
||||
if (program.bbqSauce) console.log(' - bbq');
|
||||
console.log(' - %s cheese', program.cheese);
|
||||
```
|
||||
|
||||
Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
|
||||
|
||||
Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.option('--no-sauce', 'Remove sauce')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('you ordered a pizza');
|
||||
if (program.sauce) console.log(' with sauce');
|
||||
else console.log(' without sauce');
|
||||
```
|
||||
|
||||
## Version option
|
||||
|
||||
Calling the `version` implicitly adds the `-V` and `--version` options to the command.
|
||||
When either of these options is present, the command prints the version number and exits.
|
||||
|
||||
$ ./examples/pizza -V
|
||||
0.0.1
|
||||
|
||||
If you want your program to respond to the `-v` option instead of the `-V` option, simply pass custom flags to the `version` method using the same syntax as the `option` method.
|
||||
|
||||
```js
|
||||
program
|
||||
.version('0.0.1', '-v, --version')
|
||||
```
|
||||
|
||||
The version flags can be named anything, but the long option is required.
|
||||
|
||||
## Command-specific options
|
||||
|
||||
You can attach options to a command.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.command('rm <dir>')
|
||||
.option('-r, --recursive', 'Remove recursively')
|
||||
.action(function (dir, cmd) {
|
||||
console.log('remove ' + dir + (cmd.recursive ? ' recursively' : ''))
|
||||
})
|
||||
|
||||
program.parse(process.argv)
|
||||
```
|
||||
|
||||
A command's options are validated when the command is used. Any unknown options will be reported as an error. However, if an action-based command does not define an action, then the options are not validated.
|
||||
|
||||
## Coercion
|
||||
|
||||
```js
|
||||
function range(val) {
|
||||
return val.split('..').map(Number);
|
||||
}
|
||||
|
||||
function list(val) {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
function collect(val, memo) {
|
||||
memo.push(val);
|
||||
return memo;
|
||||
}
|
||||
|
||||
function increaseVerbosity(v, total) {
|
||||
return total + 1;
|
||||
}
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.usage('[options] <file ...>')
|
||||
.option('-i, --integer <n>', 'An integer argument', parseInt)
|
||||
.option('-f, --float <n>', 'A float argument', parseFloat)
|
||||
.option('-r, --range <a>..<b>', 'A range', range)
|
||||
.option('-l, --list <items>', 'A list', list)
|
||||
.option('-o, --optional [value]', 'An optional value')
|
||||
.option('-c, --collect [value]', 'A repeatable value', collect, [])
|
||||
.option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
|
||||
.parse(process.argv);
|
||||
|
||||
console.log(' int: %j', program.integer);
|
||||
console.log(' float: %j', program.float);
|
||||
console.log(' optional: %j', program.optional);
|
||||
program.range = program.range || [];
|
||||
console.log(' range: %j..%j', program.range[0], program.range[1]);
|
||||
console.log(' list: %j', program.list);
|
||||
console.log(' collect: %j', program.collect);
|
||||
console.log(' verbosity: %j', program.verbose);
|
||||
console.log(' args: %j', program.args);
|
||||
```
|
||||
|
||||
## Regular Expression
|
||||
```js
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
|
||||
.option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
|
||||
.parse(process.argv);
|
||||
|
||||
console.log(' size: %j', program.size);
|
||||
console.log(' drink: %j', program.drink);
|
||||
```
|
||||
|
||||
## Variadic arguments
|
||||
|
||||
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
|
||||
append `...` to the argument name. Here is an example:
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('rmdir <dir> [otherDirs...]')
|
||||
.action(function (dir, otherDirs) {
|
||||
console.log('rmdir %s', dir);
|
||||
if (otherDirs) {
|
||||
otherDirs.forEach(function (oDir) {
|
||||
console.log('rmdir %s', oDir);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
|
||||
to your action as demonstrated above.
|
||||
|
||||
## Specify the argument syntax
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.arguments('<cmd> [env]')
|
||||
.action(function (cmd, env) {
|
||||
cmdValue = cmd;
|
||||
envValue = env;
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
if (typeof cmdValue === 'undefined') {
|
||||
console.error('no command given!');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('command:', cmdValue);
|
||||
console.log('environment:', envValue || "no environment given");
|
||||
```
|
||||
Angled brackets (e.g. `<cmd>`) indicate required input. Square brackets (e.g. `[env]`) indicate optional input.
|
||||
|
||||
## Git-style sub-commands
|
||||
|
||||
```js
|
||||
// file: ./examples/pm
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('install [name]', 'install one or more packages')
|
||||
.command('search [query]', 'search with optional query')
|
||||
.command('list', 'list packages installed', {isDefault: true})
|
||||
.parse(process.argv);
|
||||
```
|
||||
|
||||
When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
|
||||
The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
|
||||
|
||||
Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the subcommand from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.
|
||||
|
||||
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
|
||||
|
||||
### `--harmony`
|
||||
|
||||
You can enable `--harmony` option in two ways:
|
||||
* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern.
|
||||
* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.
|
||||
|
||||
## Automated --help
|
||||
|
||||
The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
|
||||
|
||||
```
|
||||
$ ./examples/pizza --help
|
||||
|
||||
Usage: pizza [options]
|
||||
|
||||
An application for pizzas ordering
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
-p, --peppers Add peppers
|
||||
-P, --pineapple Add pineapple
|
||||
-b, --bbq Add bbq sauce
|
||||
-c, --cheese <type> Add the specified type of cheese [marble]
|
||||
-C, --no-cheese You do not want any cheese
|
||||
|
||||
```
|
||||
|
||||
## Custom help
|
||||
|
||||
You can display arbitrary `-h, --help` information
|
||||
by listening for "--help". Commander will automatically
|
||||
exit once you are done so that the remainder of your program
|
||||
does not execute causing undesired behaviours, for example
|
||||
in the following executable "stuff" will not output when
|
||||
`--help` is used.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-f, --foo', 'enable some foo')
|
||||
.option('-b, --bar', 'enable some bar')
|
||||
.option('-B, --baz', 'enable some baz');
|
||||
|
||||
// must be before .parse() since
|
||||
// node's emit() is immediate
|
||||
|
||||
program.on('--help', function(){
|
||||
console.log(' Examples:');
|
||||
console.log('');
|
||||
console.log(' $ custom-help --help');
|
||||
console.log(' $ custom-help -h');
|
||||
console.log('');
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
console.log('stuff');
|
||||
```
|
||||
|
||||
Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
|
||||
|
||||
```
|
||||
|
||||
Usage: custom-help [options]
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
-f, --foo enable some foo
|
||||
-b, --bar enable some bar
|
||||
-B, --baz enable some baz
|
||||
|
||||
Examples:
|
||||
|
||||
$ custom-help --help
|
||||
$ custom-help -h
|
||||
|
||||
```
|
||||
|
||||
## .outputHelp(cb)
|
||||
|
||||
Output help information without exiting.
|
||||
Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
If you want to display help by default (e.g. if no command was provided), you can use something like:
|
||||
|
||||
```js
|
||||
var program = require('commander');
|
||||
var colors = require('colors');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('getstream [url]', 'get stream URL')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
program.outputHelp(make_red);
|
||||
}
|
||||
|
||||
function make_red(txt) {
|
||||
return colors.red(txt); //display the help text in red on the console
|
||||
}
|
||||
```
|
||||
|
||||
## .help(cb)
|
||||
|
||||
Output help information and exit immediately.
|
||||
Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
|
||||
## Custom event listeners
|
||||
You can execute custom actions by listening to command and option events.
|
||||
|
||||
```js
|
||||
program.on('option:verbose', function () {
|
||||
process.env.VERBOSE = this.verbose;
|
||||
});
|
||||
|
||||
// error on unknown commands
|
||||
program.on('command:*', function () {
|
||||
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
|
||||
process.exit(1);
|
||||
});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-C, --chdir <path>', 'change the working directory')
|
||||
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
.option('-T, --no-tests', 'ignore test hook');
|
||||
|
||||
program
|
||||
.command('setup [env]')
|
||||
.description('run setup commands for all envs')
|
||||
.option("-s, --setup_mode [mode]", "Which setup mode to use")
|
||||
.action(function(env, options){
|
||||
var mode = options.setup_mode || "normal";
|
||||
env = env || 'all';
|
||||
console.log('setup for %s env(s) with %s mode', env, mode);
|
||||
});
|
||||
|
||||
program
|
||||
.command('exec <cmd>')
|
||||
.alias('ex')
|
||||
.description('execute the given remote cmd')
|
||||
.option("-e, --exec_mode <mode>", "Which exec mode to use")
|
||||
.action(function(cmd, options){
|
||||
console.log('exec "%s" using %s mode', cmd, options.exec_mode);
|
||||
}).on('--help', function() {
|
||||
console.log(' Examples:');
|
||||
console.log();
|
||||
console.log(' $ deploy exec sequential');
|
||||
console.log(' $ deploy exec async');
|
||||
console.log();
|
||||
});
|
||||
|
||||
program
|
||||
.command('*')
|
||||
.action(function(env){
|
||||
console.log('deploying "%s"', env);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,20 @@
|
||||
export declare type ResponseHeaders = {
|
||||
"cache-control"?: string;
|
||||
"content-length"?: number;
|
||||
"content-type"?: string;
|
||||
date?: string;
|
||||
etag?: string;
|
||||
"last-modified"?: string;
|
||||
link?: string;
|
||||
location?: string;
|
||||
server?: string;
|
||||
status?: string;
|
||||
vary?: string;
|
||||
"x-github-mediatype"?: string;
|
||||
"x-github-request-id"?: string;
|
||||
"x-oauth-scopes"?: string;
|
||||
"x-ratelimit-limit"?: string;
|
||||
"x-ratelimit-remaining"?: string;
|
||||
"x-ratelimit-reset"?: string;
|
||||
[header: string]: string | number | undefined;
|
||||
};
|
||||
@@ -0,0 +1,211 @@
|
||||
'use strict';
|
||||
/**
|
||||
* `list` type prompt
|
||||
*/
|
||||
|
||||
var _ = {
|
||||
isNumber: require('lodash/isNumber'),
|
||||
findIndex: require('lodash/findIndex'),
|
||||
isString: require('lodash/isString'),
|
||||
};
|
||||
var chalk = require('chalk');
|
||||
var figures = require('figures');
|
||||
var cliCursor = require('cli-cursor');
|
||||
var runAsync = require('run-async');
|
||||
var { flatMap, map, take, takeUntil } = require('rxjs/operators');
|
||||
var Base = require('./base');
|
||||
var observe = require('../utils/events');
|
||||
var Paginator = require('../utils/paginator');
|
||||
var incrementListIndex = require('../utils/incrementListIndex');
|
||||
|
||||
class ListPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
this.firstRender = true;
|
||||
this.selected = 0;
|
||||
|
||||
var def = this.opt.default;
|
||||
|
||||
// If def is a Number, then use as index. Otherwise, check for value.
|
||||
if (_.isNumber(def) && def >= 0 && def < this.opt.choices.realLength) {
|
||||
this.selected = def;
|
||||
} else if (!_.isNumber(def) && def != null) {
|
||||
let index = _.findIndex(this.opt.choices.realChoices, ({ value }) => value === def);
|
||||
this.selected = Math.max(index, 0);
|
||||
}
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
var self = this;
|
||||
|
||||
var events = observe(this.rl);
|
||||
events.normalizedUpKey.pipe(takeUntil(events.line)).forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(events.line))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
events.numberKey.pipe(takeUntil(events.line)).forEach(this.onNumberKey.bind(this));
|
||||
events.line
|
||||
.pipe(
|
||||
take(1),
|
||||
map(this.getCurrentValue.bind(this)),
|
||||
flatMap((value) =>
|
||||
runAsync(self.opt.filter)(value, self.answers).catch((err) => err)
|
||||
)
|
||||
)
|
||||
.forEach(this.onSubmit.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
cliCursor.hide();
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {ListPrompt} self
|
||||
*/
|
||||
|
||||
render() {
|
||||
// Render question
|
||||
var message = this.getQuestion();
|
||||
|
||||
if (this.firstRender) {
|
||||
message += chalk.dim('(Use arrow keys)');
|
||||
}
|
||||
|
||||
// Render choices or answer depending on the state
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.opt.choices.getChoice(this.selected).short);
|
||||
} else {
|
||||
var choicesStr = listRender(this.opt.choices, this.selected);
|
||||
var indexPosition = this.opt.choices.indexOf(
|
||||
this.opt.choices.getChoice(this.selected)
|
||||
);
|
||||
var realIndexPosition =
|
||||
this.opt.choices.reduce(function (acc, value, i) {
|
||||
// Dont count lines past the choice we are looking at
|
||||
if (i > indexPosition) {
|
||||
return acc;
|
||||
}
|
||||
// Add line if it's a separator
|
||||
if (value.type === 'separator') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
var l = value.name;
|
||||
// Non-strings take up one line
|
||||
if (typeof l !== 'string') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
// Calculate lines taken up by string
|
||||
l = l.split('\n');
|
||||
return acc + l.length;
|
||||
}, 0) - 1;
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
|
||||
}
|
||||
|
||||
this.firstRender = false;
|
||||
|
||||
this.screen.render(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onSubmit(value) {
|
||||
this.status = 'answered';
|
||||
|
||||
// Rerender prompt
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
cliCursor.show();
|
||||
this.done(value);
|
||||
}
|
||||
|
||||
getCurrentValue() {
|
||||
return this.opt.choices.getChoice(this.selected).value;
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
onUpKey() {
|
||||
this.selected = incrementListIndex(this.selected, 'up', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onDownKey() {
|
||||
this.selected = incrementListIndex(this.selected, 'down', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onNumberKey(input) {
|
||||
if (input <= this.opt.choices.realLength) {
|
||||
this.selected = input - 1;
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering list choices
|
||||
* @param {Number} pointer Position of the pointer
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
function listRender(choices, pointer) {
|
||||
var output = '';
|
||||
var separatorOffset = 0;
|
||||
|
||||
choices.forEach((choice, i) => {
|
||||
if (choice.type === 'separator') {
|
||||
separatorOffset++;
|
||||
output += ' ' + choice + '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
if (choice.disabled) {
|
||||
separatorOffset++;
|
||||
output += ' - ' + choice.name;
|
||||
output += ' (' + (_.isString(choice.disabled) ? choice.disabled : 'Disabled') + ')';
|
||||
output += '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
var isSelected = i - separatorOffset === pointer;
|
||||
var line = (isSelected ? figures.pointer + ' ' : ' ') + choice.name;
|
||||
if (isSelected) {
|
||||
line = chalk.cyan(line);
|
||||
}
|
||||
|
||||
output += line + ' \n';
|
||||
});
|
||||
|
||||
return output.replace(/\n$/, '');
|
||||
}
|
||||
|
||||
module.exports = ListPrompt;
|
||||
@@ -0,0 +1,19 @@
|
||||
MIT License Copyright (c) 2020 ODIT.Services (info@odit.services)
|
||||
|
||||
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 (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/scheduler/asap"));
|
||||
//# sourceMappingURL=asap.js.map
|
||||
Reference in New Issue
Block a user