new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { executeSchedule } from '../util/executeSchedule';
|
||||
export function scheduleAsyncIterable(input, scheduler) {
|
||||
if (!input) {
|
||||
throw new Error('Iterable cannot be null');
|
||||
}
|
||||
return new Observable(function (subscriber) {
|
||||
executeSchedule(subscriber, scheduler, function () {
|
||||
var iterator = input[Symbol.asyncIterator]();
|
||||
executeSchedule(subscriber, scheduler, function () {
|
||||
iterator.next().then(function (result) {
|
||||
if (result.done) {
|
||||
subscriber.complete();
|
||||
}
|
||||
else {
|
||||
subscriber.next(result.value);
|
||||
}
|
||||
});
|
||||
}, 0, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=scheduleAsyncIterable.js.map
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow
|
||||
|
||||
module.exports = function DeletePropertyOrThrow(O, P) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
var success = delete O[P];
|
||||
if (!success) {
|
||||
throw new $TypeError('Attempt to delete property failed.');
|
||||
}
|
||||
return success;
|
||||
};
|
||||
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
@license
|
||||
Rollup.js v2.79.1
|
||||
Thu, 22 Sep 2022 04:55:29 GMT - commit 69ff4181e701a0fe0026d0ba147f31bc86beffa8
|
||||
|
||||
https://github.com/rollup/rollup
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
|
||||
const require$$0 = require('path');
|
||||
const process = require('process');
|
||||
const rollup = require('./rollup.js');
|
||||
const mergeOptions = require('./mergeOptions.js');
|
||||
const require$$2 = require('os');
|
||||
const index = require('./index.js');
|
||||
require('perf_hooks');
|
||||
require('crypto');
|
||||
require('fs');
|
||||
require('events');
|
||||
require('util');
|
||||
require('stream');
|
||||
|
||||
class FileWatcher {
|
||||
constructor(task, chokidarOptions) {
|
||||
this.transformWatchers = new Map();
|
||||
this.chokidarOptions = chokidarOptions;
|
||||
this.task = task;
|
||||
this.watcher = this.createWatcher(null);
|
||||
}
|
||||
close() {
|
||||
this.watcher.close();
|
||||
for (const watcher of this.transformWatchers.values()) {
|
||||
watcher.close();
|
||||
}
|
||||
}
|
||||
unwatch(id) {
|
||||
this.watcher.unwatch(id);
|
||||
const transformWatcher = this.transformWatchers.get(id);
|
||||
if (transformWatcher) {
|
||||
this.transformWatchers.delete(id);
|
||||
transformWatcher.close();
|
||||
}
|
||||
}
|
||||
watch(id, isTransformDependency) {
|
||||
var _a;
|
||||
if (isTransformDependency) {
|
||||
const watcher = (_a = this.transformWatchers.get(id)) !== null && _a !== void 0 ? _a : this.createWatcher(id);
|
||||
watcher.add(id);
|
||||
this.transformWatchers.set(id, watcher);
|
||||
}
|
||||
else {
|
||||
this.watcher.add(id);
|
||||
}
|
||||
}
|
||||
createWatcher(transformWatcherId) {
|
||||
const task = this.task;
|
||||
const isLinux = require$$2.platform() === 'linux';
|
||||
const isTransformDependency = transformWatcherId !== null;
|
||||
const handleChange = (id, event) => {
|
||||
const changedId = transformWatcherId || id;
|
||||
if (isLinux) {
|
||||
// unwatching and watching fixes an issue with chokidar where on certain systems,
|
||||
// a file that was unlinked and immediately recreated would create a change event
|
||||
// but then no longer any further events
|
||||
watcher.unwatch(changedId);
|
||||
watcher.add(changedId);
|
||||
}
|
||||
task.invalidate(changedId, { event, isTransformDependency });
|
||||
};
|
||||
const watcher = index.chokidar
|
||||
.watch([], this.chokidarOptions)
|
||||
.on('add', id => handleChange(id, 'create'))
|
||||
.on('change', id => handleChange(id, 'update'))
|
||||
.on('unlink', id => handleChange(id, 'delete'));
|
||||
return watcher;
|
||||
}
|
||||
}
|
||||
|
||||
const eventsRewrites = {
|
||||
create: {
|
||||
create: 'buggy',
|
||||
delete: null,
|
||||
update: 'create'
|
||||
},
|
||||
delete: {
|
||||
create: 'update',
|
||||
delete: 'buggy',
|
||||
update: 'buggy'
|
||||
},
|
||||
update: {
|
||||
create: 'buggy',
|
||||
delete: 'delete',
|
||||
update: 'update'
|
||||
}
|
||||
};
|
||||
class Watcher {
|
||||
constructor(configs, emitter) {
|
||||
this.buildDelay = 0;
|
||||
this.buildTimeout = null;
|
||||
this.invalidatedIds = new Map();
|
||||
this.rerun = false;
|
||||
this.running = true;
|
||||
this.emitter = emitter;
|
||||
emitter.close = this.close.bind(this);
|
||||
this.tasks = configs.map(config => new Task(this, config));
|
||||
this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
|
||||
? Math.max(buildDelay, watch.buildDelay)
|
||||
: buildDelay, this.buildDelay);
|
||||
process.nextTick(() => this.run());
|
||||
}
|
||||
async close() {
|
||||
if (this.buildTimeout)
|
||||
clearTimeout(this.buildTimeout);
|
||||
for (const task of this.tasks) {
|
||||
task.close();
|
||||
}
|
||||
await this.emitter.emitAndAwait('close');
|
||||
this.emitter.removeAllListeners();
|
||||
}
|
||||
invalidate(file) {
|
||||
if (file) {
|
||||
const prevEvent = this.invalidatedIds.get(file.id);
|
||||
const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event;
|
||||
if (event === 'buggy') {
|
||||
//TODO: throws or warn? Currently just ignore, uses new event
|
||||
this.invalidatedIds.set(file.id, file.event);
|
||||
}
|
||||
else if (event === null) {
|
||||
this.invalidatedIds.delete(file.id);
|
||||
}
|
||||
else {
|
||||
this.invalidatedIds.set(file.id, event);
|
||||
}
|
||||
}
|
||||
if (this.running) {
|
||||
this.rerun = true;
|
||||
return;
|
||||
}
|
||||
if (this.buildTimeout)
|
||||
clearTimeout(this.buildTimeout);
|
||||
this.buildTimeout = setTimeout(async () => {
|
||||
this.buildTimeout = null;
|
||||
try {
|
||||
await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emitAndAwait('change', id, { event })));
|
||||
this.invalidatedIds.clear();
|
||||
this.emitter.emit('restart');
|
||||
this.emitter.removeAwaited();
|
||||
this.run();
|
||||
}
|
||||
catch (error) {
|
||||
this.invalidatedIds.clear();
|
||||
this.emitter.emit('event', {
|
||||
code: 'ERROR',
|
||||
error,
|
||||
result: null
|
||||
});
|
||||
this.emitter.emit('event', {
|
||||
code: 'END'
|
||||
});
|
||||
}
|
||||
}, this.buildDelay);
|
||||
}
|
||||
async run() {
|
||||
this.running = true;
|
||||
this.emitter.emit('event', {
|
||||
code: 'START'
|
||||
});
|
||||
for (const task of this.tasks) {
|
||||
await task.run();
|
||||
}
|
||||
this.running = false;
|
||||
this.emitter.emit('event', {
|
||||
code: 'END'
|
||||
});
|
||||
if (this.rerun) {
|
||||
this.rerun = false;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
class Task {
|
||||
constructor(watcher, config) {
|
||||
this.cache = { modules: [] };
|
||||
this.watchFiles = [];
|
||||
this.closed = false;
|
||||
this.invalidated = true;
|
||||
this.watched = new Set();
|
||||
this.watcher = watcher;
|
||||
this.skipWrite = Boolean(config.watch && config.watch.skipWrite);
|
||||
this.options = mergeOptions.mergeOptions(config);
|
||||
this.outputs = this.options.output;
|
||||
this.outputFiles = this.outputs.map(output => {
|
||||
if (output.file || output.dir)
|
||||
return require$$0.resolve(output.file || output.dir);
|
||||
return undefined;
|
||||
});
|
||||
const watchOptions = this.options.watch || {};
|
||||
this.filter = rollup.createFilter(watchOptions.include, watchOptions.exclude);
|
||||
this.fileWatcher = new FileWatcher(this, {
|
||||
...watchOptions.chokidar,
|
||||
disableGlobbing: true,
|
||||
ignoreInitial: true
|
||||
});
|
||||
}
|
||||
close() {
|
||||
this.closed = true;
|
||||
this.fileWatcher.close();
|
||||
}
|
||||
invalidate(id, details) {
|
||||
this.invalidated = true;
|
||||
if (details.isTransformDependency) {
|
||||
for (const module of this.cache.modules) {
|
||||
if (!module.transformDependencies.includes(id))
|
||||
continue;
|
||||
// effective invalidation
|
||||
module.originalCode = null;
|
||||
}
|
||||
}
|
||||
this.watcher.invalidate({ event: details.event, id });
|
||||
}
|
||||
async run() {
|
||||
if (!this.invalidated)
|
||||
return;
|
||||
this.invalidated = false;
|
||||
const options = {
|
||||
...this.options,
|
||||
cache: this.cache
|
||||
};
|
||||
const start = Date.now();
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'BUNDLE_START',
|
||||
input: this.options.input,
|
||||
output: this.outputFiles
|
||||
});
|
||||
let result = null;
|
||||
try {
|
||||
result = await rollup.rollupInternal(options, this.watcher.emitter);
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.updateWatchedFiles(result);
|
||||
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'BUNDLE_END',
|
||||
duration: Date.now() - start,
|
||||
input: this.options.input,
|
||||
output: this.outputFiles,
|
||||
result
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
if (!this.closed) {
|
||||
if (Array.isArray(error.watchFiles)) {
|
||||
for (const id of error.watchFiles) {
|
||||
this.watchFile(id);
|
||||
}
|
||||
}
|
||||
if (error.id) {
|
||||
this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
|
||||
}
|
||||
}
|
||||
this.watcher.emitter.emit('event', {
|
||||
code: 'ERROR',
|
||||
error,
|
||||
result
|
||||
});
|
||||
}
|
||||
}
|
||||
updateWatchedFiles(result) {
|
||||
const previouslyWatched = this.watched;
|
||||
this.watched = new Set();
|
||||
this.watchFiles = result.watchFiles;
|
||||
this.cache = result.cache;
|
||||
for (const id of this.watchFiles) {
|
||||
this.watchFile(id);
|
||||
}
|
||||
for (const module of this.cache.modules) {
|
||||
for (const depId of module.transformDependencies) {
|
||||
this.watchFile(depId, true);
|
||||
}
|
||||
}
|
||||
for (const id of previouslyWatched) {
|
||||
if (!this.watched.has(id)) {
|
||||
this.fileWatcher.unwatch(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
watchFile(id, isTransformDependency = false) {
|
||||
if (!this.filter(id))
|
||||
return;
|
||||
this.watched.add(id);
|
||||
if (this.outputFiles.some(file => file === id)) {
|
||||
throw new Error('Cannot import the generated bundle');
|
||||
}
|
||||
// this is necessary to ensure that any 'renamed' files
|
||||
// continue to be watched following an error
|
||||
this.fileWatcher.watch(id, isTransformDependency);
|
||||
}
|
||||
}
|
||||
|
||||
exports.Task = Task;
|
||||
exports.Watcher = Watcher;
|
||||
//# sourceMappingURL=watch.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.0.0"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"takeLast.d.ts","sourceRoot":"","sources":["../../../../src/internal/operators/takeLast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAoCtE"}
|
||||
@@ -0,0 +1,416 @@
|
||||
'use strict';
|
||||
|
||||
var PlainValue = require('./PlainValue-ec8e588e.js');
|
||||
var resolveSeq = require('./resolveSeq-d03cb037.js');
|
||||
|
||||
/* global atob, btoa, Buffer */
|
||||
const binary = {
|
||||
identify: value => value instanceof Uint8Array,
|
||||
// Buffer inherits from Uint8Array
|
||||
default: false,
|
||||
tag: 'tag:yaml.org,2002:binary',
|
||||
|
||||
/**
|
||||
* Returns a Buffer in node and an Uint8Array in browsers
|
||||
*
|
||||
* To use the resulting buffer as an image, you'll want to do something like:
|
||||
*
|
||||
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
||||
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
||||
*/
|
||||
resolve: (doc, node) => {
|
||||
const src = resolveSeq.resolveString(doc, node);
|
||||
|
||||
if (typeof Buffer === 'function') {
|
||||
return Buffer.from(src, 'base64');
|
||||
} else if (typeof atob === 'function') {
|
||||
// On IE 11, atob() can't handle newlines
|
||||
const str = atob(src.replace(/[\n\r]/g, ''));
|
||||
const buffer = new Uint8Array(str.length);
|
||||
|
||||
for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
|
||||
|
||||
return buffer;
|
||||
} else {
|
||||
const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
|
||||
doc.errors.push(new PlainValue.YAMLReferenceError(node, msg));
|
||||
return null;
|
||||
}
|
||||
},
|
||||
options: resolveSeq.binaryOptions,
|
||||
stringify: ({
|
||||
comment,
|
||||
type,
|
||||
value
|
||||
}, ctx, onComment, onChompKeep) => {
|
||||
let src;
|
||||
|
||||
if (typeof Buffer === 'function') {
|
||||
src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
|
||||
} else if (typeof btoa === 'function') {
|
||||
let s = '';
|
||||
|
||||
for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
|
||||
|
||||
src = btoa(s);
|
||||
} else {
|
||||
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
||||
}
|
||||
|
||||
if (!type) type = resolveSeq.binaryOptions.defaultType;
|
||||
|
||||
if (type === PlainValue.Type.QUOTE_DOUBLE) {
|
||||
value = src;
|
||||
} else {
|
||||
const {
|
||||
lineWidth
|
||||
} = resolveSeq.binaryOptions;
|
||||
const n = Math.ceil(src.length / lineWidth);
|
||||
const lines = new Array(n);
|
||||
|
||||
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
||||
lines[i] = src.substr(o, lineWidth);
|
||||
}
|
||||
|
||||
value = lines.join(type === PlainValue.Type.BLOCK_LITERAL ? '\n' : ' ');
|
||||
}
|
||||
|
||||
return resolveSeq.stringifyString({
|
||||
comment,
|
||||
type,
|
||||
value
|
||||
}, ctx, onComment, onChompKeep);
|
||||
}
|
||||
};
|
||||
|
||||
function parsePairs(doc, cst) {
|
||||
const seq = resolveSeq.resolveSeq(doc, cst);
|
||||
|
||||
for (let i = 0; i < seq.items.length; ++i) {
|
||||
let item = seq.items[i];
|
||||
if (item instanceof resolveSeq.Pair) continue;else if (item instanceof resolveSeq.YAMLMap) {
|
||||
if (item.items.length > 1) {
|
||||
const msg = 'Each pair must have its own sequence indicator';
|
||||
throw new PlainValue.YAMLSemanticError(cst, msg);
|
||||
}
|
||||
|
||||
const pair = item.items[0] || new resolveSeq.Pair();
|
||||
if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore;
|
||||
if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment;
|
||||
item = pair;
|
||||
}
|
||||
seq.items[i] = item instanceof resolveSeq.Pair ? item : new resolveSeq.Pair(item);
|
||||
}
|
||||
|
||||
return seq;
|
||||
}
|
||||
function createPairs(schema, iterable, ctx) {
|
||||
const pairs = new resolveSeq.YAMLSeq(schema);
|
||||
pairs.tag = 'tag:yaml.org,2002:pairs';
|
||||
|
||||
for (const it of iterable) {
|
||||
let key, value;
|
||||
|
||||
if (Array.isArray(it)) {
|
||||
if (it.length === 2) {
|
||||
key = it[0];
|
||||
value = it[1];
|
||||
} else throw new TypeError(`Expected [key, value] tuple: ${it}`);
|
||||
} else if (it && it instanceof Object) {
|
||||
const keys = Object.keys(it);
|
||||
|
||||
if (keys.length === 1) {
|
||||
key = keys[0];
|
||||
value = it[key];
|
||||
} else throw new TypeError(`Expected { key: value } tuple: ${it}`);
|
||||
} else {
|
||||
key = it;
|
||||
}
|
||||
|
||||
const pair = schema.createPair(key, value, ctx);
|
||||
pairs.items.push(pair);
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
const pairs = {
|
||||
default: false,
|
||||
tag: 'tag:yaml.org,2002:pairs',
|
||||
resolve: parsePairs,
|
||||
createNode: createPairs
|
||||
};
|
||||
|
||||
class YAMLOMap extends resolveSeq.YAMLSeq {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
PlainValue._defineProperty(this, "add", resolveSeq.YAMLMap.prototype.add.bind(this));
|
||||
|
||||
PlainValue._defineProperty(this, "delete", resolveSeq.YAMLMap.prototype.delete.bind(this));
|
||||
|
||||
PlainValue._defineProperty(this, "get", resolveSeq.YAMLMap.prototype.get.bind(this));
|
||||
|
||||
PlainValue._defineProperty(this, "has", resolveSeq.YAMLMap.prototype.has.bind(this));
|
||||
|
||||
PlainValue._defineProperty(this, "set", resolveSeq.YAMLMap.prototype.set.bind(this));
|
||||
|
||||
this.tag = YAMLOMap.tag;
|
||||
}
|
||||
|
||||
toJSON(_, ctx) {
|
||||
const map = new Map();
|
||||
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
||||
|
||||
for (const pair of this.items) {
|
||||
let key, value;
|
||||
|
||||
if (pair instanceof resolveSeq.Pair) {
|
||||
key = resolveSeq.toJSON(pair.key, '', ctx);
|
||||
value = resolveSeq.toJSON(pair.value, key, ctx);
|
||||
} else {
|
||||
key = resolveSeq.toJSON(pair, '', ctx);
|
||||
}
|
||||
|
||||
if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
|
||||
map.set(key, value);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PlainValue._defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
|
||||
|
||||
function parseOMap(doc, cst) {
|
||||
const pairs = parsePairs(doc, cst);
|
||||
const seenKeys = [];
|
||||
|
||||
for (const {
|
||||
key
|
||||
} of pairs.items) {
|
||||
if (key instanceof resolveSeq.Scalar) {
|
||||
if (seenKeys.includes(key.value)) {
|
||||
const msg = 'Ordered maps must not include duplicate keys';
|
||||
throw new PlainValue.YAMLSemanticError(cst, msg);
|
||||
} else {
|
||||
seenKeys.push(key.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Object.assign(new YAMLOMap(), pairs);
|
||||
}
|
||||
|
||||
function createOMap(schema, iterable, ctx) {
|
||||
const pairs = createPairs(schema, iterable, ctx);
|
||||
const omap = new YAMLOMap();
|
||||
omap.items = pairs.items;
|
||||
return omap;
|
||||
}
|
||||
|
||||
const omap = {
|
||||
identify: value => value instanceof Map,
|
||||
nodeClass: YAMLOMap,
|
||||
default: false,
|
||||
tag: 'tag:yaml.org,2002:omap',
|
||||
resolve: parseOMap,
|
||||
createNode: createOMap
|
||||
};
|
||||
|
||||
class YAMLSet extends resolveSeq.YAMLMap {
|
||||
constructor() {
|
||||
super();
|
||||
this.tag = YAMLSet.tag;
|
||||
}
|
||||
|
||||
add(key) {
|
||||
const pair = key instanceof resolveSeq.Pair ? key : new resolveSeq.Pair(key);
|
||||
const prev = resolveSeq.findPair(this.items, pair.key);
|
||||
if (!prev) this.items.push(pair);
|
||||
}
|
||||
|
||||
get(key, keepPair) {
|
||||
const pair = resolveSeq.findPair(this.items, key);
|
||||
return !keepPair && pair instanceof resolveSeq.Pair ? pair.key instanceof resolveSeq.Scalar ? pair.key.value : pair.key : pair;
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
if (typeof value !== 'boolean') throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
|
||||
const prev = resolveSeq.findPair(this.items, key);
|
||||
|
||||
if (prev && !value) {
|
||||
this.items.splice(this.items.indexOf(prev), 1);
|
||||
} else if (!prev && value) {
|
||||
this.items.push(new resolveSeq.Pair(key));
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(_, ctx) {
|
||||
return super.toJSON(_, ctx, Set);
|
||||
}
|
||||
|
||||
toString(ctx, onComment, onChompKeep) {
|
||||
if (!ctx) return JSON.stringify(this);
|
||||
if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PlainValue._defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
|
||||
|
||||
function parseSet(doc, cst) {
|
||||
const map = resolveSeq.resolveMap(doc, cst);
|
||||
if (!map.hasAllNullValues()) throw new PlainValue.YAMLSemanticError(cst, 'Set items must all have null values');
|
||||
return Object.assign(new YAMLSet(), map);
|
||||
}
|
||||
|
||||
function createSet(schema, iterable, ctx) {
|
||||
const set = new YAMLSet();
|
||||
|
||||
for (const value of iterable) set.items.push(schema.createPair(value, null, ctx));
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
const set = {
|
||||
identify: value => value instanceof Set,
|
||||
nodeClass: YAMLSet,
|
||||
default: false,
|
||||
tag: 'tag:yaml.org,2002:set',
|
||||
resolve: parseSet,
|
||||
createNode: createSet
|
||||
};
|
||||
|
||||
const parseSexagesimal = (sign, parts) => {
|
||||
const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0);
|
||||
return sign === '-' ? -n : n;
|
||||
}; // hhhh:mm:ss.sss
|
||||
|
||||
|
||||
const stringifySexagesimal = ({
|
||||
value
|
||||
}) => {
|
||||
if (isNaN(value) || !isFinite(value)) return resolveSeq.stringifyNumber(value);
|
||||
let sign = '';
|
||||
|
||||
if (value < 0) {
|
||||
sign = '-';
|
||||
value = Math.abs(value);
|
||||
}
|
||||
|
||||
const parts = [value % 60]; // seconds, including ms
|
||||
|
||||
if (value < 60) {
|
||||
parts.unshift(0); // at least one : is required
|
||||
} else {
|
||||
value = Math.round((value - parts[0]) / 60);
|
||||
parts.unshift(value % 60); // minutes
|
||||
|
||||
if (value >= 60) {
|
||||
value = Math.round((value - parts[0]) / 60);
|
||||
parts.unshift(value); // hours
|
||||
}
|
||||
}
|
||||
|
||||
return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
|
||||
;
|
||||
};
|
||||
|
||||
const intTime = {
|
||||
identify: value => typeof value === 'number',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:int',
|
||||
format: 'TIME',
|
||||
test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
|
||||
resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
|
||||
stringify: stringifySexagesimal
|
||||
};
|
||||
const floatTime = {
|
||||
identify: value => typeof value === 'number',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:float',
|
||||
format: 'TIME',
|
||||
test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
|
||||
resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
|
||||
stringify: stringifySexagesimal
|
||||
};
|
||||
const timestamp = {
|
||||
identify: value => value instanceof Date,
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:timestamp',
|
||||
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
|
||||
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
||||
// assumed to be 00:00:00Z (start of day, UTC).
|
||||
test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
|
||||
'(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
|
||||
'([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
|
||||
'(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
|
||||
')?' + ')$'),
|
||||
resolve: (str, year, month, day, hour, minute, second, millisec, tz) => {
|
||||
if (millisec) millisec = (millisec + '00').substr(1, 3);
|
||||
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
|
||||
|
||||
if (tz && tz !== 'Z') {
|
||||
let d = parseSexagesimal(tz[0], tz.slice(1));
|
||||
if (Math.abs(d) < 30) d *= 60;
|
||||
date -= 60000 * d;
|
||||
}
|
||||
|
||||
return new Date(date);
|
||||
},
|
||||
stringify: ({
|
||||
value
|
||||
}) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
|
||||
};
|
||||
|
||||
/* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */
|
||||
function shouldWarn(deprecation) {
|
||||
const env = typeof process !== 'undefined' && process.env || {};
|
||||
|
||||
if (deprecation) {
|
||||
if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS;
|
||||
return !env.YAML_SILENCE_DEPRECATION_WARNINGS;
|
||||
}
|
||||
|
||||
if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS;
|
||||
return !env.YAML_SILENCE_WARNINGS;
|
||||
}
|
||||
|
||||
function warn(warning, type) {
|
||||
if (shouldWarn(false)) {
|
||||
const emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to
|
||||
// https://github.com/facebook/jest/issues/2549
|
||||
|
||||
if (emit) emit(warning, type);else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(type ? `${type}: ${warning}` : warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
function warnFileDeprecation(filename) {
|
||||
if (shouldWarn(true)) {
|
||||
const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
|
||||
warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning');
|
||||
}
|
||||
}
|
||||
const warned = {};
|
||||
function warnOptionDeprecation(name, alternative) {
|
||||
if (!warned[name] && shouldWarn(true)) {
|
||||
warned[name] = true;
|
||||
let msg = `The option '${name}' will be removed in a future release`;
|
||||
msg += alternative ? `, use '${alternative}' instead.` : '.';
|
||||
warn(msg, 'DeprecationWarning');
|
||||
}
|
||||
}
|
||||
|
||||
exports.binary = binary;
|
||||
exports.floatTime = floatTime;
|
||||
exports.intTime = intTime;
|
||||
exports.omap = omap;
|
||||
exports.pairs = pairs;
|
||||
exports.set = set;
|
||||
exports.timestamp = timestamp;
|
||||
exports.warn = warn;
|
||||
exports.warnFileDeprecation = warnFileDeprecation;
|
||||
exports.warnOptionDeprecation = warnOptionDeprecation;
|
||||
@@ -0,0 +1,15 @@
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||
|
||||
@category Basic
|
||||
*/
|
||||
export interface ObservableLike {
|
||||
subscribe(observer: (value: unknown) => void): void;
|
||||
[Symbol.observable](): ObservableLike;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../src/internal/operators/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAoCzF"}
|
||||
@@ -0,0 +1,492 @@
|
||||
# Fraction.js - ℚ in JavaScript
|
||||
|
||||
[](https://npmjs.org/package/fraction.js)
|
||||
|
||||
[](https://travis-ci.org/infusion/Fraction.js)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
|
||||
Tired of inprecise numbers represented by doubles, which have to store rational and irrational numbers like PI or sqrt(2) the same way? Obviously the following problem is preventable:
|
||||
|
||||
```javascript
|
||||
1 / 98 * 98 // = 0.9999999999999999
|
||||
```
|
||||
|
||||
If you need more precision or just want a fraction as a result, have a look at *Fraction.js*:
|
||||
|
||||
```javascript
|
||||
var Fraction = require('fraction.js');
|
||||
|
||||
Fraction(1).div(98).mul(98) // = 1
|
||||
```
|
||||
|
||||
Internally, numbers are represented as *numerator / denominator*, which adds just a little overhead. However, the library is written with performance in mind and outperforms any other implementation, as you can see [here](http://jsperf.com/convert-a-rational-number-to-a-babylonian-fractions/28). This basic data-type makes it the perfect basis for [Polynomial.js](https://github.com/infusion/Polynomial.js) and [Math.js](https://github.com/josdejong/mathjs).
|
||||
|
||||
Convert decimal to fraction
|
||||
===
|
||||
The simplest job for fraction.js is to get a fraction out of a decimal:
|
||||
```javascript
|
||||
var x = new Fraction(1.88);
|
||||
var res = x.toFraction(true); // String "1 22/25"
|
||||
```
|
||||
|
||||
Examples / Motivation
|
||||
===
|
||||
A simple example might be
|
||||
|
||||
```javascript
|
||||
var f = new Fraction("9.4'31'"); // 9.4313131313131...
|
||||
f.mul([-4, 3]).mod("4.'8'"); // 4.88888888888888...
|
||||
```
|
||||
The result is
|
||||
|
||||
```javascript
|
||||
console.log(f.toFraction()); // -4154 / 1485
|
||||
```
|
||||
You could of course also access the sign (s), numerator (n) and denominator (d) on your own:
|
||||
```javascript
|
||||
f.s * f.n / f.d = -1 * 4154 / 1485 = -2.797306...
|
||||
```
|
||||
|
||||
If you would try to calculate it yourself, you would come up with something like:
|
||||
|
||||
```javascript
|
||||
(9.4313131 * (-4 / 3)) % 4.888888 = -2.797308133...
|
||||
```
|
||||
|
||||
Quite okay, but yea - not as accurate as it could be.
|
||||
|
||||
|
||||
Laplace Probability
|
||||
===
|
||||
Simple example. What's the probability of throwing a 3, and 1 or 4, and 2 or 4 or 6 with a fair dice?
|
||||
|
||||
P({3}):
|
||||
```javascript
|
||||
var p = new Fraction([3].length, 6).toString(); // 0.1(6)
|
||||
```
|
||||
|
||||
P({1, 4}):
|
||||
```javascript
|
||||
var p = new Fraction([1, 4].length, 6).toString(); // 0.(3)
|
||||
```
|
||||
|
||||
P({2, 4, 6}):
|
||||
```javascript
|
||||
var p = new Fraction([2, 4, 6].length, 6).toString(); // 0.5
|
||||
```
|
||||
|
||||
Convert degrees/minutes/seconds to precise rational representation:
|
||||
===
|
||||
|
||||
57+45/60+17/3600
|
||||
```javascript
|
||||
var deg = 57; // 57°
|
||||
var min = 45; // 45 Minutes
|
||||
var sec = 17; // 17 Seconds
|
||||
|
||||
new Fraction(deg).add(min, 60).add(sec, 3600).toString() // -> 57.7547(2)
|
||||
```
|
||||
|
||||
Rounding a fraction to the closest tape measure value
|
||||
===
|
||||
|
||||
A tape measure is usually divided in parts of `1/16`. Rounding a given fraction to the closest value on a tape measure can be determined by
|
||||
|
||||
```javascript
|
||||
function closestTapeMeasure(frac) {
|
||||
|
||||
/*
|
||||
k/16 ≤ a/b < (k+1)/16
|
||||
⇔ k ≤ 16*a/b < (k+1)
|
||||
⇔ k = floor(16*a/b)
|
||||
*/
|
||||
return new Fraction(Math.round(16 * Fraction(frac).valueOf()), 16);
|
||||
}
|
||||
// closestTapeMeasure("1/3") // 5/16
|
||||
```
|
||||
|
||||
Rational approximation of irrational numbers
|
||||
===
|
||||
|
||||
Now it's getting messy ;d To approximate a number like *sqrt(5) - 2* with a numerator and denominator, you can reformat the equation as follows: *pow(n / d + 2, 2) = 5*.
|
||||
|
||||
Then the following algorithm will generate the rational number besides the binary representation.
|
||||
|
||||
```javascript
|
||||
var x = "/", s = "";
|
||||
|
||||
var a = new Fraction(0),
|
||||
b = new Fraction(1);
|
||||
for (var n = 0; n <= 10; n++) {
|
||||
|
||||
var c = a.add(b).div(2);
|
||||
|
||||
console.log(n + "\t" + a + "\t" + b + "\t" + c + "\t" + x);
|
||||
|
||||
if (c.add(2).pow(2) < 5) {
|
||||
a = c;
|
||||
x = "1";
|
||||
} else {
|
||||
b = c;
|
||||
x = "0";
|
||||
}
|
||||
s+= x;
|
||||
}
|
||||
console.log(s)
|
||||
```
|
||||
|
||||
The result is
|
||||
|
||||
```
|
||||
n a[n] b[n] c[n] x[n]
|
||||
0 0/1 1/1 1/2 /
|
||||
1 0/1 1/2 1/4 0
|
||||
2 0/1 1/4 1/8 0
|
||||
3 1/8 1/4 3/16 1
|
||||
4 3/16 1/4 7/32 1
|
||||
5 7/32 1/4 15/64 1
|
||||
6 15/64 1/4 31/128 1
|
||||
7 15/64 31/128 61/256 0
|
||||
8 15/64 61/256 121/512 0
|
||||
9 15/64 121/512 241/1024 0
|
||||
10 241/1024 121/512 483/2048 1
|
||||
```
|
||||
Thus the approximation after 11 iterations of the bisection method is *483 / 2048* and the binary representation is 0.00111100011 (see [WolframAlpha](http://www.wolframalpha.com/input/?i=sqrt%285%29-2+binary))
|
||||
|
||||
|
||||
I published another example on how to approximate PI with fraction.js on my [blog](http://www.xarg.org/2014/03/precise-calculations-in-javascript/) (Still not the best idea to approximate irrational numbers, but it illustrates the capabilities of Fraction.js perfectly).
|
||||
|
||||
|
||||
Get the exact fractional part of a number
|
||||
---
|
||||
```javascript
|
||||
var f = new Fraction("-6.(3416)");
|
||||
console.log("" + f.mod(1).abs()); // Will print 0.(3416)
|
||||
```
|
||||
|
||||
Mathematical correct modulo
|
||||
---
|
||||
The behaviour on negative congruences is different to most modulo implementations in computer science. Even the *mod()* function of Fraction.js behaves in the typical way. To solve the problem of having the mathematical correct modulo with Fraction.js you could come up with this:
|
||||
|
||||
```javascript
|
||||
var a = -1;
|
||||
var b = 10.99;
|
||||
|
||||
console.log(new Fraction(a)
|
||||
.mod(b)); // Not correct, usual Modulo
|
||||
|
||||
console.log(new Fraction(a)
|
||||
.mod(b).add(b).mod(b)); // Correct! Mathematical Modulo
|
||||
```
|
||||
|
||||
fmod() impreciseness circumvented
|
||||
---
|
||||
It turns out that Fraction.js outperforms almost any fmod() implementation, including JavaScript itself, [php.js](http://phpjs.org/functions/fmod/), C++, Python, Java and even Wolframalpha due to the fact that numbers like 0.05, 0.1, ... are infinite decimal in base 2.
|
||||
|
||||
The equation *fmod(4.55, 0.05)* gives *0.04999999999999957*, wolframalpha says *1/20*. The correct answer should be **zero**, as 0.05 divides 4.55 without any remainder.
|
||||
|
||||
|
||||
Parser
|
||||
===
|
||||
|
||||
Any function (see below) as well as the constructor of the *Fraction* class parses its input and reduce it to the smallest term.
|
||||
|
||||
You can pass either Arrays, Objects, Integers, Doubles or Strings.
|
||||
|
||||
Arrays / Objects
|
||||
---
|
||||
```javascript
|
||||
new Fraction(numerator, denominator);
|
||||
new Fraction([numerator, denominator]);
|
||||
new Fraction({n: numerator, d: denominator});
|
||||
```
|
||||
|
||||
Integers
|
||||
---
|
||||
```javascript
|
||||
new Fraction(123);
|
||||
```
|
||||
|
||||
Doubles
|
||||
---
|
||||
```javascript
|
||||
new Fraction(55.4);
|
||||
```
|
||||
|
||||
**Note:** If you pass a double as it is, Fraction.js will perform a number analysis based on Farey Sequences. If you concern performance, cache Fraction.js objects and pass arrays/objects.
|
||||
|
||||
The method is really precise, but too large exact numbers, like 1234567.9991829 will result in a wrong approximation. If you want to keep the number as it is, convert it to a string, as the string parser will not perform any further observations. If you have problems with the approximation, in the file `examples/approx.js` is a different approximation algorithm, which might work better in some more specific use-cases.
|
||||
|
||||
|
||||
Strings
|
||||
---
|
||||
```javascript
|
||||
new Fraction("123.45");
|
||||
new Fraction("123/45"); // A rational number represented as two decimals, separated by a slash
|
||||
new Fraction("123:45"); // A rational number represented as two decimals, separated by a colon
|
||||
new Fraction("4 123/45"); // A rational number represented as a whole number and a fraction
|
||||
new Fraction("123.'456'"); // Note the quotes, see below!
|
||||
new Fraction("123.(456)"); // Note the brackets, see below!
|
||||
new Fraction("123.45'6'"); // Note the quotes, see below!
|
||||
new Fraction("123.45(6)"); // Note the brackets, see below!
|
||||
```
|
||||
|
||||
Two arguments
|
||||
---
|
||||
```javascript
|
||||
new Fraction(3, 2); // 3/2 = 1.5
|
||||
```
|
||||
|
||||
Repeating decimal places
|
||||
---
|
||||
*Fraction.js* can easily handle repeating decimal places. For example *1/3* is *0.3333...*. There is only one repeating digit. As you can see in the examples above, you can pass a number like *1/3* as "0.'3'" or "0.(3)", which are synonym. There are no tests to parse something like 0.166666666 to 1/6! If you really want to handle this number, wrap around brackets on your own with the function below for example: 0.1(66666666)
|
||||
|
||||
Assume you want to divide 123.32 / 33.6(567). [WolframAlpha](http://www.wolframalpha.com/input/?i=123.32+%2F+%2812453%2F370%29) states that you'll get a period of 1776 digits. *Fraction.js* comes to the same result. Give it a try:
|
||||
|
||||
```javascript
|
||||
var f = new Fraction("123.32");
|
||||
console.log("Bam: " + f.div("33.6(567)"));
|
||||
```
|
||||
|
||||
To automatically make a number like "0.123123123" to something more Fraction.js friendly like "0.(123)", I hacked this little brute force algorithm in a 10 minutes. Improvements are welcome...
|
||||
|
||||
```javascript
|
||||
function formatDecimal(str) {
|
||||
|
||||
var comma, pre, offset, pad, times, repeat;
|
||||
|
||||
if (-1 === (comma = str.indexOf(".")))
|
||||
return str;
|
||||
|
||||
pre = str.substr(0, comma + 1);
|
||||
str = str.substr(comma + 1);
|
||||
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
|
||||
offset = str.substr(0, i);
|
||||
|
||||
for (var j = 0; j < 5; j++) {
|
||||
|
||||
pad = str.substr(i, j + 1);
|
||||
|
||||
times = Math.ceil((str.length - offset.length) / pad.length);
|
||||
|
||||
repeat = new Array(times + 1).join(pad); // Silly String.repeat hack
|
||||
|
||||
if (0 === (offset + repeat).indexOf(str)) {
|
||||
return pre + offset + "(" + pad + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var f, x = formatDecimal("13.0123123123"); // = 13.0(123)
|
||||
if (x !== null) {
|
||||
f = new Fraction(x);
|
||||
}
|
||||
```
|
||||
|
||||
Attributes
|
||||
===
|
||||
|
||||
The Fraction object allows direct access to the numerator, denominator and sign attributes. It is ensured that only the sign-attribute holds sign information so that a sign comparison is only necessary against this attribute.
|
||||
|
||||
```javascript
|
||||
var f = new Fraction('-1/2');
|
||||
console.log(f.n); // Numerator: 1
|
||||
console.log(f.d); // Denominator: 2
|
||||
console.log(f.s); // Sign: -1
|
||||
```
|
||||
|
||||
|
||||
Functions
|
||||
===
|
||||
|
||||
Fraction abs()
|
||||
---
|
||||
Returns the actual number without any sign information
|
||||
|
||||
Fraction neg()
|
||||
---
|
||||
Returns the actual number with flipped sign in order to get the additive inverse
|
||||
|
||||
Fraction add(n)
|
||||
---
|
||||
Returns the sum of the actual number and the parameter n
|
||||
|
||||
Fraction sub(n)
|
||||
---
|
||||
Returns the difference of the actual number and the parameter n
|
||||
|
||||
Fraction mul(n)
|
||||
---
|
||||
Returns the product of the actual number and the parameter n
|
||||
|
||||
Fraction div(n)
|
||||
---
|
||||
Returns the quotient of the actual number and the parameter n
|
||||
|
||||
Fraction pow(exp)
|
||||
---
|
||||
Returns the power of the actual number, raised to an possible rational exponent. If the result becomes non-rational the function returns `null`.
|
||||
|
||||
Fraction mod(n)
|
||||
---
|
||||
Returns the modulus (rest of the division) of the actual object and n (this % n). It's a much more precise [fmod()](#fmod-impreciseness-circumvented) if you will. Please note that *mod()* is just like the modulo operator of most programming languages. If you want a mathematical correct modulo, see [here](#mathematical-correct-modulo).
|
||||
|
||||
Fraction mod()
|
||||
---
|
||||
Returns the modulus (rest of the division) of the actual object (numerator mod denominator)
|
||||
|
||||
Fraction gcd(n)
|
||||
---
|
||||
Returns the fractional greatest common divisor
|
||||
|
||||
Fraction lcm(n)
|
||||
---
|
||||
Returns the fractional least common multiple
|
||||
|
||||
Fraction ceil([places=0-16])
|
||||
---
|
||||
Returns the ceiling of a rational number with Math.ceil
|
||||
|
||||
Fraction floor([places=0-16])
|
||||
---
|
||||
Returns the floor of a rational number with Math.floor
|
||||
|
||||
Fraction round([places=0-16])
|
||||
---
|
||||
Returns the rational number rounded with Math.round
|
||||
|
||||
Fraction inverse()
|
||||
---
|
||||
Returns the multiplicative inverse of the actual number (n / d becomes d / n) in order to get the reciprocal
|
||||
|
||||
Fraction simplify([eps=0.001])
|
||||
---
|
||||
Simplifies the rational number under a certain error threshold. Ex. `0.333` will be `1/3` with `eps=0.001`
|
||||
|
||||
boolean equals(n)
|
||||
---
|
||||
Check if two numbers are equal
|
||||
|
||||
int compare(n)
|
||||
---
|
||||
Compare two numbers.
|
||||
```
|
||||
result < 0: n is greater than actual number
|
||||
result > 0: n is smaller than actual number
|
||||
result = 0: n is equal to the actual number
|
||||
```
|
||||
|
||||
boolean divisible(n)
|
||||
---
|
||||
Check if two numbers are divisible (n divides this)
|
||||
|
||||
double valueOf()
|
||||
---
|
||||
Returns a decimal representation of the fraction
|
||||
|
||||
String toString([decimalPlaces=15])
|
||||
---
|
||||
Generates an exact string representation of the actual object. For repeated decimal places all digits are collected within brackets, like `1/3 = "0.(3)"`. For all other numbers, up to `decimalPlaces` significant digits are collected - which includes trailing zeros if the number is getting truncated. However, `1/2 = "0.5"` without trailing zeros of course.
|
||||
|
||||
**Note:** As `valueOf()` and `toString()` are provided, `toString()` is only called implicitly in a real string context. Using the plus-operator like `"123" + new Fraction` will call valueOf(), because JavaScript tries to combine two primitives first and concatenates them later, as string will be the more dominant type. `alert(new Fraction)` or `String(new Fraction)` on the other hand will do what you expect. If you really want to have control, you should call `toString()` or `valueOf()` explicitly!
|
||||
|
||||
String toLatex(excludeWhole=false)
|
||||
---
|
||||
Generates an exact LaTeX representation of the actual object. You can see a [live demo](http://www.xarg.org/2014/03/precise-calculations-in-javascript/) on my blog.
|
||||
|
||||
The optional boolean parameter indicates if you want to exclude the whole part. "1 1/3" instead of "4/3"
|
||||
|
||||
String toFraction(excludeWhole=false)
|
||||
---
|
||||
Gets a string representation of the fraction
|
||||
|
||||
The optional boolean parameter indicates if you want to exclude the whole part. "1 1/3" instead of "4/3"
|
||||
|
||||
Array toContinued()
|
||||
---
|
||||
Gets an array of the fraction represented as a continued fraction. The first element always contains the whole part.
|
||||
|
||||
```javascript
|
||||
var f = new Fraction('88/33');
|
||||
var c = f.toContinued(); // [2, 1, 2]
|
||||
```
|
||||
|
||||
Fraction clone()
|
||||
---
|
||||
Creates a copy of the actual Fraction object
|
||||
|
||||
|
||||
Exceptions
|
||||
===
|
||||
If a really hard error occurs (parsing error, division by zero), *fraction.js* throws exceptions! Please make sure you handle them correctly.
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
===
|
||||
Installing fraction.js is as easy as cloning this repo or use one of the following commands:
|
||||
|
||||
```
|
||||
bower install fraction.js
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
npm install fraction.js
|
||||
```
|
||||
|
||||
Using Fraction.js with the browser
|
||||
===
|
||||
```html
|
||||
<script src="fraction.js"></script>
|
||||
<script>
|
||||
console.log(Fraction("123/456"));
|
||||
</script>
|
||||
```
|
||||
|
||||
Using Fraction.js with require.js
|
||||
===
|
||||
```html
|
||||
<script src="require.js"></script>
|
||||
<script>
|
||||
requirejs(['fraction.js'],
|
||||
function(Fraction) {
|
||||
console.log(Fraction("123/456"));
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
Using Fraction.js with TypeScript
|
||||
===
|
||||
```js
|
||||
import Fraction from "fraction.js";
|
||||
console.log(Fraction("123/456"));
|
||||
```
|
||||
|
||||
Coding Style
|
||||
===
|
||||
As every library I publish, fraction.js is also built to be as small as possible after compressing it with Google Closure Compiler in advanced mode. Thus the coding style orientates a little on maxing-out the compression rate. Please make sure you keep this style if you plan to extend the library.
|
||||
|
||||
|
||||
Precision
|
||||
===
|
||||
Fraction.js tries to circumvent floating point errors, by having an internal representation of numerator and denominator. As it relies on JavaScript, there is also a limit. The biggest number representable is `Number.MAX_SAFE_INTEGER / 1` and the smallest is `-1 / Number.MAX_SAFE_INTEGER`, with `Number.MAX_SAFE_INTEGER=9007199254740991`. If this is not enough, there is `bigfraction.js` shipped experimentally, which relies on `BigInt` and should become the new Fraction.js eventually.
|
||||
|
||||
Testing
|
||||
===
|
||||
If you plan to enhance the library, make sure you add test cases and all the previous tests are passing. You can test the library with
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
|
||||
Copyright and licensing
|
||||
===
|
||||
Copyright (c) 2014-2019, [Robert Eisele](https://www.xarg.org/)
|
||||
Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { async as asyncScheduler } from '../scheduler/async';
|
||||
import { isScheduler } from '../util/isScheduler';
|
||||
import { isValidDate } from '../util/isDate';
|
||||
export function timer(dueTime, intervalOrScheduler, scheduler) {
|
||||
if (dueTime === void 0) { dueTime = 0; }
|
||||
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
||||
var intervalDuration = -1;
|
||||
if (intervalOrScheduler != null) {
|
||||
if (isScheduler(intervalOrScheduler)) {
|
||||
scheduler = intervalOrScheduler;
|
||||
}
|
||||
else {
|
||||
intervalDuration = intervalOrScheduler;
|
||||
}
|
||||
}
|
||||
return new Observable(function (subscriber) {
|
||||
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;
|
||||
if (due < 0) {
|
||||
due = 0;
|
||||
}
|
||||
var n = 0;
|
||||
return scheduler.schedule(function () {
|
||||
if (!subscriber.closed) {
|
||||
subscriber.next(n++);
|
||||
if (0 <= intervalDuration) {
|
||||
this.schedule(undefined, intervalDuration);
|
||||
}
|
||||
else {
|
||||
subscriber.complete();
|
||||
}
|
||||
}
|
||||
}, due);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=timer.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"exhaustAll.d.ts","sourceRoot":"","sources":["../../../../src/internal/operators/exhaustAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAEpG"}
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "parse-path",
|
||||
"version": "7.0.0",
|
||||
"description": "Parse paths (local paths, urls: ssh/git/etc)",
|
||||
"main": "lib/index.js",
|
||||
"directories": {
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/IonicaBizau/parse-path.git"
|
||||
},
|
||||
"keywords": [
|
||||
"parse",
|
||||
"path",
|
||||
"url",
|
||||
"node",
|
||||
"git",
|
||||
"advanced"
|
||||
],
|
||||
"author": "Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/IonicaBizau/parse-path/issues"
|
||||
},
|
||||
"homepage": "https://github.com/IonicaBizau/parse-path",
|
||||
"devDependencies": {
|
||||
"tester": "^1.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"protocols": "^2.0.0"
|
||||
},
|
||||
"files": [
|
||||
"bin/",
|
||||
"app/",
|
||||
"lib/",
|
||||
"dist/",
|
||||
"src/",
|
||||
"scripts/",
|
||||
"resources/",
|
||||
"menu/",
|
||||
"cli.js",
|
||||
"index.js",
|
||||
"bloggify.js",
|
||||
"bloggify.json",
|
||||
"bloggify/"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# @babel/highlight
|
||||
|
||||
> Syntax highlight JavaScript strings for output in terminals.
|
||||
|
||||
See our website [@babel/highlight](https://babeljs.io/docs/en/babel-highlight) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/highlight
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/highlight --dev
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object.
|
||||
|
||||
@param object - Object to add property to.
|
||||
@param propertyName - Name of the property to add.
|
||||
@param fn - Called the first time `propertyName` is accessed.
|
||||
|
||||
@example
|
||||
```
|
||||
import defineLazyProp = require('define-lazy-prop');
|
||||
|
||||
const unicorn = {
|
||||
// …
|
||||
};
|
||||
|
||||
defineLazyProp(unicorn, 'rainbow', () => expensiveComputation());
|
||||
|
||||
app.on('user-action', () => {
|
||||
doSomething(unicorn.rainbow);
|
||||
});
|
||||
```
|
||||
*/
|
||||
declare function defineLazyProp<
|
||||
ObjectType extends {[key: string]: unknown},
|
||||
PropertyNameType extends string,
|
||||
PropertyValueType
|
||||
>(
|
||||
object: ObjectType,
|
||||
propertyName: PropertyNameType,
|
||||
fn: () => PropertyValueType
|
||||
): ObjectType & {[K in PropertyNameType]: PropertyValueType};
|
||||
|
||||
export = defineLazyProp;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* INTERNAL, DO NOT USE. Code may change at any time.
|
||||
*/
|
||||
export interface Fragment {
|
||||
key: string | null;
|
||||
first: null;
|
||||
c: () => void;
|
||||
l: (nodes: any) => void;
|
||||
h: () => void;
|
||||
m: (target: HTMLElement, anchor: any) => void;
|
||||
p: (ctx: T$$['ctx'], dirty: T$$['dirty']) => void;
|
||||
r: () => void;
|
||||
f: () => void;
|
||||
a: () => void;
|
||||
i: (local: any) => void;
|
||||
o: (local: any) => void;
|
||||
d: (detaching: 0 | 1) => void;
|
||||
}
|
||||
export declare type FragmentFactory = (ctx: any) => Fragment;
|
||||
export interface T$$ {
|
||||
dirty: number[];
|
||||
ctx: any[];
|
||||
bound: any;
|
||||
update: () => void;
|
||||
callbacks: any;
|
||||
after_update: any[];
|
||||
props: Record<string, 0 | string>;
|
||||
fragment: null | false | Fragment;
|
||||
not_equal: any;
|
||||
before_update: any[];
|
||||
context: Map<any, any>;
|
||||
on_mount: any[];
|
||||
on_destroy: any[];
|
||||
skip_bound: boolean;
|
||||
on_disconnect: any[];
|
||||
root: Element | ShadowRoot;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"L G M N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K"},C:{"1":"0 1 2 3 4 5 6 7 8 9 G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB I v J D E F A B C K L EC FC"},D:{"1":"9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 I v J D E F A B C K L G M N O w g x y z"},E:{"2":"I v J D E F A HC zB IC JC KC LC 0B","132":"B C K L G qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C G M N O w PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC","132":"dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:6,C:"Opus audio format"};
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Determine browser vs node environment by testing the default top level context. Solution courtesy of: https://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser */
|
||||
const isBrowserEnvironment = (function() {
|
||||
// eslint-disable-next-line no-undef
|
||||
return (typeof window !== "undefined") && (this === window);
|
||||
}).call();
|
||||
|
||||
if (isBrowserEnvironment) {
|
||||
// Web version of reading a wasm file into an array buffer.
|
||||
|
||||
let mappingsWasm = null;
|
||||
|
||||
module.exports = function readWasm() {
|
||||
if (typeof mappingsWasm === "string") {
|
||||
return fetch(mappingsWasm)
|
||||
.then(response => response.arrayBuffer());
|
||||
}
|
||||
if (mappingsWasm instanceof ArrayBuffer) {
|
||||
return Promise.resolve(mappingsWasm);
|
||||
}
|
||||
throw new Error("You must provide the string URL or ArrayBuffer contents " +
|
||||
"of lib/mappings.wasm by calling " +
|
||||
"SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
|
||||
"before using SourceMapConsumer");
|
||||
};
|
||||
|
||||
module.exports.initialize = input => mappingsWasm = input;
|
||||
} else {
|
||||
// Node version of reading a wasm file into an array buffer.
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = function readWasm() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const wasmPath = path.join(__dirname, "mappings.wasm");
|
||||
fs.readFile(wasmPath, null, (error, data) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(data.buffer);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.initialize = _ => {
|
||||
console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
var isCallable = require("../object/is-callable")
|
||||
, value = require("../object/valid-value")
|
||||
, call = Function.prototype.call;
|
||||
|
||||
module.exports = function (fmap) {
|
||||
fmap = Object(value(fmap));
|
||||
return function (pattern) {
|
||||
var context = this;
|
||||
value(context);
|
||||
pattern = String(pattern);
|
||||
return pattern.replace(
|
||||
/%([a-zA-Z]+)|\\([\u0000-\uffff])/g,
|
||||
function (match, token, escapeChar) {
|
||||
var t, result;
|
||||
if (escapeChar) return escapeChar;
|
||||
t = token;
|
||||
while (t && !(result = fmap[t])) t = t.slice(0, -1);
|
||||
if (!result) return match;
|
||||
if (isCallable(result)) result = call.call(result, context);
|
||||
return result + token.slice(t.length);
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StatsService = void 0;
|
||||
const request_1 = require("../core/request");
|
||||
class StatsService {
|
||||
/**
|
||||
* Get
|
||||
* A very basic stats endpoint providing basic counters for a dashboard or simmilar
|
||||
* @result ResponseStats
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGet() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top runners by distance
|
||||
* Returns the top ten runners by distance.
|
||||
* @result ResponseStatsRunner
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopRunnersByDistance() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/runners/distance`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top runners by donations
|
||||
* Returns the top ten runners by donations.
|
||||
* @result ResponseStatsRunner
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopRunnersByDonations() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/runners/donations`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top runners by laptime
|
||||
* Returns the top ten runners by fastest laptime on your selected track (track by id).
|
||||
* @param track
|
||||
* @result ResponseStatsRunner
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopRunnersByLaptime(track) {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/runners/laptime`,
|
||||
query: {
|
||||
'track': track,
|
||||
},
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top runners by track time
|
||||
* Returns the top ten fastest track times (with their runner and the runner's group).
|
||||
* @result ResponseStatsRunner
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopRunnersByTrackTime() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/scans`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top teams by distance
|
||||
* Returns the top ten teams by distance.
|
||||
* @result ResponseStatsTeam
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopTeamsByDistance() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/teams/distance`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top teams by donations
|
||||
* Returns the top ten teams by donations.
|
||||
* @result ResponseStatsTeam
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopTeamsByDonations() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/teams/donations`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top orgs by distance
|
||||
* Returns the top ten organizations by distance.
|
||||
* @result ResponseStatsOrgnisation
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopOrgsByDistance() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/organizations/distance`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
/**
|
||||
* Get top orgs by donations
|
||||
* Returns the top ten organizations by donations.
|
||||
* @result ResponseStatsOrgnisation
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async statsControllerGetTopOrgsByDonations() {
|
||||
const result = await (0, request_1.request)({
|
||||
method: 'GET',
|
||||
path: `/api/stats/organizations/donations`,
|
||||
});
|
||||
return result.body;
|
||||
}
|
||||
}
|
||||
exports.StatsService = StatsService;
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('shuffle', require('../shuffle'), require('./_falseOptions'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,76 @@
|
||||
// @ts-check
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
export function indentRecursive(node, indent = 0) {
|
||||
node.each &&
|
||||
node.each((child, i) => {
|
||||
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
|
||||
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`
|
||||
}
|
||||
child.raws.after = `\n${' '.repeat(indent)}`
|
||||
indentRecursive(child, indent + 1)
|
||||
})
|
||||
}
|
||||
|
||||
export function formatNodes(root) {
|
||||
indentRecursive(root)
|
||||
if (root.first) {
|
||||
root.first.raws.before = ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When rapidly saving files atomically a couple of situations can happen:
|
||||
* - The file is missing since the external program has deleted it by the time we've gotten around to reading it from the earlier save.
|
||||
* - The file is being written to by the external program by the time we're going to read it and is thus treated as busy because a lock is held.
|
||||
*
|
||||
* To work around this we retry reading the file a handful of times with a delay between each attempt
|
||||
*
|
||||
* @param {string} path
|
||||
* @param {number} tries
|
||||
* @returns {Promise<string | undefined>}
|
||||
* @throws {Error} If the file is still missing or busy after the specified number of tries
|
||||
*/
|
||||
export async function readFileWithRetries(path, tries = 5) {
|
||||
for (let n = 0; n <= tries; n++) {
|
||||
try {
|
||||
return await fs.promises.readFile(path, 'utf8')
|
||||
} catch (err) {
|
||||
if (n !== tries) {
|
||||
if (err.code === 'ENOENT' || err.code === 'EBUSY') {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function drainStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let result = ''
|
||||
process.stdin.on('data', (chunk) => {
|
||||
result += chunk
|
||||
})
|
||||
process.stdin.on('end', () => resolve(result))
|
||||
process.stdin.on('error', (err) => reject(err))
|
||||
})
|
||||
}
|
||||
|
||||
export async function outputFile(file, newContents) {
|
||||
try {
|
||||
let currentContents = await fs.promises.readFile(file, 'utf8')
|
||||
if (currentContents === newContents) {
|
||||
return // Skip writing the file
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// Write the file
|
||||
await fs.promises.mkdir(path.dirname(file), { recursive: true })
|
||||
await fs.promises.writeFile(file, newContents, 'utf8')
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A CC","548":"B"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","516":"C K L G M N O"},C:{"1":"cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB I v J D E F EC FC","676":"0 1 2 3 4 5 6 7 8 9 A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB","1700":"NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB"},D:{"1":"jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"I v J D E F A B C K L","676":"G M N O w","804":"0 1 2 3 4 5 6 7 8 9 g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB"},E:{"1":"9B OC","2":"I v HC zB","548":"3B 4B 5B sB 6B 7B 8B","676":"IC","804":"J D E F A B C K L G JC KC LC 0B qB rB 1B MC NC 2B"},F:{"1":"cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e rB","2":"F B C PC QC RC SC qB AC TC","804":"0 1 2 3 4 5 6 7 8 9 G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC","2052":"fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D","292":"A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A","548":"B"},O:{"1":"vC"},P:{"1":"g 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","804":"I wC xC yC zC 0C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:1,C:"Full Screen API"};
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Robert Eisele
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_1 = require("http");
|
||||
/**
|
||||
* Error subclass to use when an HTTP application error has occurred.
|
||||
*/
|
||||
class HTTPError extends Error {
|
||||
constructor(statusCode, message = http_1.STATUS_CODES[statusCode]) {
|
||||
super(message);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.statusCode = statusCode;
|
||||
this.code = `E${String(message)
|
||||
.toUpperCase()
|
||||
.replace(/\s+/g, '')}`;
|
||||
}
|
||||
}
|
||||
exports.default = HTTPError;
|
||||
//# sourceMappingURL=http-error.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"has","version":"1.0.3","files":{"package.json":{"checkedAt":1678883669576,"integrity":"sha512-cSD9OHHlA8xfnD4IuBzoScWc11uXsD7gTPW7scVCYxQWS2xhkzgAB3Bz6eRM8h+awz5lAghiYDZmNXAlmc4O7A==","mode":420,"size":1011},"LICENSE-MIT":{"checkedAt":1678883669576,"integrity":"sha512-0ESYkXxGplYvlOttnBf68q3G8260455PNMAvKOgbcVPZKzUynu+JbIUWUY9lEOzQ/8SU7+shxSzLr2wRKOGLUw==","mode":420,"size":1060},"README.md":{"checkedAt":1678883669576,"integrity":"sha512-MFJjiYxPs7Aw+TFyd5H6IdaMzAibH5zV7E07TehtmdVjC3OEDgmvc/zMZOjQTNKgCbJG3vkMFd6ZPG5ra1za0Q==","mode":420,"size":239},"src/index.js":{"checkedAt":1678883669576,"integrity":"sha512-GWVDf5iWfQHMC/aZiGqbe3/xwUmAZI4Wqya9n+XSJVczvwcXE26GEt6EwftiRlTzjZRf+bcipvjWbk7cVYE83w==","mode":420,"size":129},"test/index.js":{"checkedAt":1678883669576,"integrity":"sha512-FSBdXw6CAENHsDPEco0pup8CtJi2JdqqYjxrsY+TOaukQ8VUIBPNw3oSVbGwS66ydEzBbAq+YRyxpEqSOobfoA==","mode":420,"size":331}}}
|
||||
@@ -0,0 +1,75 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const pathType = require('path-type');
|
||||
|
||||
const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
|
||||
|
||||
const getPath = (filepath, cwd) => {
|
||||
const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
|
||||
return path.isAbsolute(pth) ? pth : path.join(cwd, pth);
|
||||
};
|
||||
|
||||
const addExtensions = (file, extensions) => {
|
||||
if (path.extname(file)) {
|
||||
return `**/${file}`;
|
||||
}
|
||||
|
||||
return `**/${file}.${getExtensions(extensions)}`;
|
||||
};
|
||||
|
||||
const getGlob = (directory, options) => {
|
||||
if (options.files && !Array.isArray(options.files)) {
|
||||
throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
|
||||
}
|
||||
|
||||
if (options.extensions && !Array.isArray(options.extensions)) {
|
||||
throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
|
||||
}
|
||||
|
||||
if (options.files && options.extensions) {
|
||||
return options.files.map(x => path.posix.join(directory, addExtensions(x, options.extensions)));
|
||||
}
|
||||
|
||||
if (options.files) {
|
||||
return options.files.map(x => path.posix.join(directory, `**/${x}`));
|
||||
}
|
||||
|
||||
if (options.extensions) {
|
||||
return [path.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
|
||||
}
|
||||
|
||||
return [path.posix.join(directory, '**')];
|
||||
};
|
||||
|
||||
module.exports = async (input, options) => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
...options
|
||||
};
|
||||
|
||||
if (typeof options.cwd !== 'string') {
|
||||
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
||||
}
|
||||
|
||||
const globs = await Promise.all([].concat(input).map(async x => {
|
||||
const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
|
||||
return isDirectory ? getGlob(x, options) : x;
|
||||
}));
|
||||
|
||||
return [].concat.apply([], globs); // eslint-disable-line prefer-spread
|
||||
};
|
||||
|
||||
module.exports.sync = (input, options) => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
...options
|
||||
};
|
||||
|
||||
if (typeof options.cwd !== 'string') {
|
||||
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
||||
}
|
||||
|
||||
const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
|
||||
|
||||
return [].concat.apply([], globs); // eslint-disable-line prefer-spread
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
import { SHA2 } from './_sha2.js';
|
||||
export declare class SHA512 extends SHA2<SHA512> {
|
||||
Ah: number;
|
||||
Al: number;
|
||||
Bh: number;
|
||||
Bl: number;
|
||||
Ch: number;
|
||||
Cl: number;
|
||||
Dh: number;
|
||||
Dl: number;
|
||||
Eh: number;
|
||||
El: number;
|
||||
Fh: number;
|
||||
Fl: number;
|
||||
Gh: number;
|
||||
Gl: number;
|
||||
Hh: number;
|
||||
Hl: number;
|
||||
constructor();
|
||||
protected get(): [
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number
|
||||
];
|
||||
protected set(Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number, Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number): void;
|
||||
protected process(view: DataView, offset: number): void;
|
||||
protected roundClean(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare const sha512: {
|
||||
(message: import("./utils.js").Input): Uint8Array;
|
||||
outputLen: number;
|
||||
blockLen: number;
|
||||
create(): import("./utils.js").Hash<SHA512>;
|
||||
};
|
||||
export declare const sha512_224: {
|
||||
(message: import("./utils.js").Input): Uint8Array;
|
||||
outputLen: number;
|
||||
blockLen: number;
|
||||
create(): import("./utils.js").Hash<SHA512>;
|
||||
};
|
||||
export declare const sha512_256: {
|
||||
(message: import("./utils.js").Input): Uint8Array;
|
||||
outputLen: number;
|
||||
blockLen: number;
|
||||
create(): import("./utils.js").Hash<SHA512>;
|
||||
};
|
||||
export declare const sha384: {
|
||||
(message: import("./utils.js").Input): Uint8Array;
|
||||
outputLen: number;
|
||||
blockLen: number;
|
||||
create(): import("./utils.js").Hash<SHA512>;
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var common = require('./common');
|
||||
|
||||
|
||||
// get snippet for a single line, respecting maxLength
|
||||
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
||||
var head = '';
|
||||
var tail = '';
|
||||
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
||||
|
||||
if (position - lineStart > maxHalfLength) {
|
||||
head = ' ... ';
|
||||
lineStart = position - maxHalfLength + head.length;
|
||||
}
|
||||
|
||||
if (lineEnd - position > maxHalfLength) {
|
||||
tail = ' ...';
|
||||
lineEnd = position + maxHalfLength - tail.length;
|
||||
}
|
||||
|
||||
return {
|
||||
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,
|
||||
pos: position - lineStart + head.length // relative position
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function padStart(string, max) {
|
||||
return common.repeat(' ', max - string.length) + string;
|
||||
}
|
||||
|
||||
|
||||
function makeSnippet(mark, options) {
|
||||
options = Object.create(options || null);
|
||||
|
||||
if (!mark.buffer) return null;
|
||||
|
||||
if (!options.maxLength) options.maxLength = 79;
|
||||
if (typeof options.indent !== 'number') options.indent = 1;
|
||||
if (typeof options.linesBefore !== 'number') options.linesBefore = 3;
|
||||
if (typeof options.linesAfter !== 'number') options.linesAfter = 2;
|
||||
|
||||
var re = /\r?\n|\r|\0/g;
|
||||
var lineStarts = [ 0 ];
|
||||
var lineEnds = [];
|
||||
var match;
|
||||
var foundLineNo = -1;
|
||||
|
||||
while ((match = re.exec(mark.buffer))) {
|
||||
lineEnds.push(match.index);
|
||||
lineStarts.push(match.index + match[0].length);
|
||||
|
||||
if (mark.position <= match.index && foundLineNo < 0) {
|
||||
foundLineNo = lineStarts.length - 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
||||
|
||||
var result = '', i, line;
|
||||
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
||||
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
||||
|
||||
for (i = 1; i <= options.linesBefore; i++) {
|
||||
if (foundLineNo - i < 0) break;
|
||||
line = getLine(
|
||||
mark.buffer,
|
||||
lineStarts[foundLineNo - i],
|
||||
lineEnds[foundLineNo - i],
|
||||
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
||||
maxLineLength
|
||||
);
|
||||
result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) +
|
||||
' | ' + line.str + '\n' + result;
|
||||
}
|
||||
|
||||
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
||||
result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) +
|
||||
' | ' + line.str + '\n';
|
||||
result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n';
|
||||
|
||||
for (i = 1; i <= options.linesAfter; i++) {
|
||||
if (foundLineNo + i >= lineEnds.length) break;
|
||||
line = getLine(
|
||||
mark.buffer,
|
||||
lineStarts[foundLineNo + i],
|
||||
lineEnds[foundLineNo + i],
|
||||
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
||||
maxLineLength
|
||||
);
|
||||
result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) +
|
||||
' | ' + line.str + '\n';
|
||||
}
|
||||
|
||||
return result.replace(/\n$/, '');
|
||||
}
|
||||
|
||||
|
||||
module.exports = makeSnippet;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F CC","33":"A B"},B:{"1":"r s t u f H","33":"C K L G M N O","132":"P Q R S T U V W","260":"X Y Z a b c d e i j k l m n o p q"},C:{"1":"JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB I v EC FC","33":"0 1 2 3 4 5 6 7 8 9 J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB"},D:{"1":"X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB","132":"VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W"},E:{"2":"I v HC zB","33":"J D E F A B C K L G IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"1":"a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB PC QC RC SC qB AC TC rB","132":"IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z"},G:{"2":"zB UC","33":"E BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"4":"vC"},P:{"1":"g xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I","132":"wC"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:4,C:"CSS Hyphenation"};
|
||||
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isIMEI;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var imeiRegexWithoutHypens = /^[0-9]{15}$/;
|
||||
var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
|
||||
|
||||
function isIMEI(str, options) {
|
||||
(0, _assertString.default)(str);
|
||||
options = options || {}; // default regex for checking imei is the one without hyphens
|
||||
|
||||
var imeiRegex = imeiRegexWithoutHypens;
|
||||
|
||||
if (options.allow_hyphens) {
|
||||
imeiRegex = imeiRegexWithHypens;
|
||||
}
|
||||
|
||||
if (!imeiRegex.test(str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
str = str.replace(/-/g, '');
|
||||
var sum = 0,
|
||||
mul = 2,
|
||||
l = 14;
|
||||
|
||||
for (var i = 0; i < l; i++) {
|
||||
var digit = str.substring(l - i - 1, l - i);
|
||||
var tp = parseInt(digit, 10) * mul;
|
||||
|
||||
if (tp >= 10) {
|
||||
sum += tp % 10 + 1;
|
||||
} else {
|
||||
sum += tp;
|
||||
}
|
||||
|
||||
if (mul === 1) {
|
||||
mul += 1;
|
||||
} else {
|
||||
mul -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
var chk = (10 - sum % 10) % 10;
|
||||
|
||||
if (chk !== parseInt(str.substring(14, 15), 10)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "onetime",
|
||||
"version": "6.0.0",
|
||||
"description": "Ensure a function is only called once",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/onetime",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"once",
|
||||
"function",
|
||||
"one",
|
||||
"onetime",
|
||||
"func",
|
||||
"fn",
|
||||
"single",
|
||||
"call",
|
||||
"called",
|
||||
"prevent"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-fn": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.38.2"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _node = _interopRequireDefault(require("./node"));
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
var Nesting = /*#__PURE__*/function (_Node) {
|
||||
_inheritsLoose(Nesting, _Node);
|
||||
|
||||
function Nesting(opts) {
|
||||
var _this;
|
||||
|
||||
_this = _Node.call(this, opts) || this;
|
||||
_this.type = _types.NESTING;
|
||||
_this.value = '&';
|
||||
return _this;
|
||||
}
|
||||
|
||||
return Nesting;
|
||||
}(_node["default"]);
|
||||
|
||||
exports["default"] = Nesting;
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,167 @@
|
||||
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
|
||||
import { operate } from '../util/lift';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
import { identity } from '../util/identity';
|
||||
import { timer } from '../observable/timer';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
|
||||
/**
|
||||
* The {@link retry} operator configuration object. `retry` either accepts a `number`
|
||||
* or an object described by this interface.
|
||||
*/
|
||||
export interface RetryConfig {
|
||||
/**
|
||||
* The maximum number of times to retry. If `count` is omitted, `retry` will try to
|
||||
* resubscribe on errors infinite number of times.
|
||||
*/
|
||||
count?: number;
|
||||
/**
|
||||
* The number of milliseconds to delay before retrying, OR a function to
|
||||
* return a notifier for delaying. If a function is given, that function should
|
||||
* return a notifier that, when it emits will retry the source. If the notifier
|
||||
* completes _without_ emitting, the resulting observable will complete without error,
|
||||
* if the notifier errors, the error will be pushed to the result.
|
||||
*/
|
||||
delay?: number | ((error: any, retryCount: number) => ObservableInput<any>);
|
||||
/**
|
||||
* Whether or not to reset the retry counter when the retried subscription
|
||||
* emits its first value.
|
||||
*/
|
||||
resetOnSuccess?: boolean;
|
||||
}
|
||||
|
||||
export function retry<T>(count?: number): MonoTypeOperatorFunction<T>;
|
||||
export function retry<T>(config: RetryConfig): MonoTypeOperatorFunction<T>;
|
||||
|
||||
/**
|
||||
* Returns an Observable that mirrors the source Observable with the exception of an `error`.
|
||||
*
|
||||
* If the source Observable calls `error`, this method will resubscribe to the source Observable for a maximum of
|
||||
* `count` resubscriptions rather than propagating the `error` call.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* The number of retries is determined by the `count` parameter. It can be set either by passing a number to
|
||||
* `retry` function or by setting `count` property when `retry` is configured using {@link RetryConfig}. If
|
||||
* `count` is omitted, `retry` will try to resubscribe on errors infinite number of times.
|
||||
*
|
||||
* Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those
|
||||
* emitted during failed subscriptions. For example, if an Observable fails at first but emits `[1, 2]` then
|
||||
* succeeds the second time and emits: `[1, 2, 3, 4, 5, complete]` then the complete stream of emissions and
|
||||
* notifications would be: `[1, 2, 1, 2, 3, 4, 5, complete]`.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, mergeMap, throwError, of, retry } from 'rxjs';
|
||||
*
|
||||
* const source = interval(1000);
|
||||
* const result = source.pipe(
|
||||
* mergeMap(val => val > 5 ? throwError(() => 'Error!') : of(val)),
|
||||
* retry(2) // retry 2 times on error
|
||||
* );
|
||||
*
|
||||
* result.subscribe({
|
||||
* next: value => console.log(value),
|
||||
* error: err => console.log(`${ err }: Retried 2 times then quit!`)
|
||||
* });
|
||||
*
|
||||
* // Output:
|
||||
* // 0..1..2..3..4..5..
|
||||
* // 0..1..2..3..4..5..
|
||||
* // 0..1..2..3..4..5..
|
||||
* // 'Error!: Retried 2 times then quit!'
|
||||
* ```
|
||||
*
|
||||
* @see {@link retryWhen}
|
||||
*
|
||||
* @param configOrCount - Either number of retry attempts before failing or a {@link RetryConfig} object.
|
||||
* @return A function that returns an Observable that will resubscribe to the
|
||||
* source stream when the source stream errors, at most `count` times.
|
||||
*/
|
||||
export function retry<T>(configOrCount: number | RetryConfig = Infinity): MonoTypeOperatorFunction<T> {
|
||||
let config: RetryConfig;
|
||||
if (configOrCount && typeof configOrCount === 'object') {
|
||||
config = configOrCount;
|
||||
} else {
|
||||
config = {
|
||||
count: configOrCount as number,
|
||||
};
|
||||
}
|
||||
const { count = Infinity, delay, resetOnSuccess: resetOnSuccess = false } = config;
|
||||
|
||||
return count <= 0
|
||||
? identity
|
||||
: operate((source, subscriber) => {
|
||||
let soFar = 0;
|
||||
let innerSub: Subscription | null;
|
||||
const subscribeForRetry = () => {
|
||||
let syncUnsub = false;
|
||||
innerSub = source.subscribe(
|
||||
createOperatorSubscriber(
|
||||
subscriber,
|
||||
(value) => {
|
||||
// If we're resetting on success
|
||||
if (resetOnSuccess) {
|
||||
soFar = 0;
|
||||
}
|
||||
subscriber.next(value);
|
||||
},
|
||||
// Completions are passed through to consumer.
|
||||
undefined,
|
||||
(err) => {
|
||||
if (soFar++ < count) {
|
||||
// We are still under our retry count
|
||||
const resub = () => {
|
||||
if (innerSub) {
|
||||
innerSub.unsubscribe();
|
||||
innerSub = null;
|
||||
subscribeForRetry();
|
||||
} else {
|
||||
syncUnsub = true;
|
||||
}
|
||||
};
|
||||
|
||||
if (delay != null) {
|
||||
// The user specified a retry delay.
|
||||
// They gave us a number, use a timer, otherwise, it's a function,
|
||||
// and we're going to call it to get a notifier.
|
||||
const notifier = typeof delay === 'number' ? timer(delay) : innerFrom(delay(err, soFar));
|
||||
const notifierSubscriber = createOperatorSubscriber(
|
||||
subscriber,
|
||||
() => {
|
||||
// After we get the first notification, we
|
||||
// unsubscribe from the notifier, because we don't want anymore
|
||||
// and we resubscribe to the source.
|
||||
notifierSubscriber.unsubscribe();
|
||||
resub();
|
||||
},
|
||||
() => {
|
||||
// The notifier completed without emitting.
|
||||
// The author is telling us they want to complete.
|
||||
subscriber.complete();
|
||||
}
|
||||
);
|
||||
notifier.subscribe(notifierSubscriber);
|
||||
} else {
|
||||
// There was no notifier given. Just resub immediately.
|
||||
resub();
|
||||
}
|
||||
} else {
|
||||
// We're past our maximum number of retries.
|
||||
// Just send along the error.
|
||||
subscriber.error(err);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
if (syncUnsub) {
|
||||
innerSub.unsubscribe();
|
||||
innerSub = null;
|
||||
subscribeForRetry();
|
||||
}
|
||||
};
|
||||
subscribeForRetry();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').forEachSeries;
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var ToInt32 = require('../ToInt32');
|
||||
var ToUint32 = require('../ToUint32');
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-number-leftShift
|
||||
|
||||
module.exports = function NumberLeftShift(x, y) {
|
||||
if (Type(x) !== 'Number' || Type(y) !== 'Number') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
|
||||
}
|
||||
|
||||
var lnum = ToInt32(x);
|
||||
var rnum = ToUint32(y);
|
||||
|
||||
var shiftCount = rnum & 0x1F;
|
||||
|
||||
return lnum << shiftCount;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { combineLatestAll } from './combineLatestAll';
|
||||
|
||||
/**
|
||||
* @deprecated Renamed to {@link combineLatestAll}. Will be removed in v8.
|
||||
*/
|
||||
export const combineAll = combineLatestAll;
|
||||
@@ -0,0 +1,46 @@
|
||||
# is-set <sup>[![Version Badge][2]][1]</sup>
|
||||
|
||||
[![dependency status][5]][6]
|
||||
[![dev dependency status][7]][8]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][11]][1]
|
||||
|
||||
Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var isSet = require('is-set');
|
||||
assert(!isSet(function () {}));
|
||||
assert(!isSet(null));
|
||||
assert(!isSet(function* () { yield 42; return Infinity; });
|
||||
assert(!isSet(Symbol('foo')));
|
||||
assert(!isSet(1n));
|
||||
assert(!isSet(Object(1n)));
|
||||
|
||||
assert(!isSet(new Map()));
|
||||
assert(!isSet(new WeakSet()));
|
||||
assert(!isSet(new WeakMap()));
|
||||
|
||||
assert(isSet(new Set()));
|
||||
|
||||
class MySet extends Set {}
|
||||
assert(isSet(new MySet()));
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[1]: https://npmjs.org/package/is-set
|
||||
[2]: https://versionbadg.es/inspect-js/is-set.svg
|
||||
[5]: https://david-dm.org/inspect-js/is-set.svg
|
||||
[6]: https://david-dm.org/inspect-js/is-set
|
||||
[7]: https://david-dm.org/inspect-js/is-set/dev-status.svg
|
||||
[8]: https://david-dm.org/inspect-js/is-set#info=devDependencies
|
||||
[11]: https://nodei.co/npm/is-set.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/is-set.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/is-set.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=is-set
|
||||
@@ -0,0 +1,173 @@
|
||||
/// <reference path="operators/index.d.ts" />
|
||||
/// <reference path="testing/index.d.ts" />
|
||||
export { Observable } from './internal/Observable';
|
||||
export { ConnectableObservable } from './internal/observable/ConnectableObservable';
|
||||
export { GroupedObservable } from './internal/operators/groupBy';
|
||||
export { Operator } from './internal/Operator';
|
||||
export { observable } from './internal/symbol/observable';
|
||||
export { animationFrames } from './internal/observable/dom/animationFrames';
|
||||
export { Subject } from './internal/Subject';
|
||||
export { BehaviorSubject } from './internal/BehaviorSubject';
|
||||
export { ReplaySubject } from './internal/ReplaySubject';
|
||||
export { AsyncSubject } from './internal/AsyncSubject';
|
||||
export { asap, asapScheduler } from './internal/scheduler/asap';
|
||||
export { async, asyncScheduler } from './internal/scheduler/async';
|
||||
export { queue, queueScheduler } from './internal/scheduler/queue';
|
||||
export { animationFrame, animationFrameScheduler } from './internal/scheduler/animationFrame';
|
||||
export { VirtualTimeScheduler, VirtualAction } from './internal/scheduler/VirtualTimeScheduler';
|
||||
export { Scheduler } from './internal/Scheduler';
|
||||
export { Subscription } from './internal/Subscription';
|
||||
export { Subscriber } from './internal/Subscriber';
|
||||
export { Notification, NotificationKind } from './internal/Notification';
|
||||
export { pipe } from './internal/util/pipe';
|
||||
export { noop } from './internal/util/noop';
|
||||
export { identity } from './internal/util/identity';
|
||||
export { isObservable } from './internal/util/isObservable';
|
||||
export { lastValueFrom } from './internal/lastValueFrom';
|
||||
export { firstValueFrom } from './internal/firstValueFrom';
|
||||
export { ArgumentOutOfRangeError } from './internal/util/ArgumentOutOfRangeError';
|
||||
export { EmptyError } from './internal/util/EmptyError';
|
||||
export { NotFoundError } from './internal/util/NotFoundError';
|
||||
export { ObjectUnsubscribedError } from './internal/util/ObjectUnsubscribedError';
|
||||
export { SequenceError } from './internal/util/SequenceError';
|
||||
export { TimeoutError } from './internal/operators/timeout';
|
||||
export { UnsubscriptionError } from './internal/util/UnsubscriptionError';
|
||||
export { bindCallback } from './internal/observable/bindCallback';
|
||||
export { bindNodeCallback } from './internal/observable/bindNodeCallback';
|
||||
export { combineLatest } from './internal/observable/combineLatest';
|
||||
export { concat } from './internal/observable/concat';
|
||||
export { connectable } from './internal/observable/connectable';
|
||||
export { defer } from './internal/observable/defer';
|
||||
export { empty } from './internal/observable/empty';
|
||||
export { forkJoin } from './internal/observable/forkJoin';
|
||||
export { from } from './internal/observable/from';
|
||||
export { fromEvent } from './internal/observable/fromEvent';
|
||||
export { fromEventPattern } from './internal/observable/fromEventPattern';
|
||||
export { generate } from './internal/observable/generate';
|
||||
export { iif } from './internal/observable/iif';
|
||||
export { interval } from './internal/observable/interval';
|
||||
export { merge } from './internal/observable/merge';
|
||||
export { never } from './internal/observable/never';
|
||||
export { of } from './internal/observable/of';
|
||||
export { onErrorResumeNext } from './internal/observable/onErrorResumeNext';
|
||||
export { pairs } from './internal/observable/pairs';
|
||||
export { partition } from './internal/observable/partition';
|
||||
export { race } from './internal/observable/race';
|
||||
export { range } from './internal/observable/range';
|
||||
export { throwError } from './internal/observable/throwError';
|
||||
export { timer } from './internal/observable/timer';
|
||||
export { using } from './internal/observable/using';
|
||||
export { zip } from './internal/observable/zip';
|
||||
export { scheduled } from './internal/scheduled/scheduled';
|
||||
export { EMPTY } from './internal/observable/empty';
|
||||
export { NEVER } from './internal/observable/never';
|
||||
export * from './internal/types';
|
||||
export { config, GlobalConfig } from './internal/config';
|
||||
export { audit } from './internal/operators/audit';
|
||||
export { auditTime } from './internal/operators/auditTime';
|
||||
export { buffer } from './internal/operators/buffer';
|
||||
export { bufferCount } from './internal/operators/bufferCount';
|
||||
export { bufferTime } from './internal/operators/bufferTime';
|
||||
export { bufferToggle } from './internal/operators/bufferToggle';
|
||||
export { bufferWhen } from './internal/operators/bufferWhen';
|
||||
export { catchError } from './internal/operators/catchError';
|
||||
export { combineAll } from './internal/operators/combineAll';
|
||||
export { combineLatestAll } from './internal/operators/combineLatestAll';
|
||||
export { combineLatestWith } from './internal/operators/combineLatestWith';
|
||||
export { concatAll } from './internal/operators/concatAll';
|
||||
export { concatMap } from './internal/operators/concatMap';
|
||||
export { concatMapTo } from './internal/operators/concatMapTo';
|
||||
export { concatWith } from './internal/operators/concatWith';
|
||||
export { connect, ConnectConfig } from './internal/operators/connect';
|
||||
export { count } from './internal/operators/count';
|
||||
export { debounce } from './internal/operators/debounce';
|
||||
export { debounceTime } from './internal/operators/debounceTime';
|
||||
export { defaultIfEmpty } from './internal/operators/defaultIfEmpty';
|
||||
export { delay } from './internal/operators/delay';
|
||||
export { delayWhen } from './internal/operators/delayWhen';
|
||||
export { dematerialize } from './internal/operators/dematerialize';
|
||||
export { distinct } from './internal/operators/distinct';
|
||||
export { distinctUntilChanged } from './internal/operators/distinctUntilChanged';
|
||||
export { distinctUntilKeyChanged } from './internal/operators/distinctUntilKeyChanged';
|
||||
export { elementAt } from './internal/operators/elementAt';
|
||||
export { endWith } from './internal/operators/endWith';
|
||||
export { every } from './internal/operators/every';
|
||||
export { exhaust } from './internal/operators/exhaust';
|
||||
export { exhaustAll } from './internal/operators/exhaustAll';
|
||||
export { exhaustMap } from './internal/operators/exhaustMap';
|
||||
export { expand } from './internal/operators/expand';
|
||||
export { filter } from './internal/operators/filter';
|
||||
export { finalize } from './internal/operators/finalize';
|
||||
export { find } from './internal/operators/find';
|
||||
export { findIndex } from './internal/operators/findIndex';
|
||||
export { first } from './internal/operators/first';
|
||||
export { groupBy, BasicGroupByOptions, GroupByOptionsWithElement } from './internal/operators/groupBy';
|
||||
export { ignoreElements } from './internal/operators/ignoreElements';
|
||||
export { isEmpty } from './internal/operators/isEmpty';
|
||||
export { last } from './internal/operators/last';
|
||||
export { map } from './internal/operators/map';
|
||||
export { mapTo } from './internal/operators/mapTo';
|
||||
export { materialize } from './internal/operators/materialize';
|
||||
export { max } from './internal/operators/max';
|
||||
export { mergeAll } from './internal/operators/mergeAll';
|
||||
export { flatMap } from './internal/operators/flatMap';
|
||||
export { mergeMap } from './internal/operators/mergeMap';
|
||||
export { mergeMapTo } from './internal/operators/mergeMapTo';
|
||||
export { mergeScan } from './internal/operators/mergeScan';
|
||||
export { mergeWith } from './internal/operators/mergeWith';
|
||||
export { min } from './internal/operators/min';
|
||||
export { multicast } from './internal/operators/multicast';
|
||||
export { observeOn } from './internal/operators/observeOn';
|
||||
export { onErrorResumeNextWith } from './internal/operators/onErrorResumeNextWith';
|
||||
export { pairwise } from './internal/operators/pairwise';
|
||||
export { pluck } from './internal/operators/pluck';
|
||||
export { publish } from './internal/operators/publish';
|
||||
export { publishBehavior } from './internal/operators/publishBehavior';
|
||||
export { publishLast } from './internal/operators/publishLast';
|
||||
export { publishReplay } from './internal/operators/publishReplay';
|
||||
export { raceWith } from './internal/operators/raceWith';
|
||||
export { reduce } from './internal/operators/reduce';
|
||||
export { repeat, RepeatConfig } from './internal/operators/repeat';
|
||||
export { repeatWhen } from './internal/operators/repeatWhen';
|
||||
export { retry, RetryConfig } from './internal/operators/retry';
|
||||
export { retryWhen } from './internal/operators/retryWhen';
|
||||
export { refCount } from './internal/operators/refCount';
|
||||
export { sample } from './internal/operators/sample';
|
||||
export { sampleTime } from './internal/operators/sampleTime';
|
||||
export { scan } from './internal/operators/scan';
|
||||
export { sequenceEqual } from './internal/operators/sequenceEqual';
|
||||
export { share, ShareConfig } from './internal/operators/share';
|
||||
export { shareReplay, ShareReplayConfig } from './internal/operators/shareReplay';
|
||||
export { single } from './internal/operators/single';
|
||||
export { skip } from './internal/operators/skip';
|
||||
export { skipLast } from './internal/operators/skipLast';
|
||||
export { skipUntil } from './internal/operators/skipUntil';
|
||||
export { skipWhile } from './internal/operators/skipWhile';
|
||||
export { startWith } from './internal/operators/startWith';
|
||||
export { subscribeOn } from './internal/operators/subscribeOn';
|
||||
export { switchAll } from './internal/operators/switchAll';
|
||||
export { switchMap } from './internal/operators/switchMap';
|
||||
export { switchMapTo } from './internal/operators/switchMapTo';
|
||||
export { switchScan } from './internal/operators/switchScan';
|
||||
export { take } from './internal/operators/take';
|
||||
export { takeLast } from './internal/operators/takeLast';
|
||||
export { takeUntil } from './internal/operators/takeUntil';
|
||||
export { takeWhile } from './internal/operators/takeWhile';
|
||||
export { tap } from './internal/operators/tap';
|
||||
export { throttle, ThrottleConfig } from './internal/operators/throttle';
|
||||
export { throttleTime } from './internal/operators/throttleTime';
|
||||
export { throwIfEmpty } from './internal/operators/throwIfEmpty';
|
||||
export { timeInterval } from './internal/operators/timeInterval';
|
||||
export { timeout, TimeoutConfig, TimeoutInfo } from './internal/operators/timeout';
|
||||
export { timeoutWith } from './internal/operators/timeoutWith';
|
||||
export { timestamp } from './internal/operators/timestamp';
|
||||
export { toArray } from './internal/operators/toArray';
|
||||
export { window } from './internal/operators/window';
|
||||
export { windowCount } from './internal/operators/windowCount';
|
||||
export { windowTime } from './internal/operators/windowTime';
|
||||
export { windowToggle } from './internal/operators/windowToggle';
|
||||
export { windowWhen } from './internal/operators/windowWhen';
|
||||
export { withLatestFrom } from './internal/operators/withLatestFrom';
|
||||
export { zipAll } from './internal/operators/zipAll';
|
||||
export { zipWith } from './internal/operators/zipWith';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1,75 @@
|
||||
// This file is generated at pre-commit by running `node create-typings.js`.
|
||||
|
||||
/**
|
||||
* Returns a boolean. Will be `true` if the code is running on a CI server,
|
||||
* otherwise `false`.
|
||||
*
|
||||
* Some CI servers not listed here might still trigger the `ci.isCI`
|
||||
* boolean to be set to `true` if they use certain vendor neutral environment
|
||||
* variables. In those cases `ci.name` will be `null` and no vendor specific
|
||||
* boolean will be set to `true`.
|
||||
*/
|
||||
export const isCI: boolean;
|
||||
/**
|
||||
* Returns a boolean if PR detection is supported for the current CI server.
|
||||
* Will be `true` if a PR is being tested, otherwise `false`. If PR detection is
|
||||
* not supported for the current CI server, the value will be `null`.
|
||||
*/
|
||||
export const isPR: boolean | null;
|
||||
/**
|
||||
* Returns a string containing name of the CI server the code is running on. If
|
||||
* CI server is not detected, it returns `null`.
|
||||
*
|
||||
* Don't depend on the value of this string not to change for a specific vendor.
|
||||
* If you find your self writing `ci.name === 'Travis CI'`, you most likely want
|
||||
* to use `ci.TRAVIS` instead.
|
||||
*/
|
||||
export const name: string | null;
|
||||
|
||||
export const APPCIRCLE: boolean;
|
||||
export const APPVEYOR: boolean;
|
||||
export const CODEBUILD: boolean;
|
||||
export const AZURE_PIPELINES: boolean;
|
||||
export const BAMBOO: boolean;
|
||||
export const BITBUCKET: boolean;
|
||||
export const BITRISE: boolean;
|
||||
export const BUDDY: boolean;
|
||||
export const BUILDKITE: boolean;
|
||||
export const CIRCLE: boolean;
|
||||
export const CIRRUS: boolean;
|
||||
export const CODEFRESH: boolean;
|
||||
export const CODEMAGIC: boolean;
|
||||
export const CODESHIP: boolean;
|
||||
export const DRONE: boolean;
|
||||
export const DSARI: boolean;
|
||||
export const EAS: boolean;
|
||||
export const GERRIT: boolean;
|
||||
export const GITHUB_ACTIONS: boolean;
|
||||
export const GITLAB: boolean;
|
||||
export const GOCD: boolean;
|
||||
export const GOOGLE_CLOUD_BUILD: boolean;
|
||||
export const HARNESS: boolean;
|
||||
export const HEROKU: boolean;
|
||||
export const HUDSON: boolean;
|
||||
export const JENKINS: boolean;
|
||||
export const LAYERCI: boolean;
|
||||
export const MAGNUM: boolean;
|
||||
export const NETLIFY: boolean;
|
||||
export const NEVERCODE: boolean;
|
||||
export const RELEASEHUB: boolean;
|
||||
export const RENDER: boolean;
|
||||
export const SAIL: boolean;
|
||||
export const SCREWDRIVER: boolean;
|
||||
export const SEMAPHORE: boolean;
|
||||
export const SHIPPABLE: boolean;
|
||||
export const SOLANO: boolean;
|
||||
export const SOURCEHUT: boolean;
|
||||
export const STRIDER: boolean;
|
||||
export const TASKCLUSTER: boolean;
|
||||
export const TEAMCITY: boolean;
|
||||
export const TRAVIS: boolean;
|
||||
export const VERCEL: boolean;
|
||||
export const APPCENTER: boolean;
|
||||
export const WOODPECKER: boolean;
|
||||
export const XCODE_CLOUD: boolean;
|
||||
export const XCODE_SERVER: boolean;
|
||||
@@ -0,0 +1,2 @@
|
||||
if(typeof cptable === 'undefined') cptable = {};
|
||||
cptable[708] = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~│┤éâ╡à╢çêëèïî╖╕╣║╗╝ô╜╛ûù┐└┴┬├¤─┼╞╟╚╔╩،╦«»░▒▓╠═╬╧╨╤╥╙؛╘╒╓؟╫ءآأؤإئابةتثجحخدذرزسشصضطظعغ█▄▌▐▀ـفقكلمنهوىيًٌٍَُِّْ╪┘┌µ£■ ", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();
|
||||
@@ -0,0 +1,31 @@
|
||||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseUniq = require('./_baseUniq');
|
||||
|
||||
/**
|
||||
* This method is like `_.uniq` except that it accepts `iteratee` which is
|
||||
* invoked for each element in `array` to generate the criterion by which
|
||||
* uniqueness is computed. The order of result values is determined by the
|
||||
* order they occur in the array. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
* @example
|
||||
*
|
||||
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
|
||||
* // => [2.1, 1.2]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
||||
* // => [{ 'x': 1 }, { 'x': 2 }]
|
||||
*/
|
||||
function uniqBy(array, iteratee) {
|
||||
return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
|
||||
}
|
||||
|
||||
module.exports = uniqBy;
|
||||
@@ -0,0 +1,43 @@
|
||||
import type {IsEqual, Subtract} from './internal';
|
||||
|
||||
type Recursive<T> = Array<Recursive<T>>;
|
||||
|
||||
/**
|
||||
Creates a type that represents a multidimensional array of the given type and dimension.
|
||||
|
||||
Use-cases:
|
||||
- Return a n-dimensional array from functions.
|
||||
- Declare a n-dimensional array by defining its dimensions rather than declaring `[]` repetitively.
|
||||
- Infer the dimensions of a n-dimensional array automatically from function arguments.
|
||||
- Avoid the need to know in advance the dimensions of a n-dimensional array allowing them to be dynamic.
|
||||
|
||||
@example
|
||||
```
|
||||
import type {MultidimensionalArray} from 'type-fest';
|
||||
|
||||
function emptyMatrix<T extends number>(dimensions: T): MultidimensionalArray<unknown, T> {
|
||||
const matrix: unknown[] = [];
|
||||
|
||||
let subMatrix = matrix;
|
||||
for (let dimension = 1; dimension < dimensions; ++dimension) {
|
||||
console.log(`Initializing dimension #${dimension}`);
|
||||
|
||||
subMatrix[0] = [];
|
||||
subMatrix = subMatrix[0] as unknown[];
|
||||
}
|
||||
|
||||
return matrix as MultidimensionalArray<unknown, T>;
|
||||
}
|
||||
|
||||
const matrix = emptyMatrix(3);
|
||||
|
||||
matrix[0][0][0] = 42;
|
||||
```
|
||||
|
||||
@category Array
|
||||
*/
|
||||
export type MultidimensionalArray<Element, Dimensions extends number> = number extends Dimensions
|
||||
? Recursive<Element>
|
||||
: IsEqual<Dimensions, 0> extends true
|
||||
? Element
|
||||
: Array<MultidimensionalArray<Element, Subtract<Dimensions, 1>>>;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { combineLatestAll } from './combineLatestAll';
|
||||
/**
|
||||
* @deprecated Renamed to {@link combineLatestAll}. Will be removed in v8.
|
||||
*/
|
||||
export declare const combineAll: typeof combineLatestAll;
|
||||
//# sourceMappingURL=combineAll.d.ts.map
|
||||
Reference in New Issue
Block a user