new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
|
||||
const path = require("path");
|
||||
const globParent = require("glob-parent");
|
||||
const micromatch = require("micromatch");
|
||||
const GLOBSTAR = '**';
|
||||
const ESCAPE_SYMBOL = '\\';
|
||||
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
||||
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
|
||||
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
|
||||
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
|
||||
const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
|
||||
function isStaticPattern(pattern, options = {}) {
|
||||
return !isDynamicPattern(pattern, options);
|
||||
}
|
||||
exports.isStaticPattern = isStaticPattern;
|
||||
function isDynamicPattern(pattern, options = {}) {
|
||||
/**
|
||||
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
||||
* An empty string cannot be a dynamic pattern.
|
||||
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
||||
*/
|
||||
if (pattern === '') {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
||||
* filepath directly (without read directory).
|
||||
*/
|
||||
if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
|
||||
return true;
|
||||
}
|
||||
if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
|
||||
return true;
|
||||
}
|
||||
if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
|
||||
return true;
|
||||
}
|
||||
if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isDynamicPattern = isDynamicPattern;
|
||||
function hasBraceExpansion(pattern) {
|
||||
const openingBraceIndex = pattern.indexOf('{');
|
||||
if (openingBraceIndex === -1) {
|
||||
return false;
|
||||
}
|
||||
const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
|
||||
if (closingBraceIndex === -1) {
|
||||
return false;
|
||||
}
|
||||
const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
|
||||
return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
|
||||
}
|
||||
function convertToPositivePattern(pattern) {
|
||||
return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
|
||||
}
|
||||
exports.convertToPositivePattern = convertToPositivePattern;
|
||||
function convertToNegativePattern(pattern) {
|
||||
return '!' + pattern;
|
||||
}
|
||||
exports.convertToNegativePattern = convertToNegativePattern;
|
||||
function isNegativePattern(pattern) {
|
||||
return pattern.startsWith('!') && pattern[1] !== '(';
|
||||
}
|
||||
exports.isNegativePattern = isNegativePattern;
|
||||
function isPositivePattern(pattern) {
|
||||
return !isNegativePattern(pattern);
|
||||
}
|
||||
exports.isPositivePattern = isPositivePattern;
|
||||
function getNegativePatterns(patterns) {
|
||||
return patterns.filter(isNegativePattern);
|
||||
}
|
||||
exports.getNegativePatterns = getNegativePatterns;
|
||||
function getPositivePatterns(patterns) {
|
||||
return patterns.filter(isPositivePattern);
|
||||
}
|
||||
exports.getPositivePatterns = getPositivePatterns;
|
||||
/**
|
||||
* Returns patterns that can be applied inside the current directory.
|
||||
*
|
||||
* @example
|
||||
* // ['./*', '*', 'a/*']
|
||||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
||||
*/
|
||||
function getPatternsInsideCurrentDirectory(patterns) {
|
||||
return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
|
||||
}
|
||||
exports.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
|
||||
/**
|
||||
* Returns patterns to be expanded relative to (outside) the current directory.
|
||||
*
|
||||
* @example
|
||||
* // ['../*', './../*']
|
||||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
||||
*/
|
||||
function getPatternsOutsideCurrentDirectory(patterns) {
|
||||
return patterns.filter(isPatternRelatedToParentDirectory);
|
||||
}
|
||||
exports.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
|
||||
function isPatternRelatedToParentDirectory(pattern) {
|
||||
return pattern.startsWith('..') || pattern.startsWith('./..');
|
||||
}
|
||||
exports.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
|
||||
function getBaseDirectory(pattern) {
|
||||
return globParent(pattern, { flipBackslashes: false });
|
||||
}
|
||||
exports.getBaseDirectory = getBaseDirectory;
|
||||
function hasGlobStar(pattern) {
|
||||
return pattern.includes(GLOBSTAR);
|
||||
}
|
||||
exports.hasGlobStar = hasGlobStar;
|
||||
function endsWithSlashGlobStar(pattern) {
|
||||
return pattern.endsWith('/' + GLOBSTAR);
|
||||
}
|
||||
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
||||
function isAffectDepthOfReadingPattern(pattern) {
|
||||
const basename = path.basename(pattern);
|
||||
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
||||
}
|
||||
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
||||
function expandPatternsWithBraceExpansion(patterns) {
|
||||
return patterns.reduce((collection, pattern) => {
|
||||
return collection.concat(expandBraceExpansion(pattern));
|
||||
}, []);
|
||||
}
|
||||
exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
||||
function expandBraceExpansion(pattern) {
|
||||
return micromatch.braces(pattern, {
|
||||
expand: true,
|
||||
nodupes: true
|
||||
});
|
||||
}
|
||||
exports.expandBraceExpansion = expandBraceExpansion;
|
||||
function getPatternParts(pattern, options) {
|
||||
let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
|
||||
/**
|
||||
* The scan method returns an empty array in some cases.
|
||||
* See micromatch/picomatch#58 for more details.
|
||||
*/
|
||||
if (parts.length === 0) {
|
||||
parts = [pattern];
|
||||
}
|
||||
/**
|
||||
* The scan method does not return an empty part for the pattern with a forward slash.
|
||||
* This is another part of micromatch/picomatch#58.
|
||||
*/
|
||||
if (parts[0].startsWith('/')) {
|
||||
parts[0] = parts[0].slice(1);
|
||||
parts.unshift('');
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
exports.getPatternParts = getPatternParts;
|
||||
function makeRe(pattern, options) {
|
||||
return micromatch.makeRe(pattern, options);
|
||||
}
|
||||
exports.makeRe = makeRe;
|
||||
function convertPatternsToRe(patterns, options) {
|
||||
return patterns.map((pattern) => makeRe(pattern, options));
|
||||
}
|
||||
exports.convertPatternsToRe = convertPatternsToRe;
|
||||
function matchAny(entry, patternsRe) {
|
||||
return patternsRe.some((patternRe) => patternRe.test(entry));
|
||||
}
|
||||
exports.matchAny = matchAny;
|
||||
@@ -0,0 +1,156 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $pow = GetIntrinsic('%Math.pow%');
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
|
||||
var hasOwnProperty = require('./HasOwnProperty');
|
||||
var IsArray = require('./IsArray');
|
||||
var IsBigIntElementType = require('./IsBigIntElementType');
|
||||
var IsUnsignedElementType = require('./IsUnsignedElementType');
|
||||
var Type = require('./Type');
|
||||
|
||||
var every = require('../helpers/every');
|
||||
var isByteValue = require('../helpers/isByteValue');
|
||||
|
||||
var $reverse = callBound('Array.prototype.reverse');
|
||||
var $slice = callBound('Array.prototype.slice');
|
||||
|
||||
var keys = require('object-keys');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors
|
||||
var TypeToSizes = {
|
||||
__proto__: null,
|
||||
Int8: 1,
|
||||
Uint8: 1,
|
||||
Uint8C: 1,
|
||||
Int16: 2,
|
||||
Uint16: 2,
|
||||
Int32: 4,
|
||||
Uint32: 4,
|
||||
BigInt64: 8,
|
||||
BigUint64: 8,
|
||||
Float32: 4,
|
||||
Float64: 8
|
||||
};
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-rawbytestonumeric
|
||||
|
||||
module.exports = function RawBytesToNumeric(type, rawBytes, isLittleEndian) {
|
||||
if (!hasOwnProperty(TypeToSizes, type)) {
|
||||
throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes));
|
||||
}
|
||||
if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) {
|
||||
throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes');
|
||||
}
|
||||
if (Type(isLittleEndian) !== 'Boolean') {
|
||||
throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean');
|
||||
}
|
||||
|
||||
var elementSize = TypeToSizes[type]; // step 1
|
||||
|
||||
if (rawBytes.length !== elementSize) {
|
||||
// this assertion is not in the spec, but it'd be an editorial error if it were ever violated
|
||||
throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type);
|
||||
}
|
||||
|
||||
var isBigInt = IsBigIntElementType(type);
|
||||
if (isBigInt && !$BigInt) {
|
||||
throw new $SyntaxError('this environment does not support BigInts');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
rawBytes = $slice(rawBytes, 0, elementSize);
|
||||
if (!isLittleEndian) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
rawBytes = $reverse(rawBytes); // step 2
|
||||
}
|
||||
|
||||
/* eslint no-redeclare: 1 */
|
||||
if (type === 'Float32') { // step 3
|
||||
/*
|
||||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value.
|
||||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value.
|
||||
Return the Number value that corresponds to value.
|
||||
*/
|
||||
var sign = (rawBytes[3] & 0x80) >> 7; // first bit
|
||||
var exponent = ((rawBytes[3] & 0x7F) << 1) // 7 bits from index 3
|
||||
| ((rawBytes[2] & 0x80) >> 7); // 1 bit from index 2
|
||||
var mantissa = ((rawBytes[2] & 0x7F) << 16) // 7 bits from index 2
|
||||
| (rawBytes[1] << 8) // 8 bits from index 1
|
||||
| rawBytes[0]; // 8 bits from index 0
|
||||
|
||||
if (exponent === 0 && mantissa === 0) {
|
||||
return sign === 0 ? 0 : -0;
|
||||
}
|
||||
if (exponent === 0xFF && mantissa === 0) {
|
||||
return sign === 0 ? Infinity : -Infinity;
|
||||
}
|
||||
if (exponent === 0xFF && mantissa !== 0) {
|
||||
return NaN;
|
||||
}
|
||||
|
||||
exponent -= 127; // subtract the bias
|
||||
|
||||
// return $pow(-1, sign) * mantissa / $pow(2, 23) * $pow(2, exponent);
|
||||
// return $pow(-1, sign) * (mantissa + 0x1000000) * $pow(2, exponent - 23);
|
||||
return $pow(-1, sign) * (1 + (mantissa / $pow(2, 23))) * $pow(2, exponent);
|
||||
}
|
||||
|
||||
if (type === 'Float64') { // step 4
|
||||
/*
|
||||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value.
|
||||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value.
|
||||
Return the Number value that corresponds to value.
|
||||
*/
|
||||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit
|
||||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7
|
||||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6
|
||||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6
|
||||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5
|
||||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4
|
||||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3
|
||||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2
|
||||
+ (rawBytes[1] * 0x100) // 8 bits from index 1
|
||||
+ rawBytes[0]; // 8 bits from index 0
|
||||
|
||||
if (exponent === 0 && mantissa === 0) {
|
||||
return sign * 0;
|
||||
}
|
||||
if (exponent === 0x7FF && mantissa !== 0) {
|
||||
return NaN;
|
||||
}
|
||||
if (exponent === 0x7FF && mantissa === 0) {
|
||||
return sign * Infinity;
|
||||
}
|
||||
|
||||
exponent -= 1023; // subtract the bias
|
||||
|
||||
return sign * (mantissa + 0x10000000000000) * $pow(2, exponent - 52);
|
||||
}
|
||||
|
||||
// this is common to both branches
|
||||
var intValue = isBigInt ? $BigInt(0) : 0;
|
||||
for (var i = 0; i < rawBytes.length; i++) {
|
||||
intValue |= isBigInt ? $BigInt(rawBytes[i]) << $BigInt(8 * i) : rawBytes[i] << (8 * i);
|
||||
}
|
||||
/*
|
||||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number.
|
||||
*/
|
||||
|
||||
if (!IsUnsignedElementType(type)) { // steps 5-6
|
||||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8.
|
||||
var bitLength = elementSize * 8;
|
||||
if (bitLength < 32) {
|
||||
var x = isBigInt ? $BigInt(32 - bitLength) : 32 - bitLength;
|
||||
intValue = (intValue << x) >> x;
|
||||
}
|
||||
}
|
||||
|
||||
return intValue; // step 7
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
||||
*/
|
||||
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
||||
/**
|
||||
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
||||
*/
|
||||
export declare type Class<T = unknown, Arguments extends any[] = any[]> = new (...arguments_: Arguments) => T;
|
||||
/**
|
||||
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||
*/
|
||||
export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||
*/
|
||||
export interface ObservableLike {
|
||||
subscribe(observer: (value: unknown) => void): void;
|
||||
[Symbol.observable](): ObservableLike;
|
||||
}
|
||||
export declare type Falsy = false | 0 | 0n | '' | null | undefined;
|
||||
export interface WeakRef<T extends object> {
|
||||
readonly [Symbol.toStringTag]: 'WeakRef';
|
||||
deref(): T | undefined;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
let Value = require('../value')
|
||||
|
||||
class FilterValue extends Value {
|
||||
constructor(name, prefixes) {
|
||||
super(name, prefixes)
|
||||
if (name === 'filter-function') {
|
||||
this.name = 'filter'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterValue.names = ['filter', 'filter-function']
|
||||
|
||||
module.exports = FilterValue
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { PreprocessorGroup, Options } from '../types';
|
||||
declare const _default: (options?: Options.Postcss) => PreprocessorGroup;
|
||||
/** Adapted from https://github.com/TehShrike/svelte-preprocess-postcss */
|
||||
export default _default;
|
||||
@@ -0,0 +1,2 @@
|
||||
import{options as n}from"preact";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var e=u();return t(e)?e.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l()}catch(n){v||(v=n)}finally{i()}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function i(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{u as act,r as setupRerender,i as teardown};
|
||||
//# sourceMappingURL=testUtils.module.js.map
|
||||
@@ -0,0 +1,114 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v1.0.7](https://github.com/inspect-js/is-string/compare/v1.0.6...v1.0.7) - 2021-08-05
|
||||
|
||||
### Commits
|
||||
|
||||
- [Refactor] use `has-tostringtag` to behave correctly in the presence of symbol shams [`d973ffd`](https://github.com/inspect-js/is-string/commit/d973ffd2268e10c0e2cd4f0c57ecf8ce0a8d8578)
|
||||
- [Dev Deps] update `auto-changelog`, `core-js`, `eslint`, `tape` [`4bfaabf`](https://github.com/inspect-js/is-string/commit/4bfaabf877e874ca21d2c44be26f13add8ee2761)
|
||||
|
||||
## [v1.0.6](https://github.com/inspect-js/is-string/compare/v1.0.5...v1.0.6) - 2021-05-07
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] migrate tests to Github Actions [`c7790c8`](https://github.com/inspect-js/is-string/commit/c7790c89e5077251fe7ca32ac29eeee02f1b2751)
|
||||
- [actions] use `node/install` instead of `node/run`; use `codecov` action [`1e52bbd`](https://github.com/inspect-js/is-string/commit/1e52bbd19b1608f6932c0335d9981824584c3186)
|
||||
- [Fix] do not use `Object.prototype.toString` when `Symbol.toStringTag` is shammed [`83337eb`](https://github.com/inspect-js/is-string/commit/83337ebf55308b7bb9c1befae420760e0f8d8016)
|
||||
- [meta] do not publish github action workflow files [`b25aea2`](https://github.com/inspect-js/is-string/commit/b25aea2e8a53ed9e9090cf96481590cdc00a0957)
|
||||
- [readme] update badges [`759ccd9`](https://github.com/inspect-js/is-string/commit/759ccd94de4a2000231a179f91af6b5c12c11e00)
|
||||
- [Tests] run `nyc` on all tests [`dc02f70`](https://github.com/inspect-js/is-string/commit/dc02f7080c355f0d24368c1622db09f7cc30cdbd)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `tape`; add `aud` [`a0f76fa`](https://github.com/inspect-js/is-string/commit/a0f76fa1990bb580948f9e2daa89bdcda3fae7f0)
|
||||
- [actions] add "Allow Edits" workflow [`9ec3902`](https://github.com/inspect-js/is-string/commit/9ec390295b4faef7744d2b579c1050be66168cb7)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`57fbe21`](https://github.com/inspect-js/is-string/commit/57fbe215da83a3b601855a9c6543ad1a96de5702)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`191e55f`](https://github.com/inspect-js/is-string/commit/191e55ff1fa782654ffcce2df922e23345b56690)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`1ea2b81`](https://github.com/inspect-js/is-string/commit/1ea2b81e866775a7890e75c44c742204124aa354)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`105d1b9`](https://github.com/inspect-js/is-string/commit/105d1b9851e366ef23c2a27d4064e0d36da25939)
|
||||
- [Dev Deps] update `auto-changelog`, `tape`; add `aud` [`114cfad`](https://github.com/inspect-js/is-string/commit/114cfad854d8860421f847cd99a3bdb8ef1353dc)
|
||||
- [meta] use `prepublishOnly` script for npm 7+ [`fc38f26`](https://github.com/inspect-js/is-string/commit/fc38f26adb486f50880c5771d145ab2bffb6247a)
|
||||
- [meta] gitignore coverage output [`3419127`](https://github.com/inspect-js/is-string/commit/34191278f1fa09ba4da801a6fd7a32e31050e759)
|
||||
- [actions] update rebase action to use checkout v2 [`334eca0`](https://github.com/inspect-js/is-string/commit/334eca02d40f4cf7dc15a8e7d5ff06852028abb5)
|
||||
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`7a332e9`](https://github.com/inspect-js/is-string/commit/7a332e963f1ab717fafa671e0fa8a1b20c53d861)
|
||||
- [meta] remove explicit audit level config [`04630b1`](https://github.com/inspect-js/is-string/commit/04630b1b535084322ddeae8efb79a8810d7cf325)
|
||||
|
||||
## [v1.0.5](https://github.com/inspect-js/is-string/compare/v1.0.4...v1.0.5) - 2019-12-18
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] use shared travis-ci configs [`4121d6b`](https://github.com/inspect-js/is-string/commit/4121d6b168ae1d54a81791ee6877f9813cab6253)
|
||||
- [Tests] up to `node` `v12.4`, `v11.15`, `v10.15`, `v9.11`, `v8.15`, `v7.10`, `v6.17`, `v5.12`, `v4.9`; use `nvm install-latest-npm` [`e7a3e89`](https://github.com/inspect-js/is-string/commit/e7a3e89ccb9638d73f45dbcb2a42e509bd3153c4)
|
||||
- Update `eslint`, `tape`, `semver`; use my personal shared `eslint` config [`6c380a7`](https://github.com/inspect-js/is-string/commit/6c380a70011714370e754fa0df95f56cdcaa3e60)
|
||||
- [Tests] remove `jscs` [`3d49592`](https://github.com/inspect-js/is-string/commit/3d49592b9880fcb1a23b67286445281131a553e3)
|
||||
- Update `is`, `tape`, `covert`, `jscs`, `editorconfig-tools`, `eslint`, `nsp`, `semver`. [`cc6983d`](https://github.com/inspect-js/is-string/commit/cc6983d06bc98f4ae9b7c9439d5d73c7318d8acd)
|
||||
- [meta] add `auto-changelog` [`b857897`](https://github.com/inspect-js/is-string/commit/b85789723ce3a7064536598e0fcdd495257c6134)
|
||||
- [meta] remove unused Makefile and associated utilities [`3f0f51c`](https://github.com/inspect-js/is-string/commit/3f0f51cbae1f97dbe1466eee88d105b3df0d2f0a)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is`, `covert`, `tape`, `semver` [`9d4a95e`](https://github.com/inspect-js/is-string/commit/9d4a95e4473fe8195501878525b5af5948aa45c9)
|
||||
- Update `eslint` [`e861b4b`](https://github.com/inspect-js/is-string/commit/e861b4bc71f5390670aebdff91119a1f8aeeb88a)
|
||||
- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`172e2dd`](https://github.com/inspect-js/is-string/commit/172e2dd1a0b9eb042bcb9a80ff5e774a90ff0695)
|
||||
- Test on `node` and `io.js` latest. [`fd426cd`](https://github.com/inspect-js/is-string/commit/fd426cd18b22b0d0e1731598125393dcfe0c5704)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` [`23bdf83`](https://github.com/inspect-js/is-string/commit/23bdf83cf42138eba09f45bd0b040b069f9839d4)
|
||||
- [actions] add automatic rebasing / merge commit blocking [`96153c0`](https://github.com/inspect-js/is-string/commit/96153c0d687a7fda2261f4c02add5d0b41e8aed7)
|
||||
- [meta] create FUNDING.yml [`66ae246`](https://github.com/inspect-js/is-string/commit/66ae246d6cdaa4ccbc21f7c144b672139b8ccef6)
|
||||
- [Dev Deps] update `is`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver` [`817361a`](https://github.com/inspect-js/is-string/commit/817361a9673cd1ec9854b52578a980159f7d8701)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `semver`, `tape` [`fc35d3f`](https://github.com/inspect-js/is-string/commit/fc35d3feb40921bb22e1639903cb7f2fab77814b)
|
||||
- [Dev Deps] update `jscs` [`886767e`](https://github.com/inspect-js/is-string/commit/886767e04e5ad59ac0bc926a87233cc8546c8b4f)
|
||||
- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`3410922`](https://github.com/inspect-js/is-string/commit/341092203c11a3b92eee55a7ecb7b8265e8fcecd)
|
||||
- [Tests] up to `io.js` `v3.3`, `node` `v4.1` [`4d6c73b`](https://github.com/inspect-js/is-string/commit/4d6c73b507bcd39050ef71e554069f72fc5b222a)
|
||||
- Update `nsp`, `eslint` [`b11de49`](https://github.com/inspect-js/is-string/commit/b11de4910beee1ffe1e67fbe25ec6707ca796b27)
|
||||
- Update `eslint`, `semver` [`0777977`](https://github.com/inspect-js/is-string/commit/0777977757a85a1db75831d03a14b4b1fde05d7e)
|
||||
- Only apps should have lockfiles [`78b49ff`](https://github.com/inspect-js/is-string/commit/78b49ffd04d4cd8c57d9e7b485421fbf3641b41b)
|
||||
- [meta] add `funding` field [`81328a6`](https://github.com/inspect-js/is-string/commit/81328a6ef3eee989164127e4c0c82f1da73d3567)
|
||||
- [Dev Deps] update `eslint`, `tape` [`fc9a225`](https://github.com/inspect-js/is-string/commit/fc9a225b27935f7c9c2704281d7fddd3614d3cb8)
|
||||
- [Tests] use `eclint` instead of `editorconfig-tools` [`59c2c61`](https://github.com/inspect-js/is-string/commit/59c2c610dbd8e8ca1e4aa3fa9c9f93205cab9b07)
|
||||
- [Dev Deps] Update `tape`, `eslint` [`a429816`](https://github.com/inspect-js/is-string/commit/a429816688e23c81948b4ae72324c26c27849b7c)
|
||||
- Test on `io.js` `v2.2` [`08b476e`](https://github.com/inspect-js/is-string/commit/08b476ed0734a70e3091c04ddd2f173a2df21eb2)
|
||||
- Test up to `io.js` `v3.0` [`22637ef`](https://github.com/inspect-js/is-string/commit/22637ef9e0030533df85cf1992fc099a88b1924c)
|
||||
- [meta] add `safe-publish-latest` [`20ccb48`](https://github.com/inspect-js/is-string/commit/20ccb48fd85f0245eb893507d00003090da020d0)
|
||||
- [Dev Deps] update `tape` [`06b58a0`](https://github.com/inspect-js/is-string/commit/06b58a048c2a820e5611ad2bd9ddfbe893295a57)
|
||||
- Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`ea7cf84`](https://github.com/inspect-js/is-string/commit/ea7cf849b952c924d1687a302098251a7b827c80)
|
||||
- Test on `io.js` `v2.4` [`66ec3ea`](https://github.com/inspect-js/is-string/commit/66ec3ea390b364583a792799b53857fd186ccc88)
|
||||
- Test on `io.js` `v2.3` [`ca6e796`](https://github.com/inspect-js/is-string/commit/ca6e796f16ec433b88962162fde8012f28e18f1e)
|
||||
- Fix tests for faked @@toStringTag [`3cce832`](https://github.com/inspect-js/is-string/commit/3cce8329133dfd233987359df151018b3b136be1)
|
||||
|
||||
## [v1.0.4](https://github.com/inspect-js/is-string/compare/v1.0.3...v1.0.4) - 2015-01-29
|
||||
|
||||
### Commits
|
||||
|
||||
- If @@toStringTag is not present, use the old-school Object#toString test. [`30675ec`](https://github.com/inspect-js/is-string/commit/30675ecb5c5cc43873918661a414a1d0f8b77325)
|
||||
|
||||
## [v1.0.3](https://github.com/inspect-js/is-string/compare/v1.0.2...v1.0.3) - 2015-01-29
|
||||
|
||||
### Commits
|
||||
|
||||
- Refactor to aid optimization of non-try/catch code. [`9b2772a`](https://github.com/inspect-js/is-string/commit/9b2772abe09ba8cbaa631322cc226ee906d2db22)
|
||||
|
||||
## [v1.0.2](https://github.com/inspect-js/is-string/compare/v1.0.1...v1.0.2) - 2015-01-29
|
||||
|
||||
### Commits
|
||||
|
||||
- Fix broken package.json [`dc921d3`](https://github.com/inspect-js/is-string/commit/dc921d332b64e4041162f04e4712b0dc687863a5)
|
||||
|
||||
## [v1.0.1](https://github.com/inspect-js/is-string/compare/v1.0.0...v1.0.1) - 2015-01-29
|
||||
|
||||
### Commits
|
||||
|
||||
- Fix eslint config. [`c4e05bd`](https://github.com/inspect-js/is-string/commit/c4e05bd171da6002d432e451fd48912db8b048e0)
|
||||
- Add early exits for typeof "string", or typeof not "object". [`82f41d3`](https://github.com/inspect-js/is-string/commit/82f41d36a599bc6a06152792c84c7683e412c513)
|
||||
|
||||
## v1.0.0 - 2015-01-29
|
||||
|
||||
### Commits
|
||||
|
||||
- Dotfiles. [`45bc9dd`](https://github.com/inspect-js/is-string/commit/45bc9dd60201722344986a6c7536be9ea9ccefbf)
|
||||
- `make release` [`23707f5`](https://github.com/inspect-js/is-string/commit/23707f5ecfdf00afb0e57c06ac07f7f49cdeb606)
|
||||
- package.json [`575ad81`](https://github.com/inspect-js/is-string/commit/575ad811c61b156cfbcc60ff61947183c6ebe6a2)
|
||||
- Read me [`3f67c9a`](https://github.com/inspect-js/is-string/commit/3f67c9a0725f811845d38646a19322895cd03981)
|
||||
- Initial commit [`2c26a7a`](https://github.com/inspect-js/is-string/commit/2c26a7a2e41dec77be2c59d5847f29a6ab7c0b29)
|
||||
- Tests. [`38c987b`](https://github.com/inspect-js/is-string/commit/38c987b8513b0ac03b0897e0fce7de8135d4ee0f)
|
||||
- Implementation. [`0471d59`](https://github.com/inspect-js/is-string/commit/0471d59078d7f3f77619913ec21c57c0af27114c)
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('subtract', require('../subtract'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "ansi-styles",
|
||||
"version": "3.2.1",
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-styles",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"color-convert": "^1.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"svg-term-cli": "^2.1.1",
|
||||
"xo": "*"
|
||||
},
|
||||
"ava": {
|
||||
"require": "babel-polyfill"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,682 @@
|
||||
// import {Converter} from "../src/Converter";
|
||||
// import csv from "../src";
|
||||
// var assert = require("assert");
|
||||
// var fs = require("fs");
|
||||
// var sandbox = require("sinon").sandbox.create();
|
||||
// var file = __dirname + "/data/testData";
|
||||
// var trailCommaData = __dirname + "/data/trailingComma";
|
||||
// describe("CSV Convert in Background Process", function () {
|
||||
// afterEach(function () {
|
||||
// sandbox.restore();
|
||||
// });
|
||||
|
||||
|
||||
// it("should read from a stream", function (done) {
|
||||
// var obj = new Converter({
|
||||
// fork: true
|
||||
// });
|
||||
// var stream = fs.createReadStream(file);
|
||||
// obj.then(function (obj) {
|
||||
// assert.equal(obj.length, 2);
|
||||
// done();
|
||||
// },(err)=>{
|
||||
// console.log(err.toString());
|
||||
// });
|
||||
// stream.pipe(obj);
|
||||
// });
|
||||
|
||||
// it("should call onNext once a row is parsed.", function (done) {
|
||||
// var obj = new Converter({fork:true});
|
||||
// var stream = fs.createReadStream(file);
|
||||
// var called = false;
|
||||
// obj.subscribe(function (resultRow) {
|
||||
// assert(resultRow);
|
||||
// called = true;
|
||||
// });
|
||||
// obj.on("done", function () {
|
||||
// assert(called);
|
||||
// done();
|
||||
// });
|
||||
// stream.pipe(obj);
|
||||
// });
|
||||
|
||||
// it("should emit end_parsed message once it is finished.", function (done) {
|
||||
// var obj = new Converter({fork:true});
|
||||
// obj.then(function (result) {
|
||||
// assert(result);
|
||||
// assert(result.length === 2);
|
||||
// assert(result[0].date);
|
||||
// assert(result[0].employee);
|
||||
// assert(result[0].employee.name);
|
||||
// assert(result[0].employee.age);
|
||||
// assert(result[0].employee.number);
|
||||
// assert(result[0].employee.key.length === 2);
|
||||
// assert(result[0].address.length === 2);
|
||||
// done();
|
||||
// });
|
||||
// fs.createReadStream(file).pipe(obj);
|
||||
// });
|
||||
|
||||
// it("should handle traling comma gracefully", function (done) {
|
||||
// var stream = fs.createReadStream(trailCommaData);
|
||||
// var obj = new Converter({fork:true});
|
||||
// obj.then(function (result) {
|
||||
// assert(result);
|
||||
// assert(result.length > 0);
|
||||
// done();
|
||||
// });
|
||||
// stream.pipe(obj);
|
||||
// });
|
||||
|
||||
// it("should handle comma in column which is surrounded by qoutes", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithComma";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var obj = new Converter({
|
||||
// "quote": "#",
|
||||
// "fork":true
|
||||
// });
|
||||
// obj.then(function (result) {
|
||||
// assert(result[0].col1 === "\"Mini. Sectt");
|
||||
// assert.equal(result[3].col2, "125001,fenvkdsf");
|
||||
// // console.log(result);
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(obj);
|
||||
// });
|
||||
|
||||
// it("should be able to convert a csv to column array data", function (done) {
|
||||
// var columArrData = __dirname + "/data/columnArray";
|
||||
// var rs = fs.createReadStream(columArrData);
|
||||
// var result:any = {};
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// //end_parsed will be emitted once parsing finished
|
||||
// csvConverter.then(function () {
|
||||
// assert(result.TIMESTAMP.length === 5);
|
||||
// done();
|
||||
// });
|
||||
|
||||
// //record_parsed will be emitted each time a row has been parsed.
|
||||
// csvConverter.subscribe(function (resultRow, rowIndex) {
|
||||
// for (var key in resultRow) {
|
||||
// if (resultRow.hasOwnProperty(key)) {
|
||||
// if (!result[key] || !(result[key] instanceof Array)) {
|
||||
// result[key] = [];
|
||||
// }
|
||||
// result[key][rowIndex] = resultRow[key];
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should be able to convert csv string directly", function (done) {
|
||||
// var testData = __dirname + "/data/testData";
|
||||
// var data = fs.readFileSync(testData).toString();
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// //end_parsed will be emitted once parsing finished
|
||||
// csvConverter.then(function (jsonObj) {
|
||||
// assert.equal(jsonObj.length, 2);
|
||||
// });
|
||||
// csvConverter.fromString(data).then(function (jsonObj) {
|
||||
// assert(jsonObj.length === 2);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should be able to convert csv string with error", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithUnclosedQuotes";
|
||||
// var data = fs.readFileSync(testData).toString();
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// csvConverter.fromString(data).then(undefined, function (err) {
|
||||
// // console.log(err);
|
||||
// assert(err);
|
||||
// assert.equal(err.err, "unclosed_quote");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should be able to convert csv string without callback provided", function (done) {
|
||||
// var testData = __dirname + "/data/testData";
|
||||
// var data = fs.readFileSync(testData).toString();
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// //end_parsed will be emitted once parsing finished
|
||||
// csvConverter.then(function (jsonObj) {
|
||||
// assert(jsonObj.length === 2);
|
||||
// done();
|
||||
// });
|
||||
// csvConverter.fromString(data);
|
||||
// });
|
||||
|
||||
// it("should be able to handle columns with double quotes", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithQoutes";
|
||||
// var data = fs.readFileSync(testData).toString();
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// csvConverter.fromString(data).then(function (jsonObj) {
|
||||
// assert(jsonObj[0].TIMESTAMP === '13954264"22', JSON.stringify(jsonObj[0].TIMESTAMP));
|
||||
|
||||
// assert(jsonObj[1].TIMESTAMP === 'abc, def, ccc', JSON.stringify(jsonObj[1].TIMESTAMP));
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should be able to handle columns with two double quotes", function (done) {
|
||||
// var testData = __dirname + "/data/twodoublequotes";
|
||||
// var data = fs.readFileSync(testData).toString();
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// csvConverter.fromString(data).then(function (jsonObj) {
|
||||
// assert.equal(jsonObj[0].title, "\"");
|
||||
// assert.equal(jsonObj[0].data, "xyabcde");
|
||||
// assert.equal(jsonObj[0].uuid, "fejal\"eifa");
|
||||
// assert.equal(jsonObj[0].fieldA, "bnej\"\"falkfe");
|
||||
// assert.equal(jsonObj[0].fieldB, "\"eisjfes\"");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should handle empty csv file", function (done) {
|
||||
// var testData = __dirname + "/data/emptyFile";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// csvConverter.then(function (jsonObj) {
|
||||
// assert(jsonObj.length === 0);
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should parse large csv file", function (done) {
|
||||
// var testData = __dirname + "/data/large-csv-sample.csv";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var csvConverter = new Converter({fork:true});
|
||||
// var count = 0;
|
||||
// csvConverter.subscribe(function () {
|
||||
// // console.log(arguments);
|
||||
// count++;
|
||||
// });
|
||||
// csvConverter.then(function () {
|
||||
// assert.equal(count, 5290);
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should parse data and covert to specific types", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithType";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var csvConverter = new Converter({
|
||||
// fork:true,
|
||||
// checkType: true,
|
||||
// colParser: {
|
||||
// "column6": "string",
|
||||
// "column7": "string"
|
||||
// }
|
||||
// });
|
||||
// csvConverter.subscribe(function (d) {
|
||||
// assert(typeof d.column1 === "number");
|
||||
// assert(typeof d.column2 === "string");
|
||||
// assert.equal(d["colume4"], "someinvaliddate");
|
||||
// assert(d.column5.hello === "world");
|
||||
// assert(d.column6 === '{"hello":"world"}');
|
||||
// assert(d.column7 === "1234");
|
||||
// assert(d.column8 === "abcd");
|
||||
// assert(d.column9 === true);
|
||||
// assert(d.column10[0] === 23);
|
||||
// assert(d.column10[1] === 31);
|
||||
// assert(d.column11[0].hello === "world");
|
||||
// assert(d["name#!"] === false);
|
||||
// });
|
||||
// csvConverter.on("done", function () {
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should turn off field type check", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithType";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var csvConverter = new Converter({
|
||||
// fork:true,
|
||||
// checkType: false
|
||||
// });
|
||||
// csvConverter.subscribe(function (d) {
|
||||
// assert(typeof d.column1 === "string");
|
||||
// assert(typeof d.column2 === "string");
|
||||
// assert(d["column3"] === "2012-01-01");
|
||||
// assert(d["colume4"] === "someinvaliddate");
|
||||
// assert(d.column5 === '{"hello":"world"}');
|
||||
// assert.equal(d["column6"], '{"hello":"world"}');
|
||||
// assert(d["column7"] === "1234");
|
||||
// assert(d["column8"] === "abcd");
|
||||
// assert(d.column9 === "true");
|
||||
// assert(d.column10[0] === "23");
|
||||
// assert(d.column10[1] === "31");
|
||||
// assert(d["name#!"] === 'false');
|
||||
// });
|
||||
// csvConverter.then(function () {
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should emit data event correctly", function (done) {
|
||||
// var testData = __dirname + "/data/large-csv-sample.csv";
|
||||
|
||||
// var csvConverter = new Converter({
|
||||
// fork:true
|
||||
// },{objectMode:true});
|
||||
// var count = 0;
|
||||
// csvConverter.on("data", function (d) {
|
||||
// count++;
|
||||
// });
|
||||
// csvConverter.on("done", function () {
|
||||
// assert.equal(csvConverter.parsedLineNumber, 5290);
|
||||
// done();
|
||||
// });
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("should process column with linebreaks", function (done) {
|
||||
// var testData = __dirname + "/data/lineBreak";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var csvConverter = new Converter({
|
||||
// fork:true,
|
||||
// checkType: true
|
||||
// });
|
||||
// csvConverter.subscribe(function (d) {
|
||||
// assert(d.Period === 13);
|
||||
// assert(d["Apparent age"] === "Unknown");
|
||||
// done();
|
||||
// });
|
||||
// rs.pipe(csvConverter);
|
||||
// });
|
||||
|
||||
// it("be able to ignore empty columns", function (done) {
|
||||
// var testData = __dirname + "/data/dataIgnoreEmpty";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(csv({
|
||||
// ignoreEmpty: true ,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 3);
|
||||
// assert(j.col2.length === 2);
|
||||
// assert(j.col2[1] === "d3");
|
||||
// assert(j.col4.col3 === undefined);
|
||||
// assert(j.col4.col5 === "world");
|
||||
// assert(res[1].col1 === "d2");
|
||||
// assert(res[2].col1 === "d4");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should allow no header", function (done) {
|
||||
// var testData = __dirname + "/data/noheadercsv";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(new Converter({
|
||||
// noheader: true,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 5);
|
||||
// assert(j.field1 === "CC102-PDMI-001");
|
||||
// assert(j.field2 === "eClass_5.1.3");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should allow customised header", function (done) {
|
||||
// var testData = __dirname + "/data/noheadercsv";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(new Converter({
|
||||
// noheader: true,
|
||||
// headers: ["a", "b"],
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 5);
|
||||
// assert(j.a === "CC102-PDMI-001");
|
||||
// assert(j.b === "eClass_5.1.3");
|
||||
// assert(j.field3 === "10/3/2014");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should allow customised header to override existing header", function (done) {
|
||||
// var testData = __dirname + "/data/complexJSONCSV";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(new Converter({
|
||||
// headers: [],
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 2);
|
||||
// assert(j.field1 === "Food Factory");
|
||||
// assert(j.field2 === "Oscar");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should handle when there is an empty string", function (done) {
|
||||
// var testData = __dirname + "/data/dataWithEmptyString";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(new Converter({
|
||||
// noheader: true,
|
||||
// headers: ["a", "b", "c"],
|
||||
// checkType: true,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
|
||||
// // assert(res.length===2);
|
||||
// assert(j.a === "green");
|
||||
// assert(j.b === 40);
|
||||
// assert.equal(j.c, "");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should detect eol correctly when first chunk is smaller than header row length", function (done) {
|
||||
// var testData = __dirname + "/data/dataNoTrimCRLF";
|
||||
// var rs = fs.createReadStream(testData, { highWaterMark: 3 });
|
||||
|
||||
// var st = rs.pipe(new Converter({
|
||||
// trim: false,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 2);
|
||||
// assert(j.name === "joe");
|
||||
// assert(j.age === "20");
|
||||
// assert.equal(res[1].name, "sam");
|
||||
// assert.equal(res[1].age, "30");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should detect eol correctly when first chunk ends in middle of CRLF line break", function (done) {
|
||||
// var testData = __dirname + "/data/dataNoTrimCRLF";
|
||||
// var rs = fs.createReadStream(testData, { highWaterMark: 9 });
|
||||
|
||||
// var st = rs.pipe(new Converter({
|
||||
// trim: false,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then(function (res) {
|
||||
// var j = res[0];
|
||||
// assert(res.length === 2);
|
||||
// assert(j.name === "joe");
|
||||
// assert(j.age === "20");
|
||||
// assert.equal(res[1].name, "sam");
|
||||
// assert.equal(res[1].age, "30");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should emit eol event when line ending is detected as CRLF", function (done) {
|
||||
// var testData = __dirname + "/data/dataNoTrimCRLF";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
|
||||
// var st = rs.pipe(new Converter({
|
||||
// fork:true
|
||||
// }));
|
||||
// var eolCallback = sandbox.spy(function (eol) {
|
||||
// assert.equal(eol, "\r\n");
|
||||
// });
|
||||
// st.on("eol", eolCallback);
|
||||
// st.then(function () {
|
||||
// assert.equal(eolCallback.callCount, 1, 'should emit eol event once');
|
||||
// done();
|
||||
// })
|
||||
// });
|
||||
|
||||
// it("should emit eol event when line ending is detected as LF", function (done) {
|
||||
// var testData = __dirname + "/data/columnArray";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
|
||||
// var st = rs.pipe(new Converter({
|
||||
// fork:true
|
||||
// }));
|
||||
// var eolCallback = sandbox.spy(function (eol) {
|
||||
// assert.equal(eol, "\n");
|
||||
// });
|
||||
// st.on("eol", eolCallback);
|
||||
// st.then(function () {
|
||||
// assert.equal(eolCallback.callCount, 1, 'should emit eol event once');
|
||||
// done();
|
||||
// })
|
||||
// });
|
||||
|
||||
// it("should remove the Byte Order Mark (BOM) from input", function (done) {
|
||||
// var testData = __dirname + "/data/dataNoTrimBOM";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var st = rs.pipe(new Converter({
|
||||
// trim: false,
|
||||
// fork:true
|
||||
// }));
|
||||
// st.then( function (res) {
|
||||
// var j = res[0];
|
||||
|
||||
// assert(res.length===2);
|
||||
// assert(j.name === "joe");
|
||||
// assert(j.age === "20");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should set output as csv", function (done) {
|
||||
// var testData = __dirname + "/data/complexJSONCSV";
|
||||
// var rs = fs.createReadStream(testData);
|
||||
// var numOfRow = 0;
|
||||
// csv({ output: "csv",fork:true })
|
||||
// .fromStream(rs)
|
||||
// .subscribe(function (row, idx) {
|
||||
// numOfRow++;
|
||||
// assert(row);
|
||||
// assert(idx >= 0);
|
||||
// })
|
||||
|
||||
// .on("done", function (error) {
|
||||
// assert(!error);
|
||||
// assert.equal(2, numOfRow);
|
||||
// assert(numOfRow !== 0);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it("should process long header", function (done) {
|
||||
// var testData = __dirname + "/data/longHeader";
|
||||
// var rs = fs.createReadStream(testData, { highWaterMark: 100 });
|
||||
// var numOfRow = 0;
|
||||
// var numOfJson = 0;
|
||||
// csv({fork:true}, { highWaterMark: 100 })
|
||||
// .fromStream(rs)
|
||||
// .subscribe(function (res, idx) {
|
||||
// numOfJson++;
|
||||
// assert.equal(res.Date, '8/26/16');
|
||||
// assert(idx >= 0);
|
||||
// })
|
||||
// .on("done", function () {
|
||||
// assert(numOfJson === 1);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it("should parse #139", function (done) {
|
||||
// var rs = fs.createReadStream(__dirname + "/data/data#139");
|
||||
// csv({fork:true})
|
||||
// .fromStream(rs)
|
||||
// .then(function (res) {
|
||||
// assert.equal(res[1].field3, "9001009395 9001009990");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should ignore column", function (done) {
|
||||
// var rs = fs.createReadStream(__dirname + "/data/dataWithQoutes");
|
||||
// var headerEmitted = false;
|
||||
// csv({
|
||||
// ignoreColumns: /TIMESTAMP/,
|
||||
// fork:true
|
||||
// })
|
||||
// .fromStream(rs)
|
||||
// .on("header", function (header) {
|
||||
// assert.equal(header.indexOf("TIMESTAMP"), -1);
|
||||
// assert.equal(header.indexOf("UPDATE"), 0);
|
||||
// if (headerEmitted) {
|
||||
// throw ("header event should only happen once")
|
||||
// }
|
||||
// headerEmitted = true;
|
||||
// })
|
||||
// // .on("csv", function (row, idx) {
|
||||
// // if (!headerEmitted) {
|
||||
// // throw ("header should be emitted before any data events");
|
||||
// // }
|
||||
// // assert(idx >= 0);
|
||||
// // if (idx === 1) {
|
||||
// // assert.equal(row[0], "n");
|
||||
// // }
|
||||
// // })
|
||||
// .subscribe(function (j, idx) {
|
||||
// // console.log(j);
|
||||
// assert(!j.TIMESTAMP);
|
||||
// assert(idx >= 0);
|
||||
// })
|
||||
// .on("done", function (err) {
|
||||
// assert(!err);
|
||||
// assert(headerEmitted);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it("should include column", function (done) {
|
||||
// var rs = fs.createReadStream(__dirname + "/data/dataWithQoutes");
|
||||
// csv({
|
||||
// includeColumns: /TIMESTAMP/,
|
||||
// fork:true
|
||||
// })
|
||||
// .fromStream(rs)
|
||||
// .on("header", function (header) {
|
||||
// assert.equal(header.indexOf("TIMESTAMP"), 0);
|
||||
// assert.equal(header.indexOf("UPDATE"), -1);
|
||||
// assert.equal(header.length, 1);
|
||||
// })
|
||||
// .subscribe(function (j, idx) {
|
||||
// assert(idx >= 0);
|
||||
// if (idx === 1) {
|
||||
// assert.equal(j.TIMESTAMP, "abc, def, ccc");
|
||||
// }
|
||||
// assert(!j.UID)
|
||||
// assert(!j['BYTES SENT'])
|
||||
// })
|
||||
// .on("done", function () {
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it("should allow headers and include columns to be given as reference to the same var", function (done) {
|
||||
// var rs = fs.createReadStream(__dirname + "/data/complexJSONCSV");
|
||||
// var headers = [
|
||||
// 'first',
|
||||
// 'second',
|
||||
// 'third',
|
||||
// ];
|
||||
|
||||
// var expected = headers;
|
||||
|
||||
// csv({
|
||||
// headers: headers,
|
||||
// includeColumns: /(first|second|third)/,
|
||||
// fork:true
|
||||
// })
|
||||
// .fromStream(rs)
|
||||
// .on("header", function (header) {
|
||||
// expected.forEach(function (value, index) {
|
||||
// assert.equal(header.indexOf(value), index);
|
||||
// });
|
||||
// })
|
||||
// .subscribe(function (j, idx) {
|
||||
// assert(idx >= 0);
|
||||
// assert.equal(expected.length, Object.keys(j).length);
|
||||
// expected.forEach(function (attribute) {
|
||||
// assert(j.hasOwnProperty(attribute));
|
||||
// });
|
||||
// })
|
||||
// .on("done", function () {
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it("should leave provided params objects unmutated", function() {
|
||||
// var rs = fs.createReadStream(__dirname + "/data/complexJSONCSV");
|
||||
// var includeColumns = [
|
||||
// 'fieldA.title',
|
||||
// 'description',
|
||||
// ];
|
||||
|
||||
|
||||
// return csv({
|
||||
// includeColumns: /(fieldA\.title|description)/,
|
||||
// fork:true
|
||||
// })
|
||||
// .fromStream(rs)
|
||||
// .on("json", function(j, idx) {
|
||||
// assert(idx >= 0);
|
||||
// })
|
||||
// .on("header", function(header) {
|
||||
// includeColumns.forEach(function (value, index) {
|
||||
// assert.equal(index, header.indexOf(value));
|
||||
// });
|
||||
// })
|
||||
// });
|
||||
// it("should accept pipe as quote", function (done) {
|
||||
// csv({
|
||||
// quote: "|",
|
||||
// output: "csv",
|
||||
// "fork":true
|
||||
// })
|
||||
// .fromFile(__dirname + "/data/pipeAsQuote")
|
||||
// .subscribe(function (csv) {
|
||||
// assert.equal(csv[2], "blahhh, blah");
|
||||
// })
|
||||
// .on('done', function () {
|
||||
// done()
|
||||
// });
|
||||
// })
|
||||
// it("should allow async subscribe function", () => {
|
||||
// return csv({ trim: true,fork:true })
|
||||
// .fromString(`a,b,c
|
||||
// 1,2,3
|
||||
// 4,5,6`)
|
||||
// .subscribe((d) => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
// d.a = 10;
|
||||
// resolve();
|
||||
// }, 20);
|
||||
// })
|
||||
// })
|
||||
// .then((d) => {
|
||||
// assert.equal(d[0].a, 10);
|
||||
// assert.equal(d[1].a, 10);
|
||||
// })
|
||||
// })
|
||||
// it("should omit a column", () => {
|
||||
// return csv({
|
||||
// colParser: {
|
||||
// "a": "omit"
|
||||
// },
|
||||
// fork:true
|
||||
// })
|
||||
// .fromString(`a,b,c
|
||||
// 1,2,3
|
||||
// fefe,5,6`)
|
||||
// .then((d) => {
|
||||
// assert.strictEqual(d[0].a, undefined);
|
||||
// assert.equal(d[1].a, undefined);
|
||||
// })
|
||||
// })
|
||||
|
||||
// });
|
||||
@@ -0,0 +1,32 @@
|
||||
import {CamelCase} from './camel-case';
|
||||
|
||||
/**
|
||||
Convert object properties to camel case but not recursively.
|
||||
|
||||
This can be useful when, for example, converting some API types from a different style.
|
||||
|
||||
@see CamelCasedPropertiesDeep
|
||||
@see CamelCase
|
||||
|
||||
@example
|
||||
```
|
||||
interface User {
|
||||
UserId: number;
|
||||
UserName: string;
|
||||
}
|
||||
|
||||
const result: CamelCasedProperties<User> = {
|
||||
userId: 1,
|
||||
userName: 'Tom',
|
||||
};
|
||||
```
|
||||
|
||||
@category Template Literals
|
||||
*/
|
||||
export type CamelCasedProperties<Value> = Value extends Function
|
||||
? Value
|
||||
: Value extends Array<infer U>
|
||||
? Value
|
||||
: {
|
||||
[K in keyof Value as CamelCase<K>]: Value[K];
|
||||
};
|
||||
@@ -0,0 +1,584 @@
|
||||
import { objFilter } from './utils/obj-filter.js';
|
||||
import { YError } from './yerror.js';
|
||||
import setBlocking from './utils/set-blocking.js';
|
||||
function isBoolean(fail) {
|
||||
return typeof fail === 'boolean';
|
||||
}
|
||||
export function usage(yargs, shim) {
|
||||
const __ = shim.y18n.__;
|
||||
const self = {};
|
||||
const fails = [];
|
||||
self.failFn = function failFn(f) {
|
||||
fails.push(f);
|
||||
};
|
||||
let failMessage = null;
|
||||
let globalFailMessage = null;
|
||||
let showHelpOnFail = true;
|
||||
self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
|
||||
const [enabled, message] = typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2];
|
||||
if (yargs.getInternalMethods().isGlobalContext()) {
|
||||
globalFailMessage = message;
|
||||
}
|
||||
failMessage = message;
|
||||
showHelpOnFail = enabled;
|
||||
return self;
|
||||
};
|
||||
let failureOutput = false;
|
||||
self.fail = function fail(msg, err) {
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (fails.length) {
|
||||
for (let i = fails.length - 1; i >= 0; --i) {
|
||||
const fail = fails[i];
|
||||
if (isBoolean(fail)) {
|
||||
if (err)
|
||||
throw err;
|
||||
else if (msg)
|
||||
throw Error(msg);
|
||||
}
|
||||
else {
|
||||
fail(msg, err, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (yargs.getExitProcess())
|
||||
setBlocking(true);
|
||||
if (!failureOutput) {
|
||||
failureOutput = true;
|
||||
if (showHelpOnFail) {
|
||||
yargs.showHelp('error');
|
||||
logger.error();
|
||||
}
|
||||
if (msg || err)
|
||||
logger.error(msg || err);
|
||||
const globalOrCommandFailMessage = failMessage || globalFailMessage;
|
||||
if (globalOrCommandFailMessage) {
|
||||
if (msg || err)
|
||||
logger.error('');
|
||||
logger.error(globalOrCommandFailMessage);
|
||||
}
|
||||
}
|
||||
err = err || new YError(msg);
|
||||
if (yargs.getExitProcess()) {
|
||||
return yargs.exit(1);
|
||||
}
|
||||
else if (yargs.getInternalMethods().hasParseCallback()) {
|
||||
return yargs.exit(1, err);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
let usages = [];
|
||||
let usageDisabled = false;
|
||||
self.usage = (msg, description) => {
|
||||
if (msg === null) {
|
||||
usageDisabled = true;
|
||||
usages = [];
|
||||
return self;
|
||||
}
|
||||
usageDisabled = false;
|
||||
usages.push([msg, description || '']);
|
||||
return self;
|
||||
};
|
||||
self.getUsage = () => {
|
||||
return usages;
|
||||
};
|
||||
self.getUsageDisabled = () => {
|
||||
return usageDisabled;
|
||||
};
|
||||
self.getPositionalGroupName = () => {
|
||||
return __('Positionals:');
|
||||
};
|
||||
let examples = [];
|
||||
self.example = (cmd, description) => {
|
||||
examples.push([cmd, description || '']);
|
||||
};
|
||||
let commands = [];
|
||||
self.command = function command(cmd, description, isDefault, aliases, deprecated = false) {
|
||||
if (isDefault) {
|
||||
commands = commands.map(cmdArray => {
|
||||
cmdArray[2] = false;
|
||||
return cmdArray;
|
||||
});
|
||||
}
|
||||
commands.push([cmd, description || '', isDefault, aliases, deprecated]);
|
||||
};
|
||||
self.getCommands = () => commands;
|
||||
let descriptions = {};
|
||||
self.describe = function describe(keyOrKeys, desc) {
|
||||
if (Array.isArray(keyOrKeys)) {
|
||||
keyOrKeys.forEach(k => {
|
||||
self.describe(k, desc);
|
||||
});
|
||||
}
|
||||
else if (typeof keyOrKeys === 'object') {
|
||||
Object.keys(keyOrKeys).forEach(k => {
|
||||
self.describe(k, keyOrKeys[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
descriptions[keyOrKeys] = desc;
|
||||
}
|
||||
};
|
||||
self.getDescriptions = () => descriptions;
|
||||
let epilogs = [];
|
||||
self.epilog = msg => {
|
||||
epilogs.push(msg);
|
||||
};
|
||||
let wrapSet = false;
|
||||
let wrap;
|
||||
self.wrap = cols => {
|
||||
wrapSet = true;
|
||||
wrap = cols;
|
||||
};
|
||||
self.getWrap = () => {
|
||||
if (shim.getEnv('YARGS_DISABLE_WRAP')) {
|
||||
return null;
|
||||
}
|
||||
if (!wrapSet) {
|
||||
wrap = windowWidth();
|
||||
wrapSet = true;
|
||||
}
|
||||
return wrap;
|
||||
};
|
||||
const deferY18nLookupPrefix = '__yargsString__:';
|
||||
self.deferY18nLookup = str => deferY18nLookupPrefix + str;
|
||||
self.help = function help() {
|
||||
if (cachedHelpMessage)
|
||||
return cachedHelpMessage;
|
||||
normalizeAliases();
|
||||
const base$0 = yargs.customScriptName
|
||||
? yargs.$0
|
||||
: shim.path.basename(yargs.$0);
|
||||
const demandedOptions = yargs.getDemandedOptions();
|
||||
const demandedCommands = yargs.getDemandedCommands();
|
||||
const deprecatedOptions = yargs.getDeprecatedOptions();
|
||||
const groups = yargs.getGroups();
|
||||
const options = yargs.getOptions();
|
||||
let keys = [];
|
||||
keys = keys.concat(Object.keys(descriptions));
|
||||
keys = keys.concat(Object.keys(demandedOptions));
|
||||
keys = keys.concat(Object.keys(demandedCommands));
|
||||
keys = keys.concat(Object.keys(options.default));
|
||||
keys = keys.filter(filterHiddenOptions);
|
||||
keys = Object.keys(keys.reduce((acc, key) => {
|
||||
if (key !== '_')
|
||||
acc[key] = true;
|
||||
return acc;
|
||||
}, {}));
|
||||
const theWrap = self.getWrap();
|
||||
const ui = shim.cliui({
|
||||
width: theWrap,
|
||||
wrap: !!theWrap,
|
||||
});
|
||||
if (!usageDisabled) {
|
||||
if (usages.length) {
|
||||
usages.forEach(usage => {
|
||||
ui.div({ text: `${usage[0].replace(/\$0/g, base$0)}` });
|
||||
if (usage[1]) {
|
||||
ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] });
|
||||
}
|
||||
});
|
||||
ui.div();
|
||||
}
|
||||
else if (commands.length) {
|
||||
let u = null;
|
||||
if (demandedCommands._) {
|
||||
u = `${base$0} <${__('command')}>\n`;
|
||||
}
|
||||
else {
|
||||
u = `${base$0} [${__('command')}]\n`;
|
||||
}
|
||||
ui.div(`${u}`);
|
||||
}
|
||||
}
|
||||
if (commands.length > 1 || (commands.length === 1 && !commands[0][2])) {
|
||||
ui.div(__('Commands:'));
|
||||
const context = yargs.getInternalMethods().getContext();
|
||||
const parentCommands = context.commands.length
|
||||
? `${context.commands.join(' ')} `
|
||||
: '';
|
||||
if (yargs.getInternalMethods().getParserConfiguration()['sort-commands'] ===
|
||||
true) {
|
||||
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
|
||||
}
|
||||
const prefix = base$0 ? `${base$0} ` : '';
|
||||
commands.forEach(command => {
|
||||
const commandString = `${prefix}${parentCommands}${command[0].replace(/^\$0 ?/, '')}`;
|
||||
ui.span({
|
||||
text: commandString,
|
||||
padding: [0, 2, 0, 2],
|
||||
width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4,
|
||||
}, { text: command[1] });
|
||||
const hints = [];
|
||||
if (command[2])
|
||||
hints.push(`[${__('default')}]`);
|
||||
if (command[3] && command[3].length) {
|
||||
hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`);
|
||||
}
|
||||
if (command[4]) {
|
||||
if (typeof command[4] === 'string') {
|
||||
hints.push(`[${__('deprecated: %s', command[4])}]`);
|
||||
}
|
||||
else {
|
||||
hints.push(`[${__('deprecated')}]`);
|
||||
}
|
||||
}
|
||||
if (hints.length) {
|
||||
ui.div({
|
||||
text: hints.join(' '),
|
||||
padding: [0, 0, 0, 2],
|
||||
align: 'right',
|
||||
});
|
||||
}
|
||||
else {
|
||||
ui.div();
|
||||
}
|
||||
});
|
||||
ui.div();
|
||||
}
|
||||
const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []);
|
||||
keys = keys.filter(key => !yargs.parsed.newAliases[key] &&
|
||||
aliasKeys.every(alias => (options.alias[alias] || []).indexOf(key) === -1));
|
||||
const defaultGroup = __('Options:');
|
||||
if (!groups[defaultGroup])
|
||||
groups[defaultGroup] = [];
|
||||
addUngroupedKeys(keys, options.alias, groups, defaultGroup);
|
||||
const isLongSwitch = (sw) => /^--/.test(getText(sw));
|
||||
const displayedGroups = Object.keys(groups)
|
||||
.filter(groupName => groups[groupName].length > 0)
|
||||
.map(groupName => {
|
||||
const normalizedKeys = groups[groupName]
|
||||
.filter(filterHiddenOptions)
|
||||
.map(key => {
|
||||
if (aliasKeys.includes(key))
|
||||
return key;
|
||||
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
|
||||
if ((options.alias[aliasKey] || []).includes(key))
|
||||
return aliasKey;
|
||||
}
|
||||
return key;
|
||||
});
|
||||
return { groupName, normalizedKeys };
|
||||
})
|
||||
.filter(({ normalizedKeys }) => normalizedKeys.length > 0)
|
||||
.map(({ groupName, normalizedKeys }) => {
|
||||
const switches = normalizedKeys.reduce((acc, key) => {
|
||||
acc[key] = [key]
|
||||
.concat(options.alias[key] || [])
|
||||
.map(sw => {
|
||||
if (groupName === self.getPositionalGroupName())
|
||||
return sw;
|
||||
else {
|
||||
return ((/^[0-9]$/.test(sw)
|
||||
? options.boolean.includes(key)
|
||||
? '-'
|
||||
: '--'
|
||||
: sw.length > 1
|
||||
? '--'
|
||||
: '-') + sw);
|
||||
}
|
||||
})
|
||||
.sort((sw1, sw2) => isLongSwitch(sw1) === isLongSwitch(sw2)
|
||||
? 0
|
||||
: isLongSwitch(sw1)
|
||||
? 1
|
||||
: -1)
|
||||
.join(', ');
|
||||
return acc;
|
||||
}, {});
|
||||
return { groupName, normalizedKeys, switches };
|
||||
});
|
||||
const shortSwitchesUsed = displayedGroups
|
||||
.filter(({ groupName }) => groupName !== self.getPositionalGroupName())
|
||||
.some(({ normalizedKeys, switches }) => !normalizedKeys.every(key => isLongSwitch(switches[key])));
|
||||
if (shortSwitchesUsed) {
|
||||
displayedGroups
|
||||
.filter(({ groupName }) => groupName !== self.getPositionalGroupName())
|
||||
.forEach(({ normalizedKeys, switches }) => {
|
||||
normalizedKeys.forEach(key => {
|
||||
if (isLongSwitch(switches[key])) {
|
||||
switches[key] = addIndentation(switches[key], '-x, '.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => {
|
||||
ui.div(groupName);
|
||||
normalizedKeys.forEach(key => {
|
||||
const kswitch = switches[key];
|
||||
let desc = descriptions[key] || '';
|
||||
let type = null;
|
||||
if (desc.includes(deferY18nLookupPrefix))
|
||||
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
||||
if (options.boolean.includes(key))
|
||||
type = `[${__('boolean')}]`;
|
||||
if (options.count.includes(key))
|
||||
type = `[${__('count')}]`;
|
||||
if (options.string.includes(key))
|
||||
type = `[${__('string')}]`;
|
||||
if (options.normalize.includes(key))
|
||||
type = `[${__('string')}]`;
|
||||
if (options.array.includes(key))
|
||||
type = `[${__('array')}]`;
|
||||
if (options.number.includes(key))
|
||||
type = `[${__('number')}]`;
|
||||
const deprecatedExtra = (deprecated) => typeof deprecated === 'string'
|
||||
? `[${__('deprecated: %s', deprecated)}]`
|
||||
: `[${__('deprecated')}]`;
|
||||
const extra = [
|
||||
key in deprecatedOptions
|
||||
? deprecatedExtra(deprecatedOptions[key])
|
||||
: null,
|
||||
type,
|
||||
key in demandedOptions ? `[${__('required')}]` : null,
|
||||
options.choices && options.choices[key]
|
||||
? `[${__('choices:')} ${self.stringifiedValues(options.choices[key])}]`
|
||||
: null,
|
||||
defaultString(options.default[key], options.defaultDescription[key]),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
ui.span({
|
||||
text: getText(kswitch),
|
||||
padding: [0, 2, 0, 2 + getIndentation(kswitch)],
|
||||
width: maxWidth(switches, theWrap) + 4,
|
||||
}, desc);
|
||||
const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()['hide-types'] ===
|
||||
true;
|
||||
if (extra && !shouldHideOptionExtras)
|
||||
ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' });
|
||||
else
|
||||
ui.div();
|
||||
});
|
||||
ui.div();
|
||||
});
|
||||
if (examples.length) {
|
||||
ui.div(__('Examples:'));
|
||||
examples.forEach(example => {
|
||||
example[0] = example[0].replace(/\$0/g, base$0);
|
||||
});
|
||||
examples.forEach(example => {
|
||||
if (example[1] === '') {
|
||||
ui.div({
|
||||
text: example[0],
|
||||
padding: [0, 2, 0, 2],
|
||||
});
|
||||
}
|
||||
else {
|
||||
ui.div({
|
||||
text: example[0],
|
||||
padding: [0, 2, 0, 2],
|
||||
width: maxWidth(examples, theWrap) + 4,
|
||||
}, {
|
||||
text: example[1],
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.div();
|
||||
}
|
||||
if (epilogs.length > 0) {
|
||||
const e = epilogs
|
||||
.map(epilog => epilog.replace(/\$0/g, base$0))
|
||||
.join('\n');
|
||||
ui.div(`${e}\n`);
|
||||
}
|
||||
return ui.toString().replace(/\s*$/, '');
|
||||
};
|
||||
function maxWidth(table, theWrap, modifier) {
|
||||
let width = 0;
|
||||
if (!Array.isArray(table)) {
|
||||
table = Object.values(table).map(v => [v]);
|
||||
}
|
||||
table.forEach(v => {
|
||||
width = Math.max(shim.stringWidth(modifier ? `${modifier} ${getText(v[0])}` : getText(v[0])) + getIndentation(v[0]), width);
|
||||
});
|
||||
if (theWrap)
|
||||
width = Math.min(width, parseInt((theWrap * 0.5).toString(), 10));
|
||||
return width;
|
||||
}
|
||||
function normalizeAliases() {
|
||||
const demandedOptions = yargs.getDemandedOptions();
|
||||
const options = yargs.getOptions();
|
||||
(Object.keys(options.alias) || []).forEach(key => {
|
||||
options.alias[key].forEach(alias => {
|
||||
if (descriptions[alias])
|
||||
self.describe(key, descriptions[alias]);
|
||||
if (alias in demandedOptions)
|
||||
yargs.demandOption(key, demandedOptions[alias]);
|
||||
if (options.boolean.includes(alias))
|
||||
yargs.boolean(key);
|
||||
if (options.count.includes(alias))
|
||||
yargs.count(key);
|
||||
if (options.string.includes(alias))
|
||||
yargs.string(key);
|
||||
if (options.normalize.includes(alias))
|
||||
yargs.normalize(key);
|
||||
if (options.array.includes(alias))
|
||||
yargs.array(key);
|
||||
if (options.number.includes(alias))
|
||||
yargs.number(key);
|
||||
});
|
||||
});
|
||||
}
|
||||
let cachedHelpMessage;
|
||||
self.cacheHelpMessage = function () {
|
||||
cachedHelpMessage = this.help();
|
||||
};
|
||||
self.clearCachedHelpMessage = function () {
|
||||
cachedHelpMessage = undefined;
|
||||
};
|
||||
self.hasCachedHelpMessage = function () {
|
||||
return !!cachedHelpMessage;
|
||||
};
|
||||
function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
|
||||
let groupedKeys = [];
|
||||
let toCheck = null;
|
||||
Object.keys(groups).forEach(group => {
|
||||
groupedKeys = groupedKeys.concat(groups[group]);
|
||||
});
|
||||
keys.forEach(key => {
|
||||
toCheck = [key].concat(aliases[key]);
|
||||
if (!toCheck.some(k => groupedKeys.indexOf(k) !== -1)) {
|
||||
groups[defaultGroup].push(key);
|
||||
}
|
||||
});
|
||||
return groupedKeys;
|
||||
}
|
||||
function filterHiddenOptions(key) {
|
||||
return (yargs.getOptions().hiddenOptions.indexOf(key) < 0 ||
|
||||
yargs.parsed.argv[yargs.getOptions().showHiddenOpt]);
|
||||
}
|
||||
self.showHelp = (level) => {
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (!level)
|
||||
level = 'error';
|
||||
const emit = typeof level === 'function' ? level : logger[level];
|
||||
emit(self.help());
|
||||
};
|
||||
self.functionDescription = fn => {
|
||||
const description = fn.name
|
||||
? shim.Parser.decamelize(fn.name, '-')
|
||||
: __('generated-value');
|
||||
return ['(', description, ')'].join('');
|
||||
};
|
||||
self.stringifiedValues = function stringifiedValues(values, separator) {
|
||||
let string = '';
|
||||
const sep = separator || ', ';
|
||||
const array = [].concat(values);
|
||||
if (!values || !array.length)
|
||||
return string;
|
||||
array.forEach(value => {
|
||||
if (string.length)
|
||||
string += sep;
|
||||
string += JSON.stringify(value);
|
||||
});
|
||||
return string;
|
||||
};
|
||||
function defaultString(value, defaultDescription) {
|
||||
let string = `[${__('default:')} `;
|
||||
if (value === undefined && !defaultDescription)
|
||||
return null;
|
||||
if (defaultDescription) {
|
||||
string += defaultDescription;
|
||||
}
|
||||
else {
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
string += `"${value}"`;
|
||||
break;
|
||||
case 'object':
|
||||
string += JSON.stringify(value);
|
||||
break;
|
||||
default:
|
||||
string += value;
|
||||
}
|
||||
}
|
||||
return `${string}]`;
|
||||
}
|
||||
function windowWidth() {
|
||||
const maxWidth = 80;
|
||||
if (shim.process.stdColumns) {
|
||||
return Math.min(maxWidth, shim.process.stdColumns);
|
||||
}
|
||||
else {
|
||||
return maxWidth;
|
||||
}
|
||||
}
|
||||
let version = null;
|
||||
self.version = ver => {
|
||||
version = ver;
|
||||
};
|
||||
self.showVersion = level => {
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (!level)
|
||||
level = 'error';
|
||||
const emit = typeof level === 'function' ? level : logger[level];
|
||||
emit(version);
|
||||
};
|
||||
self.reset = function reset(localLookup) {
|
||||
failMessage = null;
|
||||
failureOutput = false;
|
||||
usages = [];
|
||||
usageDisabled = false;
|
||||
epilogs = [];
|
||||
examples = [];
|
||||
commands = [];
|
||||
descriptions = objFilter(descriptions, k => !localLookup[k]);
|
||||
return self;
|
||||
};
|
||||
const frozens = [];
|
||||
self.freeze = function freeze() {
|
||||
frozens.push({
|
||||
failMessage,
|
||||
failureOutput,
|
||||
usages,
|
||||
usageDisabled,
|
||||
epilogs,
|
||||
examples,
|
||||
commands,
|
||||
descriptions,
|
||||
});
|
||||
};
|
||||
self.unfreeze = function unfreeze(defaultCommand = false) {
|
||||
const frozen = frozens.pop();
|
||||
if (!frozen)
|
||||
return;
|
||||
if (defaultCommand) {
|
||||
descriptions = { ...frozen.descriptions, ...descriptions };
|
||||
commands = [...frozen.commands, ...commands];
|
||||
usages = [...frozen.usages, ...usages];
|
||||
examples = [...frozen.examples, ...examples];
|
||||
epilogs = [...frozen.epilogs, ...epilogs];
|
||||
}
|
||||
else {
|
||||
({
|
||||
failMessage,
|
||||
failureOutput,
|
||||
usages,
|
||||
usageDisabled,
|
||||
epilogs,
|
||||
examples,
|
||||
commands,
|
||||
descriptions,
|
||||
} = frozen);
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}
|
||||
function isIndentedText(text) {
|
||||
return typeof text === 'object';
|
||||
}
|
||||
function addIndentation(text, indent) {
|
||||
return isIndentedText(text)
|
||||
? { text: text.text, indentation: text.indentation + indent }
|
||||
: { text, indentation: indent };
|
||||
}
|
||||
function getIndentation(text) {
|
||||
return isIndentedText(text) ? text.indentation : 0;
|
||||
}
|
||||
function getText(text) {
|
||||
return isIndentedText(text) ? text.text : text;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
var baseDelay = require('./_baseDelay'),
|
||||
baseRest = require('./_baseRest');
|
||||
|
||||
/**
|
||||
* Defers invoking the `func` until the current call stack has cleared. Any
|
||||
* additional arguments are provided to `func` when it's invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to defer.
|
||||
* @param {...*} [args] The arguments to invoke `func` with.
|
||||
* @returns {number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* _.defer(function(text) {
|
||||
* console.log(text);
|
||||
* }, 'deferred');
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
var defer = baseRest(function(func, args) {
|
||||
return baseDelay(func, 1, args);
|
||||
});
|
||||
|
||||
module.exports = defer;
|
||||
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
var objUtils = require("./util/object");
|
||||
|
||||
|
||||
|
||||
function getOptions(options, defaults)
|
||||
{
|
||||
if ( objUtils.isPlainObject(options) )
|
||||
{
|
||||
var newOptions = {};
|
||||
|
||||
for (var i in defaults)
|
||||
{
|
||||
if ( defaults.hasOwnProperty(i) )
|
||||
{
|
||||
if (options[i] !== undefined)
|
||||
{
|
||||
newOptions[i] = mergeOption(options[i], defaults[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
newOptions[i] = defaults[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newOptions;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mergeOption(newValues, defaultValues)
|
||||
{
|
||||
if (defaultValues instanceof Object && newValues instanceof Object)
|
||||
{
|
||||
if (defaultValues instanceof Array && newValues instanceof Array)
|
||||
{
|
||||
return defaultValues.concat(newValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
return objUtils.shallowMerge(newValues, defaultValues);
|
||||
}
|
||||
}
|
||||
|
||||
return newValues;
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = getOptions;
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan
|
||||
|
||||
module.exports = function BigIntLessThan(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x < y;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"L G M N O","2":"C K","257":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H"},C:{"1":"PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 6 DC tB I v J D E F A B C K L G M N O w g x y z EC FC","194":"7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB"},D:{"1":"9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB","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","257":"VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"1":"D E F A B C K L G KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J HC zB IC JC"},F:{"1":"3 4 5 6 7 8 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 ZB aB bB","2":"0 1 2 F B C G M N O w g x y z PC QC RC SC qB AC TC rB","257":"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"},G:{"1":"E 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","2":"zB UC BC VC WC"},H:{"2":"oC"},I:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C h qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"2":"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:{"2":"9C"},S:{"1":"AD BD"}},B:7,C:"Speech Synthesis API"};
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = sortAscending;
|
||||
|
||||
function sortAscending(list) {
|
||||
return list.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
|
||||
;
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"rc","version":"1.2.8","files":{"LICENSE.APACHE2":{"checkedAt":1678883671346,"integrity":"sha512-cSQG0iQrnQ1857NzYCk8Zdx0ZqRMloUCN16BCM7f3jatchV3UugZBdO8TSqTtMBmOOfFzACQh0WQgAPJYoht7A==","mode":420,"size":586},"LICENSE.MIT":{"checkedAt":1678883671346,"integrity":"sha512-0XVzfm5qtEgZBVjuJNzYLrZXBkNVRJ2bSZihqDDMUXfpcIn0wI/HJBmWTAdII/9fAtR58L0egNxoUAybbupaYA==","mode":420,"size":1088},"package.json":{"checkedAt":1678883672780,"integrity":"sha512-3yRiG/2ISOk2fmpew56pS8Yin+BU4VHSExL3ELKhx59gyLXPFt4m0Jl8Jge0ebAWA6RH2obWjt8WSL68GUGaQg==","mode":420,"size":695},"browser.js":{"checkedAt":1678883672780,"integrity":"sha512-ZWM1JvxL78LqogC3zd5yxRLph0df6beyKNyZ7zclt+nLdoGQXkYTsFiJkk/w8nLK26WRXXCtsJ/EYwHjYOfIYg==","mode":420,"size":137},"cli.js":{"checkedAt":1678883672780,"integrity":"sha512-kznuSmIW4/8j1nM2II94/eprxnI8AOervf6R0zZyjHoGAwoyjqtICxp1KnpgGgG41X7KGTp3WjnsS9q0CtAskg==","mode":493,"size":109},"index.js":{"checkedAt":1678883672780,"integrity":"sha512-MgJfYBlqtexZ6Qq6kPsNz3WqAaqhDjsFMEtfdawbelB9ky5/Bj6ItJd4vtkkWJavQVzi9lvfQsFEACUGoqNG2A==","mode":493,"size":1503},"LICENSE.BSD":{"checkedAt":1678883672780,"integrity":"sha512-dZTkHTuy+WL9JQXA/c+S39uFTFMkOIlabRwVtLenGWKfKNRfXDxhQI5+kgc+NcPurWY88vKV5NW71wREKFWcXg==","mode":420,"size":1516},"README.md":{"checkedAt":1678883672782,"integrity":"sha512-ao3tpLJQBoe6geHTW/lq1oKB6RBMPih2HFAl0lQ5YKmmsEt1ALHm80mO1Wxy6LIH0EncjRTERcuYhmJtZbqgAQ==","mode":420,"size":5982},"lib/utils.js":{"checkedAt":1678883672783,"integrity":"sha512-EenaftT1iO5gqcN/2rrFIafqWgxLPqE7aD9XxpchV9UWGKkmI1vgy2vruAqLREY0lk+0+PeTKWrP0OVL3bwA1g==","mode":420,"size":2759},"test/ini.js":{"checkedAt":1678883672783,"integrity":"sha512-GzC4A8svA93zZ16drfJaQT3IKPcNM5bBfzDRLP5tTQyXt0sGsJJEgMGwaUIdx8e2Tx4HTvXysWAS+QQdZgux6A==","mode":420,"size":312},"test/test.js":{"checkedAt":1678883672783,"integrity":"sha512-cAXwsqWB1744KpGSdPrrbyGwc4wsUXuBAez/OWJZxTQ+oykDXJ2YhcXD6i7E7QXtF6B+xtZJMlCoTdKuUo2izQ==","mode":420,"size":1176},"test/nested-env-vars.js":{"checkedAt":1678883672783,"integrity":"sha512-7mTcnU5IfIaumBrl9A59SqpzufNXjc26hVtqtwpQpc4J5UbYNe2wjEjx/YAgwewEBQnqXtAvqU7CY/y3v67g6Q==","mode":420,"size":1392}}}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Workaround for http://code.google.com/p/v8/issues/detail?id=2804
|
||||
|
||||
"use strict";
|
||||
|
||||
var create = Object.create, shim;
|
||||
|
||||
if (!require("./set-prototype-of/is-implemented")()) {
|
||||
shim = require("./set-prototype-of/shim");
|
||||
}
|
||||
|
||||
module.exports = (function () {
|
||||
var nullObject, polyProps, desc;
|
||||
if (!shim) return create;
|
||||
if (shim.level !== 1) return create;
|
||||
|
||||
nullObject = {};
|
||||
polyProps = {};
|
||||
desc = { configurable: false, enumerable: false, writable: true, value: undefined };
|
||||
Object.getOwnPropertyNames(Object.prototype).forEach(function (name) {
|
||||
if (name === "__proto__") {
|
||||
polyProps[name] = {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: undefined
|
||||
};
|
||||
return;
|
||||
}
|
||||
polyProps[name] = desc;
|
||||
});
|
||||
Object.defineProperties(nullObject, polyProps);
|
||||
|
||||
Object.defineProperty(shim, "nullPolyfill", {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: nullObject
|
||||
});
|
||||
|
||||
return function (prototype, props) {
|
||||
return create(prototype === null ? nullObject : prototype, props);
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,30 @@
|
||||
import escapeClassName from './escapeClassName'
|
||||
import escapeCommas from './escapeCommas'
|
||||
|
||||
export function asClass(name) {
|
||||
return escapeCommas(`.${escapeClassName(name)}`)
|
||||
}
|
||||
|
||||
export default function nameClass(classPrefix, key) {
|
||||
return asClass(formatClass(classPrefix, key))
|
||||
}
|
||||
|
||||
export function formatClass(classPrefix, key) {
|
||||
if (key === 'DEFAULT') {
|
||||
return classPrefix
|
||||
}
|
||||
|
||||
if (key === '-' || key === '-DEFAULT') {
|
||||
return `-${classPrefix}`
|
||||
}
|
||||
|
||||
if (key.startsWith('-')) {
|
||||
return `-${classPrefix}${key}`
|
||||
}
|
||||
|
||||
if (key.startsWith('/')) {
|
||||
return `${classPrefix}${key}`
|
||||
}
|
||||
|
||||
return `${classPrefix}-${key}`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { format } from '../../util.js';
|
||||
|
||||
export default {
|
||||
release: {
|
||||
type: 'confirm',
|
||||
message: context => `Create a release on GitLab (${format(context.gitlab.releaseName, context)})?`,
|
||||
default: true
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,144 @@
|
||||
# node-error-ex [](https://travis-ci.org/Qix-/node-error-ex) [](https://coveralls.io/r/Qix-/node-error-ex)
|
||||
> Easily subclass and customize new Error types
|
||||
|
||||
## Examples
|
||||
To include in your project:
|
||||
```javascript
|
||||
var errorEx = require('error-ex');
|
||||
```
|
||||
|
||||
To create an error message type with a specific name (note, that `ErrorFn.name`
|
||||
will not reflect this):
|
||||
```javascript
|
||||
var JSONError = errorEx('JSONError');
|
||||
|
||||
var err = new JSONError('error');
|
||||
err.name; //-> JSONError
|
||||
throw err; //-> JSONError: error
|
||||
```
|
||||
|
||||
To add a stack line:
|
||||
```javascript
|
||||
var JSONError = errorEx('JSONError', {fileName: errorEx.line('in %s')});
|
||||
|
||||
var err = new JSONError('error')
|
||||
err.fileName = '/a/b/c/foo.json';
|
||||
throw err; //-> (line 2)-> in /a/b/c/foo.json
|
||||
```
|
||||
|
||||
To append to the error message:
|
||||
```javascript
|
||||
var JSONError = errorEx('JSONError', {fileName: errorEx.append('in %s')});
|
||||
|
||||
var err = new JSONError('error');
|
||||
err.fileName = '/a/b/c/foo.json';
|
||||
throw err; //-> JSONError: error in /a/b/c/foo.json
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `errorEx([name], [properties])`
|
||||
Creates a new ErrorEx error type
|
||||
|
||||
- `name`: the name of the new type (appears in the error message upon throw;
|
||||
defaults to `Error.name`)
|
||||
- `properties`: if supplied, used as a key/value dictionary of properties to
|
||||
use when building up the stack message. Keys are property names that are
|
||||
looked up on the error message, and then passed to function values.
|
||||
- `line`: if specified and is a function, return value is added as a stack
|
||||
entry (error-ex will indent for you). Passed the property value given
|
||||
the key.
|
||||
- `stack`: if specified and is a function, passed the value of the property
|
||||
using the key, and the raw stack lines as a second argument. Takes no
|
||||
return value (but the stack can be modified directly).
|
||||
- `message`: if specified and is a function, return value is used as new
|
||||
`.message` value upon get. Passed the property value of the property named
|
||||
by key, and the existing message is passed as the second argument as an
|
||||
array of lines (suitable for multi-line messages).
|
||||
|
||||
Returns a constructor (Function) that can be used just like the regular Error
|
||||
constructor.
|
||||
|
||||
```javascript
|
||||
var errorEx = require('error-ex');
|
||||
|
||||
var BasicError = errorEx();
|
||||
|
||||
var NamedError = errorEx('NamedError');
|
||||
|
||||
// --
|
||||
|
||||
var AdvancedError = errorEx('AdvancedError', {
|
||||
foo: {
|
||||
line: function (value, stack) {
|
||||
if (value) {
|
||||
return 'bar ' + value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var err = new AdvancedError('hello, world');
|
||||
err.foo = 'baz';
|
||||
throw err;
|
||||
|
||||
/*
|
||||
AdvancedError: hello, world
|
||||
bar baz
|
||||
at tryReadme() (readme.js:20:1)
|
||||
*/
|
||||
```
|
||||
|
||||
#### `errorEx.line(str)`
|
||||
Creates a stack line using a delimiter
|
||||
|
||||
> This is a helper function. It is to be used in lieu of writing a value object
|
||||
> for `properties` values.
|
||||
|
||||
- `str`: The string to create
|
||||
- Use the delimiter `%s` to specify where in the string the value should go
|
||||
|
||||
```javascript
|
||||
var errorEx = require('error-ex');
|
||||
|
||||
var FileError = errorEx('FileError', {fileName: errorEx.line('in %s')});
|
||||
|
||||
var err = new FileError('problem reading file');
|
||||
err.fileName = '/a/b/c/d/foo.js';
|
||||
throw err;
|
||||
|
||||
/*
|
||||
FileError: problem reading file
|
||||
in /a/b/c/d/foo.js
|
||||
at tryReadme() (readme.js:7:1)
|
||||
*/
|
||||
```
|
||||
|
||||
#### `errorEx.append(str)`
|
||||
Appends to the `error.message` string
|
||||
|
||||
> This is a helper function. It is to be used in lieu of writing a value object
|
||||
> for `properties` values.
|
||||
|
||||
- `str`: The string to append
|
||||
- Use the delimiter `%s` to specify where in the string the value should go
|
||||
|
||||
```javascript
|
||||
var errorEx = require('error-ex');
|
||||
|
||||
var SyntaxError = errorEx('SyntaxError', {fileName: errorEx.append('in %s')});
|
||||
|
||||
var err = new SyntaxError('improper indentation');
|
||||
err.fileName = '/a/b/c/d/foo.js';
|
||||
throw err;
|
||||
|
||||
/*
|
||||
SyntaxError: improper indentation in /a/b/c/d/foo.js
|
||||
at tryReadme() (readme.js:7:1)
|
||||
*/
|
||||
```
|
||||
|
||||
## License
|
||||
Licensed under the [MIT License](http://opensource.org/licenses/MIT).
|
||||
You can find a copy of it in [LICENSE](LICENSE).
|
||||
@@ -0,0 +1,39 @@
|
||||
if (require.main !== module) {
|
||||
throw new Error('This file should not be required');
|
||||
}
|
||||
|
||||
var childProcess = require('child_process');
|
||||
var fs = require('fs');
|
||||
|
||||
var paramFilePath = process.argv[2];
|
||||
|
||||
var serializedParams = fs.readFileSync(paramFilePath, 'utf8');
|
||||
var params = JSON.parse(serializedParams);
|
||||
|
||||
var cmd = params.command;
|
||||
var execOptions = params.execOptions;
|
||||
var pipe = params.pipe;
|
||||
var stdoutFile = params.stdoutFile;
|
||||
var stderrFile = params.stderrFile;
|
||||
|
||||
var c = childProcess.exec(cmd, execOptions, function (err) {
|
||||
if (!err) {
|
||||
process.exitCode = 0;
|
||||
} else if (err.code === undefined) {
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
process.exitCode = err.code;
|
||||
}
|
||||
});
|
||||
|
||||
var stdoutStream = fs.createWriteStream(stdoutFile);
|
||||
var stderrStream = fs.createWriteStream(stderrFile);
|
||||
|
||||
c.stdout.pipe(stdoutStream);
|
||||
c.stderr.pipe(stderrStream);
|
||||
c.stdout.pipe(process.stdout);
|
||||
c.stderr.pipe(process.stderr);
|
||||
|
||||
if (pipe) {
|
||||
c.stdin.end(pipe);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').timesLimit;
|
||||
@@ -0,0 +1,3 @@
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Title from '../../nodes/Title';
|
||||
export default function (node: Title, renderer: Renderer, options: RenderOptions): void;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Returns the best matching date time pattern if a date time skeleton
|
||||
* pattern is provided with a locale. Follows the Unicode specification:
|
||||
* https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
|
||||
* @param skeleton date time skeleton pattern that possibly includes j, J or C
|
||||
* @param locale
|
||||
*/
|
||||
export declare function getBestPattern(skeleton: string, locale: Intl.Locale): string;
|
||||
//# sourceMappingURL=date-time-pattern-generator.d.ts.map
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* A specialized version of `baseAggregator` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [array] The array to iterate over.
|
||||
* @param {Function} setter The function to set `accumulator` values.
|
||||
* @param {Function} iteratee The iteratee to transform keys.
|
||||
* @param {Object} accumulator The initial aggregated object.
|
||||
* @returns {Function} Returns `accumulator`.
|
||||
*/
|
||||
function arrayAggregator(array, setter, iteratee, accumulator) {
|
||||
var index = -1,
|
||||
length = array == null ? 0 : array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
setter(accumulator, value, iteratee(value), array);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
module.exports = arrayAggregator;
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
|
||||
var HasOwnProperty = require('./HasOwnProperty');
|
||||
var IsExtensible = require('./IsExtensible');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-setfunctionlength
|
||||
|
||||
module.exports = function SetFunctionLength(F, length) {
|
||||
if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) {
|
||||
throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property');
|
||||
}
|
||||
if (Type(length) !== 'Number') {
|
||||
throw new $TypeError('Assertion failed: `length` must be a Number');
|
||||
}
|
||||
if (length !== Infinity && (!IsIntegralNumber(length) || length < 0)) {
|
||||
throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0');
|
||||
}
|
||||
return DefinePropertyOrThrow(F, 'length', {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': length,
|
||||
'[[Writable]]': false
|
||||
});
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
||||
const picomatch = require('picomatch');
|
||||
const normalizePath = require('normalize-path');
|
||||
|
||||
/**
|
||||
* @typedef {(testString: string) => boolean} AnymatchFn
|
||||
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern
|
||||
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher
|
||||
*/
|
||||
const BANG = '!';
|
||||
const DEFAULT_OPTIONS = {returnIndex: false};
|
||||
const arrify = (item) => Array.isArray(item) ? item : [item];
|
||||
|
||||
/**
|
||||
* @param {AnymatchPattern} matcher
|
||||
* @param {object} options
|
||||
* @returns {AnymatchFn}
|
||||
*/
|
||||
const createPattern = (matcher, options) => {
|
||||
if (typeof matcher === 'function') {
|
||||
return matcher;
|
||||
}
|
||||
if (typeof matcher === 'string') {
|
||||
const glob = picomatch(matcher, options);
|
||||
return (string) => matcher === string || glob(string);
|
||||
}
|
||||
if (matcher instanceof RegExp) {
|
||||
return (string) => matcher.test(string);
|
||||
}
|
||||
return (string) => false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Array<Function>} patterns
|
||||
* @param {Array<Function>} negPatterns
|
||||
* @param {String|Array} args
|
||||
* @param {Boolean} returnIndex
|
||||
* @returns {boolean|number}
|
||||
*/
|
||||
const matchPatterns = (patterns, negPatterns, args, returnIndex) => {
|
||||
const isList = Array.isArray(args);
|
||||
const _path = isList ? args[0] : args;
|
||||
if (!isList && typeof _path !== 'string') {
|
||||
throw new TypeError('anymatch: second argument must be a string: got ' +
|
||||
Object.prototype.toString.call(_path))
|
||||
}
|
||||
const path = normalizePath(_path, false);
|
||||
|
||||
for (let index = 0; index < negPatterns.length; index++) {
|
||||
const nglob = negPatterns[index];
|
||||
if (nglob(path)) {
|
||||
return returnIndex ? -1 : false;
|
||||
}
|
||||
}
|
||||
|
||||
const applied = isList && [path].concat(args.slice(1));
|
||||
for (let index = 0; index < patterns.length; index++) {
|
||||
const pattern = patterns[index];
|
||||
if (isList ? pattern(...applied) : pattern(path)) {
|
||||
return returnIndex ? index : true;
|
||||
}
|
||||
}
|
||||
|
||||
return returnIndex ? -1 : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AnymatchMatcher} matchers
|
||||
* @param {Array|string} testString
|
||||
* @param {object} options
|
||||
* @returns {boolean|number|Function}
|
||||
*/
|
||||
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => {
|
||||
if (matchers == null) {
|
||||
throw new TypeError('anymatch: specify first argument');
|
||||
}
|
||||
const opts = typeof options === 'boolean' ? {returnIndex: options} : options;
|
||||
const returnIndex = opts.returnIndex || false;
|
||||
|
||||
// Early cache for matchers.
|
||||
const mtchers = arrify(matchers);
|
||||
const negatedGlobs = mtchers
|
||||
.filter(item => typeof item === 'string' && item.charAt(0) === BANG)
|
||||
.map(item => item.slice(1))
|
||||
.map(item => picomatch(item, opts));
|
||||
const patterns = mtchers
|
||||
.filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG))
|
||||
.map(matcher => createPattern(matcher, opts));
|
||||
|
||||
if (testString == null) {
|
||||
return (testString, ri = false) => {
|
||||
const returnIndex = typeof ri === 'boolean' ? ri : false;
|
||||
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||
};
|
||||
|
||||
anymatch.default = anymatch;
|
||||
module.exports = anymatch;
|
||||
@@ -0,0 +1,32 @@
|
||||
# xtend
|
||||
|
||||
[![browser support][3]][4]
|
||||
|
||||
[](http://github.com/badges/stability-badges)
|
||||
|
||||
Extend like a boss
|
||||
|
||||
xtend is a basic utility library which allows you to extend an object by appending all of the properties from each object in a list. When there are identical properties, the right-most property takes precedence.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
var extend = require("xtend")
|
||||
|
||||
// extend returns a new object. Does not mutate arguments
|
||||
var combination = extend({
|
||||
a: "a",
|
||||
b: "c"
|
||||
}, {
|
||||
b: "b"
|
||||
})
|
||||
// { a: "a", b: "b" }
|
||||
```
|
||||
|
||||
## Stability status: Locked
|
||||
|
||||
## MIT Licensed
|
||||
|
||||
|
||||
[3]: http://ci.testling.com/Raynos/xtend.png
|
||||
[4]: http://ci.testling.com/Raynos/xtend
|
||||
@@ -0,0 +1,90 @@
|
||||
var getAllKeys = require('./_getAllKeys');
|
||||
|
||||
/** Used to compose bitmasks for value comparisons. */
|
||||
var COMPARE_PARTIAL_FLAG = 1;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseIsEqualDeep` for objects with support for
|
||||
* partial deep comparisons.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to compare.
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
||||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
||||
objProps = getAllKeys(object),
|
||||
objLength = objProps.length,
|
||||
othProps = getAllKeys(other),
|
||||
othLength = othProps.length;
|
||||
|
||||
if (objLength != othLength && !isPartial) {
|
||||
return false;
|
||||
}
|
||||
var index = objLength;
|
||||
while (index--) {
|
||||
var key = objProps[index];
|
||||
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check that cyclic values are equal.
|
||||
var objStacked = stack.get(object);
|
||||
var othStacked = stack.get(other);
|
||||
if (objStacked && othStacked) {
|
||||
return objStacked == other && othStacked == object;
|
||||
}
|
||||
var result = true;
|
||||
stack.set(object, other);
|
||||
stack.set(other, object);
|
||||
|
||||
var skipCtor = isPartial;
|
||||
while (++index < objLength) {
|
||||
key = objProps[index];
|
||||
var objValue = object[key],
|
||||
othValue = other[key];
|
||||
|
||||
if (customizer) {
|
||||
var compared = isPartial
|
||||
? customizer(othValue, objValue, key, other, object, stack)
|
||||
: customizer(objValue, othValue, key, object, other, stack);
|
||||
}
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
if (!(compared === undefined
|
||||
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
||||
: compared
|
||||
)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
skipCtor || (skipCtor = key == 'constructor');
|
||||
}
|
||||
if (result && !skipCtor) {
|
||||
var objCtor = object.constructor,
|
||||
othCtor = other.constructor;
|
||||
|
||||
// Non `Object` object instances with different constructors are not equal.
|
||||
if (objCtor != othCtor &&
|
||||
('constructor' in object && 'constructor' in other) &&
|
||||
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
||||
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
stack['delete'](object);
|
||||
stack['delete'](other);
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = equalObjects;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Subject } from './Subject';
|
||||
export class AsyncSubject extends Subject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._value = null;
|
||||
this._hasValue = false;
|
||||
this._isComplete = false;
|
||||
}
|
||||
_checkFinalizedStatuses(subscriber) {
|
||||
const { hasError, _hasValue, _value, thrownError, isStopped, _isComplete } = this;
|
||||
if (hasError) {
|
||||
subscriber.error(thrownError);
|
||||
}
|
||||
else if (isStopped || _isComplete) {
|
||||
_hasValue && subscriber.next(_value);
|
||||
subscriber.complete();
|
||||
}
|
||||
}
|
||||
next(value) {
|
||||
if (!this.isStopped) {
|
||||
this._value = value;
|
||||
this._hasValue = true;
|
||||
}
|
||||
}
|
||||
complete() {
|
||||
const { _hasValue, _value, _isComplete } = this;
|
||||
if (!_isComplete) {
|
||||
this._isComplete = true;
|
||||
_hasValue && super.next(_value);
|
||||
super.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=AsyncSubject.js.map
|
||||
@@ -0,0 +1,30 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
const level = (() => {
|
||||
if (navigator.userAgentData) {
|
||||
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
||||
if (brand && brand.version > 93) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
})();
|
||||
|
||||
const colorSupport = level !== 0 && {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
|
||||
const supportsColor = {
|
||||
stdout: colorSupport,
|
||||
stderr: colorSupport,
|
||||
};
|
||||
|
||||
export default supportsColor;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Join all arguments together and normalize the resulting url.
|
||||
* This works similar to `path.join` but you shouldn't use `path.join` for urls since it works
|
||||
* differently depending on the operating system and also doesn't work for some cases.
|
||||
*/
|
||||
declare function urlJoin(...parts: string[]): string;
|
||||
declare function urlJoin(parts: string[]): string;
|
||||
|
||||
export default urlJoin;
|
||||
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-stringtobigint
|
||||
|
||||
module.exports = function StringToBigInt(argument) {
|
||||
if (typeof argument !== 'string') {
|
||||
throw new $TypeError('`argument` must be a string');
|
||||
}
|
||||
if (!$BigInt) {
|
||||
throw new $SyntaxError('BigInts are not supported in this environment');
|
||||
}
|
||||
try {
|
||||
return $BigInt(argument);
|
||||
} catch (e) {
|
||||
return NaN;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2016-20 [these people](https://github.com/sveltejs/svelte-preprocess/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
export default function full_char_code_at(str: string, i: number): number;
|
||||
@@ -0,0 +1,6 @@
|
||||
export type CreateDistanceDonation = {
|
||||
runner: number;
|
||||
amountPerDistance: number;
|
||||
donor: number;
|
||||
paidAmount?: number;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* The base implementation of `_.unary` without support for storing metadata.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to cap arguments for.
|
||||
* @returns {Function} Returns the new capped function.
|
||||
*/
|
||||
function baseUnary(func) {
|
||||
return function(value) {
|
||||
return func(value);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = baseUnary;
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"is-array-buffer","version":"3.0.2","files":{".nycrc":{"checkedAt":1678883669555,"integrity":"sha512-2vm1RFz8Ajl/OYrfoCWPJIm3Bpnf7Gyn5bha/lZx/cq+We3uMy9xj15XeP6x4wF3jf/pO7KMHAkU9mllm605xg==","mode":420,"size":139},".eslintrc":{"checkedAt":1678883673405,"integrity":"sha512-GJfZ1ARR8/7NEtm1V1LQp0vyNlbIqwNxLAg+bEsnO/FYwdHzKClOXaAb6gvwFrtTRu6XWshDWVOSwCxb0fIguA==","mode":420,"size":144},"LICENSE":{"checkedAt":1678883673405,"integrity":"sha512-8UrJlp9an1kJuCKTVslewUkB5mCbYkptSOysQCuaoHVB/YUMb9SxZrGhd8i4A7KkR5dAPq42rRVNCJ/yquVmTQ==","mode":420,"size":1082},"test/index.js":{"checkedAt":1678883673405,"integrity":"sha512-JLffwezLuEhyhSnxDpLwhUIeqPDW+xT0Msd+0wMXnqzwHmZ3jt8S1wqfdMNkTeyv+zL4APLQ2lZwfIvGt/ZM6A==","mode":420,"size":1348},"index.js":{"checkedAt":1678883673405,"integrity":"sha512-dt/AQQvdPm+5QficmQvuyszb0WpaCTUC+l8Z1A94jHsYq34SegDgEhTlSYZtm2RE/hSxCBNFyuSqCNbkhT0E5Q==","mode":420,"size":1258},"package.json":{"checkedAt":1678883673405,"integrity":"sha512-jcnuBxQIO30ipDdsWbwqHCk5zUT/nkfCA1VttWiUEg1/JKr1V3dJyCZcvHrYq/a44+py+BStfhpWf94Tu93LlQ==","mode":420,"size":2057},"CHANGELOG.md":{"checkedAt":1678883673405,"integrity":"sha512-0pa8xYlRFMd69rlnMmSfKv3lH3mZCSHlCuttKPokFx0tTJb2oM4c0f7NUFBQ5lvXXVsw25COztJQOTXD1Bktvg==","mode":420,"size":2863},"README.md":{"checkedAt":1678883673406,"integrity":"sha512-G+B2F/nNPTXZKlkT4OQxwi1x4YQ73K8Wjve7hkzHDF65Uy6/AQ7Ch4ibhuEx5kFOChFRPRO69KV1S47wFp1v+A==","mode":420,"size":2405},".github/FUNDING.yml":{"checkedAt":1678883673406,"integrity":"sha512-pSuxXNPfSOswRKNAtRVoxesnfhnisjMnQiYIn67Tn1w2r8Am7IptgIkaAujIQ+J7osf8CDLKCBGLjOJ0Ahrlow==","mode":420,"size":586}}}
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
var minimist = require("minimist");
|
||||
var argv = process.argv;
|
||||
argv.shift();
|
||||
argv.shift();
|
||||
var args = minimist(argv);
|
||||
var headers = ["name", "header1", "file2", "description", "header2", "field2", "header3"];
|
||||
|
||||
if (args.headers) {
|
||||
headers = JSON.parse(args.headers);
|
||||
}
|
||||
var rowNum = args.row ? args.row : 10000;
|
||||
var chars = args.chars ? args.chars : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
var maxLength = parseInt(args.max ? args.max : "15");
|
||||
console.log(headers.join(","));
|
||||
for (var i = 0; i < rowNum; i++) {
|
||||
var row = [];
|
||||
for (var j = 0; j < headers.length; j++) {
|
||||
row.push(genWord());
|
||||
}
|
||||
console.log(row.join(","));
|
||||
}
|
||||
|
||||
function genWord() {
|
||||
var len = Math.round(Math.random() * maxLength);
|
||||
var rtn = "";
|
||||
for (var i = 0; i < len; i++) {
|
||||
var pos = Math.round(Math.random() * chars.length);
|
||||
rtn += chars[pos];
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var concatMap = require('../');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Gets the value at `key` of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} [object] The object to query.
|
||||
* @param {string} key The key of the property to get.
|
||||
* @returns {*} Returns the property value.
|
||||
*/
|
||||
function getValue(object, key) {
|
||||
return object == null ? undefined : object[key];
|
||||
}
|
||||
|
||||
module.exports = getValue;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,633 @@
|
||||
smart-buffer [](https://travis-ci.org/JoshGlazebrook/smart-buffer) [](https://coveralls.io/github/JoshGlazebrook/smart-buffer?branch=master)
|
||||
=============
|
||||
|
||||
smart-buffer is a Buffer wrapper that adds automatic read & write offset tracking, string operations, data insertions, and more.
|
||||
|
||||

|
||||
|
||||
**Key Features**:
|
||||
* Proxies all of the Buffer write and read functions
|
||||
* Keeps track of read and write offsets automatically
|
||||
* Grows the internal Buffer as needed
|
||||
* Useful string operations. (Null terminating strings)
|
||||
* Allows for inserting values at specific points in the Buffer
|
||||
* Built in TypeScript
|
||||
* Type Definitions Provided
|
||||
* Browser Support (using Webpack/Browserify)
|
||||
* Full test coverage
|
||||
|
||||
**Requirements**:
|
||||
* Node v4.0+ is supported at this time. (Versions prior to 2.0 will work on node 0.10)
|
||||
|
||||
|
||||
|
||||
## Breaking Changes in v4.0
|
||||
|
||||
* Old constructor patterns have been completely removed. It's now required to use the SmartBuffer.fromXXX() factory constructors.
|
||||
* rewind(), skip(), moveTo() have been removed. (see [offsets](#offsets))
|
||||
* Internal private properties are now prefixed with underscores (_)
|
||||
* **All** writeXXX() methods that are given an offset will now **overwrite data** instead of insert. (see [write vs insert](#write-vs-insert))
|
||||
* insertXXX() methods have been added for when you want to insert data at a specific offset (this replaces the old behavior of writeXXX() when an offset was provided)
|
||||
|
||||
|
||||
## Looking for v3 docs?
|
||||
|
||||
Legacy documentation for version 3 and prior can be found [here](https://github.com/JoshGlazebrook/smart-buffer/blob/master/docs/README_v3.md).
|
||||
|
||||
## Installing:
|
||||
|
||||
`yarn add smart-buffer`
|
||||
|
||||
or
|
||||
|
||||
`npm install smart-buffer`
|
||||
|
||||
Note: The published NPM package includes the built javascript library.
|
||||
If you cloned this repo and wish to build the library manually use:
|
||||
|
||||
`npm run build`
|
||||
|
||||
## Using smart-buffer
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
const SmartBuffer = require('smart-buffer').SmartBuffer;
|
||||
|
||||
// Typescript
|
||||
import { SmartBuffer, SmartBufferOptions} from 'smart-buffer';
|
||||
```
|
||||
|
||||
### Simple Example
|
||||
|
||||
Building a packet that uses the following protocol specification:
|
||||
|
||||
`[PacketType:2][PacketLength:2][Data:XX]`
|
||||
|
||||
To build this packet using the vanilla Buffer class, you would have to count up the length of the data payload beforehand. You would also need to keep track of the current "cursor" position in your Buffer so you write everything in the right places. With smart-buffer you don't have to do either of those things.
|
||||
|
||||
```javascript
|
||||
function createLoginPacket(username, password, age, country) {
|
||||
const packet = new SmartBuffer();
|
||||
packet.writeUInt16LE(0x0060); // Some packet type
|
||||
packet.writeStringNT(username);
|
||||
packet.writeStringNT(password);
|
||||
packet.writeUInt8(age);
|
||||
packet.writeStringNT(country);
|
||||
packet.insertUInt16LE(packet.length - 2, 2);
|
||||
|
||||
return packet.toBuffer();
|
||||
}
|
||||
```
|
||||
With the above function, you now can do this:
|
||||
```javascript
|
||||
const login = createLoginPacket("Josh", "secret123", 22, "United States");
|
||||
|
||||
// <Buffer 60 00 1e 00 4a 6f 73 68 00 73 65 63 72 65 74 31 32 33 00 16 55 6e 69 74 65 64 20 53 74 61 74 65 73 00>
|
||||
```
|
||||
Notice that the `[PacketLength:2]` value (1e 00) was inserted at position 2.
|
||||
|
||||
Reading back the packet we created above is just as easy:
|
||||
```javascript
|
||||
|
||||
const reader = SmartBuffer.fromBuffer(login);
|
||||
|
||||
const logininfo = {
|
||||
packetType: reader.readUInt16LE(),
|
||||
packetLength: reader.readUInt16LE(),
|
||||
username: reader.readStringNT(),
|
||||
password: reader.readStringNT(),
|
||||
age: reader.readUInt8(),
|
||||
country: reader.readStringNT()
|
||||
};
|
||||
|
||||
/*
|
||||
{
|
||||
packetType: 96, (0x0060)
|
||||
packetLength: 30,
|
||||
username: 'Josh',
|
||||
password: 'secret123',
|
||||
age: 22,
|
||||
country: 'United States'
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
## Write vs Insert
|
||||
In prior versions of SmartBuffer, .writeXXX(value, offset) calls would insert data when an offset was provided. In version 4, this will now overwrite the data at the offset position. To insert data there are now corresponding .insertXXX(value, offset) methods.
|
||||
|
||||
**SmartBuffer v3**:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));
|
||||
buff.writeInt8(7, 2);
|
||||
console.log(buff.toBuffer())
|
||||
|
||||
// <Buffer 01 02 07 03 04 05 06>
|
||||
```
|
||||
|
||||
**SmartBuffer v4**:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));
|
||||
buff.writeInt8(7, 2);
|
||||
console.log(buff.toBuffer());
|
||||
|
||||
// <Buffer 01 02 07 04 05 06>
|
||||
```
|
||||
|
||||
To insert you instead should use:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));
|
||||
buff.insertInt8(7, 2);
|
||||
console.log(buff.toBuffer());
|
||||
|
||||
// <Buffer 01 02 07 03 04 05 06>
|
||||
```
|
||||
|
||||
**Note:** Insert/Writing to a position beyond the currently tracked internal Buffer will zero pad to your offset.
|
||||
|
||||
## Constructing a smart-buffer
|
||||
|
||||
There are a few different ways to construct a SmartBuffer instance.
|
||||
|
||||
```javascript
|
||||
// Creating SmartBuffer from existing Buffer
|
||||
const buff = SmartBuffer.fromBuffer(buffer); // Creates instance from buffer. (Uses default utf8 encoding)
|
||||
const buff = SmartBuffer.fromBuffer(buffer, 'ascii'); // Creates instance from buffer with ascii encoding for strings.
|
||||
|
||||
// Creating SmartBuffer with specified internal Buffer size. (Note: this is not a hard cap, the internal buffer will grow as needed).
|
||||
const buff = SmartBuffer.fromSize(1024); // Creates instance with internal Buffer size of 1024.
|
||||
const buff = SmartBuffer.fromSize(1024, 'utf8'); // Creates instance with internal Buffer size of 1024, and utf8 encoding for strings.
|
||||
|
||||
// Creating SmartBuffer with options object. This one specifies size and encoding.
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
size: 1024,
|
||||
encoding: 'ascii'
|
||||
});
|
||||
|
||||
// Creating SmartBuffer with options object. This one specified an existing Buffer.
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
buff: buffer
|
||||
});
|
||||
|
||||
// Creating SmartBuffer from a string.
|
||||
const buff = SmartBuffer.fromBuffer(Buffer.from('some string', 'utf8'));
|
||||
|
||||
// Just want a regular SmartBuffer with all default options?
|
||||
const buff = new SmartBuffer();
|
||||
```
|
||||
|
||||
# Api Reference:
|
||||
|
||||
**Note:** SmartBuffer is fully documented with Typescript definitions as well as jsdocs so your favorite editor/IDE will have intellisense.
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
1. [Constructing](#constructing)
|
||||
2. **Numbers**
|
||||
1. [Integers](#integers)
|
||||
2. [Floating Points](#floating-point-numbers)
|
||||
3. **Strings**
|
||||
1. [Strings](#strings)
|
||||
2. [Null Terminated Strings](#null-terminated-strings)
|
||||
4. [Buffers](#buffers)
|
||||
5. [Offsets](#offsets)
|
||||
6. [Other](#other)
|
||||
|
||||
|
||||
## Constructing
|
||||
|
||||
### constructor()
|
||||
### constructor([options])
|
||||
- ```options``` *{SmartBufferOptions}* An optional options object to construct a SmartBuffer with.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = new SmartBuffer();
|
||||
const buff = new SmartBuffer({
|
||||
size: 1024,
|
||||
encoding: 'ascii'
|
||||
});
|
||||
```
|
||||
|
||||
### Class Method: fromBuffer(buffer[, encoding])
|
||||
- ```buffer``` *{Buffer}* The Buffer instance to wrap.
|
||||
- ```encoding``` *{string}* The string encoding to use. ```Default: 'utf8'```
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const someBuffer = Buffer.from('some string');
|
||||
const buff = SmartBuffer.fromBuffer(someBuffer); // Defaults to utf8
|
||||
const buff = SmartBuffer.fromBuffer(someBuffer, 'ascii');
|
||||
```
|
||||
|
||||
### Class Method: fromSize(size[, encoding])
|
||||
- ```size``` *{number}* The size to initialize the internal Buffer.
|
||||
- ```encoding``` *{string}* The string encoding to use. ```Default: 'utf8'```
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromSize(1024); // Defaults to utf8
|
||||
const buff = SmartBuffer.fromSize(1024, 'ascii');
|
||||
```
|
||||
|
||||
### Class Method: fromOptions(options)
|
||||
- ```options``` *{SmartBufferOptions}* The Buffer instance to wrap.
|
||||
|
||||
```typescript
|
||||
interface SmartBufferOptions {
|
||||
encoding?: BufferEncoding; // Defaults to utf8
|
||||
size?: number; // Defaults to 4096
|
||||
buff?: Buffer;
|
||||
}
|
||||
```
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
size: 1024
|
||||
};
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
size: 1024,
|
||||
encoding: 'utf8'
|
||||
});
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
encoding: 'utf8'
|
||||
});
|
||||
|
||||
const someBuff = Buffer.from('some string', 'utf8');
|
||||
const buff = SmartBuffer.fromOptions({
|
||||
buffer: someBuff,
|
||||
encoding: 'utf8'
|
||||
});
|
||||
```
|
||||
|
||||
## Integers
|
||||
|
||||
### buff.readInt8([offset])
|
||||
### buff.readUInt8([offset])
|
||||
- ```offset``` *{number}* Optional position to start reading data from. **Default**: ```Auto managed offset```
|
||||
- Returns *{number}*
|
||||
|
||||
Read a Int8 value.
|
||||
|
||||
### buff.readInt16BE([offset])
|
||||
### buff.readInt16LE([offset])
|
||||
### buff.readUInt16BE([offset])
|
||||
### buff.readUInt16LE([offset])
|
||||
- ```offset``` *{number}* Optional position to start reading data from. **Default**: ```Auto managed offset```
|
||||
- Returns *{number}*
|
||||
|
||||
Read a 16 bit integer value.
|
||||
|
||||
### buff.readInt32BE([offset])
|
||||
### buff.readInt32LE([offset])
|
||||
### buff.readUInt32BE([offset])
|
||||
### buff.readUInt32LE([offset])
|
||||
- ```offset``` *{number}* Optional position to start reading data from. **Default**: ```Auto managed offset```
|
||||
- Returns *{number}*
|
||||
|
||||
Read a 32 bit integer value.
|
||||
|
||||
|
||||
### buff.writeInt8(value[, offset])
|
||||
### buff.writeUInt8(value[, offset])
|
||||
- ```value``` *{number}* The value to write.
|
||||
- ```offset``` *{number}* An optional offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- Returns *{this}*
|
||||
|
||||
Write a Int8 value.
|
||||
|
||||
### buff.insertInt8(value, offset)
|
||||
### buff.insertUInt8(value, offset)
|
||||
- ```value``` *{number}* The value to insert.
|
||||
- ```offset``` *{number}* The offset to insert this data at.
|
||||
- Returns *{this}*
|
||||
|
||||
Insert a Int8 value.
|
||||
|
||||
|
||||
### buff.writeInt16BE(value[, offset])
|
||||
### buff.writeInt16LE(value[, offset])
|
||||
### buff.writeUInt16BE(value[, offset])
|
||||
### buff.writeUInt16LE(value[, offset])
|
||||
- ```value``` *{number}* The value to write.
|
||||
- ```offset``` *{number}* An optional offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- Returns *{this}*
|
||||
|
||||
Write a 16 bit integer value.
|
||||
|
||||
### buff.insertInt16BE(value, offset)
|
||||
### buff.insertInt16LE(value, offset)
|
||||
### buff.insertUInt16BE(value, offset)
|
||||
### buff.insertUInt16LE(value, offset)
|
||||
- ```value``` *{number}* The value to insert.
|
||||
- ```offset``` *{number}* The offset to insert this data at.
|
||||
- Returns *{this}*
|
||||
|
||||
Insert a 16 bit integer value.
|
||||
|
||||
|
||||
### buff.writeInt32BE(value[, offset])
|
||||
### buff.writeInt32LE(value[, offset])
|
||||
### buff.writeUInt32BE(value[, offset])
|
||||
### buff.writeUInt32LE(value[, offset])
|
||||
- ```value``` *{number}* The value to write.
|
||||
- ```offset``` *{number}* An optional offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- Returns *{this}*
|
||||
|
||||
Write a 32 bit integer value.
|
||||
|
||||
### buff.insertInt32BE(value, offset)
|
||||
### buff.insertInt32LE(value, offset)
|
||||
### buff.insertUInt32BE(value, offset)
|
||||
### buff.nsertUInt32LE(value, offset)
|
||||
- ```value``` *{number}* The value to insert.
|
||||
- ```offset``` *{number}* The offset to insert this data at.
|
||||
- Returns *{this}*
|
||||
|
||||
Insert a 32 bit integer value.
|
||||
|
||||
|
||||
## Floating Point Numbers
|
||||
|
||||
### buff.readFloatBE([offset])
|
||||
### buff.readFloatLE([offset])
|
||||
- ```offset``` *{number}* Optional position to start reading data from. **Default**: ```Auto managed offset```
|
||||
- Returns *{number}*
|
||||
|
||||
Read a Float value.
|
||||
|
||||
### buff.readDoubleBE([offset])
|
||||
### buff.readDoubleLE([offset])
|
||||
- ```offset``` *{number}* Optional position to start reading data from. **Default**: ```Auto managed offset```
|
||||
- Returns *{number}*
|
||||
|
||||
Read a Double value.
|
||||
|
||||
|
||||
### buff.writeFloatBE(value[, offset])
|
||||
### buff.writeFloatLE(value[, offset])
|
||||
- ```value``` *{number}* The value to write.
|
||||
- ```offset``` *{number}* An optional offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- Returns *{this}*
|
||||
|
||||
Write a Float value.
|
||||
|
||||
### buff.insertFloatBE(value, offset)
|
||||
### buff.insertFloatLE(value, offset)
|
||||
- ```value``` *{number}* The value to insert.
|
||||
- ```offset``` *{number}* The offset to insert this data at.
|
||||
- Returns *{this}*
|
||||
|
||||
Insert a Float value.
|
||||
|
||||
|
||||
### buff.writeDoubleBE(value[, offset])
|
||||
### buff.writeDoubleLE(value[, offset])
|
||||
- ```value``` *{number}* The value to write.
|
||||
- ```offset``` *{number}* An optional offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- Returns *{this}*
|
||||
|
||||
Write a Double value.
|
||||
|
||||
### buff.insertDoubleBE(value, offset)
|
||||
### buff.insertDoubleLE(value, offset)
|
||||
- ```value``` *{number}* The value to insert.
|
||||
- ```offset``` *{number}* The offset to insert this data at.
|
||||
- Returns *{this}*
|
||||
|
||||
Insert a Double value.
|
||||
|
||||
## Strings
|
||||
|
||||
### buff.readString()
|
||||
### buff.readString(size[, encoding])
|
||||
### buff.readString(encoding)
|
||||
- ```size``` *{number}* The number of bytes to read. **Default:** ```Reads to the end of the Buffer.```
|
||||
- ```encoding``` *{string}* The string encoding to use. **Default:** ```utf8```.
|
||||
|
||||
Read a string value.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromBuffer(Buffer.from('hello there', 'utf8'));
|
||||
buff.readString(); // 'hello there'
|
||||
buff.readString(2); // 'he'
|
||||
buff.readString(2, 'utf8'); // 'he'
|
||||
buff.readString('utf8'); // 'hello there'
|
||||
```
|
||||
|
||||
### buff.writeString(value)
|
||||
### buff.writeString(value[, offset])
|
||||
### buff.writeString(value[, encoding])
|
||||
### buff.writeString(value[, offset[, encoding]])
|
||||
- ```value``` *{string}* The string value to write.
|
||||
- ```offset``` *{number}* The offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- ```encoding``` *{string}* An optional string encoding to use. **Default:** ```utf8```
|
||||
|
||||
Write a string value.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
buff.writeString('hello'); // Auto managed offset
|
||||
buff.writeString('hello', 2);
|
||||
buff.writeString('hello', 'utf8') // Auto managed offset
|
||||
buff.writeString('hello', 2, 'utf8');
|
||||
```
|
||||
|
||||
### buff.insertString(value, offset[, encoding])
|
||||
- ```value``` *{string}* The string value to write.
|
||||
- ```offset``` *{number}* The offset to write this value to.
|
||||
- ```encoding``` *{string}* An optional string encoding to use. **Default:** ```utf8```
|
||||
|
||||
Insert a string value.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
buff.insertString('hello', 2);
|
||||
buff.insertString('hello', 2, 'utf8');
|
||||
```
|
||||
|
||||
## Null Terminated Strings
|
||||
|
||||
### buff.readStringNT()
|
||||
### buff.readStringNT(encoding)
|
||||
- ```encoding``` *{string}* The string encoding to use. **Default:** ```utf8```.
|
||||
|
||||
Read a null terminated string value. (If a null is not found, it will read to the end of the Buffer).
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromBuffer(Buffer.from('hello\0 there', 'utf8'));
|
||||
buff.readStringNT(); // 'hello'
|
||||
|
||||
// If we called this again:
|
||||
buff.readStringNT(); // ' there'
|
||||
```
|
||||
|
||||
### buff.writeStringNT(value)
|
||||
### buff.writeStringNT(value[, offset])
|
||||
### buff.writeStringNT(value[, encoding])
|
||||
### buff.writeStringNT(value[, offset[, encoding]])
|
||||
- ```value``` *{string}* The string value to write.
|
||||
- ```offset``` *{number}* The offset to write this value to. **Default:** ```Auto managed offset```
|
||||
- ```encoding``` *{string}* An optional string encoding to use. **Default:** ```utf8```
|
||||
|
||||
Write a null terminated string value.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
buff.writeStringNT('hello'); // Auto managed offset <Buffer 68 65 6c 6c 6f 00>
|
||||
buff.writeStringNT('hello', 2); // <Buffer 00 00 68 65 6c 6c 6f 00>
|
||||
buff.writeStringNT('hello', 'utf8') // Auto managed offset
|
||||
buff.writeStringNT('hello', 2, 'utf8');
|
||||
```
|
||||
|
||||
### buff.insertStringNT(value, offset[, encoding])
|
||||
- ```value``` *{string}* The string value to write.
|
||||
- ```offset``` *{number}* The offset to write this value to.
|
||||
- ```encoding``` *{string}* An optional string encoding to use. **Default:** ```utf8```
|
||||
|
||||
Insert a null terminated string value.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
buff.insertStringNT('hello', 2);
|
||||
buff.insertStringNT('hello', 2, 'utf8');
|
||||
```
|
||||
|
||||
## Buffers
|
||||
|
||||
### buff.readBuffer([length])
|
||||
- ```length``` *{number}* The number of bytes to read into a Buffer. **Default:** ```Reads to the end of the Buffer```
|
||||
|
||||
Read a Buffer of a specified size.
|
||||
|
||||
### buff.writeBuffer(value[, offset])
|
||||
- ```value``` *{Buffer}* The buffer value to write.
|
||||
- ```offset``` *{number}* An optional offset to write the value to. **Default:** ```Auto managed offset```
|
||||
|
||||
### buff.insertBuffer(value, offset)
|
||||
- ```value``` *{Buffer}* The buffer value to write.
|
||||
- ```offset``` *{number}* The offset to write the value to.
|
||||
|
||||
|
||||
### buff.readBufferNT()
|
||||
|
||||
Read a null terminated Buffer.
|
||||
|
||||
### buff.writeBufferNT(value[, offset])
|
||||
- ```value``` *{Buffer}* The buffer value to write.
|
||||
- ```offset``` *{number}* An optional offset to write the value to. **Default:** ```Auto managed offset```
|
||||
|
||||
Write a null terminated Buffer.
|
||||
|
||||
|
||||
### buff.insertBufferNT(value, offset)
|
||||
- ```value``` *{Buffer}* The buffer value to write.
|
||||
- ```offset``` *{number}* The offset to write the value to.
|
||||
|
||||
Insert a null terminated Buffer.
|
||||
|
||||
|
||||
## Offsets
|
||||
|
||||
### buff.readOffset
|
||||
### buff.readOffset(offset)
|
||||
- ```offset``` *{number}* The new read offset value to set.
|
||||
- Returns: ```The current read offset```
|
||||
|
||||
Gets or sets the current read offset.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const currentOffset = buff.readOffset; // 5
|
||||
|
||||
buff.readOffset = 10;
|
||||
|
||||
console.log(buff.readOffset) // 10
|
||||
```
|
||||
|
||||
### buff.writeOffset
|
||||
### buff.writeOffset(offset)
|
||||
- ```offset``` *{number}* The new write offset value to set.
|
||||
- Returns: ```The current write offset```
|
||||
|
||||
Gets or sets the current write offset.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const currentOffset = buff.writeOffset; // 5
|
||||
|
||||
buff.writeOffset = 10;
|
||||
|
||||
console.log(buff.writeOffset) // 10
|
||||
```
|
||||
|
||||
### buff.encoding
|
||||
### buff.encoding(encoding)
|
||||
- ```encoding``` *{string}* The new string encoding to set.
|
||||
- Returns: ```The current string encoding```
|
||||
|
||||
Gets or sets the current string encoding.
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const currentEncoding = buff.encoding; // 'utf8'
|
||||
|
||||
buff.encoding = 'ascii';
|
||||
|
||||
console.log(buff.encoding) // 'ascii'
|
||||
```
|
||||
|
||||
## Other
|
||||
|
||||
### buff.clear()
|
||||
|
||||
Clear and resets the SmartBuffer instance.
|
||||
|
||||
### buff.remaining()
|
||||
- Returns ```Remaining data left to be read```
|
||||
|
||||
Gets the number of remaining bytes to be read.
|
||||
|
||||
|
||||
### buff.internalBuffer
|
||||
- Returns: *{Buffer}*
|
||||
|
||||
Gets the internally managed Buffer (Includes unmanaged data).
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromSize(16);
|
||||
buff.writeString('hello');
|
||||
console.log(buff.InternalBuffer); // <Buffer 68 65 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00>
|
||||
```
|
||||
|
||||
### buff.toBuffer()
|
||||
- Returns: *{Buffer}*
|
||||
|
||||
Gets a sliced Buffer instance of the internally managed Buffer. (Only includes managed data)
|
||||
|
||||
Examples:
|
||||
```javascript
|
||||
const buff = SmartBuffer.fromSize(16);
|
||||
buff.writeString('hello');
|
||||
console.log(buff.toBuffer()); // <Buffer 68 65 6c 6c 6f>
|
||||
```
|
||||
|
||||
### buff.toString([encoding])
|
||||
- ```encoding``` *{string}* The string encoding to use when converting to a string. **Default:** ```utf8```
|
||||
- Returns *{string}*
|
||||
|
||||
Gets a string representation of all data in the SmartBuffer.
|
||||
|
||||
### buff.destroy()
|
||||
|
||||
Destroys the SmartBuffer instance.
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This work is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fromEventPattern.js","sourceRoot":"","sources":["../../../../src/internal/observable/fromEventPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAyI5D,MAAM,UAAU,gBAAgB,CAC9B,UAA8C,EAC9C,aAAiE,EACjE,cAAsC;IAEtC,IAAI,cAAc,EAAE;QAClB,OAAO,gBAAgB,CAAI,UAAU,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;KAC9F;IAED,OAAO,IAAI,UAAU,CAAU,UAAC,UAAU;QACxC,IAAM,OAAO,GAAG;YAAC,WAAS;iBAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;gBAAT,sBAAS;;YAAK,OAAA,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAA1C,CAA0C,CAAC;QAC1E,IAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAhC,CAAgC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { concat } from '../observable/concat';
|
||||
import { popScheduler } from '../util/args';
|
||||
import { operate } from '../util/lift';
|
||||
export function startWith(...values) {
|
||||
const scheduler = popScheduler(values);
|
||||
return operate((source, subscriber) => {
|
||||
(scheduler ? concat(values, source, scheduler) : concat(values, source)).subscribe(subscriber);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=startWith.js.map
|
||||
Reference in New Issue
Block a user