new license file version [CI SKIP]
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
/// <reference types="node" resolution-mode="require"/>
|
||||
import type { EventEmitter } from 'node:events';
|
||||
export default function proxyEvents(from: EventEmitter, to: EventEmitter, events: Readonly<string[]>): () => void;
|
||||
@@ -0,0 +1,757 @@
|
||||
'use strict';
|
||||
|
||||
var PlainValue = require('./PlainValue-ec8e588e.js');
|
||||
var resolveSeq = require('./resolveSeq-d03cb037.js');
|
||||
var Schema = require('./Schema-88e323a7.js');
|
||||
|
||||
const defaultOptions = {
|
||||
anchorPrefix: 'a',
|
||||
customTags: null,
|
||||
indent: 2,
|
||||
indentSeq: true,
|
||||
keepCstNodes: false,
|
||||
keepNodeTypes: true,
|
||||
keepBlobsInJSON: true,
|
||||
mapAsMap: false,
|
||||
maxAliasCount: 100,
|
||||
prettyErrors: false,
|
||||
// TODO Set true in v2
|
||||
simpleKeys: false,
|
||||
version: '1.2'
|
||||
};
|
||||
const scalarOptions = {
|
||||
get binary() {
|
||||
return resolveSeq.binaryOptions;
|
||||
},
|
||||
|
||||
set binary(opt) {
|
||||
Object.assign(resolveSeq.binaryOptions, opt);
|
||||
},
|
||||
|
||||
get bool() {
|
||||
return resolveSeq.boolOptions;
|
||||
},
|
||||
|
||||
set bool(opt) {
|
||||
Object.assign(resolveSeq.boolOptions, opt);
|
||||
},
|
||||
|
||||
get int() {
|
||||
return resolveSeq.intOptions;
|
||||
},
|
||||
|
||||
set int(opt) {
|
||||
Object.assign(resolveSeq.intOptions, opt);
|
||||
},
|
||||
|
||||
get null() {
|
||||
return resolveSeq.nullOptions;
|
||||
},
|
||||
|
||||
set null(opt) {
|
||||
Object.assign(resolveSeq.nullOptions, opt);
|
||||
},
|
||||
|
||||
get str() {
|
||||
return resolveSeq.strOptions;
|
||||
},
|
||||
|
||||
set str(opt) {
|
||||
Object.assign(resolveSeq.strOptions, opt);
|
||||
}
|
||||
|
||||
};
|
||||
const documentOptions = {
|
||||
'1.0': {
|
||||
schema: 'yaml-1.1',
|
||||
merge: true,
|
||||
tagPrefixes: [{
|
||||
handle: '!',
|
||||
prefix: PlainValue.defaultTagPrefix
|
||||
}, {
|
||||
handle: '!!',
|
||||
prefix: 'tag:private.yaml.org,2002:'
|
||||
}]
|
||||
},
|
||||
1.1: {
|
||||
schema: 'yaml-1.1',
|
||||
merge: true,
|
||||
tagPrefixes: [{
|
||||
handle: '!',
|
||||
prefix: '!'
|
||||
}, {
|
||||
handle: '!!',
|
||||
prefix: PlainValue.defaultTagPrefix
|
||||
}]
|
||||
},
|
||||
1.2: {
|
||||
schema: 'core',
|
||||
merge: false,
|
||||
tagPrefixes: [{
|
||||
handle: '!',
|
||||
prefix: '!'
|
||||
}, {
|
||||
handle: '!!',
|
||||
prefix: PlainValue.defaultTagPrefix
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
function stringifyTag(doc, tag) {
|
||||
if ((doc.version || doc.options.version) === '1.0') {
|
||||
const priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);
|
||||
if (priv) return '!' + priv[1];
|
||||
const vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);
|
||||
return vocab ? `!${vocab[1]}/${vocab[2]}` : `!${tag.replace(/^tag:/, '')}`;
|
||||
}
|
||||
|
||||
let p = doc.tagPrefixes.find(p => tag.indexOf(p.prefix) === 0);
|
||||
|
||||
if (!p) {
|
||||
const dtp = doc.getDefaults().tagPrefixes;
|
||||
p = dtp && dtp.find(p => tag.indexOf(p.prefix) === 0);
|
||||
}
|
||||
|
||||
if (!p) return tag[0] === '!' ? tag : `!<${tag}>`;
|
||||
const suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, ch => ({
|
||||
'!': '%21',
|
||||
',': '%2C',
|
||||
'[': '%5B',
|
||||
']': '%5D',
|
||||
'{': '%7B',
|
||||
'}': '%7D'
|
||||
})[ch]);
|
||||
return p.handle + suffix;
|
||||
}
|
||||
|
||||
function getTagObject(tags, item) {
|
||||
if (item instanceof resolveSeq.Alias) return resolveSeq.Alias;
|
||||
|
||||
if (item.tag) {
|
||||
const match = tags.filter(t => t.tag === item.tag);
|
||||
if (match.length > 0) return match.find(t => t.format === item.format) || match[0];
|
||||
}
|
||||
|
||||
let tagObj, obj;
|
||||
|
||||
if (item instanceof resolveSeq.Scalar) {
|
||||
obj = item.value; // TODO: deprecate/remove class check
|
||||
|
||||
const match = tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class);
|
||||
tagObj = match.find(t => t.format === item.format) || match.find(t => !t.format);
|
||||
} else {
|
||||
obj = item;
|
||||
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
||||
}
|
||||
|
||||
if (!tagObj) {
|
||||
const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
|
||||
throw new Error(`Tag not resolved for ${name} value`);
|
||||
}
|
||||
|
||||
return tagObj;
|
||||
} // needs to be called before value stringifier to allow for circular anchor refs
|
||||
|
||||
|
||||
function stringifyProps(node, tagObj, {
|
||||
anchors,
|
||||
doc
|
||||
}) {
|
||||
const props = [];
|
||||
const anchor = doc.anchors.getName(node);
|
||||
|
||||
if (anchor) {
|
||||
anchors[anchor] = node;
|
||||
props.push(`&${anchor}`);
|
||||
}
|
||||
|
||||
if (node.tag) {
|
||||
props.push(stringifyTag(doc, node.tag));
|
||||
} else if (!tagObj.default) {
|
||||
props.push(stringifyTag(doc, tagObj.tag));
|
||||
}
|
||||
|
||||
return props.join(' ');
|
||||
}
|
||||
|
||||
function stringify(item, ctx, onComment, onChompKeep) {
|
||||
const {
|
||||
anchors,
|
||||
schema
|
||||
} = ctx.doc;
|
||||
let tagObj;
|
||||
|
||||
if (!(item instanceof resolveSeq.Node)) {
|
||||
const createCtx = {
|
||||
aliasNodes: [],
|
||||
onTagObj: o => tagObj = o,
|
||||
prevObjects: new Map()
|
||||
};
|
||||
item = schema.createNode(item, true, null, createCtx);
|
||||
|
||||
for (const alias of createCtx.aliasNodes) {
|
||||
alias.source = alias.source.node;
|
||||
let name = anchors.getName(alias.source);
|
||||
|
||||
if (!name) {
|
||||
name = anchors.newName();
|
||||
anchors.map[name] = alias.source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof resolveSeq.Pair) return item.toString(ctx, onComment, onChompKeep);
|
||||
if (!tagObj) tagObj = getTagObject(schema.tags, item);
|
||||
const props = stringifyProps(item, tagObj, ctx);
|
||||
if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1;
|
||||
const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof resolveSeq.Scalar ? resolveSeq.stringifyString(item, ctx, onComment, onChompKeep) : item.toString(ctx, onComment, onChompKeep);
|
||||
if (!props) return str;
|
||||
return item instanceof resolveSeq.Scalar || str[0] === '{' || str[0] === '[' ? `${props} ${str}` : `${props}\n${ctx.indent}${str}`;
|
||||
}
|
||||
|
||||
class Anchors {
|
||||
static validAnchorNode(node) {
|
||||
return node instanceof resolveSeq.Scalar || node instanceof resolveSeq.YAMLSeq || node instanceof resolveSeq.YAMLMap;
|
||||
}
|
||||
|
||||
constructor(prefix) {
|
||||
PlainValue._defineProperty(this, "map", Object.create(null));
|
||||
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
createAlias(node, name) {
|
||||
this.setAnchor(node, name);
|
||||
return new resolveSeq.Alias(node);
|
||||
}
|
||||
|
||||
createMergePair(...sources) {
|
||||
const merge = new resolveSeq.Merge();
|
||||
merge.value.items = sources.map(s => {
|
||||
if (s instanceof resolveSeq.Alias) {
|
||||
if (s.source instanceof resolveSeq.YAMLMap) return s;
|
||||
} else if (s instanceof resolveSeq.YAMLMap) {
|
||||
return this.createAlias(s);
|
||||
}
|
||||
|
||||
throw new Error('Merge sources must be Map nodes or their Aliases');
|
||||
});
|
||||
return merge;
|
||||
}
|
||||
|
||||
getName(node) {
|
||||
const {
|
||||
map
|
||||
} = this;
|
||||
return Object.keys(map).find(a => map[a] === node);
|
||||
}
|
||||
|
||||
getNames() {
|
||||
return Object.keys(this.map);
|
||||
}
|
||||
|
||||
getNode(name) {
|
||||
return this.map[name];
|
||||
}
|
||||
|
||||
newName(prefix) {
|
||||
if (!prefix) prefix = this.prefix;
|
||||
const names = Object.keys(this.map);
|
||||
|
||||
for (let i = 1; true; ++i) {
|
||||
const name = `${prefix}${i}`;
|
||||
if (!names.includes(name)) return name;
|
||||
}
|
||||
} // During parsing, map & aliases contain CST nodes
|
||||
|
||||
|
||||
resolveNodes() {
|
||||
const {
|
||||
map,
|
||||
_cstAliases
|
||||
} = this;
|
||||
Object.keys(map).forEach(a => {
|
||||
map[a] = map[a].resolved;
|
||||
});
|
||||
|
||||
_cstAliases.forEach(a => {
|
||||
a.source = a.source.resolved;
|
||||
});
|
||||
|
||||
delete this._cstAliases;
|
||||
}
|
||||
|
||||
setAnchor(node, name) {
|
||||
if (node != null && !Anchors.validAnchorNode(node)) {
|
||||
throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
|
||||
}
|
||||
|
||||
if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
|
||||
throw new Error('Anchor names must not contain whitespace or control characters');
|
||||
}
|
||||
|
||||
const {
|
||||
map
|
||||
} = this;
|
||||
const prev = node && Object.keys(map).find(a => map[a] === node);
|
||||
|
||||
if (prev) {
|
||||
if (!name) {
|
||||
return prev;
|
||||
} else if (prev !== name) {
|
||||
delete map[prev];
|
||||
map[name] = node;
|
||||
}
|
||||
} else {
|
||||
if (!name) {
|
||||
if (!node) return null;
|
||||
name = this.newName();
|
||||
}
|
||||
|
||||
map[name] = node;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const visit = (node, tags) => {
|
||||
if (node && typeof node === 'object') {
|
||||
const {
|
||||
tag
|
||||
} = node;
|
||||
|
||||
if (node instanceof resolveSeq.Collection) {
|
||||
if (tag) tags[tag] = true;
|
||||
node.items.forEach(n => visit(n, tags));
|
||||
} else if (node instanceof resolveSeq.Pair) {
|
||||
visit(node.key, tags);
|
||||
visit(node.value, tags);
|
||||
} else if (node instanceof resolveSeq.Scalar) {
|
||||
if (tag) tags[tag] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return tags;
|
||||
};
|
||||
|
||||
const listTagNames = node => Object.keys(visit(node, {}));
|
||||
|
||||
function parseContents(doc, contents) {
|
||||
const comments = {
|
||||
before: [],
|
||||
after: []
|
||||
};
|
||||
let body = undefined;
|
||||
let spaceBefore = false;
|
||||
|
||||
for (const node of contents) {
|
||||
if (node.valueRange) {
|
||||
if (body !== undefined) {
|
||||
const msg = 'Document contains trailing content not separated by a ... or --- line';
|
||||
doc.errors.push(new PlainValue.YAMLSyntaxError(node, msg));
|
||||
break;
|
||||
}
|
||||
|
||||
const res = resolveSeq.resolveNode(doc, node);
|
||||
|
||||
if (spaceBefore) {
|
||||
res.spaceBefore = true;
|
||||
spaceBefore = false;
|
||||
}
|
||||
|
||||
body = res;
|
||||
} else if (node.comment !== null) {
|
||||
const cc = body === undefined ? comments.before : comments.after;
|
||||
cc.push(node.comment);
|
||||
} else if (node.type === PlainValue.Type.BLANK_LINE) {
|
||||
spaceBefore = true;
|
||||
|
||||
if (body === undefined && comments.before.length > 0 && !doc.commentBefore) {
|
||||
// space-separated comments at start are parsed as document comments
|
||||
doc.commentBefore = comments.before.join('\n');
|
||||
comments.before = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doc.contents = body || null;
|
||||
|
||||
if (!body) {
|
||||
doc.comment = comments.before.concat(comments.after).join('\n') || null;
|
||||
} else {
|
||||
const cb = comments.before.join('\n');
|
||||
|
||||
if (cb) {
|
||||
const cbNode = body instanceof resolveSeq.Collection && body.items[0] ? body.items[0] : body;
|
||||
cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb;
|
||||
}
|
||||
|
||||
doc.comment = comments.after.join('\n') || null;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveTagDirective({
|
||||
tagPrefixes
|
||||
}, directive) {
|
||||
const [handle, prefix] = directive.parameters;
|
||||
|
||||
if (!handle || !prefix) {
|
||||
const msg = 'Insufficient parameters given for %TAG directive';
|
||||
throw new PlainValue.YAMLSemanticError(directive, msg);
|
||||
}
|
||||
|
||||
if (tagPrefixes.some(p => p.handle === handle)) {
|
||||
const msg = 'The %TAG directive must only be given at most once per handle in the same document.';
|
||||
throw new PlainValue.YAMLSemanticError(directive, msg);
|
||||
}
|
||||
|
||||
return {
|
||||
handle,
|
||||
prefix
|
||||
};
|
||||
}
|
||||
|
||||
function resolveYamlDirective(doc, directive) {
|
||||
let [version] = directive.parameters;
|
||||
if (directive.name === 'YAML:1.0') version = '1.0';
|
||||
|
||||
if (!version) {
|
||||
const msg = 'Insufficient parameters given for %YAML directive';
|
||||
throw new PlainValue.YAMLSemanticError(directive, msg);
|
||||
}
|
||||
|
||||
if (!documentOptions[version]) {
|
||||
const v0 = doc.version || doc.options.version;
|
||||
const msg = `Document will be parsed as YAML ${v0} rather than YAML ${version}`;
|
||||
doc.warnings.push(new PlainValue.YAMLWarning(directive, msg));
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
function parseDirectives(doc, directives, prevDoc) {
|
||||
const directiveComments = [];
|
||||
let hasDirectives = false;
|
||||
|
||||
for (const directive of directives) {
|
||||
const {
|
||||
comment,
|
||||
name
|
||||
} = directive;
|
||||
|
||||
switch (name) {
|
||||
case 'TAG':
|
||||
try {
|
||||
doc.tagPrefixes.push(resolveTagDirective(doc, directive));
|
||||
} catch (error) {
|
||||
doc.errors.push(error);
|
||||
}
|
||||
|
||||
hasDirectives = true;
|
||||
break;
|
||||
|
||||
case 'YAML':
|
||||
case 'YAML:1.0':
|
||||
if (doc.version) {
|
||||
const msg = 'The %YAML directive must only be given at most once per document.';
|
||||
doc.errors.push(new PlainValue.YAMLSemanticError(directive, msg));
|
||||
}
|
||||
|
||||
try {
|
||||
doc.version = resolveYamlDirective(doc, directive);
|
||||
} catch (error) {
|
||||
doc.errors.push(error);
|
||||
}
|
||||
|
||||
hasDirectives = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (name) {
|
||||
const msg = `YAML only supports %TAG and %YAML directives, and not %${name}`;
|
||||
doc.warnings.push(new PlainValue.YAMLWarning(directive, msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (comment) directiveComments.push(comment);
|
||||
}
|
||||
|
||||
if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) {
|
||||
const copyTagPrefix = ({
|
||||
handle,
|
||||
prefix
|
||||
}) => ({
|
||||
handle,
|
||||
prefix
|
||||
});
|
||||
|
||||
doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
|
||||
doc.version = prevDoc.version;
|
||||
}
|
||||
|
||||
doc.commentBefore = directiveComments.join('\n') || null;
|
||||
}
|
||||
|
||||
function assertCollection(contents) {
|
||||
if (contents instanceof resolveSeq.Collection) return true;
|
||||
throw new Error('Expected a YAML collection as document contents');
|
||||
}
|
||||
|
||||
class Document {
|
||||
constructor(options) {
|
||||
this.anchors = new Anchors(options.anchorPrefix);
|
||||
this.commentBefore = null;
|
||||
this.comment = null;
|
||||
this.contents = null;
|
||||
this.directivesEndMarker = null;
|
||||
this.errors = [];
|
||||
this.options = options;
|
||||
this.schema = null;
|
||||
this.tagPrefixes = [];
|
||||
this.version = null;
|
||||
this.warnings = [];
|
||||
}
|
||||
|
||||
add(value) {
|
||||
assertCollection(this.contents);
|
||||
return this.contents.add(value);
|
||||
}
|
||||
|
||||
addIn(path, value) {
|
||||
assertCollection(this.contents);
|
||||
this.contents.addIn(path, value);
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
assertCollection(this.contents);
|
||||
return this.contents.delete(key);
|
||||
}
|
||||
|
||||
deleteIn(path) {
|
||||
if (resolveSeq.isEmptyPath(path)) {
|
||||
if (this.contents == null) return false;
|
||||
this.contents = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
assertCollection(this.contents);
|
||||
return this.contents.deleteIn(path);
|
||||
}
|
||||
|
||||
getDefaults() {
|
||||
return Document.defaults[this.version] || Document.defaults[this.options.version] || {};
|
||||
}
|
||||
|
||||
get(key, keepScalar) {
|
||||
return this.contents instanceof resolveSeq.Collection ? this.contents.get(key, keepScalar) : undefined;
|
||||
}
|
||||
|
||||
getIn(path, keepScalar) {
|
||||
if (resolveSeq.isEmptyPath(path)) return !keepScalar && this.contents instanceof resolveSeq.Scalar ? this.contents.value : this.contents;
|
||||
return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(path, keepScalar) : undefined;
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this.contents instanceof resolveSeq.Collection ? this.contents.has(key) : false;
|
||||
}
|
||||
|
||||
hasIn(path) {
|
||||
if (resolveSeq.isEmptyPath(path)) return this.contents !== undefined;
|
||||
return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(path) : false;
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
assertCollection(this.contents);
|
||||
this.contents.set(key, value);
|
||||
}
|
||||
|
||||
setIn(path, value) {
|
||||
if (resolveSeq.isEmptyPath(path)) this.contents = value;else {
|
||||
assertCollection(this.contents);
|
||||
this.contents.setIn(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
setSchema(id, customTags) {
|
||||
if (!id && !customTags && this.schema) return;
|
||||
if (typeof id === 'number') id = id.toFixed(1);
|
||||
|
||||
if (id === '1.0' || id === '1.1' || id === '1.2') {
|
||||
if (this.version) this.version = id;else this.options.version = id;
|
||||
delete this.options.schema;
|
||||
} else if (id && typeof id === 'string') {
|
||||
this.options.schema = id;
|
||||
}
|
||||
|
||||
if (Array.isArray(customTags)) this.options.customTags = customTags;
|
||||
const opt = Object.assign({}, this.getDefaults(), this.options);
|
||||
this.schema = new Schema.Schema(opt);
|
||||
}
|
||||
|
||||
parse(node, prevDoc) {
|
||||
if (this.options.keepCstNodes) this.cstNode = node;
|
||||
if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
|
||||
const {
|
||||
directives = [],
|
||||
contents = [],
|
||||
directivesEndMarker,
|
||||
error,
|
||||
valueRange
|
||||
} = node;
|
||||
|
||||
if (error) {
|
||||
if (!error.source) error.source = this;
|
||||
this.errors.push(error);
|
||||
}
|
||||
|
||||
parseDirectives(this, directives, prevDoc);
|
||||
if (directivesEndMarker) this.directivesEndMarker = true;
|
||||
this.range = valueRange ? [valueRange.start, valueRange.end] : null;
|
||||
this.setSchema();
|
||||
this.anchors._cstAliases = [];
|
||||
parseContents(this, contents);
|
||||
this.anchors.resolveNodes();
|
||||
|
||||
if (this.options.prettyErrors) {
|
||||
for (const error of this.errors) if (error instanceof PlainValue.YAMLError) error.makePretty();
|
||||
|
||||
for (const warn of this.warnings) if (warn instanceof PlainValue.YAMLError) warn.makePretty();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
listNonDefaultTags() {
|
||||
return listTagNames(this.contents).filter(t => t.indexOf(Schema.Schema.defaultPrefix) !== 0);
|
||||
}
|
||||
|
||||
setTagPrefix(handle, prefix) {
|
||||
if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !');
|
||||
|
||||
if (prefix) {
|
||||
const prev = this.tagPrefixes.find(p => p.handle === handle);
|
||||
if (prev) prev.prefix = prefix;else this.tagPrefixes.push({
|
||||
handle,
|
||||
prefix
|
||||
});
|
||||
} else {
|
||||
this.tagPrefixes = this.tagPrefixes.filter(p => p.handle !== handle);
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(arg, onAnchor) {
|
||||
const {
|
||||
keepBlobsInJSON,
|
||||
mapAsMap,
|
||||
maxAliasCount
|
||||
} = this.options;
|
||||
const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof resolveSeq.Scalar));
|
||||
const ctx = {
|
||||
doc: this,
|
||||
indentStep: ' ',
|
||||
keep,
|
||||
mapAsMap: keep && !!mapAsMap,
|
||||
maxAliasCount,
|
||||
stringify // Requiring directly in Pair would create circular dependencies
|
||||
|
||||
};
|
||||
const anchorNames = Object.keys(this.anchors.map);
|
||||
if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], {
|
||||
alias: [],
|
||||
aliasCount: 0,
|
||||
count: 1
|
||||
}]));
|
||||
const res = resolveSeq.toJSON(this.contents, arg, ctx);
|
||||
if (typeof onAnchor === 'function' && ctx.anchors) for (const {
|
||||
count,
|
||||
res
|
||||
} of ctx.anchors.values()) onAnchor(res, count);
|
||||
return res;
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
|
||||
const indentSize = this.options.indent;
|
||||
|
||||
if (!Number.isInteger(indentSize) || indentSize <= 0) {
|
||||
const s = JSON.stringify(indentSize);
|
||||
throw new Error(`"indent" option must be a positive integer, not ${s}`);
|
||||
}
|
||||
|
||||
this.setSchema();
|
||||
const lines = [];
|
||||
let hasDirectives = false;
|
||||
|
||||
if (this.version) {
|
||||
let vd = '%YAML 1.2';
|
||||
|
||||
if (this.schema.name === 'yaml-1.1') {
|
||||
if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1';
|
||||
}
|
||||
|
||||
lines.push(vd);
|
||||
hasDirectives = true;
|
||||
}
|
||||
|
||||
const tagNames = this.listNonDefaultTags();
|
||||
this.tagPrefixes.forEach(({
|
||||
handle,
|
||||
prefix
|
||||
}) => {
|
||||
if (tagNames.some(t => t.indexOf(prefix) === 0)) {
|
||||
lines.push(`%TAG ${handle} ${prefix}`);
|
||||
hasDirectives = true;
|
||||
}
|
||||
});
|
||||
if (hasDirectives || this.directivesEndMarker) lines.push('---');
|
||||
|
||||
if (this.commentBefore) {
|
||||
if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
|
||||
lines.unshift(this.commentBefore.replace(/^/gm, '#'));
|
||||
}
|
||||
|
||||
const ctx = {
|
||||
anchors: Object.create(null),
|
||||
doc: this,
|
||||
indent: '',
|
||||
indentStep: ' '.repeat(indentSize),
|
||||
stringify // Requiring directly in nodes would create circular dependencies
|
||||
|
||||
};
|
||||
let chompKeep = false;
|
||||
let contentComment = null;
|
||||
|
||||
if (this.contents) {
|
||||
if (this.contents instanceof resolveSeq.Node) {
|
||||
if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
|
||||
if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
|
||||
|
||||
ctx.forceBlockIndent = !!this.comment;
|
||||
contentComment = this.contents.comment;
|
||||
}
|
||||
|
||||
const onChompKeep = contentComment ? null : () => chompKeep = true;
|
||||
const body = stringify(this.contents, ctx, () => contentComment = null, onChompKeep);
|
||||
lines.push(resolveSeq.addComment(body, '', contentComment));
|
||||
} else if (this.contents !== undefined) {
|
||||
lines.push(stringify(this.contents, ctx));
|
||||
}
|
||||
|
||||
if (this.comment) {
|
||||
if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push('');
|
||||
lines.push(this.comment.replace(/^/gm, '#'));
|
||||
}
|
||||
|
||||
return lines.join('\n') + '\n';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PlainValue._defineProperty(Document, "defaults", documentOptions);
|
||||
|
||||
exports.Document = Document;
|
||||
exports.defaultOptions = defaultOptions;
|
||||
exports.scalarOptions = scalarOptions;
|
||||
@@ -0,0 +1,11 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function map(project, thisArg) {
|
||||
return operate((source, subscriber) => {
|
||||
let index = 0;
|
||||
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
||||
subscriber.next(project.call(thisArg, value, index++));
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=map.js.map
|
||||
@@ -0,0 +1,27 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
<a name="2.0.3"></a>
|
||||
## [2.0.3](https://github.com/medikoo/es6-iterator/compare/v2.0.2...v2.0.3) (2017-10-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* configurability of toStringTag ([b99f692](https://github.com/medikoo/es6-iterator/commit/b99f692))
|
||||
|
||||
|
||||
|
||||
<a name="2.0.2"></a>
|
||||
## [2.0.2](https://github.com/medikoo/es6-iterator/compare/v2.0.1...v2.0.2) (2017-10-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* constructor exposure ([dbc0c51](https://github.com/medikoo/es6-iterator/commit/dbc0c51))
|
||||
* do not allow non constructor calls ([1f2f800](https://github.com/medikoo/es6-iterator/commit/1f2f800))
|
||||
* toString and toStringTag symbol definitions. ([2d17786](https://github.com/medikoo/es6-iterator/commit/2d17786)), closes [#6](https://github.com/medikoo/es6-iterator/issues/6)
|
||||
|
||||
## Changelog for previous versions
|
||||
|
||||
See `CHANGES` file
|
||||
@@ -0,0 +1,318 @@
|
||||
"use strict";;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var types_1 = tslib_1.__importDefault(require("./types"));
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
function scopePlugin(fork) {
|
||||
var types = fork.use(types_1.default);
|
||||
var Type = types.Type;
|
||||
var namedTypes = types.namedTypes;
|
||||
var Node = namedTypes.Node;
|
||||
var Expression = namedTypes.Expression;
|
||||
var isArray = types.builtInTypes.array;
|
||||
var b = types.builders;
|
||||
var Scope = function Scope(path, parentScope) {
|
||||
if (!(this instanceof Scope)) {
|
||||
throw new Error("Scope constructor cannot be invoked without 'new'");
|
||||
}
|
||||
ScopeType.assert(path.value);
|
||||
var depth;
|
||||
if (parentScope) {
|
||||
if (!(parentScope instanceof Scope)) {
|
||||
throw new Error("");
|
||||
}
|
||||
depth = parentScope.depth + 1;
|
||||
}
|
||||
else {
|
||||
parentScope = null;
|
||||
depth = 0;
|
||||
}
|
||||
Object.defineProperties(this, {
|
||||
path: { value: path },
|
||||
node: { value: path.value },
|
||||
isGlobal: { value: !parentScope, enumerable: true },
|
||||
depth: { value: depth },
|
||||
parent: { value: parentScope },
|
||||
bindings: { value: {} },
|
||||
types: { value: {} },
|
||||
});
|
||||
};
|
||||
var scopeTypes = [
|
||||
// Program nodes introduce global scopes.
|
||||
namedTypes.Program,
|
||||
// Function is the supertype of FunctionExpression,
|
||||
// FunctionDeclaration, ArrowExpression, etc.
|
||||
namedTypes.Function,
|
||||
// In case you didn't know, the caught parameter shadows any variable
|
||||
// of the same name in an outer scope.
|
||||
namedTypes.CatchClause
|
||||
];
|
||||
var ScopeType = Type.or.apply(Type, scopeTypes);
|
||||
Scope.isEstablishedBy = function (node) {
|
||||
return ScopeType.check(node);
|
||||
};
|
||||
var Sp = Scope.prototype;
|
||||
// Will be overridden after an instance lazily calls scanScope.
|
||||
Sp.didScan = false;
|
||||
Sp.declares = function (name) {
|
||||
this.scan();
|
||||
return hasOwn.call(this.bindings, name);
|
||||
};
|
||||
Sp.declaresType = function (name) {
|
||||
this.scan();
|
||||
return hasOwn.call(this.types, name);
|
||||
};
|
||||
Sp.declareTemporary = function (prefix) {
|
||||
if (prefix) {
|
||||
if (!/^[a-z$_]/i.test(prefix)) {
|
||||
throw new Error("");
|
||||
}
|
||||
}
|
||||
else {
|
||||
prefix = "t$";
|
||||
}
|
||||
// Include this.depth in the name to make sure the name does not
|
||||
// collide with any variables in nested/enclosing scopes.
|
||||
prefix += this.depth.toString(36) + "$";
|
||||
this.scan();
|
||||
var index = 0;
|
||||
while (this.declares(prefix + index)) {
|
||||
++index;
|
||||
}
|
||||
var name = prefix + index;
|
||||
return this.bindings[name] = types.builders.identifier(name);
|
||||
};
|
||||
Sp.injectTemporary = function (identifier, init) {
|
||||
identifier || (identifier = this.declareTemporary());
|
||||
var bodyPath = this.path.get("body");
|
||||
if (namedTypes.BlockStatement.check(bodyPath.value)) {
|
||||
bodyPath = bodyPath.get("body");
|
||||
}
|
||||
bodyPath.unshift(b.variableDeclaration("var", [b.variableDeclarator(identifier, init || null)]));
|
||||
return identifier;
|
||||
};
|
||||
Sp.scan = function (force) {
|
||||
if (force || !this.didScan) {
|
||||
for (var name in this.bindings) {
|
||||
// Empty out this.bindings, just in cases.
|
||||
delete this.bindings[name];
|
||||
}
|
||||
scanScope(this.path, this.bindings, this.types);
|
||||
this.didScan = true;
|
||||
}
|
||||
};
|
||||
Sp.getBindings = function () {
|
||||
this.scan();
|
||||
return this.bindings;
|
||||
};
|
||||
Sp.getTypes = function () {
|
||||
this.scan();
|
||||
return this.types;
|
||||
};
|
||||
function scanScope(path, bindings, scopeTypes) {
|
||||
var node = path.value;
|
||||
ScopeType.assert(node);
|
||||
if (namedTypes.CatchClause.check(node)) {
|
||||
// A catch clause establishes a new scope but the only variable
|
||||
// bound in that scope is the catch parameter. Any other
|
||||
// declarations create bindings in the outer scope.
|
||||
var param = path.get("param");
|
||||
if (param.value) {
|
||||
addPattern(param, bindings);
|
||||
}
|
||||
}
|
||||
else {
|
||||
recursiveScanScope(path, bindings, scopeTypes);
|
||||
}
|
||||
}
|
||||
function recursiveScanScope(path, bindings, scopeTypes) {
|
||||
var node = path.value;
|
||||
if (path.parent &&
|
||||
namedTypes.FunctionExpression.check(path.parent.node) &&
|
||||
path.parent.node.id) {
|
||||
addPattern(path.parent.get("id"), bindings);
|
||||
}
|
||||
if (!node) {
|
||||
// None of the remaining cases matter if node is falsy.
|
||||
}
|
||||
else if (isArray.check(node)) {
|
||||
path.each(function (childPath) {
|
||||
recursiveScanChild(childPath, bindings, scopeTypes);
|
||||
});
|
||||
}
|
||||
else if (namedTypes.Function.check(node)) {
|
||||
path.get("params").each(function (paramPath) {
|
||||
addPattern(paramPath, bindings);
|
||||
});
|
||||
recursiveScanChild(path.get("body"), bindings, scopeTypes);
|
||||
}
|
||||
else if ((namedTypes.TypeAlias && namedTypes.TypeAlias.check(node)) ||
|
||||
(namedTypes.InterfaceDeclaration && namedTypes.InterfaceDeclaration.check(node)) ||
|
||||
(namedTypes.TSTypeAliasDeclaration && namedTypes.TSTypeAliasDeclaration.check(node)) ||
|
||||
(namedTypes.TSInterfaceDeclaration && namedTypes.TSInterfaceDeclaration.check(node))) {
|
||||
addTypePattern(path.get("id"), scopeTypes);
|
||||
}
|
||||
else if (namedTypes.VariableDeclarator.check(node)) {
|
||||
addPattern(path.get("id"), bindings);
|
||||
recursiveScanChild(path.get("init"), bindings, scopeTypes);
|
||||
}
|
||||
else if (node.type === "ImportSpecifier" ||
|
||||
node.type === "ImportNamespaceSpecifier" ||
|
||||
node.type === "ImportDefaultSpecifier") {
|
||||
addPattern(
|
||||
// Esprima used to use the .name field to refer to the local
|
||||
// binding identifier for ImportSpecifier nodes, but .id for
|
||||
// ImportNamespaceSpecifier and ImportDefaultSpecifier nodes.
|
||||
// ESTree/Acorn/ESpree use .local for all three node types.
|
||||
path.get(node.local ? "local" :
|
||||
node.name ? "name" : "id"), bindings);
|
||||
}
|
||||
else if (Node.check(node) && !Expression.check(node)) {
|
||||
types.eachField(node, function (name, child) {
|
||||
var childPath = path.get(name);
|
||||
if (!pathHasValue(childPath, child)) {
|
||||
throw new Error("");
|
||||
}
|
||||
recursiveScanChild(childPath, bindings, scopeTypes);
|
||||
});
|
||||
}
|
||||
}
|
||||
function pathHasValue(path, value) {
|
||||
if (path.value === value) {
|
||||
return true;
|
||||
}
|
||||
// Empty arrays are probably produced by defaults.emptyArray, in which
|
||||
// case is makes sense to regard them as equivalent, if not ===.
|
||||
if (Array.isArray(path.value) &&
|
||||
path.value.length === 0 &&
|
||||
Array.isArray(value) &&
|
||||
value.length === 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function recursiveScanChild(path, bindings, scopeTypes) {
|
||||
var node = path.value;
|
||||
if (!node || Expression.check(node)) {
|
||||
// Ignore falsy values and Expressions.
|
||||
}
|
||||
else if (namedTypes.FunctionDeclaration.check(node) &&
|
||||
node.id !== null) {
|
||||
addPattern(path.get("id"), bindings);
|
||||
}
|
||||
else if (namedTypes.ClassDeclaration &&
|
||||
namedTypes.ClassDeclaration.check(node)) {
|
||||
addPattern(path.get("id"), bindings);
|
||||
}
|
||||
else if (ScopeType.check(node)) {
|
||||
if (namedTypes.CatchClause.check(node) &&
|
||||
// TODO Broaden this to accept any pattern.
|
||||
namedTypes.Identifier.check(node.param)) {
|
||||
var catchParamName = node.param.name;
|
||||
var hadBinding = hasOwn.call(bindings, catchParamName);
|
||||
// Any declarations that occur inside the catch body that do
|
||||
// not have the same name as the catch parameter should count
|
||||
// as bindings in the outer scope.
|
||||
recursiveScanScope(path.get("body"), bindings, scopeTypes);
|
||||
// If a new binding matching the catch parameter name was
|
||||
// created while scanning the catch body, ignore it because it
|
||||
// actually refers to the catch parameter and not the outer
|
||||
// scope that we're currently scanning.
|
||||
if (!hadBinding) {
|
||||
delete bindings[catchParamName];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
recursiveScanScope(path, bindings, scopeTypes);
|
||||
}
|
||||
}
|
||||
function addPattern(patternPath, bindings) {
|
||||
var pattern = patternPath.value;
|
||||
namedTypes.Pattern.assert(pattern);
|
||||
if (namedTypes.Identifier.check(pattern)) {
|
||||
if (hasOwn.call(bindings, pattern.name)) {
|
||||
bindings[pattern.name].push(patternPath);
|
||||
}
|
||||
else {
|
||||
bindings[pattern.name] = [patternPath];
|
||||
}
|
||||
}
|
||||
else if (namedTypes.AssignmentPattern &&
|
||||
namedTypes.AssignmentPattern.check(pattern)) {
|
||||
addPattern(patternPath.get('left'), bindings);
|
||||
}
|
||||
else if (namedTypes.ObjectPattern &&
|
||||
namedTypes.ObjectPattern.check(pattern)) {
|
||||
patternPath.get('properties').each(function (propertyPath) {
|
||||
var property = propertyPath.value;
|
||||
if (namedTypes.Pattern.check(property)) {
|
||||
addPattern(propertyPath, bindings);
|
||||
}
|
||||
else if (namedTypes.Property.check(property)) {
|
||||
addPattern(propertyPath.get('value'), bindings);
|
||||
}
|
||||
else if (namedTypes.SpreadProperty &&
|
||||
namedTypes.SpreadProperty.check(property)) {
|
||||
addPattern(propertyPath.get('argument'), bindings);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (namedTypes.ArrayPattern &&
|
||||
namedTypes.ArrayPattern.check(pattern)) {
|
||||
patternPath.get('elements').each(function (elementPath) {
|
||||
var element = elementPath.value;
|
||||
if (namedTypes.Pattern.check(element)) {
|
||||
addPattern(elementPath, bindings);
|
||||
}
|
||||
else if (namedTypes.SpreadElement &&
|
||||
namedTypes.SpreadElement.check(element)) {
|
||||
addPattern(elementPath.get("argument"), bindings);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (namedTypes.PropertyPattern &&
|
||||
namedTypes.PropertyPattern.check(pattern)) {
|
||||
addPattern(patternPath.get('pattern'), bindings);
|
||||
}
|
||||
else if ((namedTypes.SpreadElementPattern &&
|
||||
namedTypes.SpreadElementPattern.check(pattern)) ||
|
||||
(namedTypes.SpreadPropertyPattern &&
|
||||
namedTypes.SpreadPropertyPattern.check(pattern))) {
|
||||
addPattern(patternPath.get('argument'), bindings);
|
||||
}
|
||||
}
|
||||
function addTypePattern(patternPath, types) {
|
||||
var pattern = patternPath.value;
|
||||
namedTypes.Pattern.assert(pattern);
|
||||
if (namedTypes.Identifier.check(pattern)) {
|
||||
if (hasOwn.call(types, pattern.name)) {
|
||||
types[pattern.name].push(patternPath);
|
||||
}
|
||||
else {
|
||||
types[pattern.name] = [patternPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
Sp.lookup = function (name) {
|
||||
for (var scope = this; scope; scope = scope.parent)
|
||||
if (scope.declares(name))
|
||||
break;
|
||||
return scope;
|
||||
};
|
||||
Sp.lookupType = function (name) {
|
||||
for (var scope = this; scope; scope = scope.parent)
|
||||
if (scope.declaresType(name))
|
||||
break;
|
||||
return scope;
|
||||
};
|
||||
Sp.getGlobalScope = function () {
|
||||
var scope = this;
|
||||
while (!scope.isGlobal)
|
||||
scope = scope.parent;
|
||||
return scope;
|
||||
};
|
||||
return Scope;
|
||||
}
|
||||
exports.default = scopePlugin;
|
||||
module.exports = exports["default"];
|
||||
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const { PassThrough } = require('stream');
|
||||
|
||||
module.exports = function (/*streams...*/) {
|
||||
var sources = []
|
||||
var output = new PassThrough({objectMode: true})
|
||||
|
||||
output.setMaxListeners(0)
|
||||
|
||||
output.add = add
|
||||
output.isEmpty = isEmpty
|
||||
|
||||
output.on('unpipe', remove)
|
||||
|
||||
Array.prototype.slice.call(arguments).forEach(add)
|
||||
|
||||
return output
|
||||
|
||||
function add (source) {
|
||||
if (Array.isArray(source)) {
|
||||
source.forEach(add)
|
||||
return this
|
||||
}
|
||||
|
||||
sources.push(source);
|
||||
source.once('end', remove.bind(null, source))
|
||||
source.once('error', output.emit.bind(output, 'error'))
|
||||
source.pipe(output, {end: false})
|
||||
return this
|
||||
}
|
||||
|
||||
function isEmpty () {
|
||||
return sources.length == 0;
|
||||
}
|
||||
|
||||
function remove (source) {
|
||||
sources = sources.filter(function (it) { return it !== source })
|
||||
if (!sources.length && output.readable) { output.end() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import assert from './_assert.js';
|
||||
import { Hash, createView, toBytes } from './utils.js';
|
||||
// Polyfill for Safari 14
|
||||
function setBigUint64(view, byteOffset, value, isLE) {
|
||||
if (typeof view.setBigUint64 === 'function')
|
||||
return view.setBigUint64(byteOffset, value, isLE);
|
||||
const _32n = BigInt(32);
|
||||
const _u32_max = BigInt(0xffffffff);
|
||||
const wh = Number((value >> _32n) & _u32_max);
|
||||
const wl = Number(value & _u32_max);
|
||||
const h = isLE ? 4 : 0;
|
||||
const l = isLE ? 0 : 4;
|
||||
view.setUint32(byteOffset + h, wh, isLE);
|
||||
view.setUint32(byteOffset + l, wl, isLE);
|
||||
}
|
||||
// Base SHA2 class (RFC 6234)
|
||||
export class SHA2 extends Hash {
|
||||
constructor(blockLen, outputLen, padOffset, isLE) {
|
||||
super();
|
||||
this.blockLen = blockLen;
|
||||
this.outputLen = outputLen;
|
||||
this.padOffset = padOffset;
|
||||
this.isLE = isLE;
|
||||
this.finished = false;
|
||||
this.length = 0;
|
||||
this.pos = 0;
|
||||
this.destroyed = false;
|
||||
this.buffer = new Uint8Array(blockLen);
|
||||
this.view = createView(this.buffer);
|
||||
}
|
||||
update(data) {
|
||||
assert.exists(this);
|
||||
const { view, buffer, blockLen } = this;
|
||||
data = toBytes(data);
|
||||
const len = data.length;
|
||||
for (let pos = 0; pos < len;) {
|
||||
const take = Math.min(blockLen - this.pos, len - pos);
|
||||
// Fast path: we have at least one block in input, cast it to view and process
|
||||
if (take === blockLen) {
|
||||
const dataView = createView(data);
|
||||
for (; blockLen <= len - pos; pos += blockLen)
|
||||
this.process(dataView, pos);
|
||||
continue;
|
||||
}
|
||||
buffer.set(data.subarray(pos, pos + take), this.pos);
|
||||
this.pos += take;
|
||||
pos += take;
|
||||
if (this.pos === blockLen) {
|
||||
this.process(view, 0);
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
this.length += data.length;
|
||||
this.roundClean();
|
||||
return this;
|
||||
}
|
||||
digestInto(out) {
|
||||
assert.exists(this);
|
||||
assert.output(out, this);
|
||||
this.finished = true;
|
||||
// Padding
|
||||
// We can avoid allocation of buffer for padding completely if it
|
||||
// was previously not allocated here. But it won't change performance.
|
||||
const { buffer, view, blockLen, isLE } = this;
|
||||
let { pos } = this;
|
||||
// append the bit '1' to the message
|
||||
buffer[pos++] = 0b10000000;
|
||||
this.buffer.subarray(pos).fill(0);
|
||||
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
||||
if (this.padOffset > blockLen - pos) {
|
||||
this.process(view, 0);
|
||||
pos = 0;
|
||||
}
|
||||
// Pad until full block byte with zeros
|
||||
for (let i = pos; i < blockLen; i++)
|
||||
buffer[i] = 0;
|
||||
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
||||
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
||||
// So we just write lowest 64 bits of that value.
|
||||
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
||||
this.process(view, 0);
|
||||
const oview = createView(out);
|
||||
const len = this.outputLen;
|
||||
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
||||
if (len % 4)
|
||||
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
||||
const outLen = len / 4;
|
||||
const state = this.get();
|
||||
if (outLen > state.length)
|
||||
throw new Error('_sha2: outputLen bigger than state');
|
||||
for (let i = 0; i < outLen; i++)
|
||||
oview.setUint32(4 * i, state[i], isLE);
|
||||
}
|
||||
digest() {
|
||||
const { buffer, outputLen } = this;
|
||||
this.digestInto(buffer);
|
||||
const res = buffer.slice(0, outputLen);
|
||||
this.destroy();
|
||||
return res;
|
||||
}
|
||||
_cloneInto(to) {
|
||||
to || (to = new this.constructor());
|
||||
to.set(...this.get());
|
||||
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
||||
to.length = length;
|
||||
to.pos = pos;
|
||||
to.finished = finished;
|
||||
to.destroyed = destroyed;
|
||||
if (length % blockLen)
|
||||
to.buffer.set(buffer);
|
||||
return to;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=_sha2.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CoerceOptionsToObject.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/CoerceOptionsToObject.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAKvD"}
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('./csvtojson.js')();
|
||||
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Object = GetIntrinsic('%Object%');
|
||||
|
||||
var RequireObjectCoercible = require('./RequireObjectCoercible');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-toobject
|
||||
|
||||
module.exports = function ToObject(value) {
|
||||
RequireObjectCoercible(value);
|
||||
return $Object(value);
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
var path = require('path');
|
||||
var test = require('tape');
|
||||
var resolve = require('../');
|
||||
|
||||
test('moduleDirectory strings', function (t) {
|
||||
t.plan(4);
|
||||
var dir = path.join(__dirname, 'module_dir');
|
||||
var xopts = {
|
||||
basedir: dir,
|
||||
moduleDirectory: 'xmodules'
|
||||
};
|
||||
resolve('aaa', xopts, function (err, res, pkg) {
|
||||
t.ifError(err);
|
||||
t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
||||
});
|
||||
|
||||
var yopts = {
|
||||
basedir: dir,
|
||||
moduleDirectory: 'ymodules'
|
||||
};
|
||||
resolve('aaa', yopts, function (err, res, pkg) {
|
||||
t.ifError(err);
|
||||
t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
||||
});
|
||||
});
|
||||
|
||||
test('moduleDirectory array', function (t) {
|
||||
t.plan(6);
|
||||
var dir = path.join(__dirname, 'module_dir');
|
||||
var aopts = {
|
||||
basedir: dir,
|
||||
moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
||||
};
|
||||
resolve('aaa', aopts, function (err, res, pkg) {
|
||||
t.ifError(err);
|
||||
t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
||||
});
|
||||
|
||||
var bopts = {
|
||||
basedir: dir,
|
||||
moduleDirectory: ['zmodules', 'ymodules', 'xmodules']
|
||||
};
|
||||
resolve('aaa', bopts, function (err, res, pkg) {
|
||||
t.ifError(err);
|
||||
t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
||||
});
|
||||
|
||||
var copts = {
|
||||
basedir: dir,
|
||||
moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
||||
};
|
||||
resolve('bbb', copts, function (err, res, pkg) {
|
||||
t.ifError(err);
|
||||
t.equal(res, path.join(dir, '/zmodules/bbb/main.js'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import{options as n}from"preact";var t,r,u,i,o=0,f=[],c=[],e=n.__b,a=n.__r,v=n.diffed,l=n.__c,m=n.unmount;function d(t,u){n.__h&&n.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c}),i.__[t]}function p(n){return o=1,y(B,n)}function y(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){r.u=!0;var f=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!f||f.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!(!i&&o.__c.props===n)&&(!f||f.call(this,n,t,r))}}return o.__N||o.__}function h(u,i){var o=d(t++,3);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o))}function s(u,i){var o=d(t++,4);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o))}function _(n){return o=5,F(function(){return{current:n}},[])}function A(n,t,r){o=6,s(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function x(t,r){n.useDebugValue&&n.useDebugValue(r?r(t):t)}function P(n){var u=d(t++,10),i=p();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function V(){var n=d(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++}return n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[]}catch(r){t.__H.__h=[],n.__e(r,t.__v)}}n.__b=function(n){r=null,e&&e(n)},n.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[])),u=r},n.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===n.requestAnimationFrame||((i=n.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c})),u=r=null},n.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return!n.__||w(n)})}catch(u){r.some(function(n){n.__h&&(n.__h=[])}),r=[],n.__e(u,t.__v)}}),l&&l(t,r)},n.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n)}catch(n){r=n}}),u.__H=void 0,r&&n.__e(r,u.__v))};var g="function"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r))}function k(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function w(n){var t=r;n.__c=n.__(),r=t}function z(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B(n,t){return"function"==typeof t?t(n):t}export{T as useCallback,q as useContext,x as useDebugValue,h as useEffect,P as useErrorBoundary,V as useId,A as useImperativeHandle,s as useLayoutEffect,F as useMemo,y as useReducer,_ as useRef,p as useState};
|
||||
//# sourceMappingURL=hooks.module.js.map
|
||||
@@ -0,0 +1,38 @@
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
* (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
* (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
* (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
* (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
## Moderation Policy
|
||||
|
||||
The [Node.js Moderation Policy] applies to this WG.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
The [Node.js Code of Conduct][] applies to this WG.
|
||||
|
||||
[Node.js Code of Conduct]:
|
||||
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
|
||||
[Node.js Moderation Policy]:
|
||||
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('isFunction', require('../isFunction'), require('./_falseOptions'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { GraphqlResponseError } from "./error";
|
||||
const NON_VARIABLE_OPTIONS = [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"query",
|
||||
"mediaType",
|
||||
];
|
||||
const FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
||||
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||||
export function graphql(request, query, options) {
|
||||
if (options) {
|
||||
if (typeof query === "string" && "query" in options) {
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
||||
}
|
||||
for (const key in options) {
|
||||
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
||||
continue;
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
||||
}
|
||||
}
|
||||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
||||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
||||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||||
result[key] = parsedOptions[key];
|
||||
return result;
|
||||
}
|
||||
if (!result.variables) {
|
||||
result.variables = {};
|
||||
}
|
||||
result.variables[key] = parsedOptions[key];
|
||||
return result;
|
||||
}, {});
|
||||
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
|
||||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
|
||||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
|
||||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||||
}
|
||||
return request(requestOptions).then((response) => {
|
||||
if (response.data.errors) {
|
||||
const headers = {};
|
||||
for (const key of Object.keys(response.headers)) {
|
||||
headers[key] = response.headers[key];
|
||||
}
|
||||
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
||||
}
|
||||
return response.data.data;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export type Donation = {
|
||||
id: number;
|
||||
donor: string;
|
||||
paidAmount: number;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../../src/internal/operators/tap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAoG5C,MAAM,UAAU,GAAG,CACjB,cAAsE,EACtE,KAAiC,EACjC,QAA8B;IAK9B,IAAM,WAAW,GACf,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,IAAI,QAAQ;QAC7C,CAAC;YACE,EAAE,IAAI,EAAE,cAAyE,EAAE,KAAK,OAAA,EAAE,QAAQ,UAAA,EAA8B;QACnI,CAAC,CAAC,cAAc,CAAC;IAErB,OAAO,WAAW;QAChB,CAAC,CAAC,OAAO,CAAC,UAAC,MAAM,EAAE,UAAU;;YACzB,MAAA,WAAW,CAAC,SAAS,+CAArB,WAAW,CAAc,CAAC;YAC1B,IAAI,OAAO,GAAG,IAAI,CAAC;YACnB,MAAM,CAAC,SAAS,CACd,wBAAwB,CACtB,UAAU,EACV,UAAC,KAAK;;gBACJ,MAAA,WAAW,CAAC,IAAI,+CAAhB,WAAW,EAAQ,KAAK,CAAC,CAAC;gBAC1B,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC,EACD;;gBACE,OAAO,GAAG,KAAK,CAAC;gBAChB,MAAA,WAAW,CAAC,QAAQ,+CAApB,WAAW,CAAa,CAAC;gBACzB,UAAU,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC,EACD,UAAC,GAAG;;gBACF,OAAO,GAAG,KAAK,CAAC;gBAChB,MAAA,WAAW,CAAC,KAAK,+CAAjB,WAAW,EAAS,GAAG,CAAC,CAAC;gBACzB,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC,EACD;;gBACE,IAAI,OAAO,EAAE;oBACX,MAAA,WAAW,CAAC,WAAW,+CAAvB,WAAW,CAAgB,CAAC;iBAC7B;gBACD,MAAA,WAAW,CAAC,QAAQ,+CAApB,WAAW,CAAa,CAAC;YAC3B,CAAC,CACF,CACF,CAAC;QACJ,CAAC,CAAC;QACJ,CAAC;YAGC,QAAQ,CAAC;AACf,CAAC"}
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "has-bigints",
|
||||
"version": "1.0.2",
|
||||
"description": "Determine if the JS environment has BigInt support.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"version": "auto-changelog && git add CHANGELOG.md",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "nyc tape 'test/**/*.js'",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "aud --production"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/has-bigints.git"
|
||||
},
|
||||
"keywords": [
|
||||
"BigInt",
|
||||
"bigints",
|
||||
"typeof",
|
||||
"ES2020"
|
||||
],
|
||||
"author": "Jordan Harband <ljharb@gmail.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/has-bigints/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/has-bigints#readme",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^21.0.0",
|
||||
"aud": "^2.0.0",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"eslint": "=8.8.0",
|
||||
"in-publish": "^2.0.1",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.5.3"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = { throw: require("./throw") };
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Terkel
|
||||
|
||||
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,4 @@
|
||||
export type UserEmailNeededError = {
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isEmpty;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
var _merge = _interopRequireDefault(require("./util/merge"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var default_is_empty_options = {
|
||||
ignore_whitespace: false
|
||||
};
|
||||
|
||||
function isEmpty(str, options) {
|
||||
(0, _assertString.default)(str);
|
||||
options = (0, _merge.default)(options, default_is_empty_options);
|
||||
return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@odit/lfk-client-js",
|
||||
"description": "A lib to interact with https://git.odit.services/lfk/backend. Use this version for native JS applications.",
|
||||
"version": "0.13.3",
|
||||
"license": "CC-BY-NC-SA-4.0",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://git.odit.services/lfk/lfk-client-js"
|
||||
},
|
||||
"keywords": [
|
||||
"odit",
|
||||
"odit.services",
|
||||
"lfk"
|
||||
],
|
||||
"author": "ODIT.Services",
|
||||
"files": [
|
||||
"dist",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm run build:prepare && npm run build:lib && npm run build:compile && npm run build:cleanup",
|
||||
"build:prepare": "rimraf ./lib ./dist",
|
||||
"build:lib": "openapi --input ./openapi.json --output ./lib --client fetch",
|
||||
"build:compile": "tsc",
|
||||
"build:cleanup": "rimraf ./lib"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://git.odit.services/lfk/lfk-client-js/issues"
|
||||
},
|
||||
"homepage": "https://git.odit.services/lfk/lfk-client-js/",
|
||||
"devDependencies": {
|
||||
"openapi-typescript-codegen": "0.7.0",
|
||||
"rimraf": "4.1.2",
|
||||
"typescript": "4.9.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*!
|
||||
* is-glob <https://github.com/jonschlinkert/is-glob>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
var isExtglob = require('is-extglob');
|
||||
var chars = { '{': '}', '(': ')', '[': ']'};
|
||||
var strictCheck = function(str) {
|
||||
if (str[0] === '!') {
|
||||
return true;
|
||||
}
|
||||
var index = 0;
|
||||
var pipeIndex = -2;
|
||||
var closeSquareIndex = -2;
|
||||
var closeCurlyIndex = -2;
|
||||
var closeParenIndex = -2;
|
||||
var backSlashIndex = -2;
|
||||
while (index < str.length) {
|
||||
if (str[index] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') {
|
||||
if (closeSquareIndex < index) {
|
||||
closeSquareIndex = str.indexOf(']', index);
|
||||
}
|
||||
if (closeSquareIndex > index) {
|
||||
if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
|
||||
return true;
|
||||
}
|
||||
backSlashIndex = str.indexOf('\\', index);
|
||||
if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') {
|
||||
closeCurlyIndex = str.indexOf('}', index);
|
||||
if (closeCurlyIndex > index) {
|
||||
backSlashIndex = str.indexOf('\\', index);
|
||||
if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
|
||||
closeParenIndex = str.indexOf(')', index);
|
||||
if (closeParenIndex > index) {
|
||||
backSlashIndex = str.indexOf('\\', index);
|
||||
if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') {
|
||||
if (pipeIndex < index) {
|
||||
pipeIndex = str.indexOf('|', index);
|
||||
}
|
||||
if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') {
|
||||
closeParenIndex = str.indexOf(')', pipeIndex);
|
||||
if (closeParenIndex > pipeIndex) {
|
||||
backSlashIndex = str.indexOf('\\', pipeIndex);
|
||||
if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (str[index] === '\\') {
|
||||
var open = str[index + 1];
|
||||
index += 2;
|
||||
var close = chars[open];
|
||||
|
||||
if (close) {
|
||||
var n = str.indexOf(close, index);
|
||||
if (n !== -1) {
|
||||
index = n + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (str[index] === '!') {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var relaxedCheck = function(str) {
|
||||
if (str[0] === '!') {
|
||||
return true;
|
||||
}
|
||||
var index = 0;
|
||||
while (index < str.length) {
|
||||
if (/[*?{}()[\]]/.test(str[index])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str[index] === '\\') {
|
||||
var open = str[index + 1];
|
||||
index += 2;
|
||||
var close = chars[open];
|
||||
|
||||
if (close) {
|
||||
var n = str.indexOf(close, index);
|
||||
if (n !== -1) {
|
||||
index = n + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (str[index] === '!') {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
module.exports = function isGlob(str, options) {
|
||||
if (typeof str !== 'string' || str === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isExtglob(str)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var check = strictCheck;
|
||||
|
||||
// optionally relax check
|
||||
if (options && options.strict === false) {
|
||||
check = relaxedCheck;
|
||||
}
|
||||
|
||||
return check(str);
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../types';
|
||||
/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */
|
||||
export declare function filter<T, S extends T, A>(predicate: (this: A, value: T, index: number) => value is S, thisArg: A): OperatorFunction<T, S>;
|
||||
export declare function filter<T, S extends T>(predicate: (value: T, index: number) => value is S): OperatorFunction<T, S>;
|
||||
export declare function filter<T>(predicate: BooleanConstructor): OperatorFunction<T, TruthyTypesOf<T>>;
|
||||
/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */
|
||||
export declare function filter<T, A>(predicate: (this: A, value: T, index: number) => boolean, thisArg: A): MonoTypeOperatorFunction<T>;
|
||||
export declare function filter<T>(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction<T>;
|
||||
//# sourceMappingURL=filter.d.ts.map
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? Array.prototype.values : require("./shim");
|
||||
@@ -0,0 +1,265 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'connect' command
|
||||
|
||||
The connect command is the most common use-case for a SOCKS proxy. This establishes a direct connection to a destination host through a proxy server. The destination host only has knowledge of the proxy server connecting to it and does not know about the origin client (you).
|
||||
|
||||
**Origin Client (you) <-> Proxy Server <-> Destination Server**
|
||||
|
||||
In this example, we are connecting to a web server on port 80, and sending a very basic HTTP request to receive a response. It's worth noting that there are many socks-http-agents that can be used with the node http module (and libraries such as request.js) to make this easier. This HTTP request is used as a simple example.
|
||||
|
||||
The 'connect' command can be used via the SocksClient.createConnection() factory function as well as by creating a SocksClient instance and using event handlers.
|
||||
|
||||
### Using createConnection with async/await
|
||||
|
||||
Since SocksClient.createConnection returns a Promise, we can easily use async/await for flow control.
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
const info = await SocksClient.createConnection(options);
|
||||
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
} catch (err) {
|
||||
// Handle errors
|
||||
}
|
||||
}
|
||||
|
||||
start();
|
||||
```
|
||||
|
||||
### Using createConnection with Promises
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options)
|
||||
.then(info => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
// handle errors
|
||||
});
|
||||
```
|
||||
|
||||
### Using createConnection with callbacks
|
||||
|
||||
SocksClient.createConnection() optionally accepts a callback function as a second parameter.
|
||||
|
||||
**Note:** If a callback function is provided, a Promise is still returned from the function, but the promise will always resolve regardless of if there was en error. (tldr: Do not mix callbacks and Promises).
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options, (err, info) => {
|
||||
if (err) {
|
||||
// handle errors
|
||||
} else {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Using event handlers
|
||||
|
||||
SocksClient also supports instance creation of a SocksClient. This allows for event based flow control.
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
client.on('established', (info) => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
// Failed to establish proxy connection to destination.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
|
||||
// Start connection
|
||||
client.connect();
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
import { iterator as Symbol_iterator } from '../symbol/iterator';
|
||||
import { isFunction } from './isFunction';
|
||||
|
||||
/** Identifies an input as being an Iterable */
|
||||
export function isIterable(input: any): input is Iterable<any> {
|
||||
return isFunction(input?.[Symbol_iterator]);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseGlob", {
|
||||
enumerable: true,
|
||||
get: ()=>parseGlob
|
||||
});
|
||||
const _globParent = /*#__PURE__*/ _interopRequireDefault(require("glob-parent"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function parseGlob(pattern) {
|
||||
let glob = pattern;
|
||||
let base = (0, _globParent.default)(pattern);
|
||||
if (base !== ".") {
|
||||
glob = pattern.substr(base.length);
|
||||
if (glob.charAt(0) === "/") {
|
||||
glob = glob.substr(1);
|
||||
}
|
||||
}
|
||||
if (glob.substr(0, 2) === "./") {
|
||||
glob = glob.substr(2);
|
||||
}
|
||||
if (glob.charAt(0) === "/") {
|
||||
glob = glob.substr(1);
|
||||
}
|
||||
return {
|
||||
base,
|
||||
glob
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
Get the element type of an `Iterable`/`AsyncIterable`. For example, an array or a generator.
|
||||
|
||||
This can be useful, for example, if you want to get the type that is yielded in a generator function. Often the return type of those functions are not specified.
|
||||
|
||||
This type works with both `Iterable`s and `AsyncIterable`s, so it can be use with synchronous and asynchronous generators.
|
||||
|
||||
Here is an example of `IterableElement` in action with a generator function:
|
||||
|
||||
@example
|
||||
```
|
||||
import type {IterableElement} from 'type-fest';
|
||||
|
||||
function * iAmGenerator() {
|
||||
yield 1;
|
||||
yield 2;
|
||||
}
|
||||
|
||||
type MeNumber = IterableElement<ReturnType<typeof iAmGenerator>>
|
||||
```
|
||||
|
||||
And here is an example with an async generator:
|
||||
|
||||
@example
|
||||
```
|
||||
import type {IterableElement} from 'type-fest';
|
||||
|
||||
async function * iAmGeneratorAsync() {
|
||||
yield 'hi';
|
||||
yield true;
|
||||
}
|
||||
|
||||
type MeStringOrBoolean = IterableElement<ReturnType<typeof iAmGeneratorAsync>>
|
||||
```
|
||||
|
||||
Many types in JavaScript/TypeScript are iterables. This type works on all types that implement those interfaces. For example, `Array`, `Set`, `Map`, `stream.Readable`, etc.
|
||||
|
||||
An example with an array of strings:
|
||||
|
||||
@example
|
||||
```
|
||||
import type {IterableElement} from 'type-fest';
|
||||
|
||||
type MeString = IterableElement<string[]>
|
||||
```
|
||||
|
||||
@category Iterable
|
||||
*/
|
||||
export type IterableElement<TargetIterable> =
|
||||
TargetIterable extends Iterable<infer ElementType> ?
|
||||
ElementType :
|
||||
TargetIterable extends AsyncIterable<infer ElementType> ?
|
||||
ElementType :
|
||||
never;
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('lowerCase', require('../lowerCase'), require('./_falseOptions'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Notification } from '../Notification';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function materialize() {
|
||||
return operate(function (source, subscriber) {
|
||||
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
||||
subscriber.next(Notification.createNext(value));
|
||||
}, function () {
|
||||
subscriber.next(Notification.createComplete());
|
||||
subscriber.complete();
|
||||
}, function (err) {
|
||||
subscriber.next(Notification.createError(err));
|
||||
subscriber.complete();
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=materialize.js.map
|
||||
@@ -0,0 +1,300 @@
|
||||
import log from '../util/log'
|
||||
|
||||
function warn({ version, from, to }) {
|
||||
log.warn(`${from}-color-renamed`, [
|
||||
`As of Tailwind CSS ${version}, \`${from}\` has been renamed to \`${to}\`.`,
|
||||
'Update your configuration file to silence this warning.',
|
||||
])
|
||||
}
|
||||
|
||||
export default {
|
||||
inherit: 'inherit',
|
||||
current: 'currentColor',
|
||||
transparent: 'transparent',
|
||||
black: '#000',
|
||||
white: '#fff',
|
||||
slate: {
|
||||
50: '#f8fafc',
|
||||
100: '#f1f5f9',
|
||||
200: '#e2e8f0',
|
||||
300: '#cbd5e1',
|
||||
400: '#94a3b8',
|
||||
500: '#64748b',
|
||||
600: '#475569',
|
||||
700: '#334155',
|
||||
800: '#1e293b',
|
||||
900: '#0f172a',
|
||||
},
|
||||
gray: {
|
||||
50: '#f9fafb',
|
||||
100: '#f3f4f6',
|
||||
200: '#e5e7eb',
|
||||
300: '#d1d5db',
|
||||
400: '#9ca3af',
|
||||
500: '#6b7280',
|
||||
600: '#4b5563',
|
||||
700: '#374151',
|
||||
800: '#1f2937',
|
||||
900: '#111827',
|
||||
},
|
||||
zinc: {
|
||||
50: '#fafafa',
|
||||
100: '#f4f4f5',
|
||||
200: '#e4e4e7',
|
||||
300: '#d4d4d8',
|
||||
400: '#a1a1aa',
|
||||
500: '#71717a',
|
||||
600: '#52525b',
|
||||
700: '#3f3f46',
|
||||
800: '#27272a',
|
||||
900: '#18181b',
|
||||
},
|
||||
neutral: {
|
||||
50: '#fafafa',
|
||||
100: '#f5f5f5',
|
||||
200: '#e5e5e5',
|
||||
300: '#d4d4d4',
|
||||
400: '#a3a3a3',
|
||||
500: '#737373',
|
||||
600: '#525252',
|
||||
700: '#404040',
|
||||
800: '#262626',
|
||||
900: '#171717',
|
||||
},
|
||||
stone: {
|
||||
50: '#fafaf9',
|
||||
100: '#f5f5f4',
|
||||
200: '#e7e5e4',
|
||||
300: '#d6d3d1',
|
||||
400: '#a8a29e',
|
||||
500: '#78716c',
|
||||
600: '#57534e',
|
||||
700: '#44403c',
|
||||
800: '#292524',
|
||||
900: '#1c1917',
|
||||
},
|
||||
red: {
|
||||
50: '#fef2f2',
|
||||
100: '#fee2e2',
|
||||
200: '#fecaca',
|
||||
300: '#fca5a5',
|
||||
400: '#f87171',
|
||||
500: '#ef4444',
|
||||
600: '#dc2626',
|
||||
700: '#b91c1c',
|
||||
800: '#991b1b',
|
||||
900: '#7f1d1d',
|
||||
},
|
||||
orange: {
|
||||
50: '#fff7ed',
|
||||
100: '#ffedd5',
|
||||
200: '#fed7aa',
|
||||
300: '#fdba74',
|
||||
400: '#fb923c',
|
||||
500: '#f97316',
|
||||
600: '#ea580c',
|
||||
700: '#c2410c',
|
||||
800: '#9a3412',
|
||||
900: '#7c2d12',
|
||||
},
|
||||
amber: {
|
||||
50: '#fffbeb',
|
||||
100: '#fef3c7',
|
||||
200: '#fde68a',
|
||||
300: '#fcd34d',
|
||||
400: '#fbbf24',
|
||||
500: '#f59e0b',
|
||||
600: '#d97706',
|
||||
700: '#b45309',
|
||||
800: '#92400e',
|
||||
900: '#78350f',
|
||||
},
|
||||
yellow: {
|
||||
50: '#fefce8',
|
||||
100: '#fef9c3',
|
||||
200: '#fef08a',
|
||||
300: '#fde047',
|
||||
400: '#facc15',
|
||||
500: '#eab308',
|
||||
600: '#ca8a04',
|
||||
700: '#a16207',
|
||||
800: '#854d0e',
|
||||
900: '#713f12',
|
||||
},
|
||||
lime: {
|
||||
50: '#f7fee7',
|
||||
100: '#ecfccb',
|
||||
200: '#d9f99d',
|
||||
300: '#bef264',
|
||||
400: '#a3e635',
|
||||
500: '#84cc16',
|
||||
600: '#65a30d',
|
||||
700: '#4d7c0f',
|
||||
800: '#3f6212',
|
||||
900: '#365314',
|
||||
},
|
||||
green: {
|
||||
50: '#f0fdf4',
|
||||
100: '#dcfce7',
|
||||
200: '#bbf7d0',
|
||||
300: '#86efac',
|
||||
400: '#4ade80',
|
||||
500: '#22c55e',
|
||||
600: '#16a34a',
|
||||
700: '#15803d',
|
||||
800: '#166534',
|
||||
900: '#14532d',
|
||||
},
|
||||
emerald: {
|
||||
50: '#ecfdf5',
|
||||
100: '#d1fae5',
|
||||
200: '#a7f3d0',
|
||||
300: '#6ee7b7',
|
||||
400: '#34d399',
|
||||
500: '#10b981',
|
||||
600: '#059669',
|
||||
700: '#047857',
|
||||
800: '#065f46',
|
||||
900: '#064e3b',
|
||||
},
|
||||
teal: {
|
||||
50: '#f0fdfa',
|
||||
100: '#ccfbf1',
|
||||
200: '#99f6e4',
|
||||
300: '#5eead4',
|
||||
400: '#2dd4bf',
|
||||
500: '#14b8a6',
|
||||
600: '#0d9488',
|
||||
700: '#0f766e',
|
||||
800: '#115e59',
|
||||
900: '#134e4a',
|
||||
},
|
||||
cyan: {
|
||||
50: '#ecfeff',
|
||||
100: '#cffafe',
|
||||
200: '#a5f3fc',
|
||||
300: '#67e8f9',
|
||||
400: '#22d3ee',
|
||||
500: '#06b6d4',
|
||||
600: '#0891b2',
|
||||
700: '#0e7490',
|
||||
800: '#155e75',
|
||||
900: '#164e63',
|
||||
},
|
||||
sky: {
|
||||
50: '#f0f9ff',
|
||||
100: '#e0f2fe',
|
||||
200: '#bae6fd',
|
||||
300: '#7dd3fc',
|
||||
400: '#38bdf8',
|
||||
500: '#0ea5e9',
|
||||
600: '#0284c7',
|
||||
700: '#0369a1',
|
||||
800: '#075985',
|
||||
900: '#0c4a6e',
|
||||
},
|
||||
blue: {
|
||||
50: '#eff6ff',
|
||||
100: '#dbeafe',
|
||||
200: '#bfdbfe',
|
||||
300: '#93c5fd',
|
||||
400: '#60a5fa',
|
||||
500: '#3b82f6',
|
||||
600: '#2563eb',
|
||||
700: '#1d4ed8',
|
||||
800: '#1e40af',
|
||||
900: '#1e3a8a',
|
||||
},
|
||||
indigo: {
|
||||
50: '#eef2ff',
|
||||
100: '#e0e7ff',
|
||||
200: '#c7d2fe',
|
||||
300: '#a5b4fc',
|
||||
400: '#818cf8',
|
||||
500: '#6366f1',
|
||||
600: '#4f46e5',
|
||||
700: '#4338ca',
|
||||
800: '#3730a3',
|
||||
900: '#312e81',
|
||||
},
|
||||
violet: {
|
||||
50: '#f5f3ff',
|
||||
100: '#ede9fe',
|
||||
200: '#ddd6fe',
|
||||
300: '#c4b5fd',
|
||||
400: '#a78bfa',
|
||||
500: '#8b5cf6',
|
||||
600: '#7c3aed',
|
||||
700: '#6d28d9',
|
||||
800: '#5b21b6',
|
||||
900: '#4c1d95',
|
||||
},
|
||||
purple: {
|
||||
50: '#faf5ff',
|
||||
100: '#f3e8ff',
|
||||
200: '#e9d5ff',
|
||||
300: '#d8b4fe',
|
||||
400: '#c084fc',
|
||||
500: '#a855f7',
|
||||
600: '#9333ea',
|
||||
700: '#7e22ce',
|
||||
800: '#6b21a8',
|
||||
900: '#581c87',
|
||||
},
|
||||
fuchsia: {
|
||||
50: '#fdf4ff',
|
||||
100: '#fae8ff',
|
||||
200: '#f5d0fe',
|
||||
300: '#f0abfc',
|
||||
400: '#e879f9',
|
||||
500: '#d946ef',
|
||||
600: '#c026d3',
|
||||
700: '#a21caf',
|
||||
800: '#86198f',
|
||||
900: '#701a75',
|
||||
},
|
||||
pink: {
|
||||
50: '#fdf2f8',
|
||||
100: '#fce7f3',
|
||||
200: '#fbcfe8',
|
||||
300: '#f9a8d4',
|
||||
400: '#f472b6',
|
||||
500: '#ec4899',
|
||||
600: '#db2777',
|
||||
700: '#be185d',
|
||||
800: '#9d174d',
|
||||
900: '#831843',
|
||||
},
|
||||
rose: {
|
||||
50: '#fff1f2',
|
||||
100: '#ffe4e6',
|
||||
200: '#fecdd3',
|
||||
300: '#fda4af',
|
||||
400: '#fb7185',
|
||||
500: '#f43f5e',
|
||||
600: '#e11d48',
|
||||
700: '#be123c',
|
||||
800: '#9f1239',
|
||||
900: '#881337',
|
||||
},
|
||||
get lightBlue() {
|
||||
warn({ version: 'v2.2', from: 'lightBlue', to: 'sky' })
|
||||
return this.sky
|
||||
},
|
||||
get warmGray() {
|
||||
warn({ version: 'v3.0', from: 'warmGray', to: 'stone' })
|
||||
return this.stone
|
||||
},
|
||||
get trueGray() {
|
||||
warn({ version: 'v3.0', from: 'trueGray', to: 'neutral' })
|
||||
return this.neutral
|
||||
},
|
||||
get coolGray() {
|
||||
warn({ version: 'v3.0', from: 'coolGray', to: 'gray' })
|
||||
return this.gray
|
||||
},
|
||||
get blueGray() {
|
||||
warn({ version: 'v3.0', from: 'blueGray', to: 'slate' })
|
||||
return this.slate
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.merge = void 0;
|
||||
var lift_1 = require("../util/lift");
|
||||
var argsOrArgArray_1 = require("../util/argsOrArgArray");
|
||||
var mergeAll_1 = require("./mergeAll");
|
||||
var args_1 = require("../util/args");
|
||||
var from_1 = require("../observable/from");
|
||||
function merge() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var scheduler = args_1.popScheduler(args);
|
||||
var concurrent = args_1.popNumber(args, Infinity);
|
||||
args = argsOrArgArray_1.argsOrArgArray(args);
|
||||
return lift_1.operate(function (source, subscriber) {
|
||||
mergeAll_1.mergeAll(concurrent)(from_1.from(__spreadArray([source], __read(args)), scheduler)).subscribe(subscriber);
|
||||
});
|
||||
}
|
||||
exports.merge = merge;
|
||||
//# sourceMappingURL=merge.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"path-key","version":"4.0.0","files":{"license":{"checkedAt":1678883669302,"integrity":"sha512-0fM2/ycrxrltyaBKfQ748Ck23VlPUUBgNAR47ldf4B1V/HoXTfWBSk+vcshGKwEpmOynu4mOP5o+hyBfuRNa8g==","mode":420,"size":1117},"readme.md":{"checkedAt":1678883670751,"integrity":"sha512-epuYqgY57BscmkXqrdoRcn/4HIq0xU1O0n1ykuch+ikQCatUGMC7knTmFlwQsirgaxYrWDY0OwVwu1LC4SZjjA==","mode":420,"size":1205},"index.js":{"checkedAt":1678883670751,"integrity":"sha512-K31M3GbMfvVCOumU6ARL1XdNLCicVJTQolgwzeeByKpG13D5bJ1xO75fNBLMA0pwFwhkcXXUk+reLyx/d9/NKg==","mode":420,"size":263},"index.d.ts":{"checkedAt":1678883670751,"integrity":"sha512-Ss1uKFzhS5XAi4iO/Wng9LLcdsaVlTlpcHb4QAcY8bBUrqhdw7hzeNxuK+Hl4dknHI7AFTmf8J+R4fvMC58AoA==","mode":420,"size":730},"package.json":{"checkedAt":1678883670751,"integrity":"sha512-EC94HrfFFkYmagndKD/0YjePw/MmwdY1fjXxwsMQ6znv53T+H4ZKK5O7VfiUnPO6I4YS9yFHayhB5bNNUNrbKA==","mode":420,"size":754}}}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,866 @@
|
||||
/***********************************************************************
|
||||
|
||||
A JavaScript tokenizer / parser / beautifier / compressor.
|
||||
https://github.com/mishoo/UglifyJS
|
||||
|
||||
-------------------------------- (C) ---------------------------------
|
||||
|
||||
Author: Mihai Bazon
|
||||
<mihai.bazon@gmail.com>
|
||||
http://mihai.bazon.net/blog
|
||||
|
||||
Distributed under the BSD license:
|
||||
|
||||
Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
"use strict";
|
||||
|
||||
function SymbolDef(id, scope, orig, init) {
|
||||
this._bits = 0;
|
||||
this.defun = undefined;
|
||||
this.eliminated = 0;
|
||||
this.id = id;
|
||||
this.init = init;
|
||||
this.mangled_name = null;
|
||||
this.name = orig.name;
|
||||
this.orig = [ orig ];
|
||||
this.references = [];
|
||||
this.replaced = 0;
|
||||
this.safe_ids = undefined;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
SymbolDef.prototype = {
|
||||
forEach: function(fn) {
|
||||
this.orig.forEach(fn);
|
||||
this.references.forEach(fn);
|
||||
},
|
||||
mangle: function(options) {
|
||||
if (this.mangled_name) return;
|
||||
var cache = this.global && options.cache && options.cache.props;
|
||||
if (cache && cache.has(this.name)) {
|
||||
this.mangled_name = cache.get(this.name);
|
||||
} else if (this.unmangleable(options)) {
|
||||
names_in_use(this.scope, options).set(this.name, true);
|
||||
} else {
|
||||
var def = this.redefined();
|
||||
if (def) {
|
||||
this.mangled_name = def.mangled_name || def.name;
|
||||
} else {
|
||||
this.mangled_name = next_mangled_name(this, options);
|
||||
}
|
||||
if (cache) cache.set(this.name, this.mangled_name);
|
||||
}
|
||||
},
|
||||
redefined: function() {
|
||||
var self = this;
|
||||
var scope = self.defun;
|
||||
if (!scope) return;
|
||||
var name = self.name;
|
||||
var def = scope.variables.get(name)
|
||||
|| scope instanceof AST_Toplevel && scope.globals.get(name)
|
||||
|| self.orig[0] instanceof AST_SymbolConst && find_if(function(def) {
|
||||
return def.name == name;
|
||||
}, scope.enclosed);
|
||||
if (def && def !== self) return def.redefined() || def;
|
||||
},
|
||||
unmangleable: function(options) {
|
||||
if (this.exported) return true;
|
||||
if (this.undeclared) return true;
|
||||
if (!options.eval && this.scope.pinned()) return true;
|
||||
if (options.keep_fargs && is_funarg(this)) return true;
|
||||
if (options.keep_fnames) {
|
||||
var sym = this.orig[0];
|
||||
if (sym instanceof AST_SymbolClass) return true;
|
||||
if (sym instanceof AST_SymbolDefClass) return true;
|
||||
if (sym instanceof AST_SymbolDefun) return true;
|
||||
if (sym instanceof AST_SymbolLambda) return true;
|
||||
}
|
||||
if (!options.toplevel && this.global) return true;
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
DEF_BITPROPS(SymbolDef, [
|
||||
"const_redefs",
|
||||
"cross_loop",
|
||||
"direct_access",
|
||||
"exported",
|
||||
"global",
|
||||
"undeclared",
|
||||
]);
|
||||
|
||||
function is_funarg(def) {
|
||||
return def.orig[0] instanceof AST_SymbolFunarg || def.orig[1] instanceof AST_SymbolFunarg;
|
||||
}
|
||||
|
||||
var unary_side_effects = makePredicate("delete ++ --");
|
||||
|
||||
function is_lhs(node, parent) {
|
||||
if (parent instanceof AST_Assign) return parent.left === node && node;
|
||||
if (parent instanceof AST_DefaultValue) return parent.name === node && node;
|
||||
if (parent instanceof AST_Destructured) return node;
|
||||
if (parent instanceof AST_DestructuredKeyVal) return node;
|
||||
if (parent instanceof AST_ForEnumeration) return parent.init === node && node;
|
||||
if (parent instanceof AST_Unary) return unary_side_effects[parent.operator] && parent.expression;
|
||||
}
|
||||
|
||||
AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
options = defaults(options, {
|
||||
cache: null,
|
||||
ie: false,
|
||||
});
|
||||
|
||||
// pass 1: setup scope chaining and handle definitions
|
||||
var self = this;
|
||||
var defun = null;
|
||||
var exported = false;
|
||||
var next_def_id = 0;
|
||||
var scope = self.parent_scope = null;
|
||||
var tw = new TreeWalker(function(node, descend) {
|
||||
if (node instanceof AST_DefClass) {
|
||||
var save_exported = exported;
|
||||
exported = tw.parent() instanceof AST_ExportDeclaration;
|
||||
node.name.walk(tw);
|
||||
exported = save_exported;
|
||||
walk_scope(function() {
|
||||
if (node.extends) node.extends.walk(tw);
|
||||
node.properties.forEach(function(prop) {
|
||||
prop.walk(tw);
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Definitions) {
|
||||
var save_exported = exported;
|
||||
exported = tw.parent() instanceof AST_ExportDeclaration;
|
||||
descend();
|
||||
exported = save_exported;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_LambdaDefinition) {
|
||||
var save_exported = exported;
|
||||
exported = tw.parent() instanceof AST_ExportDeclaration;
|
||||
node.name.walk(tw);
|
||||
exported = save_exported;
|
||||
walk_scope(function() {
|
||||
node.argnames.forEach(function(argname) {
|
||||
argname.walk(tw);
|
||||
});
|
||||
if (node.rest) node.rest.walk(tw);
|
||||
walk_body(node, tw);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SwitchBranch) {
|
||||
node.init_vars(scope);
|
||||
descend();
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Try) {
|
||||
walk_scope(function() {
|
||||
walk_body(node, tw);
|
||||
});
|
||||
if (node.bcatch) node.bcatch.walk(tw);
|
||||
if (node.bfinally) node.bfinally.walk(tw);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_With) {
|
||||
var s = scope;
|
||||
do {
|
||||
s = s.resolve();
|
||||
if (s.uses_with) break;
|
||||
s.uses_with = true;
|
||||
} while (s = s.parent_scope);
|
||||
walk_scope(descend);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_BlockScope) {
|
||||
walk_scope(descend);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Symbol) {
|
||||
node.scope = scope;
|
||||
}
|
||||
if (node instanceof AST_Label) {
|
||||
node.thedef = node;
|
||||
node.references = [];
|
||||
}
|
||||
if (node instanceof AST_SymbolCatch) {
|
||||
scope.def_variable(node).defun = defun;
|
||||
} else if (node instanceof AST_SymbolConst) {
|
||||
var def = scope.def_variable(node);
|
||||
def.defun = defun;
|
||||
if (exported) def.exported = true;
|
||||
} else if (node instanceof AST_SymbolDefun) {
|
||||
var def = defun.def_function(node, tw.parent());
|
||||
if (exported) def.exported = true;
|
||||
} else if (node instanceof AST_SymbolFunarg) {
|
||||
defun.def_variable(node);
|
||||
} else if (node instanceof AST_SymbolLambda) {
|
||||
var def = defun.def_function(node, node.name == "arguments" ? undefined : defun);
|
||||
if (options.ie && node.name != "arguments") def.defun = defun.parent_scope.resolve();
|
||||
} else if (node instanceof AST_SymbolLet) {
|
||||
var def = scope.def_variable(node);
|
||||
if (exported) def.exported = true;
|
||||
} else if (node instanceof AST_SymbolVar) {
|
||||
var def = defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null);
|
||||
if (exported) def.exported = true;
|
||||
}
|
||||
|
||||
function walk_scope(descend) {
|
||||
node.init_vars(scope);
|
||||
var save_defun = defun;
|
||||
var save_scope = scope;
|
||||
if (node instanceof AST_Scope) defun = node;
|
||||
scope = node;
|
||||
descend();
|
||||
scope = save_scope;
|
||||
defun = save_defun;
|
||||
}
|
||||
});
|
||||
self.make_def = function(orig, init) {
|
||||
return new SymbolDef(++next_def_id, this, orig, init);
|
||||
};
|
||||
self.walk(tw);
|
||||
|
||||
// pass 2: find back references and eval
|
||||
self.globals = new Dictionary();
|
||||
var in_arg = [];
|
||||
var tw = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Catch) {
|
||||
if (!(node.argname instanceof AST_Destructured)) return;
|
||||
in_arg.push(node);
|
||||
node.argname.walk(tw);
|
||||
in_arg.pop();
|
||||
walk_body(node, tw);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Lambda) {
|
||||
in_arg.push(node);
|
||||
if (node.name) node.name.walk(tw);
|
||||
node.argnames.forEach(function(argname) {
|
||||
argname.walk(tw);
|
||||
});
|
||||
if (node.rest) node.rest.walk(tw);
|
||||
in_arg.pop();
|
||||
walk_lambda(node, tw);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_LoopControl) {
|
||||
if (node.label) node.label.thedef.references.push(node);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolDeclaration) {
|
||||
var def = node.definition();
|
||||
def.preinit = def.references.length;
|
||||
if (node instanceof AST_SymbolCatch) {
|
||||
// ensure mangling works if `catch` reuses a scope variable
|
||||
var redef = def.redefined();
|
||||
if (redef) for (var s = node.scope; s; s = s.parent_scope) {
|
||||
if (!push_uniq(s.enclosed, redef)) break;
|
||||
if (s === redef.scope) break;
|
||||
}
|
||||
} else if (node instanceof AST_SymbolConst) {
|
||||
// ensure compression works if `const` reuses a scope variable
|
||||
var redef = def.redefined();
|
||||
if (redef) redef.const_redefs = true;
|
||||
} else if (def.scope !== node.scope && (node instanceof AST_SymbolDefun
|
||||
|| node instanceof AST_SymbolFunarg
|
||||
|| node instanceof AST_SymbolVar)) {
|
||||
node.mark_enclosed(options);
|
||||
var redef = node.scope.find_variable(node.name);
|
||||
if (node.thedef !== redef) {
|
||||
node.thedef = redef;
|
||||
redef.orig.push(node);
|
||||
node.mark_enclosed(options);
|
||||
}
|
||||
}
|
||||
if (node.name != "arguments") return true;
|
||||
var parent = node instanceof AST_SymbolVar && tw.parent();
|
||||
if (parent instanceof AST_VarDef && !parent.value) return true;
|
||||
var sym = node.scope.resolve().find_variable("arguments");
|
||||
if (sym && is_arguments(sym)) sym.scope.uses_arguments = 3;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
var name = node.name;
|
||||
var sym = node.scope.find_variable(name);
|
||||
for (var i = in_arg.length; i > 0 && sym;) {
|
||||
i = in_arg.lastIndexOf(sym.scope, i - 1);
|
||||
if (i < 0) break;
|
||||
var decl = sym.orig[0];
|
||||
if (decl instanceof AST_SymbolCatch
|
||||
|| decl instanceof AST_SymbolFunarg
|
||||
|| decl instanceof AST_SymbolLambda) {
|
||||
node.in_arg = true;
|
||||
break;
|
||||
}
|
||||
sym = sym.scope.parent_scope.find_variable(name);
|
||||
}
|
||||
if (!sym) {
|
||||
sym = self.def_global(node);
|
||||
} else if (name == "arguments" && is_arguments(sym)) {
|
||||
var parent = tw.parent();
|
||||
if (is_lhs(node, parent)) {
|
||||
sym.scope.uses_arguments = 3;
|
||||
} else if (sym.scope.uses_arguments < 2
|
||||
&& !(parent instanceof AST_PropAccess && parent.expression === node)) {
|
||||
sym.scope.uses_arguments = 2;
|
||||
} else if (!sym.scope.uses_arguments) {
|
||||
sym.scope.uses_arguments = true;
|
||||
}
|
||||
}
|
||||
if (name == "eval") {
|
||||
var parent = tw.parent();
|
||||
if (parent.TYPE == "Call" && parent.expression === node) {
|
||||
var s = node.scope;
|
||||
do {
|
||||
s = s.resolve();
|
||||
if (s.uses_eval) break;
|
||||
s.uses_eval = true;
|
||||
} while (s = s.parent_scope);
|
||||
} else if (sym.undeclared) {
|
||||
self.uses_eval = true;
|
||||
}
|
||||
}
|
||||
if (sym.init instanceof AST_LambdaDefinition && sym.scope !== sym.init.name.scope) {
|
||||
var scope = node.scope;
|
||||
do {
|
||||
if (scope === sym.init.name.scope) break;
|
||||
} while (scope = scope.parent_scope);
|
||||
if (!scope) sym.init = undefined;
|
||||
}
|
||||
node.thedef = sym;
|
||||
node.reference(options);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
self.walk(tw);
|
||||
|
||||
// pass 3: fix up any scoping issue with IE8
|
||||
if (options.ie) self.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_SymbolCatch) {
|
||||
var def = node.thedef;
|
||||
var scope = def.defun;
|
||||
if (def.name != "arguments" && scope.name instanceof AST_SymbolLambda && scope.name.name == def.name) {
|
||||
scope = scope.parent_scope.resolve();
|
||||
}
|
||||
redefine(node, scope);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolLambda) {
|
||||
var def = node.thedef;
|
||||
if (!redefine(node, node.scope.parent_scope.resolve())) {
|
||||
def.defun = undefined;
|
||||
} else if (typeof node.thedef.init !== "undefined") {
|
||||
node.thedef.init = false;
|
||||
} else if (def.init) {
|
||||
node.thedef.init = def.init;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
|
||||
function is_arguments(sym) {
|
||||
return sym.orig[0] instanceof AST_SymbolFunarg
|
||||
&& !(sym.orig[1] instanceof AST_SymbolFunarg || sym.orig[2] instanceof AST_SymbolFunarg)
|
||||
&& !is_arrow(sym.scope);
|
||||
}
|
||||
|
||||
function redefine(node, scope) {
|
||||
var name = node.name;
|
||||
var old_def = node.thedef;
|
||||
if (!all(old_def.orig, function(sym) {
|
||||
return !(sym instanceof AST_SymbolConst || sym instanceof AST_SymbolLet);
|
||||
})) return false;
|
||||
var new_def = scope.find_variable(name);
|
||||
if (new_def) {
|
||||
var redef = new_def.redefined();
|
||||
if (redef) new_def = redef;
|
||||
} else {
|
||||
new_def = self.globals.get(name);
|
||||
}
|
||||
if (new_def) {
|
||||
new_def.orig.push(node);
|
||||
} else {
|
||||
new_def = scope.def_variable(node);
|
||||
}
|
||||
if (new_def.undeclared) self.variables.set(name, new_def);
|
||||
if (name == "arguments" && is_arguments(old_def) && node instanceof AST_SymbolLambda) return true;
|
||||
old_def.defun = new_def.scope;
|
||||
old_def.forEach(function(node) {
|
||||
node.redef = old_def;
|
||||
node.thedef = new_def;
|
||||
node.reference(options);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
AST_Toplevel.DEFMETHOD("def_global", function(node) {
|
||||
var globals = this.globals, name = node.name;
|
||||
if (globals.has(name)) {
|
||||
return globals.get(name);
|
||||
} else {
|
||||
var g = this.make_def(node);
|
||||
g.undeclared = true;
|
||||
g.global = true;
|
||||
globals.set(name, g);
|
||||
return g;
|
||||
}
|
||||
});
|
||||
|
||||
function init_block_vars(scope, parent) {
|
||||
scope.enclosed = []; // variables from this or outer scope(s) that are referenced from this or inner scopes
|
||||
scope.parent_scope = parent; // the parent scope (null if this is the top level)
|
||||
scope.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
|
||||
scope.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
|
||||
if (parent) scope.make_def = parent.make_def; // top-level tracking of SymbolDef instances
|
||||
}
|
||||
|
||||
function init_scope_vars(scope, parent) {
|
||||
init_block_vars(scope, parent);
|
||||
scope.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
|
||||
scope.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
|
||||
}
|
||||
|
||||
AST_BlockScope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_block_vars(this, parent_scope);
|
||||
});
|
||||
AST_Scope.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
});
|
||||
AST_Arrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
return this;
|
||||
});
|
||||
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
});
|
||||
AST_Lambda.DEFMETHOD("init_vars", function(parent_scope) {
|
||||
init_scope_vars(this, parent_scope);
|
||||
this.uses_arguments = false;
|
||||
this.def_variable(new AST_SymbolFunarg({
|
||||
name: "arguments",
|
||||
scope: this,
|
||||
start: this.start,
|
||||
end: this.end,
|
||||
}));
|
||||
return this;
|
||||
});
|
||||
|
||||
AST_Symbol.DEFMETHOD("mark_enclosed", function(options) {
|
||||
var def = this.definition();
|
||||
for (var s = this.scope; s; s = s.parent_scope) {
|
||||
if (!push_uniq(s.enclosed, def)) break;
|
||||
if (!options) {
|
||||
s._var_names = undefined;
|
||||
} else {
|
||||
if (options.keep_fargs && s instanceof AST_Lambda) s.each_argname(function(arg) {
|
||||
push_uniq(def.scope.enclosed, arg.definition());
|
||||
});
|
||||
if (options.keep_fnames) s.functions.each(function(d) {
|
||||
push_uniq(def.scope.enclosed, d);
|
||||
});
|
||||
}
|
||||
if (s === def.scope) break;
|
||||
}
|
||||
});
|
||||
|
||||
AST_Symbol.DEFMETHOD("reference", function(options) {
|
||||
this.definition().references.push(this);
|
||||
this.mark_enclosed(options);
|
||||
});
|
||||
|
||||
AST_BlockScope.DEFMETHOD("find_variable", function(name) {
|
||||
return this.variables.get(name)
|
||||
|| this.parent_scope && this.parent_scope.find_variable(name);
|
||||
});
|
||||
|
||||
AST_BlockScope.DEFMETHOD("def_function", function(symbol, init) {
|
||||
var def = this.def_variable(symbol, init);
|
||||
if (!def.init || def.init instanceof AST_LambdaDefinition) def.init = init;
|
||||
this.functions.set(symbol.name, def);
|
||||
return def;
|
||||
});
|
||||
|
||||
AST_BlockScope.DEFMETHOD("def_variable", function(symbol, init) {
|
||||
var def = this.variables.get(symbol.name);
|
||||
if (def) {
|
||||
def.orig.push(symbol);
|
||||
if (def.init instanceof AST_LambdaExpression) def.init = init;
|
||||
} else {
|
||||
def = this.make_def(symbol, init);
|
||||
this.variables.set(symbol.name, def);
|
||||
def.global = !this.parent_scope;
|
||||
}
|
||||
return symbol.thedef = def;
|
||||
});
|
||||
|
||||
function names_in_use(scope, options) {
|
||||
var names = scope.names_in_use;
|
||||
if (!names) {
|
||||
scope.cname = -1;
|
||||
scope.cname_holes = [];
|
||||
scope.names_in_use = names = new Dictionary();
|
||||
var cache = options.cache && options.cache.props;
|
||||
scope.enclosed.forEach(function(def) {
|
||||
if (def.unmangleable(options)) names.set(def.name, true);
|
||||
if (def.global && cache && cache.has(def.name)) {
|
||||
names.set(cache.get(def.name), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
function next_mangled_name(def, options) {
|
||||
var scope = def.scope;
|
||||
var in_use = names_in_use(scope, options);
|
||||
var holes = scope.cname_holes;
|
||||
var names = new Dictionary();
|
||||
var scopes = [ scope ];
|
||||
def.forEach(function(sym) {
|
||||
var scope = sym.scope;
|
||||
do {
|
||||
if (member(scope, scopes)) break;
|
||||
names_in_use(scope, options).each(function(marker, name) {
|
||||
names.set(name, marker);
|
||||
});
|
||||
scopes.push(scope);
|
||||
} while (scope = scope.parent_scope);
|
||||
});
|
||||
var name;
|
||||
for (var i = 0; i < holes.length; i++) {
|
||||
name = base54(holes[i]);
|
||||
if (names.has(name)) continue;
|
||||
holes.splice(i, 1);
|
||||
in_use.set(name, true);
|
||||
return name;
|
||||
}
|
||||
while (true) {
|
||||
name = base54(++scope.cname);
|
||||
if (in_use.has(name) || RESERVED_WORDS[name] || options.reserved.has[name]) continue;
|
||||
if (!names.has(name)) break;
|
||||
holes.push(scope.cname);
|
||||
}
|
||||
in_use.set(name, true);
|
||||
return name;
|
||||
}
|
||||
|
||||
AST_Symbol.DEFMETHOD("unmangleable", function(options) {
|
||||
var def = this.definition();
|
||||
return !def || def.unmangleable(options);
|
||||
});
|
||||
|
||||
// labels are always mangleable
|
||||
AST_Label.DEFMETHOD("unmangleable", return_false);
|
||||
|
||||
AST_Symbol.DEFMETHOD("definition", function() {
|
||||
return this.thedef;
|
||||
});
|
||||
|
||||
function _default_mangler_options(options) {
|
||||
options = defaults(options, {
|
||||
eval : false,
|
||||
ie : false,
|
||||
keep_fargs : false,
|
||||
keep_fnames : false,
|
||||
reserved : [],
|
||||
toplevel : false,
|
||||
v8 : false,
|
||||
webkit : false,
|
||||
});
|
||||
if (!Array.isArray(options.reserved)) options.reserved = [];
|
||||
// Never mangle `arguments`
|
||||
push_uniq(options.reserved, "arguments");
|
||||
options.reserved.has = makePredicate(options.reserved);
|
||||
return options;
|
||||
}
|
||||
|
||||
// We only need to mangle declaration nodes. Special logic wired into the code
|
||||
// generator will display the mangled name if it is present (and for
|
||||
// `AST_SymbolRef`s it will use the mangled name of the `AST_SymbolDeclaration`
|
||||
// that it points to).
|
||||
AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
||||
options = _default_mangler_options(options);
|
||||
if (options.cache && options.cache.props) {
|
||||
var mangled_names = names_in_use(this, options);
|
||||
options.cache.props.each(function(mangled_name) {
|
||||
mangled_names.set(mangled_name, true);
|
||||
});
|
||||
}
|
||||
var cutoff = 36;
|
||||
var lname = -1;
|
||||
var redefined = [];
|
||||
var tw = new TreeWalker(function(node, descend) {
|
||||
var save_nesting;
|
||||
if (node instanceof AST_BlockScope) {
|
||||
// `lname` is incremented when we get to the `AST_Label`
|
||||
if (node instanceof AST_LabeledStatement) save_nesting = lname;
|
||||
if (options.webkit && node instanceof AST_IterationStatement && node.init instanceof AST_Let) {
|
||||
node.init.definitions.forEach(function(defn) {
|
||||
defn.name.match_symbol(function(sym) {
|
||||
if (!(sym instanceof AST_SymbolLet)) return;
|
||||
var def = sym.definition();
|
||||
var scope = sym.scope.parent_scope;
|
||||
var redef = scope.def_variable(sym);
|
||||
sym.thedef = def;
|
||||
scope.to_mangle.push(redef);
|
||||
def.redefined = function() {
|
||||
return redef;
|
||||
};
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
var to_mangle = node.to_mangle = [];
|
||||
node.variables.each(function(def) {
|
||||
if (!defer_redef(def)) to_mangle.push(def);
|
||||
});
|
||||
descend();
|
||||
if (options.cache && node instanceof AST_Toplevel) {
|
||||
node.globals.each(mangle);
|
||||
}
|
||||
if (node instanceof AST_Defun && tw.has_directive("use asm")) {
|
||||
var sym = new AST_SymbolRef(node.name);
|
||||
sym.scope = node;
|
||||
sym.reference(options);
|
||||
}
|
||||
if (to_mangle.length > cutoff) {
|
||||
var indices = to_mangle.map(function(def, index) {
|
||||
return index;
|
||||
}).sort(function(i, j) {
|
||||
return to_mangle[j].references.length - to_mangle[i].references.length || i - j;
|
||||
});
|
||||
to_mangle = indices.slice(0, cutoff).sort(function(i, j) {
|
||||
return i - j;
|
||||
}).map(function(index) {
|
||||
return to_mangle[index];
|
||||
}).concat(indices.slice(cutoff).sort(function(i, j) {
|
||||
return i - j;
|
||||
}).map(function(index) {
|
||||
return to_mangle[index];
|
||||
}));
|
||||
}
|
||||
to_mangle.forEach(mangle);
|
||||
if (node instanceof AST_LabeledStatement && !(options.v8 && in_label(tw))) lname = save_nesting;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Label) {
|
||||
var name;
|
||||
do {
|
||||
name = base54(++lname);
|
||||
} while (RESERVED_WORDS[name]);
|
||||
node.mangled_name = name;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.walk(tw);
|
||||
redefined.forEach(mangle);
|
||||
|
||||
function mangle(def) {
|
||||
if (options.reserved.has[def.name]) return;
|
||||
def.mangle(options);
|
||||
}
|
||||
|
||||
function defer_redef(def) {
|
||||
var sym = def.orig[0];
|
||||
var redef = def.redefined();
|
||||
if (!redef) {
|
||||
if (!(sym instanceof AST_SymbolConst)) return false;
|
||||
var scope = def.scope.resolve();
|
||||
if (def.scope === scope) return false;
|
||||
if (def.scope.parent_scope.find_variable(sym.name)) return false;
|
||||
redef = scope.def_variable(sym);
|
||||
scope.to_mangle.push(redef);
|
||||
}
|
||||
redefined.push(def);
|
||||
def.references.forEach(reference);
|
||||
if (sym instanceof AST_SymbolCatch || sym instanceof AST_SymbolConst) {
|
||||
reference(sym);
|
||||
def.redefined = function() {
|
||||
return redef;
|
||||
};
|
||||
}
|
||||
return true;
|
||||
|
||||
function reference(sym) {
|
||||
sym.thedef = redef;
|
||||
sym.reference(options);
|
||||
sym.thedef = def;
|
||||
}
|
||||
}
|
||||
|
||||
function in_label(tw) {
|
||||
var level = 0, parent;
|
||||
while (parent = tw.parent(level++)) {
|
||||
if (parent instanceof AST_Block) return parent instanceof AST_Toplevel && !options.toplevel;
|
||||
if (parent instanceof AST_LabeledStatement) return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
|
||||
var cache = options.cache && options.cache.props;
|
||||
var avoid = Object.create(RESERVED_WORDS);
|
||||
options.reserved.forEach(to_avoid);
|
||||
this.globals.each(add_def);
|
||||
this.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_BlockScope) node.variables.each(add_def);
|
||||
}));
|
||||
return avoid;
|
||||
|
||||
function to_avoid(name) {
|
||||
avoid[name] = true;
|
||||
}
|
||||
|
||||
function add_def(def) {
|
||||
var name = def.name;
|
||||
if (def.global && cache && cache.has(name)) name = cache.get(name);
|
||||
else if (!def.unmangleable(options)) return;
|
||||
to_avoid(name);
|
||||
}
|
||||
});
|
||||
|
||||
AST_Toplevel.DEFMETHOD("expand_names", function(options) {
|
||||
base54.reset();
|
||||
base54.sort();
|
||||
options = _default_mangler_options(options);
|
||||
var avoid = this.find_colliding_names(options);
|
||||
var cname = 0;
|
||||
this.globals.each(rename);
|
||||
this.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_BlockScope) node.variables.each(rename);
|
||||
}));
|
||||
|
||||
function next_name() {
|
||||
var name;
|
||||
do {
|
||||
name = base54(cname++);
|
||||
} while (avoid[name]);
|
||||
return name;
|
||||
}
|
||||
|
||||
function rename(def) {
|
||||
if (def.global && options.cache) return;
|
||||
if (def.unmangleable(options)) return;
|
||||
if (options.reserved.has[def.name]) return;
|
||||
var redef = def.redefined();
|
||||
var name = redef ? redef.rename || redef.name : next_name();
|
||||
def.rename = name;
|
||||
def.forEach(function(sym) {
|
||||
if (sym.definition() === def) sym.name = name;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
AST_Node.DEFMETHOD("tail_node", return_this);
|
||||
AST_Sequence.DEFMETHOD("tail_node", function() {
|
||||
return this.expressions[this.expressions.length - 1];
|
||||
});
|
||||
|
||||
AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
|
||||
options = _default_mangler_options(options);
|
||||
base54.reset();
|
||||
var fn = AST_Symbol.prototype.add_source_map;
|
||||
try {
|
||||
AST_Symbol.prototype.add_source_map = function() {
|
||||
if (!this.unmangleable(options)) base54.consider(this.name, -1);
|
||||
};
|
||||
if (options.properties) {
|
||||
AST_Dot.prototype.add_source_map = function() {
|
||||
base54.consider(this.property, -1);
|
||||
};
|
||||
AST_Sub.prototype.add_source_map = function() {
|
||||
skip_string(this.property);
|
||||
};
|
||||
}
|
||||
base54.consider(this.print_to_string(), 1);
|
||||
} finally {
|
||||
AST_Symbol.prototype.add_source_map = fn;
|
||||
delete AST_Dot.prototype.add_source_map;
|
||||
delete AST_Sub.prototype.add_source_map;
|
||||
}
|
||||
base54.sort();
|
||||
|
||||
function skip_string(node) {
|
||||
if (node instanceof AST_String) {
|
||||
base54.consider(node.value, -1);
|
||||
} else if (node instanceof AST_Conditional) {
|
||||
skip_string(node.consequent);
|
||||
skip_string(node.alternative);
|
||||
} else if (node instanceof AST_Sequence) {
|
||||
skip_string(node.tail_node());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var base54 = (function() {
|
||||
var freq = Object.create(null);
|
||||
function init(chars) {
|
||||
var array = [];
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
var ch = chars[i];
|
||||
array.push(ch);
|
||||
freq[ch] = -1e-2 * i;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
var digits = init("0123456789");
|
||||
var leading = init("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_");
|
||||
var chars, frequency;
|
||||
function reset() {
|
||||
chars = null;
|
||||
frequency = Object.create(freq);
|
||||
}
|
||||
base54.consider = function(str, delta) {
|
||||
for (var i = str.length; --i >= 0;) {
|
||||
frequency[str[i]] += delta;
|
||||
}
|
||||
};
|
||||
function compare(a, b) {
|
||||
return frequency[b] - frequency[a];
|
||||
}
|
||||
base54.sort = function() {
|
||||
chars = leading.sort(compare).concat(digits).sort(compare);
|
||||
};
|
||||
base54.reset = reset;
|
||||
reset();
|
||||
function base54(num) {
|
||||
var ret = leading[num % 54];
|
||||
for (num = Math.floor(num / 54); --num >= 0; num >>= 6) {
|
||||
ret += chars[num & 0x3F];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return base54;
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,39 @@
|
||||
var baseSlice = require('./_baseSlice'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with `n` elements taken from the end.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @param {number} [n=1] The number of elements to take.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.takeRight([1, 2, 3]);
|
||||
* // => [3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 2);
|
||||
* // => [2, 3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 5);
|
||||
* // => [1, 2, 3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 0);
|
||||
* // => []
|
||||
*/
|
||||
function takeRight(array, n, guard) {
|
||||
var length = array == null ? 0 : array.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
n = (guard || n === undefined) ? 1 : toInteger(n);
|
||||
n = length - n;
|
||||
return baseSlice(array, n < 0 ? 0 : n, length);
|
||||
}
|
||||
|
||||
module.exports = takeRight;
|
||||
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getDirectory = getDirectory;
|
||||
exports.getDirectorySync = getDirectorySync;
|
||||
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
|
||||
var _pathType = require("path-type");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
async function getDirectory(filepath) {
|
||||
const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath);
|
||||
|
||||
if (filePathIsDirectory === true) {
|
||||
return filepath;
|
||||
}
|
||||
|
||||
const directory = _path.default.dirname(filepath);
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
function getDirectorySync(filepath) {
|
||||
const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath);
|
||||
|
||||
if (filePathIsDirectory === true) {
|
||||
return filepath;
|
||||
}
|
||||
|
||||
const directory = _path.default.dirname(filepath);
|
||||
|
||||
return directory;
|
||||
}
|
||||
//# sourceMappingURL=getDirectory.js.map
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').forEachOf;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J D CC","132":"A","260":"E F"},B:{"1":"C K L G M N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H"},C:{"1":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB 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 EC FC","2":"DC tB","1025":"vB aB bB cB dB eB fB gB hB iB"},D:{"1":"0 1 2 3 4 5 6 7 8 9 K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB 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","132":"I v J D E F A B C"},E:{"2":"HC zB","513":"J D E F A B C K L G JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","644":"I v IC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e rB","2":"F B PC QC RC SC qB AC TC"},G:{"513":"E WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","644":"zB UC BC VC"},H:{"2":"oC"},I:{"1":"f tC uC","132":"tB I pC qC rC sC BC"},J:{"1":"A","132":"D"},K:{"1":"C h rB","2":"A B qB AC"},L:{"1":"H"},M:{"1":"H"},N:{"1":"B","132":"A"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:1,C:"Cross-Origin Resource Sharing"};
|
||||
@@ -0,0 +1,114 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var homedir = require('../lib/homedir');
|
||||
var path = require('path');
|
||||
|
||||
var test = require('tape');
|
||||
var mkdirp = require('mkdirp');
|
||||
var rimraf = require('rimraf');
|
||||
var mv = require('mv');
|
||||
var copyDir = require('copy-dir');
|
||||
var tmp = require('tmp');
|
||||
|
||||
var HOME = homedir();
|
||||
|
||||
var hnm = path.join(HOME, '.node_modules');
|
||||
var hnl = path.join(HOME, '.node_libraries');
|
||||
|
||||
var resolve = require('../sync');
|
||||
|
||||
function makeDir(t, dir, cb) {
|
||||
mkdirp(dir, function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
t.teardown(function cleanup() {
|
||||
rimraf.sync(dir);
|
||||
});
|
||||
cb();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makeTempDir(t, dir, cb) {
|
||||
if (fs.existsSync(dir)) {
|
||||
var tmpResult = tmp.dirSync();
|
||||
t.teardown(tmpResult.removeCallback);
|
||||
var backup = path.join(tmpResult.name, path.basename(dir));
|
||||
mv(dir, backup, function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
t.teardown(function () {
|
||||
mv(backup, dir, cb);
|
||||
});
|
||||
makeDir(t, dir, cb);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
makeDir(t, dir, cb);
|
||||
}
|
||||
}
|
||||
|
||||
test('homedir module paths', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
makeTempDir(t, hnm, function (err) {
|
||||
t.error(err, 'no error with HNM temp dir');
|
||||
if (err) {
|
||||
return t.end();
|
||||
}
|
||||
|
||||
var bazHNMDir = path.join(hnm, 'baz');
|
||||
var dotMainDir = path.join(hnm, 'dot_main');
|
||||
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNMDir);
|
||||
copyDir.sync(path.join(__dirname, 'resolver/dot_main'), dotMainDir);
|
||||
|
||||
var bazHNMmain = path.join(bazHNMDir, 'quux.js');
|
||||
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
||||
var dotMainMain = path.join(dotMainDir, 'index.js');
|
||||
t.equal(require.resolve('dot_main'), dotMainMain, 'sanity check: require.resolve finds `dot_main`');
|
||||
|
||||
makeTempDir(t, hnl, function (err) {
|
||||
t.error(err, 'no error with HNL temp dir');
|
||||
if (err) {
|
||||
return t.end();
|
||||
}
|
||||
var bazHNLDir = path.join(hnl, 'baz');
|
||||
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNLDir);
|
||||
|
||||
var dotSlashMainDir = path.join(hnl, 'dot_slash_main');
|
||||
var dotSlashMainMain = path.join(dotSlashMainDir, 'index.js');
|
||||
copyDir.sync(path.join(__dirname, 'resolver/dot_slash_main'), dotSlashMainDir);
|
||||
|
||||
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
||||
t.equal(require.resolve('dot_slash_main'), dotSlashMainMain, 'sanity check: require.resolve finds HNL `dot_slash_main`');
|
||||
|
||||
t.test('with temp dirs', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
st.test('just in `$HOME/.node_modules`', function (s2t) {
|
||||
s2t.plan(1);
|
||||
|
||||
var res = resolve('dot_main');
|
||||
s2t.equal(res, dotMainMain, '`dot_main` resolves in `$HOME/.node_modules`');
|
||||
});
|
||||
|
||||
st.test('just in `$HOME/.node_libraries`', function (s2t) {
|
||||
s2t.plan(1);
|
||||
|
||||
var res = resolve('dot_slash_main');
|
||||
s2t.equal(res, dotSlashMainMain, '`dot_slash_main` resolves in `$HOME/.node_libraries`');
|
||||
});
|
||||
|
||||
st.test('in `$HOME/.node_libraries` and `$HOME/.node_modules`', function (s2t) {
|
||||
s2t.plan(1);
|
||||
|
||||
var res = resolve('baz');
|
||||
s2t.equal(res, bazHNMmain, '`baz` resolves in `$HOME/.node_modules` when in both');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,148 @@
|
||||
import {promisify} from 'util';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const randomBytesAsync = promisify(crypto.randomBytes);
|
||||
|
||||
const urlSafeCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'.split('');
|
||||
const numericCharacters = '0123456789'.split('');
|
||||
const distinguishableCharacters = 'CDEHKMPRTUWXY012458'.split('');
|
||||
const asciiPrintableCharacters = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.split('');
|
||||
const alphanumericCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split('');
|
||||
|
||||
const generateForCustomCharacters = (length, characters) => {
|
||||
// Generating entropy is faster than complex math operations, so we use the simplest way
|
||||
const characterCount = characters.length;
|
||||
const maxValidSelector = (Math.floor(0x10000 / characterCount) * characterCount) - 1; // Using values above this will ruin distribution when using modular division
|
||||
const entropyLength = 2 * Math.ceil(1.1 * length); // Generating a bit more than required so chances we need more than one pass will be really low
|
||||
let string = '';
|
||||
let stringLength = 0;
|
||||
|
||||
while (stringLength < length) { // In case we had many bad values, which may happen for character sets of size above 0x8000 but close to it
|
||||
const entropy = crypto.randomBytes(entropyLength);
|
||||
let entropyPosition = 0;
|
||||
|
||||
while (entropyPosition < entropyLength && stringLength < length) {
|
||||
const entropyValue = entropy.readUInt16LE(entropyPosition);
|
||||
entropyPosition += 2;
|
||||
if (entropyValue > maxValidSelector) { // Skip values which will ruin distribution when using modular division
|
||||
continue;
|
||||
}
|
||||
|
||||
string += characters[entropyValue % characterCount];
|
||||
stringLength++;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
const generateForCustomCharactersAsync = async (length, characters) => {
|
||||
// Generating entropy is faster than complex math operations, so we use the simplest way
|
||||
const characterCount = characters.length;
|
||||
const maxValidSelector = (Math.floor(0x10000 / characterCount) * characterCount) - 1; // Using values above this will ruin distribution when using modular division
|
||||
const entropyLength = 2 * Math.ceil(1.1 * length); // Generating a bit more than required so chances we need more than one pass will be really low
|
||||
let string = '';
|
||||
let stringLength = 0;
|
||||
|
||||
while (stringLength < length) { // In case we had many bad values, which may happen for character sets of size above 0x8000 but close to it
|
||||
const entropy = await randomBytesAsync(entropyLength); // eslint-disable-line no-await-in-loop
|
||||
let entropyPosition = 0;
|
||||
|
||||
while (entropyPosition < entropyLength && stringLength < length) {
|
||||
const entropyValue = entropy.readUInt16LE(entropyPosition);
|
||||
entropyPosition += 2;
|
||||
if (entropyValue > maxValidSelector) { // Skip values which will ruin distribution when using modular division
|
||||
continue;
|
||||
}
|
||||
|
||||
string += characters[entropyValue % characterCount];
|
||||
stringLength++;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
const generateRandomBytes = (byteLength, type, length) => crypto.randomBytes(byteLength).toString(type).slice(0, length);
|
||||
|
||||
const generateRandomBytesAsync = async (byteLength, type, length) => {
|
||||
const buffer = await randomBytesAsync(byteLength);
|
||||
return buffer.toString(type).slice(0, length);
|
||||
};
|
||||
|
||||
const allowedTypes = new Set([
|
||||
undefined,
|
||||
'hex',
|
||||
'base64',
|
||||
'url-safe',
|
||||
'numeric',
|
||||
'distinguishable',
|
||||
'ascii-printable',
|
||||
'alphanumeric'
|
||||
]);
|
||||
|
||||
const createGenerator = (generateForCustomCharacters, generateRandomBytes) => ({length, type, characters}) => {
|
||||
if (!(length >= 0 && Number.isFinite(length))) {
|
||||
throw new TypeError('Expected a `length` to be a non-negative finite number');
|
||||
}
|
||||
|
||||
if (type !== undefined && characters !== undefined) {
|
||||
throw new TypeError('Expected either `type` or `characters`');
|
||||
}
|
||||
|
||||
if (characters !== undefined && typeof characters !== 'string') {
|
||||
throw new TypeError('Expected `characters` to be string');
|
||||
}
|
||||
|
||||
if (!allowedTypes.has(type)) {
|
||||
throw new TypeError(`Unknown type: ${type}`);
|
||||
}
|
||||
|
||||
if (type === undefined && characters === undefined) {
|
||||
type = 'hex';
|
||||
}
|
||||
|
||||
if (type === 'hex' || (type === undefined && characters === undefined)) {
|
||||
return generateRandomBytes(Math.ceil(length * 0.5), 'hex', length); // Need 0.5 byte entropy per character
|
||||
}
|
||||
|
||||
if (type === 'base64') {
|
||||
return generateRandomBytes(Math.ceil(length * 0.75), 'base64', length); // Need 0.75 byte of entropy per character
|
||||
}
|
||||
|
||||
if (type === 'url-safe') {
|
||||
return generateForCustomCharacters(length, urlSafeCharacters);
|
||||
}
|
||||
|
||||
if (type === 'numeric') {
|
||||
return generateForCustomCharacters(length, numericCharacters);
|
||||
}
|
||||
|
||||
if (type === 'distinguishable') {
|
||||
return generateForCustomCharacters(length, distinguishableCharacters);
|
||||
}
|
||||
|
||||
if (type === 'ascii-printable') {
|
||||
return generateForCustomCharacters(length, asciiPrintableCharacters);
|
||||
}
|
||||
|
||||
if (type === 'alphanumeric') {
|
||||
return generateForCustomCharacters(length, alphanumericCharacters);
|
||||
}
|
||||
|
||||
if (characters.length === 0) {
|
||||
throw new TypeError('Expected `characters` string length to be greater than or equal to 1');
|
||||
}
|
||||
|
||||
if (characters.length > 0x10000) {
|
||||
throw new TypeError('Expected `characters` string length to be less or equal to 65536');
|
||||
}
|
||||
|
||||
return generateForCustomCharacters(length, characters.split(''));
|
||||
};
|
||||
|
||||
const cryptoRandomString = createGenerator(generateForCustomCharacters, generateRandomBytes);
|
||||
|
||||
cryptoRandomString.async = createGenerator(generateForCustomCharactersAsync, generateRandomBytesAsync);
|
||||
|
||||
export default cryptoRandomString;
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.scheduleObservable = void 0;
|
||||
var innerFrom_1 = require("../observable/innerFrom");
|
||||
var observeOn_1 = require("../operators/observeOn");
|
||||
var subscribeOn_1 = require("../operators/subscribeOn");
|
||||
function scheduleObservable(input, scheduler) {
|
||||
return innerFrom_1.innerFrom(input).pipe(subscribeOn_1.subscribeOn(scheduler), observeOn_1.observeOn(scheduler));
|
||||
}
|
||||
exports.scheduleObservable = scheduleObservable;
|
||||
//# sourceMappingURL=scheduleObservable.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mapTo.js","sourceRoot":"","sources":["../../../../src/internal/operators/mapTo.ts"],"names":[],"mappings":";;;AACA,6BAA4B;AA4C5B,SAAgB,KAAK,CAAI,KAAQ;IAC/B,OAAO,SAAG,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;AAC1B,CAAC;AAFD,sBAEC"}
|
||||
@@ -0,0 +1,90 @@
|
||||
<img src="media/logo.svg" alt="mimic-fn" width="400">
|
||||
<br>
|
||||
|
||||
> Make a function mimic another one
|
||||
|
||||
Useful when you wrap a function in another function and like to preserve the original name and other properties.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install mimic-fn
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import mimicFunction from 'mimic-fn';
|
||||
|
||||
function foo() {}
|
||||
foo.unicorn = '🦄';
|
||||
|
||||
function wrapper() {
|
||||
return foo();
|
||||
}
|
||||
|
||||
console.log(wrapper.name);
|
||||
//=> 'wrapper'
|
||||
|
||||
mimicFunction(wrapper, foo);
|
||||
|
||||
console.log(wrapper.name);
|
||||
//=> 'foo'
|
||||
|
||||
console.log(wrapper.unicorn);
|
||||
//=> '🦄'
|
||||
|
||||
console.log(String(wrapper));
|
||||
//=> '/* Wrapped with wrapper() */\nfunction foo() {}'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### mimicFunction(to, from, options?)
|
||||
|
||||
Modifies the `to` function to mimic the `from` function. Returns the `to` function.
|
||||
|
||||
`name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.
|
||||
|
||||
`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.
|
||||
|
||||
#### to
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Mimicking function.
|
||||
|
||||
#### from
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Function to mimic.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### ignoreNonConfigurable
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
|
||||
|
||||
## Related
|
||||
|
||||
- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function
|
||||
- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name and other properties
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-mimic-fn?utm_source=npm-mimic-fn&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
Reference in New Issue
Block a user