new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isFunction.js","sources":["../../src/internal/util/isFunction.ts"],"names":[],"mappings":";;AAAA,SAAgB,UAAU,CAAC,CAAM;IAC/B,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;AACjC,CAAC;AAFD,gCAEC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/ignoreElements");
|
||||
//# sourceMappingURL=ignoreElements.js.map
|
||||
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isISBN;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
|
||||
var isbn13Maybe = /^(?:[0-9]{13})$/;
|
||||
var factor = [1, 3];
|
||||
|
||||
function isISBN(str) {
|
||||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
(0, _assertString.default)(str);
|
||||
version = String(version);
|
||||
|
||||
if (!version) {
|
||||
return isISBN(str, 10) || isISBN(str, 13);
|
||||
}
|
||||
|
||||
var sanitized = str.replace(/[\s-]+/g, '');
|
||||
var checksum = 0;
|
||||
var i;
|
||||
|
||||
if (version === '10') {
|
||||
if (!isbn10Maybe.test(sanitized)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
checksum += (i + 1) * sanitized.charAt(i);
|
||||
}
|
||||
|
||||
if (sanitized.charAt(9) === 'X') {
|
||||
checksum += 10 * 10;
|
||||
} else {
|
||||
checksum += 10 * sanitized.charAt(9);
|
||||
}
|
||||
|
||||
if (checksum % 11 === 0) {
|
||||
return !!sanitized;
|
||||
}
|
||||
} else if (version === '13') {
|
||||
if (!isbn13Maybe.test(sanitized)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
checksum += factor[i % 2] * sanitized.charAt(i);
|
||||
}
|
||||
|
||||
if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
|
||||
return !!sanitized;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { SchedulerLike } from '../types';
|
||||
/**
|
||||
* Creates an Observable that emits sequential numbers every specified
|
||||
* interval of time, on a specified {@link SchedulerLike}.
|
||||
*
|
||||
* <span class="informal">Emits incremental numbers periodically in time.
|
||||
* </span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `interval` returns an Observable that emits an infinite sequence of
|
||||
* ascending integers, with a constant interval of time of your choosing
|
||||
* between those emissions. The first emission is not sent immediately, but
|
||||
* only after the first period has passed. By default, this operator uses the
|
||||
* `async` {@link SchedulerLike} to provide a notion of time, but you may pass any
|
||||
* {@link SchedulerLike} to it.
|
||||
*
|
||||
* ## Example
|
||||
* Emits ascending numbers, one every second (1000ms) up to the number 3
|
||||
* ```ts
|
||||
* import { interval } from 'rxjs';
|
||||
* import { take } from 'rxjs/operators';
|
||||
*
|
||||
* const numbers = interval(1000);
|
||||
*
|
||||
* const takeFourNumbers = numbers.pipe(take(4));
|
||||
*
|
||||
* takeFourNumbers.subscribe(x => console.log('Next: ', x));
|
||||
*
|
||||
* // Logs:
|
||||
* // Next: 0
|
||||
* // Next: 1
|
||||
* // Next: 2
|
||||
* // Next: 3
|
||||
* ```
|
||||
*
|
||||
* @see {@link timer}
|
||||
* @see {@link delay}
|
||||
*
|
||||
* @param {number} [period=0] The interval size in milliseconds (by default)
|
||||
* or the time unit determined by the scheduler's clock.
|
||||
* @param {SchedulerLike} [scheduler=async] The {@link SchedulerLike} to use for scheduling
|
||||
* the emission of values, and providing a notion of "time".
|
||||
* @return {Observable} An Observable that emits a sequential number each time
|
||||
* interval.
|
||||
* @static true
|
||||
* @name interval
|
||||
* @owner Observable
|
||||
*/
|
||||
export declare function interval(period?: number, scheduler?: SchedulerLike): Observable<number>;
|
||||
@@ -0,0 +1,38 @@
|
||||
// Types that are compatible with all supported TypeScript versions.
|
||||
// It's shared between all TypeScript version-specific definitions.
|
||||
|
||||
// Basic
|
||||
export * from './source/basic';
|
||||
|
||||
// Utilities
|
||||
export {Except} from './source/except';
|
||||
export {Mutable} from './source/mutable';
|
||||
export {Merge} from './source/merge';
|
||||
export {MergeExclusive} from './source/merge-exclusive';
|
||||
export {RequireAtLeastOne} from './source/require-at-least-one';
|
||||
export {RequireExactlyOne} from './source/require-exactly-one';
|
||||
export {PartialDeep} from './source/partial-deep';
|
||||
export {ReadonlyDeep} from './source/readonly-deep';
|
||||
export {LiteralUnion} from './source/literal-union';
|
||||
export {Promisable} from './source/promisable';
|
||||
export {Opaque} from './source/opaque';
|
||||
export {SetOptional} from './source/set-optional';
|
||||
export {SetRequired} from './source/set-required';
|
||||
export {ValueOf} from './source/value-of';
|
||||
export {PromiseValue} from './source/promise-value';
|
||||
export {AsyncReturnType} from './source/async-return-type';
|
||||
export {ConditionalExcept} from './source/conditional-except';
|
||||
export {ConditionalKeys} from './source/conditional-keys';
|
||||
export {ConditionalPick} from './source/conditional-pick';
|
||||
export {UnionToIntersection} from './source/union-to-intersection';
|
||||
export {Stringified} from './source/stringified';
|
||||
export {FixedLengthArray} from './source/fixed-length-array';
|
||||
export {IterableElement} from './source/iterable-element';
|
||||
export {Entry} from './source/entry';
|
||||
export {Entries} from './source/entries';
|
||||
export {SetReturnType} from './source/set-return-type';
|
||||
export {Asyncify} from './source/asyncify';
|
||||
|
||||
// Miscellaneous
|
||||
export {PackageJson} from './source/package-json';
|
||||
export {TsConfigJson} from './source/tsconfig-json';
|
||||
@@ -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/observable/concat"));
|
||||
//# sourceMappingURL=concat.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SubscribeOnObservable.js","sources":["../src/observable/SubscribeOnObservable.ts"],"names":[],"mappings":";;;;;AAAA,kEAA6D"}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
||||
export function sample(notifier) {
|
||||
return (source) => source.lift(new SampleOperator(notifier));
|
||||
}
|
||||
class SampleOperator {
|
||||
constructor(notifier) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
call(subscriber, source) {
|
||||
const sampleSubscriber = new SampleSubscriber(subscriber);
|
||||
const subscription = source.subscribe(sampleSubscriber);
|
||||
subscription.add(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
class SampleSubscriber extends SimpleOuterSubscriber {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.hasValue = false;
|
||||
}
|
||||
_next(value) {
|
||||
this.value = value;
|
||||
this.hasValue = true;
|
||||
}
|
||||
notifyNext() {
|
||||
this.emitValue();
|
||||
}
|
||||
notifyComplete() {
|
||||
this.emitValue();
|
||||
}
|
||||
emitValue() {
|
||||
if (this.hasValue) {
|
||||
this.hasValue = false;
|
||||
this.destination.next(this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=sample.js.map
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { Subscription } from '../Subscription';
|
||||
export function pairs(obj, scheduler) {
|
||||
if (!scheduler) {
|
||||
return new Observable(subscriber => {
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length && !subscriber.closed; i++) {
|
||||
const key = keys[i];
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
subscriber.next([key, obj[key]]);
|
||||
}
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
else {
|
||||
return new Observable(subscriber => {
|
||||
const keys = Object.keys(obj);
|
||||
const subscription = new Subscription();
|
||||
subscription.add(scheduler.schedule(dispatch, 0, { keys, index: 0, subscriber, subscription, obj }));
|
||||
return subscription;
|
||||
});
|
||||
}
|
||||
}
|
||||
export function dispatch(state) {
|
||||
const { keys, index, subscriber, subscription, obj } = state;
|
||||
if (!subscriber.closed) {
|
||||
if (index < keys.length) {
|
||||
const key = keys[index];
|
||||
subscriber.next([key, obj[key]]);
|
||||
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
||||
}
|
||||
else {
|
||||
subscriber.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=pairs.js.map
|
||||
@@ -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/symbol/iterator"));
|
||||
//# sourceMappingURL=iterator.js.map
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function hostReportError(err) {
|
||||
setTimeout(function () { throw err; }, 0);
|
||||
}
|
||||
exports.hostReportError = hostReportError;
|
||||
//# sourceMappingURL=hostReportError.js.map
|
||||
@@ -0,0 +1,19 @@
|
||||
let flexSpec = require('./flex-spec')
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class FlexWrap extends Declaration {
|
||||
/**
|
||||
* Don't add prefix for 2009 spec
|
||||
*/
|
||||
set (decl, prefix) {
|
||||
let spec = flexSpec(prefix)[0]
|
||||
if (spec !== 2009) {
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
FlexWrap.names = ['flex-wrap']
|
||||
|
||||
module.exports = FlexWrap
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "fflate",
|
||||
"version": "0.3.11",
|
||||
"description": "High performance (de)compression in an 8kB package",
|
||||
"main": "./lib/index.js",
|
||||
"module": "./esm/index.mjs",
|
||||
"types": "./lib/index.d.ts",
|
||||
"unpkg": "./umd/index.js",
|
||||
"jsdelivr": "./umd/index.js",
|
||||
"browser": {
|
||||
"./lib/node-worker.js": "./lib/worker.js",
|
||||
"./esm/index.mjs": "./esm/browser.js"
|
||||
},
|
||||
"targets": {
|
||||
"main": false,
|
||||
"module": false,
|
||||
"browser": false,
|
||||
"types": false
|
||||
},
|
||||
"sideEffects": false,
|
||||
"repository": "https://github.com/101arrowz/fflate",
|
||||
"author": "Arjun Barrett",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"gzip",
|
||||
"gunzip",
|
||||
"deflate",
|
||||
"inflate",
|
||||
"compression",
|
||||
"decompression",
|
||||
"zlib",
|
||||
"pako",
|
||||
"jszip",
|
||||
"browser",
|
||||
"node.js",
|
||||
"tiny",
|
||||
"zip",
|
||||
"unzip",
|
||||
"non-blocking"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "yarn build:lib && yarn build:docs && yarn build:rewrite && yarn build:demo",
|
||||
"script": "node -r ts-node/register scripts/$SC.ts",
|
||||
"build:lib": "tsc && tsc --project tsconfig.esm.json && yarn build:umd",
|
||||
"build:umd": "SC=buildUMD yarn script",
|
||||
"build:rewrite": "SC=rewriteBuilds yarn script",
|
||||
"build:demo": "tsc --project tsconfig.demo.json && parcel build demo/index.html --public-url \"./\" && SC=cpGHPages yarn script",
|
||||
"build:docs": "typedoc --mode library --plugin typedoc-plugin-markdown --hideProjectName --hideBreadcrumbs --readme none --disableSources --excludePrivate --excludeProtected --out docs/ src/index.ts",
|
||||
"test": "TS_NODE_PROJECT=test/tsconfig.json uvu -b -r ts-node/register test",
|
||||
"prepack": "yarn build && yarn test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.11.2",
|
||||
"@types/pako": "*",
|
||||
"@types/react": "^16.9.55",
|
||||
"@types/react-dom": "^16.9.9",
|
||||
"jszip": "^3.5.0",
|
||||
"pako": "*",
|
||||
"parcel": "^2.0.0-nightly.440",
|
||||
"parcel-config-precache-manifest": "^0.0.3",
|
||||
"preact": "^10.5.5",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"rmwc": "^6.1.4",
|
||||
"simple-git": "^2.22.0",
|
||||
"terser": "^5.3.8",
|
||||
"tiny-inflate": "*",
|
||||
"ts-node": "^9.0.0",
|
||||
"typedoc": "^0.17.0-3",
|
||||
"typedoc-plugin-markdown": "^3.0.2",
|
||||
"typescript": "^4.0.2",
|
||||
"uvu": "^0.3.3",
|
||||
"uzip": "*"
|
||||
},
|
||||
"alias": {
|
||||
"react": "preact/compat",
|
||||
"react-dom": "preact/compat",
|
||||
"react-dom/test-utils": "preact/test-utils"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { Operator } from '../Operator';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { Observable } from '../Observable';
|
||||
import { OperatorFunction } from '../types';
|
||||
|
||||
/**
|
||||
* Emits false if the input observable emits any values, or emits true if the
|
||||
* input observable completes without emitting any values.
|
||||
*
|
||||
* <span class="informal">Tells whether any values are emitted by an observable</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `isEmpty` transforms an Observable that emits values into an Observable that
|
||||
* emits a single boolean value representing whether or not any values were
|
||||
* emitted by the source Observable. As soon as the source Observable emits a
|
||||
* value, `isEmpty` will emit a `false` and complete. If the source Observable
|
||||
* completes having not emitted anything, `isEmpty` will emit a `true` and
|
||||
* complete.
|
||||
*
|
||||
* A similar effect could be achieved with {@link count}, but `isEmpty` can emit
|
||||
* a `false` value sooner.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Emit `false` for a non-empty Observable
|
||||
* ```javascript
|
||||
* import { Subject } from 'rxjs';
|
||||
* import { isEmpty } from 'rxjs/operators';
|
||||
*
|
||||
* const source = new Subject<string>();
|
||||
* const result = source.pipe(isEmpty());
|
||||
* source.subscribe(x => console.log(x));
|
||||
* result.subscribe(x => console.log(x));
|
||||
* source.next('a');
|
||||
* source.next('b');
|
||||
* source.next('c');
|
||||
* source.complete();
|
||||
*
|
||||
* // Results in:
|
||||
* // a
|
||||
* // false
|
||||
* // b
|
||||
* // c
|
||||
* ```
|
||||
*
|
||||
* Emit `true` for an empty Observable
|
||||
* ```javascript
|
||||
* import { EMPTY } from 'rxjs';
|
||||
* import { isEmpty } from 'rxjs/operators';
|
||||
*
|
||||
* const result = EMPTY.pipe(isEmpty());
|
||||
* result.subscribe(x => console.log(x));
|
||||
* // Results in:
|
||||
* // true
|
||||
* ```
|
||||
*
|
||||
* @see {@link count}
|
||||
* @see {@link EMPTY}
|
||||
*
|
||||
* @return {OperatorFunction<T, boolean>} An Observable of a boolean value indicating whether observable was empty or not
|
||||
* @method isEmpty
|
||||
* @owner Observable
|
||||
*/
|
||||
|
||||
export function isEmpty<T>(): OperatorFunction<T, boolean> {
|
||||
return (source: Observable<T>) => source.lift(new IsEmptyOperator());
|
||||
}
|
||||
|
||||
class IsEmptyOperator implements Operator<any, boolean> {
|
||||
call (observer: Subscriber<boolean>, source: any): any {
|
||||
return source.subscribe(new IsEmptySubscriber(observer));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
class IsEmptySubscriber extends Subscriber<any> {
|
||||
constructor(destination: Subscriber<boolean>) {
|
||||
super(destination);
|
||||
}
|
||||
|
||||
private notifyComplete(isEmpty: boolean): void {
|
||||
const destination = this.destination;
|
||||
|
||||
destination.next(isEmpty);
|
||||
destination.complete();
|
||||
}
|
||||
|
||||
protected _next(value: boolean) {
|
||||
this.notifyComplete(false);
|
||||
}
|
||||
|
||||
protected _complete() {
|
||||
this.notifyComplete(true);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function not(pred, thisArg) {
|
||||
function notPred() {
|
||||
return !(notPred.pred.apply(notPred.thisArg, arguments));
|
||||
}
|
||||
notPred.pred = pred;
|
||||
notPred.thisArg = thisArg;
|
||||
return notPred;
|
||||
}
|
||||
exports.not = not;
|
||||
//# sourceMappingURL=not.js.map
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/util/pipe';
|
||||
@@ -0,0 +1,34 @@
|
||||
<script>
|
||||
import {createRouteObject} from './../dist/tinro_lib';
|
||||
|
||||
export let path = '/*';
|
||||
export let fallback = false;
|
||||
export let redirect = false;
|
||||
export let firstmatch = false;
|
||||
export let breadcrumb = null;
|
||||
|
||||
let showContent = false;
|
||||
let params = {}; /* DEPRECATED */
|
||||
let meta = {};
|
||||
|
||||
const route = createRouteObject({
|
||||
fallback,
|
||||
onShow(){showContent=true},
|
||||
onHide(){showContent=false},
|
||||
onMeta(newmeta){
|
||||
meta=newmeta;
|
||||
params = meta.params /* DEPRECATED */
|
||||
}
|
||||
});
|
||||
|
||||
$: route.update({
|
||||
path,
|
||||
redirect,
|
||||
firstmatch,
|
||||
breadcrumb,
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if showContent}
|
||||
<slot {params} {meta}></slot>
|
||||
{/if}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeScan.js","sources":["../src/operator/mergeScan.ts"],"names":[],"mappings":";;;;;AAAA,oDAA+C"}
|
||||
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* This file and its definitions are needed just so that ESDoc sees these
|
||||
* JSDoc documentation comments. Originally they were meant for some TypeScript
|
||||
* interfaces, but TypeScript strips away JSDoc comments near interfaces. Hence,
|
||||
* we need these bogus classes, which are not stripped away. This file on the
|
||||
* other hand, is not included in the release bundle.
|
||||
*/
|
||||
import { Observer, TeardownLogic } from './internal/types';
|
||||
import { Observable } from './internal/Observable';
|
||||
import './internal/observable/dom/MiscJSDoc';
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @extends {Ignored}
|
||||
* @hide true
|
||||
*/
|
||||
export class ObservableDoc {
|
||||
/**
|
||||
* Creates a new Observable, that will execute the specified function when an
|
||||
* {@link Observer} subscribes to it.
|
||||
*
|
||||
* <span class="informal">Create custom Observable, that does whatever you like.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `create` converts an `onSubscription` function to an actual Observable.
|
||||
* Whenever someone subscribes to that Observable, the function will be called
|
||||
* with an {@link Observer} instance as a first and only parameter. `onSubscription` should
|
||||
* then invoke the Observers `next`, `error` and `complete` methods.
|
||||
*
|
||||
* Calling `next` with a value will emit that value to the observer. Calling `complete`
|
||||
* means that Observable finished emitting and will not do anything else.
|
||||
* Calling `error` means that something went wrong - value passed to `error` method should
|
||||
* provide details on what exactly happened.
|
||||
*
|
||||
* A well-formed Observable can emit as many values as it needs via `next` method,
|
||||
* but `complete` and `error` methods can be called only once and nothing else can be called
|
||||
* thereafter. If you try to invoke `next`, `complete` or `error` methods after created
|
||||
* Observable already completed or ended with an error, these calls will be ignored to
|
||||
* preserve so called *Observable Contract*. Note that you are not required to call
|
||||
* `complete` at any point - it is perfectly fine to create an Observable that never ends,
|
||||
* depending on your needs.
|
||||
*
|
||||
* `onSubscription` can optionally return either a function or an object with
|
||||
* `unsubscribe` method. In both cases function or method will be called when
|
||||
* subscription to Observable is being cancelled and should be used to clean up all
|
||||
* resources. So, for example, if you are using `setTimeout` in your custom
|
||||
* Observable, when someone unsubscribes, you can clear planned timeout, so that
|
||||
* it does not fire needlessly and browser (or other environment) does not waste
|
||||
* computing power on timing event that no one will listen to anyways.
|
||||
*
|
||||
* Most of the times you should not need to use `create`, because existing
|
||||
* operators allow you to create an Observable for most of the use cases.
|
||||
* That being said, `create` is low-level mechanism allowing you to create
|
||||
* any Observable, if you have very specific needs.
|
||||
*
|
||||
* **TypeScript signature issue**
|
||||
*
|
||||
* Because Observable extends class which already has defined static `create` function,
|
||||
* but with different type signature, it was impossible to assign proper signature to
|
||||
* `Observable.create`. Because of that, it has very general type `Function` and thus
|
||||
* function passed to `create` will not be type checked, unless you explicitly state
|
||||
* what signature it should have.
|
||||
*
|
||||
* When using TypeScript we recommend to declare type signature of function passed to
|
||||
* `create` as `(observer: Observer) => TeardownLogic`, where {@link Observer}
|
||||
* and {@link TeardownLogic} are interfaces provided by the library.
|
||||
*
|
||||
* @example <caption>Emit three numbers, then complete.</caption>
|
||||
* var observable = Rx.Observable.create(function (observer) {
|
||||
* observer.next(1);
|
||||
* observer.next(2);
|
||||
* observer.next(3);
|
||||
* observer.complete();
|
||||
* });
|
||||
* observable.subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('this is the end')
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // "this is the end"
|
||||
*
|
||||
*
|
||||
* @example <caption>Emit an error</caption>
|
||||
* const observable = Rx.Observable.create((observer) => {
|
||||
* observer.error('something went really wrong...');
|
||||
* });
|
||||
*
|
||||
* observable.subscribe(
|
||||
* value => console.log(value), // will never be called
|
||||
* err => console.log(err),
|
||||
* () => console.log('complete') // will never be called
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // "something went really wrong..."
|
||||
*
|
||||
*
|
||||
* @example <caption>Return unsubscribe function</caption>
|
||||
*
|
||||
* const observable = Rx.Observable.create(observer => {
|
||||
* const id = setTimeout(() => observer.next('...'), 5000); // emit value after 5s
|
||||
*
|
||||
* return () => { clearTimeout(id); console.log('cleared!'); };
|
||||
* });
|
||||
*
|
||||
* const subscription = observable.subscribe(value => console.log(value));
|
||||
*
|
||||
* setTimeout(() => subscription.unsubscribe(), 3000); // cancel subscription after 3s
|
||||
*
|
||||
* // Logs:
|
||||
* // "cleared!" after 3s
|
||||
*
|
||||
* // Never logs "..."
|
||||
*
|
||||
*
|
||||
* @see {@link empty}
|
||||
* @see {@link never}
|
||||
* @see {@link of}
|
||||
* @see {@link throw}
|
||||
*
|
||||
* @param {function(observer: Observer): TeardownLogic} onSubscription A
|
||||
* function that accepts an Observer, and invokes its `next`,
|
||||
* `error`, and `complete` methods as appropriate, and optionally returns some
|
||||
* logic for cleaning up resources.
|
||||
* @return {Observable} An Observable that, whenever subscribed, will execute the
|
||||
* specified function.
|
||||
* @static true
|
||||
* @name create
|
||||
* @owner Observable
|
||||
* @nocollapse
|
||||
*/
|
||||
static create<T>(onSubscription: <R>(observer: Observer<R>) => TeardownLogic): Observable<T> {
|
||||
return new Observable<T>(onSubscription);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface for a consumer of push-based notifications delivered by an
|
||||
* {@link Observable}.
|
||||
*
|
||||
* ```ts
|
||||
* interface Observer<T> {
|
||||
* closed?: boolean;
|
||||
* next: (value: T) => void;
|
||||
* error: (err: any) => void;
|
||||
* complete: () => void;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* An object conforming to the Observer interface is usually
|
||||
* given to the `observable.subscribe(observer)` method, and the Observable will
|
||||
* call the Observer's `next(value)` method to provide notifications. A
|
||||
* well-behaved Observable will call an Observer's `complete()` method exactly
|
||||
* once or the Observer's `error(err)` method exactly once, as the last
|
||||
* notification delivered.
|
||||
*
|
||||
* @interface
|
||||
* @name Observer
|
||||
* @noimport true
|
||||
*/
|
||||
export class ObserverDoc<T> {
|
||||
/**
|
||||
* An optional flag to indicate whether this Observer, when used as a
|
||||
* subscriber, has already been unsubscribed from its Observable.
|
||||
* @type {boolean}
|
||||
*/
|
||||
closed: boolean = false;
|
||||
/**
|
||||
* The callback to receive notifications of type `next` from the Observable,
|
||||
* with a value. The Observable may call this method 0 or more times.
|
||||
* @param {T} value The `next` value.
|
||||
* @return {void}
|
||||
*/
|
||||
next(value: T): void {
|
||||
return void 0;
|
||||
}
|
||||
/**
|
||||
* The callback to receive notifications of type `error` from the Observable,
|
||||
* with an attached {@link Error}. Notifies the Observer that the Observable
|
||||
* has experienced an error condition.
|
||||
* @param {any} err The `error` exception.
|
||||
* @return {void}
|
||||
*/
|
||||
error(err: any): void {
|
||||
return void 0;
|
||||
}
|
||||
/**
|
||||
* The callback to receive a valueless notification of type `complete` from
|
||||
* the Observable. Notifies the Observer that the Observable has finished
|
||||
* sending push-based notifications.
|
||||
* @return {void}
|
||||
*/
|
||||
complete(): void {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `SubscribableOrPromise` interface describes values that behave like either
|
||||
* Observables or Promises. Every operator that accepts arguments annotated
|
||||
* with this interface, can be also used with parameters that are not necessarily
|
||||
* RxJS Observables.
|
||||
*
|
||||
* Following types of values might be passed to operators expecting this interface:
|
||||
*
|
||||
* ## Observable
|
||||
*
|
||||
* RxJS {@link Observable} instance.
|
||||
*
|
||||
* ## Observable-like (Subscribable)
|
||||
*
|
||||
* This might be any object that has `Symbol.observable` method. This method,
|
||||
* when called, should return object with `subscribe` method on it, which should
|
||||
* behave the same as RxJS `Observable.subscribe`.
|
||||
*
|
||||
* `Symbol.observable` is part of https://github.com/tc39/proposal-observable proposal.
|
||||
* Since currently it is not supported natively, and every symbol is equal only to itself,
|
||||
* you should use https://github.com/blesh/symbol-observable polyfill, when implementing
|
||||
* custom Observable-likes.
|
||||
*
|
||||
* **TypeScript Subscribable interface issue**
|
||||
*
|
||||
* Although TypeScript interface claims that Subscribable is an object that has `subscribe`
|
||||
* method declared directly on it, passing custom objects that have `subscribe`
|
||||
* method but not `Symbol.observable` method will fail at runtime. Conversely, passing
|
||||
* objects with `Symbol.observable` but without `subscribe` will fail at compile time
|
||||
* (if you use TypeScript).
|
||||
*
|
||||
* TypeScript has problem supporting interfaces with methods defined as symbol
|
||||
* properties. To get around that, you should implement `subscribe` directly on
|
||||
* passed object, and make `Symbol.observable` method simply return `this`. That way
|
||||
* everything will work as expected, and compiler will not complain. If you really
|
||||
* do not want to put `subscribe` directly on your object, you will have to type cast
|
||||
* it to `any`, before passing it to an operator.
|
||||
*
|
||||
* When this issue is resolved, Subscribable interface will only permit Observable-like
|
||||
* objects with `Symbol.observable` defined, no matter if they themselves implement
|
||||
* `subscribe` method or not.
|
||||
*
|
||||
* ## ES6 Promise
|
||||
*
|
||||
* Promise can be interpreted as Observable that emits value and completes
|
||||
* when it is resolved or errors when it is rejected.
|
||||
*
|
||||
* ## Promise-like (Thenable)
|
||||
*
|
||||
* Promises passed to operators do not have to be native ES6 Promises.
|
||||
* They can be implementations from popular Promise libraries, polyfills
|
||||
* or even custom ones. They just need to have `then` method that works
|
||||
* as the same as ES6 Promise `then`.
|
||||
*
|
||||
* @example <caption>Use merge and then map with non-RxJS observable</caption>
|
||||
* const nonRxJSObservable = {
|
||||
* subscribe(observer) {
|
||||
* observer.next(1000);
|
||||
* observer.complete();
|
||||
* },
|
||||
* [Symbol.observable]() {
|
||||
* return this;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* Rx.Observable.merge(nonRxJSObservable)
|
||||
* .map(value => "This value is " + value)
|
||||
* .subscribe(result => console.log(result)); // Logs "This value is 1000"
|
||||
*
|
||||
*
|
||||
* @example <caption>Use combineLatest with ES6 Promise</caption>
|
||||
* Rx.Observable.combineLatest(Promise.resolve(5), Promise.resolve(10), Promise.resolve(15))
|
||||
* .subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('the end!')
|
||||
* );
|
||||
* // Logs
|
||||
* // [5, 10, 15]
|
||||
* // "the end!"
|
||||
*
|
||||
*
|
||||
* @interface
|
||||
* @name SubscribableOrPromise
|
||||
* @noimport true
|
||||
*/
|
||||
export class SubscribableOrPromiseDoc<T> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* `ObservableInput` interface describes all values that are either an
|
||||
* {@link SubscribableOrPromise} or some kind of collection of values that
|
||||
* can be transformed to Observable emitting that values. Every operator that
|
||||
* accepts arguments annotated with this interface, can be also used with
|
||||
* parameters that are not necessarily RxJS Observables.
|
||||
*
|
||||
* `ObservableInput` extends {@link SubscribableOrPromise} with following types:
|
||||
*
|
||||
* ## Array
|
||||
*
|
||||
* Arrays can be interpreted as observables that emit all values in array one by one,
|
||||
* from left to right, and then complete immediately.
|
||||
*
|
||||
* ## Array-like
|
||||
*
|
||||
* Arrays passed to operators do not have to be built-in JavaScript Arrays. They
|
||||
* can be also, for example, `arguments` property available inside every function,
|
||||
* [DOM NodeList](https://developer.mozilla.org/pl/docs/Web/API/NodeList),
|
||||
* or, actually, any object that has `length` property (which is a number)
|
||||
* and stores values under non-negative (zero and up) integers.
|
||||
*
|
||||
* ## ES6 Iterable
|
||||
*
|
||||
* Operators will accept both built-in and custom ES6 Iterables, by treating them as
|
||||
* observables that emit all its values in order of iteration and then complete
|
||||
* when iteration ends. Note that contrary to arrays, Iterables do not have to
|
||||
* necessarily be finite, so creating Observables that never complete is possible as well.
|
||||
*
|
||||
* Note that you can make iterator an instance of Iterable by having it return itself
|
||||
* in `Symbol.iterator` method. It means that every operator accepting Iterables accepts,
|
||||
* though indirectly, iterators themselves as well. All native ES6 iterators are instances
|
||||
* of Iterable by default, so you do not have to implement their `Symbol.iterator` method
|
||||
* yourself.
|
||||
*
|
||||
* **TypeScript Iterable interface issue**
|
||||
*
|
||||
* TypeScript `ObservableInput` interface actually lacks type signature for Iterables,
|
||||
* because of issues it caused in some projects (see [this issue](https://github.com/ReactiveX/rxjs/issues/2306)).
|
||||
* If you want to use Iterable as argument for operator, cast it to `any` first.
|
||||
* Remember of course that, because of casting, you have to yourself ensure that passed
|
||||
* argument really implements said interface.
|
||||
*
|
||||
*
|
||||
* @example <caption>Use merge with arrays</caption>
|
||||
* Rx.Observable.merge([1, 2], [4], [5, 6])
|
||||
* .subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('ta dam!')
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // 4
|
||||
* // 5
|
||||
* // 6
|
||||
* // "ta dam!"
|
||||
*
|
||||
*
|
||||
* @example <caption>Use merge with array-like</caption>
|
||||
* Rx.Observable.merge({0: 1, 1: 2, length: 2}, {0: 3, length: 1})
|
||||
* .subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('nice, huh?')
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // "nice, huh?"
|
||||
*
|
||||
* @example <caption>Use merge with an Iterable (Map)</caption>
|
||||
* const firstMap = new Map([[1, 'a'], [2, 'b']]);
|
||||
* const secondMap = new Map([[3, 'c'], [4, 'd']]);
|
||||
*
|
||||
* Rx.Observable.merge(
|
||||
* firstMap, // pass Iterable
|
||||
* secondMap.values() // pass iterator, which is itself an Iterable
|
||||
* ).subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('yup!')
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // [1, "a"]
|
||||
* // [2, "b"]
|
||||
* // "c"
|
||||
* // "d"
|
||||
* // "yup!"
|
||||
*
|
||||
* @example <caption>Use from with generator (returning infinite iterator)</caption>
|
||||
* // infinite stream of incrementing numbers
|
||||
* const infinite = function* () {
|
||||
* let i = 0;
|
||||
*
|
||||
* while (true) {
|
||||
* yield i++;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* Rx.Observable.from(infinite())
|
||||
* .take(3) // only take 3, cause this is infinite
|
||||
* .subscribe(
|
||||
* value => console.log(value),
|
||||
* err => {},
|
||||
* () => console.log('ta dam!')
|
||||
* );
|
||||
*
|
||||
* // Logs
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* // "ta dam!"
|
||||
*
|
||||
* @interface
|
||||
* @name ObservableInput
|
||||
* @noimport true
|
||||
*/
|
||||
export class ObservableInputDoc<T> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This interface describes what should be returned by function passed to Observable
|
||||
* constructor or static {@link create} function. Value of that interface will be used
|
||||
* to cancel subscription for given Observable.
|
||||
*
|
||||
* `TeardownLogic` can be:
|
||||
*
|
||||
* ## Function
|
||||
*
|
||||
* Function that takes no parameters. When consumer of created Observable calls `unsubscribe`,
|
||||
* that function will be called
|
||||
*
|
||||
* ## AnonymousSubscription
|
||||
*
|
||||
* `AnonymousSubscription` is simply an object with `unsubscribe` method on it. That method
|
||||
* will work the same as function
|
||||
*
|
||||
* ## void
|
||||
*
|
||||
* If created Observable does not have any resources to clean up, function does not have to
|
||||
* return anything.
|
||||
*
|
||||
* @interface
|
||||
* @name TeardownLogic
|
||||
* @noimport true
|
||||
*/
|
||||
export class TeardownLogicDoc {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J E F G A BC"},B:{"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 p q r s D t"},C:{"1":"0 1 2 3 4 5 6 7 8 9 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","2":"CC tB I u J E F G A B C 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 t xB yB DC EC"},D:{"1":"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","2":"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 b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"F G A B C KC 0B qB","2":"I u J E GC zB HC IC JC","129":"K L H rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 H M N O v w x y z AB BB CB DB EB FB IB KB rB","2":"G B C GB HB JB 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 P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC"},G:{"1":"F XC YC ZC aC bC cC dC eC","2":"zB TC AC UC VC WC","257":"fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"2":"nC"},I:{"1":"tB I rC AC sC tC","2":"D oC pC qC"},J:{"2":"E A"},K:{"1":"rB","2":"A B C e qB 9B"},L:{"2":"D"},M:{"2":"D"},N:{"1":"B","2":"A"},O:{"2":"uC"},P:{"1":"I","2":"vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"1":"9C"}},B:7,C:"SPDY protocol"};
|
||||
@@ -0,0 +1,60 @@
|
||||
# xdg-basedir [](https://travis-ci.org/sindresorhus/xdg-basedir)
|
||||
|
||||
> Get [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) paths
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install xdg-basedir
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const xdgBasedir = require('xdg-basedir');
|
||||
|
||||
xdgBasedir.data;
|
||||
//=> '/home/sindresorhus/.local/share'
|
||||
|
||||
xdgBasedir.config;
|
||||
//=> '/home/sindresorhus/.config'
|
||||
|
||||
xdgBasedir.dataDirs
|
||||
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
The properties `.data`, `.config`, `.cache`, `.runtime` will return `null` in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to [fall back to a temp directory](https://github.com/yeoman/configstore/blob/b82690fc401318ad18dcd7d151a0003a4898a314/index.js#L15).
|
||||
|
||||
### .data
|
||||
|
||||
Directory for user-specific data files.
|
||||
|
||||
### .config
|
||||
|
||||
Directory for user-specific configuration files.
|
||||
|
||||
### .cache
|
||||
|
||||
Directory for user-specific non-essential data files.
|
||||
|
||||
### .runtime
|
||||
|
||||
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
|
||||
|
||||
### .dataDirs
|
||||
|
||||
Preference-ordered array of base directories to search for data files in addition to `.data`.
|
||||
|
||||
### .configDirs
|
||||
|
||||
Preference-ordered array of base directories to search for configuration files in addition to `.config`.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
@@ -0,0 +1,46 @@
|
||||
/** PURE_IMPORTS_START _Observable,_Subscription,_symbol_iterator PURE_IMPORTS_END */
|
||||
import { Observable } from '../Observable';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { iterator as Symbol_iterator } from '../symbol/iterator';
|
||||
export function scheduleIterable(input, scheduler) {
|
||||
if (!input) {
|
||||
throw new Error('Iterable cannot be null');
|
||||
}
|
||||
return new Observable(function (subscriber) {
|
||||
var sub = new Subscription();
|
||||
var iterator;
|
||||
sub.add(function () {
|
||||
if (iterator && typeof iterator.return === 'function') {
|
||||
iterator.return();
|
||||
}
|
||||
});
|
||||
sub.add(scheduler.schedule(function () {
|
||||
iterator = input[Symbol_iterator]();
|
||||
sub.add(scheduler.schedule(function () {
|
||||
if (subscriber.closed) {
|
||||
return;
|
||||
}
|
||||
var value;
|
||||
var done;
|
||||
try {
|
||||
var result = iterator.next();
|
||||
value = result.value;
|
||||
done = result.done;
|
||||
}
|
||||
catch (err) {
|
||||
subscriber.error(err);
|
||||
return;
|
||||
}
|
||||
if (done) {
|
||||
subscriber.complete();
|
||||
}
|
||||
else {
|
||||
subscriber.next(value);
|
||||
this.schedule();
|
||||
}
|
||||
}));
|
||||
}));
|
||||
return sub;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=scheduleIterable.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"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 t","2":"C K L H M N O","66":"P Q R"},C:{"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 t xB yB DC EC"},D:{"1":"R 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 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","66":"lB mB nB oB pB P Q"},E:{"1":"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 sB"},F:{"1":"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","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 OC PC QC RC qB 9B SC rB","66":"eB fB"},G:{"1":"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 sB"},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:{"1":"2C 3C 4C sB 5C 6C 7C","2":"I vC wC xC yC zC 0B 0C 1C"},Q:{"2":"1B"},R:{"1":"8C"},S:{"2":"9C"}},B:7,C:"URL Scroll-To-Text Fragment"};
|
||||
@@ -0,0 +1,264 @@
|
||||
# ora
|
||||
|
||||
> Elegant terminal spinner
|
||||
|
||||
<p align="center">
|
||||
<br>
|
||||
<img src="screenshot.svg" width="500">
|
||||
<br>
|
||||
</p>
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ora
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const ora = require('ora');
|
||||
|
||||
const spinner = ora('Loading unicorns').start();
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.color = 'yellow';
|
||||
spinner.text = 'Loading rainbows';
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### ora(text)
|
||||
### ora(options)
|
||||
|
||||
If a string is provided, it is treated as a shortcut for [`options.text`](#text).
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
Text to display after the spinner.
|
||||
|
||||
##### prefixText
|
||||
|
||||
Type: `string | () => string`
|
||||
|
||||
Text or a function that returns text to display before the spinner. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
##### spinner
|
||||
|
||||
Type: `string | object`\
|
||||
Default: `'dots'` <img src="screenshot-spinner.gif" width="14">
|
||||
|
||||
Name of one of the [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json). See `example.js` in this repo if you want to test out different spinners. On Windows, it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support.
|
||||
|
||||
Or an object like:
|
||||
|
||||
```js
|
||||
{
|
||||
interval: 80, // Optional
|
||||
frames: ['-', '+', '-']
|
||||
}
|
||||
```
|
||||
|
||||
##### color
|
||||
|
||||
Type: `string`\
|
||||
Default: `'cyan'`\
|
||||
Values: `'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'`
|
||||
|
||||
Color of the spinner.
|
||||
|
||||
##### hideCursor
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Set to `false` to stop Ora from hiding the cursor.
|
||||
|
||||
##### indent
|
||||
|
||||
Type: `number`\
|
||||
Default: `0`
|
||||
|
||||
Indent the spinner with the given number of spaces.
|
||||
|
||||
##### interval
|
||||
|
||||
Type: `number`\
|
||||
Default: Provided by the spinner or `100`
|
||||
|
||||
Interval between each frame.
|
||||
|
||||
Spinners provide their own recommended interval, so you don't really need to specify this.
|
||||
|
||||
##### stream
|
||||
|
||||
Type: `stream.Writable`\
|
||||
Default: `process.stderr`
|
||||
|
||||
Stream to write the output.
|
||||
|
||||
You could for example set this to `process.stdout` instead.
|
||||
|
||||
##### isEnabled
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Force enable/disable the spinner. If not specified, the spinner will be enabled if the `stream` is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.
|
||||
|
||||
Note that `{isEnabled: false}` doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.
|
||||
|
||||
##### isSilent
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Disable the spinner and all log text. All output is suppressed and `isEnabled` will be considered `false`.
|
||||
|
||||
##### discardStdin
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on <kbd>Enter</kbd> key presses, and prevents buffering of input while the spinner is running.
|
||||
|
||||
This has no effect on Windows as there's no good way to implement discarding stdin properly there.
|
||||
|
||||
### Instance
|
||||
|
||||
#### .start(text?)
|
||||
|
||||
Start the spinner. Returns the instance. Set the current text if `text` is provided.
|
||||
|
||||
#### .stop()
|
||||
|
||||
Stop and clear the spinner. Returns the instance.
|
||||
|
||||
#### .succeed(text?)
|
||||
|
||||
Stop the spinner, change it to a green `✔` and persist the current text, or `text` if provided. Returns the instance. See the GIF below.
|
||||
|
||||
#### .fail(text?)
|
||||
|
||||
Stop the spinner, change it to a red `✖` and persist the current text, or `text` if provided. Returns the instance. See the GIF below.
|
||||
|
||||
#### .warn(text?)
|
||||
|
||||
Stop the spinner, change it to a yellow `⚠` and persist the current text, or `text` if provided. Returns the instance.
|
||||
|
||||
#### .info(text?)
|
||||
|
||||
Stop the spinner, change it to a blue `ℹ` and persist the current text, or `text` if provided. Returns the instance.
|
||||
|
||||
#### .isSpinning
|
||||
|
||||
A boolean of whether the instance is currently spinning.
|
||||
|
||||
#### .stopAndPersist(options?)
|
||||
|
||||
Stop the spinner and change the symbol or text. Returns the instance. See the GIF below.
|
||||
|
||||
##### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
###### symbol
|
||||
|
||||
Type: `string`\
|
||||
Default: `' '`
|
||||
|
||||
Symbol to replace the spinner with.
|
||||
|
||||
###### text
|
||||
|
||||
Type: `string`\
|
||||
Default: Current `'text'`
|
||||
|
||||
Text to be persisted after the symbol
|
||||
|
||||
###### prefixText
|
||||
|
||||
Type: `string`\
|
||||
Default: Current `prefixText`
|
||||
|
||||
Text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
<img src="screenshot-2.gif" width="480">
|
||||
|
||||
#### .clear()
|
||||
|
||||
Clear the spinner. Returns the instance.
|
||||
|
||||
#### .render()
|
||||
|
||||
Manually render a new frame. Returns the instance.
|
||||
|
||||
#### .frame()
|
||||
|
||||
Get a new frame.
|
||||
|
||||
#### .text
|
||||
|
||||
Change the text after the spinner.
|
||||
|
||||
#### .prefixText
|
||||
|
||||
Change the text before the spinner. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
#### .color
|
||||
|
||||
Change the spinner color.
|
||||
|
||||
#### .spinner
|
||||
|
||||
Change the spinner.
|
||||
|
||||
#### .indent
|
||||
|
||||
Change the spinner indent.
|
||||
|
||||
### ora.promise(action, text)
|
||||
### ora.promise(action, options)
|
||||
|
||||
Starts a spinner for a promise. The spinner is stopped with `.succeed()` if the promise fulfills or with `.fail()` if it rejects. Returns the spinner instance.
|
||||
|
||||
#### action
|
||||
|
||||
Type: `Promise`
|
||||
|
||||
## FAQ
|
||||
|
||||
### How do I change the color of the text?
|
||||
|
||||
Use [Chalk](https://github.com/chalk/chalk):
|
||||
|
||||
```js
|
||||
const ora = require('ora');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const spinner = ora(`Loading ${chalk.red('unicorns')}`).start();
|
||||
```
|
||||
|
||||
### Why does the spinner freeze?
|
||||
|
||||
JavaScript is single-threaded, so synchronous operations blocks the thread, including the spinner animation. Prefer asynchronous operations whenever possible.
|
||||
|
||||
## Related
|
||||
|
||||
- [cli-spinners](https://github.com/sindresorhus/cli-spinners) - Spinners for use in the terminal
|
||||
- [listr](https://github.com/SamVerschueren/listr) - Terminal task list
|
||||
- [CLISpinner](https://github.com/kiliankoe/CLISpinner) - Terminal spinner library for Swift
|
||||
- [halo](https://github.com/ManrajGrover/halo) - Python port
|
||||
- [spinners](https://github.com/FGRibreau/spinners) - Terminal spinners for Rust
|
||||
- [marquee-ora](https://github.com/joeycozza/marquee-ora) - Scrolling marquee spinner for Ora
|
||||
- [briandowns/spinner](https://github.com/briandowns/spinner) - Terminal spinner/progress indicator for Go
|
||||
- [tj/go-spin](https://github.com/tj/go-spin) - Terminal spinner package for Go
|
||||
- [observablehq.com/@victordidenko/ora](https://observablehq.com/@victordidenko/ora) - Ora port to Observable notebooks
|
||||
- [spinnies](https://github.com/jcarpanelli/spinnies) - Terminal multi-spinner library for Node.js
|
||||
- [kia](https://github.com/HarryPeach/kia) - Simple terminal spinners for Deno 🦕
|
||||
@@ -0,0 +1,54 @@
|
||||
import Wrapper from './shared/Wrapper';
|
||||
import Renderer from '../Renderer';
|
||||
import Block from '../Block';
|
||||
import EachBlock from '../../nodes/EachBlock';
|
||||
import IfBlock from '../../nodes/IfBlock';
|
||||
import ElseBlock from '../../nodes/ElseBlock';
|
||||
import FragmentWrapper from './Fragment';
|
||||
import { Identifier, Node, UnaryExpression } from 'estree';
|
||||
declare class IfBlockBranch extends Wrapper {
|
||||
block: Block;
|
||||
fragment: FragmentWrapper;
|
||||
dependencies?: string[];
|
||||
condition?: any;
|
||||
snippet?: Node;
|
||||
is_dynamic: boolean;
|
||||
var: any;
|
||||
constructor(renderer: Renderer, block: Block, parent: IfBlockWrapper, node: IfBlock | ElseBlock, strip_whitespace: boolean, next_sibling: Wrapper);
|
||||
}
|
||||
export default class IfBlockWrapper extends Wrapper {
|
||||
node: IfBlock;
|
||||
branches: IfBlockBranch[];
|
||||
needs_update: boolean;
|
||||
var: Identifier;
|
||||
constructor(renderer: Renderer, block: Block, parent: Wrapper, node: EachBlock, strip_whitespace: boolean, next_sibling: Wrapper);
|
||||
render(block: Block, parent_node: Identifier, parent_nodes: Identifier): void;
|
||||
render_compound(block: Block, parent_node: Identifier, _parent_nodes: Identifier, dynamic: any, { name, anchor, has_else, if_exists_condition, has_transitions }: {
|
||||
name: any;
|
||||
anchor: any;
|
||||
has_else: any;
|
||||
if_exists_condition: any;
|
||||
has_transitions: any;
|
||||
}, detaching: any): void;
|
||||
render_compound_with_outros(block: Block, parent_node: Identifier, _parent_nodes: Identifier, dynamic: any, { name, anchor, has_else, has_transitions, if_exists_condition }: {
|
||||
name: any;
|
||||
anchor: any;
|
||||
has_else: any;
|
||||
has_transitions: any;
|
||||
if_exists_condition: any;
|
||||
}, detaching: any): void;
|
||||
render_simple(block: Block, parent_node: Identifier, _parent_nodes: Identifier, dynamic: any, { name, anchor, if_exists_condition, has_transitions }: {
|
||||
name: any;
|
||||
anchor: any;
|
||||
if_exists_condition: any;
|
||||
has_transitions: any;
|
||||
}, detaching: any): void;
|
||||
get_initial_dirty_bit(): {
|
||||
readonly type: "ArrayExpression" | "UnaryExpression";
|
||||
elements: UnaryExpression[];
|
||||
operator: import("estree").UnaryOperator;
|
||||
prefix: true;
|
||||
argument: import("estree").Expression;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
Reference in New Issue
Block a user