new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var ToIndex = require('./ToIndex');
|
||||
|
||||
var isTypedArray = require('is-typed-array');
|
||||
var typedArrayLength = require('typed-array-length');
|
||||
|
||||
// https://262.ecma-international.org/8.0/#sec-validateatomicaccess
|
||||
|
||||
module.exports = function ValidateAtomicAccess(typedArray, requestIndex) {
|
||||
if (!isTypedArray(typedArray)) {
|
||||
throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); // step 1
|
||||
}
|
||||
|
||||
var accessIndex = ToIndex(requestIndex); // step 2
|
||||
|
||||
var length = typedArrayLength(typedArray); // step 3
|
||||
|
||||
/*
|
||||
// this assertion can never be reached
|
||||
if (!(accessIndex >= 0)) {
|
||||
throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4
|
||||
}
|
||||
*/
|
||||
|
||||
if (accessIndex >= length) {
|
||||
throw new $RangeError('index out of range'); // step 5
|
||||
}
|
||||
|
||||
return accessIndex; // step 6
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
var arrayFilter = require('./_arrayFilter'),
|
||||
isFunction = require('./isFunction');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.functions` which creates an array of
|
||||
* `object` function property names filtered from `props`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
* @param {Array} props The property names to filter.
|
||||
* @returns {Array} Returns the function names.
|
||||
*/
|
||||
function baseFunctions(object, props) {
|
||||
return arrayFilter(props, function(key) {
|
||||
return isFunction(object[key]);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = baseFunctions;
|
||||
@@ -0,0 +1,726 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var test = require('tape');
|
||||
|
||||
var resolve = require('../');
|
||||
var sync = require('../sync');
|
||||
|
||||
var requireResolveSupportsPaths = require.resolve.length > 1
|
||||
&& !(/^v12\.[012]\./).test(process.version); // broken in v12.0-12.2, see https://github.com/nodejs/node/issues/27794
|
||||
|
||||
test('`./sync` entry point', function (t) {
|
||||
t.equal(resolve.sync, sync, '`./sync` entry point is the same as `.sync` on `main`');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('foo', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./foo', { basedir: dir }),
|
||||
path.join(dir, 'foo.js'),
|
||||
'./foo'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./foo', { basedir: dir }),
|
||||
require.resolve('./foo', { paths: [dir] }),
|
||||
'./foo: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./foo.js', { basedir: dir }),
|
||||
path.join(dir, 'foo.js'),
|
||||
'./foo.js'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./foo.js', { basedir: dir }),
|
||||
require.resolve('./foo.js', { paths: [dir] }),
|
||||
'./foo.js: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./foo.js', { basedir: dir, filename: path.join(dir, 'bar.js') }),
|
||||
path.join(dir, 'foo.js')
|
||||
);
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('foo', { basedir: dir });
|
||||
});
|
||||
|
||||
// Test that filename is reported as the "from" value when passed.
|
||||
t.throws(
|
||||
function () {
|
||||
resolve.sync('foo', { basedir: dir, filename: path.join(dir, 'bar.js') });
|
||||
},
|
||||
{
|
||||
name: 'Error',
|
||||
message: "Cannot find module 'foo' from '" + path.join(dir, 'bar.js') + "'"
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('bar', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
var basedir = path.join(dir, 'bar');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('foo', { basedir: basedir }),
|
||||
path.join(dir, 'bar/node_modules/foo/index.js'),
|
||||
'foo in bar'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('foo', { basedir: basedir }),
|
||||
require.resolve('foo', { paths: [basedir] }),
|
||||
'foo in bar: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('baz', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./baz', { basedir: dir }),
|
||||
path.join(dir, 'baz/quux.js'),
|
||||
'./baz'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./baz', { basedir: dir }),
|
||||
require.resolve('./baz', { paths: [dir] }),
|
||||
'./baz: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('biz', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver/biz/node_modules');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./grux', { basedir: dir }),
|
||||
path.join(dir, 'grux/index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./grux', { basedir: dir }),
|
||||
require.resolve('./grux', { paths: [dir] }),
|
||||
'./grux: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
var tivDir = path.join(dir, 'grux');
|
||||
t.equal(
|
||||
resolve.sync('tiv', { basedir: tivDir }),
|
||||
path.join(dir, 'tiv/index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('tiv', { basedir: tivDir }),
|
||||
require.resolve('tiv', { paths: [tivDir] }),
|
||||
'tiv: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
var gruxDir = path.join(dir, 'tiv');
|
||||
t.equal(
|
||||
resolve.sync('grux', { basedir: gruxDir }),
|
||||
path.join(dir, 'grux/index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('grux', { basedir: gruxDir }),
|
||||
require.resolve('grux', { paths: [gruxDir] }),
|
||||
'grux: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('normalize', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver/biz/node_modules/grux');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('../grux', { basedir: dir }),
|
||||
path.join(dir, 'index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('../grux', { basedir: dir }),
|
||||
require.resolve('../grux', { paths: [dir] }),
|
||||
'../grux: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cup', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./cup', {
|
||||
basedir: dir,
|
||||
extensions: ['.js', '.coffee']
|
||||
}),
|
||||
path.join(dir, 'cup.coffee'),
|
||||
'./cup -> ./cup.coffee'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./cup.coffee', { basedir: dir }),
|
||||
path.join(dir, 'cup.coffee'),
|
||||
'./cup.coffee'
|
||||
);
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('./cup', {
|
||||
basedir: dir,
|
||||
extensions: ['.js']
|
||||
});
|
||||
});
|
||||
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./cup.coffee', { basedir: dir, extensions: ['.js', '.coffee'] }),
|
||||
require.resolve('./cup.coffee', { paths: [dir] }),
|
||||
'./cup.coffee: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('mug', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./mug', { basedir: dir }),
|
||||
path.join(dir, 'mug.js'),
|
||||
'./mug -> ./mug.js'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./mug', { basedir: dir }),
|
||||
require.resolve('./mug', { paths: [dir] }),
|
||||
'./mug: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./mug', {
|
||||
basedir: dir,
|
||||
extensions: ['.coffee', '.js']
|
||||
}),
|
||||
path.join(dir, 'mug.coffee'),
|
||||
'./mug -> ./mug.coffee'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./mug', {
|
||||
basedir: dir,
|
||||
extensions: ['.js', '.coffee']
|
||||
}),
|
||||
path.join(dir, 'mug.js'),
|
||||
'./mug -> ./mug.js'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('other path', function (t) {
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
var dir = path.join(resolverDir, 'bar');
|
||||
var otherDir = path.join(resolverDir, 'other_path');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('root', {
|
||||
basedir: dir,
|
||||
paths: [otherDir]
|
||||
}),
|
||||
path.join(resolverDir, 'other_path/root.js')
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync('lib/other-lib', {
|
||||
basedir: dir,
|
||||
paths: [otherDir]
|
||||
}),
|
||||
path.join(resolverDir, 'other_path/lib/other-lib.js')
|
||||
);
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('root', { basedir: dir });
|
||||
});
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('zzz', {
|
||||
basedir: dir,
|
||||
paths: [otherDir]
|
||||
});
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('path iterator', function (t) {
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
|
||||
var exactIterator = function (x, start, getPackageCandidates, opts) {
|
||||
return [path.join(resolverDir, x)];
|
||||
};
|
||||
|
||||
t.equal(
|
||||
resolve.sync('baz', { packageIterator: exactIterator }),
|
||||
path.join(resolverDir, 'baz/quux.js')
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('incorrect main', function (t) {
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
var dir = path.join(resolverDir, 'incorrect_main');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./incorrect_main', { basedir: resolverDir }),
|
||||
path.join(dir, 'index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./incorrect_main', { basedir: resolverDir }),
|
||||
require.resolve('./incorrect_main', { paths: [resolverDir] }),
|
||||
'./incorrect_main: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('missing index', function (t) {
|
||||
t.plan(requireResolveSupportsPaths ? 2 : 1);
|
||||
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
try {
|
||||
resolve.sync('./missing_index', { basedir: resolverDir });
|
||||
t.fail('did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
if (requireResolveSupportsPaths) {
|
||||
try {
|
||||
require.resolve('./missing_index', { basedir: resolverDir });
|
||||
t.fail('require.resolve did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('missing main', function (t) {
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
|
||||
try {
|
||||
resolve.sync('./missing_main', { basedir: resolverDir });
|
||||
t.fail('require.resolve did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
if (requireResolveSupportsPaths) {
|
||||
try {
|
||||
resolve.sync('./missing_main', { basedir: resolverDir });
|
||||
t.fail('require.resolve did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('null main', function (t) {
|
||||
var resolverDir = path.join(__dirname, 'resolver');
|
||||
|
||||
try {
|
||||
resolve.sync('./null_main', { basedir: resolverDir });
|
||||
t.fail('require.resolve did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
if (requireResolveSupportsPaths) {
|
||||
try {
|
||||
resolve.sync('./null_main', { basedir: resolverDir });
|
||||
t.fail('require.resolve did not fail');
|
||||
} catch (err) {
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');
|
||||
}
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('main: false', function (t) {
|
||||
var basedir = path.join(__dirname, 'resolver');
|
||||
var dir = path.join(basedir, 'false_main');
|
||||
t.equal(
|
||||
resolve.sync('./false_main', { basedir: basedir }),
|
||||
path.join(dir, 'index.js'),
|
||||
'`"main": false`: resolves to `index.js`'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./false_main', { basedir: basedir }),
|
||||
require.resolve('./false_main', { paths: [basedir] }),
|
||||
'`"main": false`: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
var stubStatSync = function stubStatSync(fn) {
|
||||
var statSync = fs.statSync;
|
||||
try {
|
||||
fs.statSync = function () {
|
||||
throw new EvalError('Unknown Error');
|
||||
};
|
||||
return fn();
|
||||
} finally {
|
||||
fs.statSync = statSync;
|
||||
}
|
||||
};
|
||||
|
||||
test('#79 - re-throw non ENOENT errors from stat', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
|
||||
stubStatSync(function () {
|
||||
t.throws(function () {
|
||||
resolve.sync('foo', { basedir: dir });
|
||||
}, /Unknown Error/);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
var basedir = path.join(dir, 'same_names');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./foo', { basedir: basedir }),
|
||||
path.join(dir, 'same_names/foo.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./foo', { basedir: basedir }),
|
||||
require.resolve('./foo', { paths: [basedir] }),
|
||||
'./foo: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./foo/', { basedir: basedir }),
|
||||
path.join(dir, 'same_names/foo/index.js')
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./foo/', { basedir: basedir }),
|
||||
require.resolve('./foo/', { paths: [basedir] }),
|
||||
'./foo/: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('#211 - incorrectly resolves module-paths like "." when from inside a folder with a sibling file of the same name', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
var basedir = path.join(dir, 'same_names/foo');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./', { basedir: basedir }),
|
||||
path.join(dir, 'same_names/foo/index.js'),
|
||||
'./'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./', { basedir: basedir }),
|
||||
require.resolve('./', { paths: [basedir] }),
|
||||
'./: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('.', { basedir: basedir }),
|
||||
path.join(dir, 'same_names/foo/index.js'),
|
||||
'.'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('.', { basedir: basedir }),
|
||||
require.resolve('.', { paths: [basedir] }),
|
||||
'.: resolve.sync === require.resolve',
|
||||
{ todo: true }
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('sync: #121 - treating an existing file as a dir when no basedir', function (t) {
|
||||
var testFile = path.basename(__filename);
|
||||
|
||||
t.test('sanity check', function (st) {
|
||||
st.equal(
|
||||
resolve.sync('./' + testFile),
|
||||
__filename,
|
||||
'sanity check'
|
||||
);
|
||||
st.equal(
|
||||
resolve.sync('./' + testFile),
|
||||
require.resolve('./' + testFile),
|
||||
'sanity check: resolve.sync === require.resolve'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('with a fake directory', function (st) {
|
||||
function run() { return resolve.sync('./' + testFile + '/blah'); }
|
||||
|
||||
st.throws(run, 'throws an error');
|
||||
|
||||
try {
|
||||
run();
|
||||
} catch (e) {
|
||||
st.equal(e.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
|
||||
st.equal(
|
||||
e.message,
|
||||
'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'',
|
||||
'can not find nonexistent module'
|
||||
);
|
||||
}
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('sync dot main', function (t) {
|
||||
var start = new Date();
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./resolver/dot_main'),
|
||||
path.join(__dirname, 'resolver/dot_main/index.js'),
|
||||
'./resolver/dot_main'
|
||||
);
|
||||
t.equal(
|
||||
resolve.sync('./resolver/dot_main'),
|
||||
require.resolve('./resolver/dot_main'),
|
||||
'./resolver/dot_main: resolve.sync === require.resolve'
|
||||
);
|
||||
|
||||
t.ok(new Date() - start < 50, 'resolve.sync timedout');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('sync dot slash main', function (t) {
|
||||
var start = new Date();
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./resolver/dot_slash_main'),
|
||||
path.join(__dirname, 'resolver/dot_slash_main/index.js')
|
||||
);
|
||||
t.equal(
|
||||
resolve.sync('./resolver/dot_slash_main'),
|
||||
require.resolve('./resolver/dot_slash_main'),
|
||||
'./resolver/dot_slash_main: resolve.sync === require.resolve'
|
||||
);
|
||||
|
||||
t.ok(new Date() - start < 50, 'resolve.sync timedout');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('not a directory', function (t) {
|
||||
var path = './foo';
|
||||
try {
|
||||
resolve.sync(path, { basedir: __filename });
|
||||
t.fail();
|
||||
} catch (err) {
|
||||
t.ok(err, 'a non-directory errors');
|
||||
t.equal(err && err.message, 'Cannot find module \'' + path + "' from '" + __filename + "'");
|
||||
t.equal(err && err.code, 'MODULE_NOT_FOUND');
|
||||
}
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('non-string "main" field in package.json', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
try {
|
||||
var result = resolve.sync('./invalid_main', { basedir: dir });
|
||||
t.equal(result, undefined, 'result should not exist');
|
||||
t.fail('should not get here');
|
||||
} catch (err) {
|
||||
t.ok(err, 'errors on non-string main');
|
||||
t.equal(err.message, 'package “invalid_main” `main` must be a string');
|
||||
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
|
||||
}
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('non-string "main" field in package.json', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
try {
|
||||
var result = resolve.sync('./invalid_main', { basedir: dir });
|
||||
t.equal(result, undefined, 'result should not exist');
|
||||
t.fail('should not get here');
|
||||
} catch (err) {
|
||||
t.ok(err, 'errors on non-string main');
|
||||
t.equal(err.message, 'package “invalid_main” `main` must be a string');
|
||||
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
|
||||
}
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('browser field in package.json', function (t) {
|
||||
var dir = path.join(__dirname, 'resolver');
|
||||
var res = resolve.sync('./browser_field', {
|
||||
basedir: dir,
|
||||
packageFilter: function packageFilter(pkg) {
|
||||
if (pkg.browser) {
|
||||
pkg.main = pkg.browser; // eslint-disable-line no-param-reassign
|
||||
delete pkg.browser; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
});
|
||||
t.equal(res, path.join(dir, 'browser_field', 'b.js'));
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('absolute paths', function (t) {
|
||||
var extensionless = __filename.slice(0, -path.extname(__filename).length);
|
||||
|
||||
t.equal(
|
||||
resolve.sync(__filename),
|
||||
__filename,
|
||||
'absolute path to this file resolves'
|
||||
);
|
||||
t.equal(
|
||||
resolve.sync(__filename),
|
||||
require.resolve(__filename),
|
||||
'absolute path to this file: resolve.sync === require.resolve'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync(extensionless),
|
||||
__filename,
|
||||
'extensionless absolute path to this file resolves'
|
||||
);
|
||||
t.equal(
|
||||
resolve.sync(__filename),
|
||||
require.resolve(__filename),
|
||||
'absolute path to this file: resolve.sync === require.resolve'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync(__filename, { basedir: process.cwd() }),
|
||||
__filename,
|
||||
'absolute path to this file with a basedir resolves'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync(__filename, { basedir: process.cwd() }),
|
||||
require.resolve(__filename, { paths: [process.cwd()] }),
|
||||
'absolute path to this file + basedir: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync(extensionless, { basedir: process.cwd() }),
|
||||
__filename,
|
||||
'extensionless absolute path to this file with a basedir resolves'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync(extensionless, { basedir: process.cwd() }),
|
||||
require.resolve(extensionless, { paths: [process.cwd()] }),
|
||||
'extensionless absolute path to this file + basedir: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('malformed package.json', function (t) {
|
||||
t.plan(5 + (requireResolveSupportsPaths ? 1 : 0));
|
||||
|
||||
var basedir = path.join(__dirname, 'resolver/malformed_package_json');
|
||||
var expected = path.join(basedir, 'index.js');
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./index.js', { basedir: basedir }),
|
||||
expected,
|
||||
'malformed package.json is silently ignored'
|
||||
);
|
||||
if (requireResolveSupportsPaths) {
|
||||
t.equal(
|
||||
resolve.sync('./index.js', { basedir: basedir }),
|
||||
require.resolve('./index.js', { paths: [basedir] }),
|
||||
'malformed package.json: resolve.sync === require.resolve'
|
||||
);
|
||||
}
|
||||
|
||||
var res1 = resolve.sync(
|
||||
'./index.js',
|
||||
{
|
||||
basedir: basedir,
|
||||
packageFilter: function (pkg, pkgfile, dir) {
|
||||
t.fail('should not reach here');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
t.equal(
|
||||
res1,
|
||||
expected,
|
||||
'with packageFilter: malformed package.json is silently ignored'
|
||||
);
|
||||
|
||||
var res2 = resolve.sync(
|
||||
'./index.js',
|
||||
{
|
||||
basedir: basedir,
|
||||
readPackageSync: function (readFileSync, pkgfile) {
|
||||
t.equal(pkgfile, path.join(basedir, 'package.json'), 'readPackageSync: `pkgfile` is package.json path');
|
||||
var result = String(readFileSync(pkgfile));
|
||||
try {
|
||||
return JSON.parse(result);
|
||||
} catch (e) {
|
||||
t.ok(e instanceof SyntaxError, 'readPackageSync: malformed package.json parses as a syntax error');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
t.equal(
|
||||
res2,
|
||||
expected,
|
||||
'with readPackageSync: malformed package.json is silently ignored'
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,208 @@
|
||||
var isCore = require('is-core-module');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var getHomedir = require('./homedir');
|
||||
var caller = require('./caller');
|
||||
var nodeModulesPaths = require('./node-modules-paths');
|
||||
var normalizeOptions = require('./normalize-options');
|
||||
|
||||
var realpathFS = process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync;
|
||||
|
||||
var homedir = getHomedir();
|
||||
var defaultPaths = function () {
|
||||
return [
|
||||
path.join(homedir, '.node_modules'),
|
||||
path.join(homedir, '.node_libraries')
|
||||
];
|
||||
};
|
||||
|
||||
var defaultIsFile = function isFile(file) {
|
||||
try {
|
||||
var stat = fs.statSync(file, { throwIfNoEntry: false });
|
||||
} catch (e) {
|
||||
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
||||
throw e;
|
||||
}
|
||||
return !!stat && (stat.isFile() || stat.isFIFO());
|
||||
};
|
||||
|
||||
var defaultIsDir = function isDirectory(dir) {
|
||||
try {
|
||||
var stat = fs.statSync(dir, { throwIfNoEntry: false });
|
||||
} catch (e) {
|
||||
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
||||
throw e;
|
||||
}
|
||||
return !!stat && stat.isDirectory();
|
||||
};
|
||||
|
||||
var defaultRealpathSync = function realpathSync(x) {
|
||||
try {
|
||||
return realpathFS(x);
|
||||
} catch (realpathErr) {
|
||||
if (realpathErr.code !== 'ENOENT') {
|
||||
throw realpathErr;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
};
|
||||
|
||||
var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
return realpathSync(x);
|
||||
}
|
||||
return x;
|
||||
};
|
||||
|
||||
var defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) {
|
||||
var body = readFileSync(pkgfile);
|
||||
try {
|
||||
var pkg = JSON.parse(body);
|
||||
return pkg;
|
||||
} catch (jsonErr) {}
|
||||
};
|
||||
|
||||
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
||||
var dirs = nodeModulesPaths(start, opts, x);
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
dirs[i] = path.join(dirs[i], x);
|
||||
}
|
||||
return dirs;
|
||||
};
|
||||
|
||||
module.exports = function resolveSync(x, options) {
|
||||
if (typeof x !== 'string') {
|
||||
throw new TypeError('Path must be a string.');
|
||||
}
|
||||
var opts = normalizeOptions(x, options);
|
||||
|
||||
var isFile = opts.isFile || defaultIsFile;
|
||||
var readFileSync = opts.readFileSync || fs.readFileSync;
|
||||
var isDirectory = opts.isDirectory || defaultIsDir;
|
||||
var realpathSync = opts.realpathSync || defaultRealpathSync;
|
||||
var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
|
||||
if (opts.readFileSync && opts.readPackageSync) {
|
||||
throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.');
|
||||
}
|
||||
var packageIterator = opts.packageIterator;
|
||||
|
||||
var extensions = opts.extensions || ['.js'];
|
||||
var includeCoreModules = opts.includeCoreModules !== false;
|
||||
var basedir = opts.basedir || path.dirname(caller());
|
||||
var parent = opts.filename || basedir;
|
||||
|
||||
opts.paths = opts.paths || defaultPaths();
|
||||
|
||||
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
||||
var absoluteStart = maybeRealpathSync(realpathSync, path.resolve(basedir), opts);
|
||||
|
||||
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
||||
var res = path.resolve(absoluteStart, x);
|
||||
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
||||
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
||||
if (m) return maybeRealpathSync(realpathSync, m, opts);
|
||||
} else if (includeCoreModules && isCore(x)) {
|
||||
return x;
|
||||
} else {
|
||||
var n = loadNodeModulesSync(x, absoluteStart);
|
||||
if (n) return maybeRealpathSync(realpathSync, n, opts);
|
||||
}
|
||||
|
||||
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
|
||||
function loadAsFileSync(x) {
|
||||
var pkg = loadpkg(path.dirname(x));
|
||||
|
||||
if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
|
||||
var rfile = path.relative(pkg.dir, x);
|
||||
var r = opts.pathFilter(pkg.pkg, x, rfile);
|
||||
if (r) {
|
||||
x = path.resolve(pkg.dir, r); // eslint-disable-line no-param-reassign
|
||||
}
|
||||
}
|
||||
|
||||
if (isFile(x)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
for (var i = 0; i < extensions.length; i++) {
|
||||
var file = x + extensions[i];
|
||||
if (isFile(file)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadpkg(dir) {
|
||||
if (dir === '' || dir === '/') return;
|
||||
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
||||
return;
|
||||
}
|
||||
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
|
||||
|
||||
var pkgfile = path.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
|
||||
|
||||
if (!isFile(pkgfile)) {
|
||||
return loadpkg(path.dirname(dir));
|
||||
}
|
||||
|
||||
var pkg = readPackageSync(readFileSync, pkgfile);
|
||||
|
||||
if (pkg && opts.packageFilter) {
|
||||
// v2 will pass pkgfile
|
||||
pkg = opts.packageFilter(pkg, /*pkgfile,*/ dir); // eslint-disable-line spaced-comment
|
||||
}
|
||||
|
||||
return { pkg: pkg, dir: dir };
|
||||
}
|
||||
|
||||
function loadAsDirectorySync(x) {
|
||||
var pkgfile = path.join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
|
||||
if (isFile(pkgfile)) {
|
||||
try {
|
||||
var pkg = readPackageSync(readFileSync, pkgfile);
|
||||
} catch (e) {}
|
||||
|
||||
if (pkg && opts.packageFilter) {
|
||||
// v2 will pass pkgfile
|
||||
pkg = opts.packageFilter(pkg, /*pkgfile,*/ x); // eslint-disable-line spaced-comment
|
||||
}
|
||||
|
||||
if (pkg && pkg.main) {
|
||||
if (typeof pkg.main !== 'string') {
|
||||
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
||||
mainError.code = 'INVALID_PACKAGE_MAIN';
|
||||
throw mainError;
|
||||
}
|
||||
if (pkg.main === '.' || pkg.main === './') {
|
||||
pkg.main = 'index';
|
||||
}
|
||||
try {
|
||||
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
||||
if (m) return m;
|
||||
var n = loadAsDirectorySync(path.resolve(x, pkg.main));
|
||||
if (n) return n;
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return loadAsFileSync(path.join(x, '/index'));
|
||||
}
|
||||
|
||||
function loadNodeModulesSync(x, start) {
|
||||
var thunk = function () { return getPackageCandidates(x, start, opts); };
|
||||
var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
|
||||
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
var dir = dirs[i];
|
||||
if (isDirectory(path.dirname(dir))) {
|
||||
var m = loadAsFileSync(dir);
|
||||
if (m) return m;
|
||||
var n = loadAsDirectorySync(dir);
|
||||
if (n) return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,82 @@
|
||||
import { Component, PreactElement, VNode, Options } from '../../src/internal';
|
||||
|
||||
export { Component, PreactElement, VNode, Options };
|
||||
|
||||
export interface DevtoolsInjectOptions {
|
||||
/** 1 = DEV, 0 = production */
|
||||
bundleType: 1 | 0;
|
||||
/** The devtools enable different features for different versions of react */
|
||||
version: string;
|
||||
/** Informative string, currently unused in the devtools */
|
||||
rendererPackageName: string;
|
||||
/** Find the root dom node of a vnode */
|
||||
findHostInstanceByFiber(vnode: VNode): HTMLElement | null;
|
||||
/** Find the closest vnode given a dom node */
|
||||
findFiberByHostInstance(instance: HTMLElement): VNode | null;
|
||||
}
|
||||
|
||||
export interface DevtoolsUpdater {
|
||||
setState(objOrFn: any): void;
|
||||
forceUpdate(): void;
|
||||
setInState(path: Array<string | number>, value: any): void;
|
||||
setInProps(path: Array<string | number>, value: any): void;
|
||||
setInContext(): void;
|
||||
}
|
||||
|
||||
export type NodeType = 'Composite' | 'Native' | 'Wrapper' | 'Text';
|
||||
|
||||
export interface DevtoolData {
|
||||
nodeType: NodeType;
|
||||
// Component type
|
||||
type: any;
|
||||
name: string;
|
||||
ref: any;
|
||||
key: string | number;
|
||||
updater: DevtoolsUpdater | null;
|
||||
text: string | number | null;
|
||||
state: any;
|
||||
props: any;
|
||||
children: VNode[] | string | number | null;
|
||||
publicInstance: PreactElement | Text | Component;
|
||||
memoizedInteractions: any[];
|
||||
|
||||
actualDuration: number;
|
||||
actualStartTime: number;
|
||||
treeBaseDuration: number;
|
||||
}
|
||||
|
||||
export type EventType =
|
||||
| 'unmount'
|
||||
| 'rootCommitted'
|
||||
| 'root'
|
||||
| 'mount'
|
||||
| 'update'
|
||||
| 'updateProfileTimes';
|
||||
|
||||
export interface DevtoolsEvent {
|
||||
data?: DevtoolData;
|
||||
internalInstance: VNode;
|
||||
renderer: string;
|
||||
type: EventType;
|
||||
}
|
||||
|
||||
export interface DevtoolsHook {
|
||||
_renderers: Record<string, any>;
|
||||
_roots: Set<VNode>;
|
||||
on(ev: string, listener: () => void): void;
|
||||
emit(ev: string, data?: object): void;
|
||||
helpers: Record<string, any>;
|
||||
getFiberRoots(rendererId: string): Set<any>;
|
||||
inject(config: DevtoolsInjectOptions): string;
|
||||
onCommitFiberRoot(rendererId: string, root: VNode): void;
|
||||
onCommitFiberUnmount(rendererId: string, vnode: VNode): void;
|
||||
}
|
||||
|
||||
export interface DevtoolsWindow extends Window {
|
||||
/**
|
||||
* If the devtools extension is installed it will inject this object into
|
||||
* the dom. This hook handles all communications between preact and the
|
||||
* devtools panel.
|
||||
*/
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__?: DevtoolsHook;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/testNew/testErrorHandle.ts</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">csv2json/testNew</a> testErrorHandle.ts
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>12/12</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>2/2</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>12/12</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a></td><td class="line-coverage quiet"><span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span></td><td class="text"><pre class="prettyprint lang-js">Unable to lookup source: /Users/kxiang/work/projects/csv2json/testNew/testErrorHandle.ts(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/testNew/testErrorHandle.ts')
|
||||
Error: Unable to lookup source: /Users/kxiang/work/projects/csv2json/testNew/testErrorHandle.ts(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/testNew/testErrorHandle.ts')
|
||||
at Context.defaultSourceLookup [as sourceFinder] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:15:15)
|
||||
at Context.getSource (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:74:17)
|
||||
at Object.annotateSourceCode (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/annotator.js:172:38)
|
||||
at HtmlReport.onDetail (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/index.js:237:39)
|
||||
at LcovReport.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/lcov/index.js:24:24)
|
||||
at Visitor.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:34:30)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:123:17)
|
||||
at /Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:116:23
|
||||
at Array.forEach (native)
|
||||
at visitChildren (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:115:32)</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:20:20 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
<script src="../../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,47 @@
|
||||
'use strict'
|
||||
|
||||
const req = require('./req.js')
|
||||
|
||||
/**
|
||||
* Load Options
|
||||
*
|
||||
* @private
|
||||
* @method options
|
||||
*
|
||||
* @param {Object} config PostCSS Config
|
||||
*
|
||||
* @return {Object} options PostCSS Options
|
||||
*/
|
||||
const options = (config, file) => {
|
||||
if (config.parser && typeof config.parser === 'string') {
|
||||
try {
|
||||
config.parser = req(config.parser, file)
|
||||
} catch (err) {
|
||||
throw new Error(`Loading PostCSS Parser failed: ${err.message}\n\n(@${file})`)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.syntax && typeof config.syntax === 'string') {
|
||||
try {
|
||||
config.syntax = req(config.syntax, file)
|
||||
} catch (err) {
|
||||
throw new Error(`Loading PostCSS Syntax failed: ${err.message}\n\n(@${file})`)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.stringifier && typeof config.stringifier === 'string') {
|
||||
try {
|
||||
config.stringifier = req(config.stringifier, file)
|
||||
} catch (err) {
|
||||
throw new Error(`Loading PostCSS Stringifier failed: ${err.message}\n\n(@${file})`)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.plugins) {
|
||||
delete config.plugins
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
module.exports = options
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: ()=>bigSign
|
||||
});
|
||||
function bigSign(bigIntValue) {
|
||||
return (bigIntValue > 0n) - (bigIntValue < 0n);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"env": {
|
||||
"es6": true,
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"array-bracket-newline": 0,
|
||||
"complexity": 0,
|
||||
"eqeqeq": [2, "allow-null"],
|
||||
"func-name-matching": 0,
|
||||
"id-length": [2, { "min": 1, "max": 40 }],
|
||||
"max-params": [2, 4],
|
||||
"max-lines-per-function": 1,
|
||||
"max-statements": 1,
|
||||
"max-statements-per-line": [2, { "max": 2 }],
|
||||
"multiline-comment-style": 0,
|
||||
"no-magic-numbers": 0,
|
||||
"new-cap": 0,
|
||||
"no-extra-parens": 1,
|
||||
"sort-keys": 0,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": "GetIntrinsic.js",
|
||||
"rules": {
|
||||
"max-statements": 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "operations/*",
|
||||
"rules": {
|
||||
"max-lines": 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"operations/deltas.js",
|
||||
"operations/getOps.js",
|
||||
"operations/spackle.js",
|
||||
"operations/years.js",
|
||||
],
|
||||
"extends": "@ljharb/eslint-config/node/latest",
|
||||
"rules": {
|
||||
"complexity": 0,
|
||||
"func-style": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"max-nested-callbacks": 0,
|
||||
"max-statements": 0,
|
||||
"no-magic-numbers": 0,
|
||||
"no-throw-literal": 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
"files": "test/**",
|
||||
"extends": "@ljharb/eslint-config/tests",
|
||||
"rules": {
|
||||
"max-len": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"no-implicit-coercion": 0,
|
||||
"no-invalid-this": 1,
|
||||
"prefer-promise-reject-errors": 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
"files": "*/RawBytesToNum*.js",
|
||||
"rules": {
|
||||
"operator-linebreak": [2, "before", {
|
||||
"overrides": {
|
||||
"=": "none"
|
||||
}
|
||||
}],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { asyncScheduler } from '../scheduler/async';
|
||||
import { operate } from '../util/lift';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
export function debounceTime(dueTime, scheduler) {
|
||||
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
||||
return operate(function (source, subscriber) {
|
||||
var activeTask = null;
|
||||
var lastValue = null;
|
||||
var lastTime = null;
|
||||
var emit = function () {
|
||||
if (activeTask) {
|
||||
activeTask.unsubscribe();
|
||||
activeTask = null;
|
||||
var value = lastValue;
|
||||
lastValue = null;
|
||||
subscriber.next(value);
|
||||
}
|
||||
};
|
||||
function emitWhenIdle() {
|
||||
var targetTime = lastTime + dueTime;
|
||||
var now = scheduler.now();
|
||||
if (now < targetTime) {
|
||||
activeTask = this.schedule(undefined, targetTime - now);
|
||||
subscriber.add(activeTask);
|
||||
return;
|
||||
}
|
||||
emit();
|
||||
}
|
||||
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
||||
lastValue = value;
|
||||
lastTime = scheduler.now();
|
||||
if (!activeTask) {
|
||||
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
||||
subscriber.add(activeTask);
|
||||
}
|
||||
}, function () {
|
||||
emit();
|
||||
subscriber.complete();
|
||||
}, undefined, function () {
|
||||
lastValue = activeTask = null;
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=debounceTime.js.map
|
||||
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isArrayish(obj) {
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj instanceof Array || Array.isArray(obj) ||
|
||||
(obj.length >= 0 && obj.splice instanceof Function);
|
||||
};
|
||||
@@ -0,0 +1,174 @@
|
||||
let shim;
|
||||
class Y18N {
|
||||
constructor(opts) {
|
||||
// configurable options.
|
||||
opts = opts || {};
|
||||
this.directory = opts.directory || './locales';
|
||||
this.updateFiles = typeof opts.updateFiles === 'boolean' ? opts.updateFiles : true;
|
||||
this.locale = opts.locale || 'en';
|
||||
this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true;
|
||||
// internal stuff.
|
||||
this.cache = Object.create(null);
|
||||
this.writeQueue = [];
|
||||
}
|
||||
__(...args) {
|
||||
if (typeof arguments[0] !== 'string') {
|
||||
return this._taggedLiteral(arguments[0], ...arguments);
|
||||
}
|
||||
const str = args.shift();
|
||||
let cb = function () { }; // start with noop.
|
||||
if (typeof args[args.length - 1] === 'function')
|
||||
cb = args.pop();
|
||||
cb = cb || function () { }; // noop.
|
||||
if (!this.cache[this.locale])
|
||||
this._readLocaleFile();
|
||||
// we've observed a new string, update the language file.
|
||||
if (!this.cache[this.locale][str] && this.updateFiles) {
|
||||
this.cache[this.locale][str] = str;
|
||||
// include the current directory and locale,
|
||||
// since these values could change before the
|
||||
// write is performed.
|
||||
this._enqueueWrite({
|
||||
directory: this.directory,
|
||||
locale: this.locale,
|
||||
cb
|
||||
});
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
}
|
||||
return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args));
|
||||
}
|
||||
__n() {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
const singular = args.shift();
|
||||
const plural = args.shift();
|
||||
const quantity = args.shift();
|
||||
let cb = function () { }; // start with noop.
|
||||
if (typeof args[args.length - 1] === 'function')
|
||||
cb = args.pop();
|
||||
if (!this.cache[this.locale])
|
||||
this._readLocaleFile();
|
||||
let str = quantity === 1 ? singular : plural;
|
||||
if (this.cache[this.locale][singular]) {
|
||||
const entry = this.cache[this.locale][singular];
|
||||
str = entry[quantity === 1 ? 'one' : 'other'];
|
||||
}
|
||||
// we've observed a new string, update the language file.
|
||||
if (!this.cache[this.locale][singular] && this.updateFiles) {
|
||||
this.cache[this.locale][singular] = {
|
||||
one: singular,
|
||||
other: plural
|
||||
};
|
||||
// include the current directory and locale,
|
||||
// since these values could change before the
|
||||
// write is performed.
|
||||
this._enqueueWrite({
|
||||
directory: this.directory,
|
||||
locale: this.locale,
|
||||
cb
|
||||
});
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
}
|
||||
// if a %d placeholder is provided, add quantity
|
||||
// to the arguments expanded by util.format.
|
||||
const values = [str];
|
||||
if (~str.indexOf('%d'))
|
||||
values.push(quantity);
|
||||
return shim.format.apply(shim.format, values.concat(args));
|
||||
}
|
||||
setLocale(locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
updateLocale(obj) {
|
||||
if (!this.cache[this.locale])
|
||||
this._readLocaleFile();
|
||||
for (const key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
this.cache[this.locale][key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
_taggedLiteral(parts, ...args) {
|
||||
let str = '';
|
||||
parts.forEach(function (part, i) {
|
||||
const arg = args[i + 1];
|
||||
str += part;
|
||||
if (typeof arg !== 'undefined') {
|
||||
str += '%s';
|
||||
}
|
||||
});
|
||||
return this.__.apply(this, [str].concat([].slice.call(args, 1)));
|
||||
}
|
||||
_enqueueWrite(work) {
|
||||
this.writeQueue.push(work);
|
||||
if (this.writeQueue.length === 1)
|
||||
this._processWriteQueue();
|
||||
}
|
||||
_processWriteQueue() {
|
||||
const _this = this;
|
||||
const work = this.writeQueue[0];
|
||||
// destructure the enqueued work.
|
||||
const directory = work.directory;
|
||||
const locale = work.locale;
|
||||
const cb = work.cb;
|
||||
const languageFile = this._resolveLocaleFile(directory, locale);
|
||||
const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
|
||||
shim.fs.writeFile(languageFile, serializedLocale, 'utf-8', function (err) {
|
||||
_this.writeQueue.shift();
|
||||
if (_this.writeQueue.length > 0)
|
||||
_this._processWriteQueue();
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
_readLocaleFile() {
|
||||
let localeLookup = {};
|
||||
const languageFile = this._resolveLocaleFile(this.directory, this.locale);
|
||||
try {
|
||||
// When using a bundler such as webpack, readFileSync may not be defined:
|
||||
if (shim.fs.readFileSync) {
|
||||
localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, 'utf-8'));
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
err.message = 'syntax error in ' + languageFile;
|
||||
}
|
||||
if (err.code === 'ENOENT')
|
||||
localeLookup = {};
|
||||
else
|
||||
throw err;
|
||||
}
|
||||
this.cache[this.locale] = localeLookup;
|
||||
}
|
||||
_resolveLocaleFile(directory, locale) {
|
||||
let file = shim.resolve(directory, './', locale + '.json');
|
||||
if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf('_')) {
|
||||
// attempt fallback to language only
|
||||
const languageFile = shim.resolve(directory, './', locale.split('_')[0] + '.json');
|
||||
if (this._fileExistsSync(languageFile))
|
||||
file = languageFile;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
_fileExistsSync(file) {
|
||||
return shim.exists(file);
|
||||
}
|
||||
}
|
||||
export function y18n(opts, _shim) {
|
||||
shim = _shim;
|
||||
const y18n = new Y18N(opts);
|
||||
return {
|
||||
__: y18n.__.bind(y18n),
|
||||
__n: y18n.__n.bind(y18n),
|
||||
setLocale: y18n.setLocale.bind(y18n),
|
||||
getLocale: y18n.getLocale.bind(y18n),
|
||||
updateLocale: y18n.updateLocale.bind(y18n),
|
||||
locale: y18n.locale
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lastValueFrom.js","sourceRoot":"","sources":["../../../src/internal/lastValueFrom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAoD/C,MAAM,UAAU,aAAa,CAAO,MAAqB,EAAE,MAA+B;IACxF,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC;IAC7C,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5C,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,MAAS,CAAC;QACd,MAAM,CAAC,SAAS,CAAC;YACf,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;gBACd,MAAM,GAAG,KAAK,CAAC;gBACf,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,GAAG,EAAE;gBACb,IAAI,SAAS,EAAE;oBACb,OAAO,CAAC,MAAM,CAAC,CAAC;iBACjB;qBAAM,IAAI,SAAS,EAAE;oBACpB,OAAO,CAAC,MAAO,CAAC,YAAY,CAAC,CAAC;iBAC/B;qBAAM;oBACL,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;iBAC1B;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"globby","version":"13.1.3","files":{"license":{"checkedAt":1678883669302,"integrity":"sha512-0fM2/ycrxrltyaBKfQ748Ck23VlPUUBgNAR47ldf4B1V/HoXTfWBSk+vcshGKwEpmOynu4mOP5o+hyBfuRNa8g==","mode":420,"size":1117},"ignore.js":{"checkedAt":1678883670819,"integrity":"sha512-H9OY69bp5qM9kUmnLzM6gJxFrZlQxlxFfQuKYr/V16giDu6+/y+ZM3jnKwFUg52X7lDMYABoGb0Xxs7ChSvc1w==","mode":420,"size":2576},"package.json":{"checkedAt":1678883670820,"integrity":"sha512-hnJsMcyIICoMlOhLcvmRjQYHU+48MeFiFtIP3pc0xevzvpppgX0VvSitHHTnDAJ7MJNcJTLZmhptuXBOs4GEJA==","mode":420,"size":1601},"utilities.js":{"checkedAt":1678883670820,"integrity":"sha512-6HLJFb3TZ7JYYzuxbyUGUeieSyz5fGNwzt83CjvfWf+0H9OzNPFGX4QsS29YtNfUWTe/2WQ+t3Z+83nMjO+0ww==","mode":420,"size":462},"index.js":{"checkedAt":1678883670820,"integrity":"sha512-w/MLsN6dYLB/ThD4/t9fAT0ibP918Qrb/ereJkiZ4YSTLyDvt5lqRB1cA+Nn9Y21TdqdL/T4o7x+NJROnmfE1Q==","mode":420,"size":5953},"readme.md":{"checkedAt":1678883670834,"integrity":"sha512-221hFSvzO5lrZvg97WA2Trs2EAp0ZUsKSvDS13Om31vUXmSlm2Rq4oxVa59MHg2sKeEAiPdPZDv936X+qKDGWQ==","mode":420,"size":6056},"index.d.ts":{"checkedAt":1678883670834,"integrity":"sha512-cVRXwcYqeayjOhbUiHbMYfbxtwCfE9qHg2kdmr0ImWE12+ZuaEi7qeG+SEs/FTyG0Odr3XJpGJ4FLupLfleztQ==","mode":420,"size":7059}}}
|
||||
@@ -0,0 +1,53 @@
|
||||
var baseClone = require('./_baseClone'),
|
||||
baseIteratee = require('./_baseIteratee');
|
||||
|
||||
/** Used to compose bitmasks for cloning. */
|
||||
var CLONE_DEEP_FLAG = 1;
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with the arguments of the created
|
||||
* function. If `func` is a property name, the created function returns the
|
||||
* property value for a given element. If `func` is an array or object, the
|
||||
* created function returns `true` for elements that contain the equivalent
|
||||
* source properties, otherwise it returns `false`.
|
||||
*
|
||||
* @static
|
||||
* @since 4.0.0
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {*} [func=_.identity] The value to convert to a callback.
|
||||
* @returns {Function} Returns the callback.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': true },
|
||||
* { 'user': 'fred', 'age': 40, 'active': false }
|
||||
* ];
|
||||
*
|
||||
* // The `_.matches` iteratee shorthand.
|
||||
* _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
|
||||
* // => [{ 'user': 'barney', 'age': 36, 'active': true }]
|
||||
*
|
||||
* // The `_.matchesProperty` iteratee shorthand.
|
||||
* _.filter(users, _.iteratee(['user', 'fred']));
|
||||
* // => [{ 'user': 'fred', 'age': 40 }]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.map(users, _.iteratee('user'));
|
||||
* // => ['barney', 'fred']
|
||||
*
|
||||
* // Create custom iteratee shorthands.
|
||||
* _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
|
||||
* return !_.isRegExp(func) ? iteratee(func) : function(string) {
|
||||
* return func.test(string);
|
||||
* };
|
||||
* });
|
||||
*
|
||||
* _.filter(['abc', 'def'], /ef/);
|
||||
* // => ['def']
|
||||
*/
|
||||
function iteratee(func) {
|
||||
return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
|
||||
}
|
||||
|
||||
module.exports = iteratee;
|
||||
@@ -0,0 +1,85 @@
|
||||
import {signalsByName} from 'human-signals';
|
||||
|
||||
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
|
||||
if (timedOut) {
|
||||
return `timed out after ${timeout} milliseconds`;
|
||||
}
|
||||
|
||||
if (isCanceled) {
|
||||
return 'was canceled';
|
||||
}
|
||||
|
||||
if (errorCode !== undefined) {
|
||||
return `failed with ${errorCode}`;
|
||||
}
|
||||
|
||||
if (signal !== undefined) {
|
||||
return `was killed with ${signal} (${signalDescription})`;
|
||||
}
|
||||
|
||||
if (exitCode !== undefined) {
|
||||
return `failed with exit code ${exitCode}`;
|
||||
}
|
||||
|
||||
return 'failed';
|
||||
};
|
||||
|
||||
export const makeError = ({
|
||||
stdout,
|
||||
stderr,
|
||||
all,
|
||||
error,
|
||||
signal,
|
||||
exitCode,
|
||||
command,
|
||||
escapedCommand,
|
||||
timedOut,
|
||||
isCanceled,
|
||||
killed,
|
||||
parsed: {options: {timeout}},
|
||||
}) => {
|
||||
// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
|
||||
// We normalize them to `undefined`
|
||||
exitCode = exitCode === null ? undefined : exitCode;
|
||||
signal = signal === null ? undefined : signal;
|
||||
const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
|
||||
|
||||
const errorCode = error && error.code;
|
||||
|
||||
const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
|
||||
const execaMessage = `Command ${prefix}: ${command}`;
|
||||
const isError = Object.prototype.toString.call(error) === '[object Error]';
|
||||
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
|
||||
const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
|
||||
|
||||
if (isError) {
|
||||
error.originalMessage = error.message;
|
||||
error.message = message;
|
||||
} else {
|
||||
error = new Error(message);
|
||||
}
|
||||
|
||||
error.shortMessage = shortMessage;
|
||||
error.command = command;
|
||||
error.escapedCommand = escapedCommand;
|
||||
error.exitCode = exitCode;
|
||||
error.signal = signal;
|
||||
error.signalDescription = signalDescription;
|
||||
error.stdout = stdout;
|
||||
error.stderr = stderr;
|
||||
|
||||
if (all !== undefined) {
|
||||
error.all = all;
|
||||
}
|
||||
|
||||
if ('bufferedData' in error) {
|
||||
delete error.bufferedData;
|
||||
}
|
||||
|
||||
error.failed = true;
|
||||
error.timedOut = Boolean(timedOut);
|
||||
error.isCanceled = isCanceled;
|
||||
error.killed = killed && !timedOut;
|
||||
|
||||
return error;
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const stream_1 = require("stream");
|
||||
const crypto_1 = require("crypto");
|
||||
const data_uri_to_buffer_1 = __importDefault(require("data-uri-to-buffer"));
|
||||
const notmodified_1 = __importDefault(require("./notmodified"));
|
||||
const debug = debug_1.default('get-uri:data');
|
||||
class DataReadable extends stream_1.Readable {
|
||||
constructor(hash, buf) {
|
||||
super();
|
||||
this.push(buf);
|
||||
this.push(null);
|
||||
this.hash = hash;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a Readable stream from a "data:" URI.
|
||||
*/
|
||||
function get({ href: uri }, { cache }) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// need to create a SHA1 hash of the URI string, for cacheability checks
|
||||
// in future `getUri()` calls with the same data URI passed in.
|
||||
const shasum = crypto_1.createHash('sha1');
|
||||
shasum.update(uri);
|
||||
const hash = shasum.digest('hex');
|
||||
debug('generated SHA1 hash for "data:" URI: %o', hash);
|
||||
// check if the cache is the same "data:" URI that was previously passed in.
|
||||
if (cache && cache.hash === hash) {
|
||||
debug('got matching cache SHA1 hash: %o', hash);
|
||||
throw new notmodified_1.default();
|
||||
}
|
||||
else {
|
||||
debug('creating Readable stream from "data:" URI buffer');
|
||||
const buf = data_uri_to_buffer_1.default(uri);
|
||||
return new DataReadable(hash, buf);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.default = get;
|
||||
//# sourceMappingURL=data.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
export type UpdateScan = {
|
||||
id: number;
|
||||
runner: number;
|
||||
valid?: boolean;
|
||||
distance: number;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm test
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@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 HOLDERS AND CONTRIBUTORS "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 <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.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true node:true */
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
root = path.join(path.dirname(fs.realpathSync(__filename)), '..'),
|
||||
escodegen = require(root),
|
||||
optionator = require('optionator')({
|
||||
prepend: 'Usage: esgenerate [options] file.json ...',
|
||||
options: [
|
||||
{
|
||||
option: 'config',
|
||||
alias: 'c',
|
||||
type: 'String',
|
||||
description: 'configuration json for escodegen'
|
||||
}
|
||||
]
|
||||
}),
|
||||
args = optionator.parse(process.argv),
|
||||
files = args._,
|
||||
options;
|
||||
|
||||
if (files.length === 0) {
|
||||
console.log(optionator.generateHelp());
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args.config) {
|
||||
try {
|
||||
options = JSON.parse(fs.readFileSync(args.config, 'utf-8'))
|
||||
} catch (err) {
|
||||
console.error('Error parsing config: ', err);
|
||||
}
|
||||
}
|
||||
|
||||
files.forEach(function (filename) {
|
||||
var content = fs.readFileSync(filename, 'utf-8');
|
||||
console.log(escodegen.generate(JSON.parse(content), options));
|
||||
});
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"acorn-node","version":"1.8.2","files":{"build.js":{"checkedAt":1678883672877,"integrity":"sha512-YwOzSxyoca4C1YR68Ax3UFVTlqkpVupM5OCUuAX6Zy0rMV56JYgDHhVSpXBIykkRLooF2tF/VT8EVIw5bmSiaw==","mode":420,"size":1518},"lib/bigint/index.js":{"checkedAt":1678883672877,"integrity":"sha512-WwUAnnUySvLtkFfoeVZ26aTFwjvKpFB0SwxwsKUDp4V/c/Mfvi7pgfcsgLGdiWr3i9TM5ax257UNKuVQUQlK0A==","mode":420,"size":2601},"lib/class-fields/index.js":{"checkedAt":1678883672877,"integrity":"sha512-PoLcjatCgPoGhssyesCS8mT3Ip5KMyrdahHZSNLSel+cisX6Yc2OT6mLOmFGY2wxadie+NX/+ow1C+F//yYgCQ==","mode":420,"size":2624},"lib/dynamic-import/index.js":{"checkedAt":1678883672877,"integrity":"sha512-NZlJ6qKEbTB1PswSo2k57dJ670ERBFFIRAbPB+VN6YV1jp19Gmq+hxuckPe+g7gwtq4KBiuRsrNRDRil5Hm1xw==","mode":420,"size":4073},"index.js":{"checkedAt":1678883672877,"integrity":"sha512-lbybpN6Xu5Vqu9j8kN74zIer/5WAiT7pjmz7nHZ+X5mIMfktYI+0dYpvHUkIQWjgJY/vvM4oV6BJmO9nGS0QdQ==","mode":420,"size":1122},"lib/export-ns-from/index.js":{"checkedAt":1678883672880,"integrity":"sha512-yRb3xSGl6WwgxK7OZZKhrCgkiw/jcycgcJa2ZYN92Vb8bEOUegEGnqvdkGYRBmGBVqxlrMyW2eq/Noioi4fqhg==","mode":420,"size":1475},"lib/import-meta/index.js":{"checkedAt":1678883672880,"integrity":"sha512-Lsee3UwGFntsvA2w6s0JkLxJLHwjJ8c8DdDaonORkVonXjxbtXC08DAhICVNH0TnHIkZ6dhL4BzExrC3jYWy0w==","mode":420,"size":1898},"lib/numeric-separator/index.js":{"checkedAt":1678883672880,"integrity":"sha512-L1i0VOHk+2bnoNqn6FnIjDDMkSY58JorOcSt3JFkjTa/BIh8p2nMeKxMiarf1K2D9oHeQ6bDwBljxCDB0Dj++g==","mode":420,"size":2212},"lib/private-class-elements/index.js":{"checkedAt":1678883672880,"integrity":"sha512-w8rYpkn4VaRwTz1Mb9Sl8uyrdglxA3hgBUb+ITeatvocOx8JqJUBSL6E9OcEOKtOrSOsart8sJMIAcgwpDzvbA==","mode":420,"size":5738},"lib/static-class-features/index.js":{"checkedAt":1678883672882,"integrity":"sha512-m9vQ7/iRKazqSGsdG+Ok3m1X/3N/qDOra+dtvzVq1WDyoce19DNqzuOEtT4ICbmO8n311QjhMAFf4+pUexq4vQ==","mode":420,"size":5542},"walk.js":{"checkedAt":1678883672882,"integrity":"sha512-Rde97xMCqll1WRNMCkZBrHZ6iKczbGViNP3rlM4kLF6P3g2Rx32LhfGF1ahkyM31TADLKvgUYOhOGizwYEBXxA==","mode":420,"size":1791},"package.json":{"checkedAt":1678883672882,"integrity":"sha512-b5uO6+mely2dXv3iQ0kBhtYM0teR3opgo9LNtgcLkW6KlAhrL8DWWr/j+7UNfqpetwbHL9PxsguodYJ0JW+5xw==","mode":420,"size":1304},"test/index.js":{"checkedAt":1678883672882,"integrity":"sha512-NYEysiJFhc59CRe5BAXR0HcEK0ftr0RwfU/Wi9CUwdPyn6U8pc4t3+scvAro2EG5r0i5PW29EmG9h2ROXunAAQ==","mode":420,"size":3868},"CHANGELOG.md":{"checkedAt":1678883672882,"integrity":"sha512-/rfM1AVdO8CPqYUjpY1j7/QyNzXCEv2GhjRTqo17OrzpRQPydwxhtcZMS1GOc9FGpdb1+yy9zoZJ2BFnwkmQLQ==","mode":420,"size":2075},"LICENSE.md":{"checkedAt":1678883672883,"integrity":"sha512-r5EeYJBfyIqFt9sHbTmxnweKgtYM6IF13jRuwqDVQedDDsBuEFJXOqIrVtfYjbOw2hlKzjiJDwRgBw9sOIds2Q==","mode":420,"size":4433},"README.md":{"checkedAt":1678883672883,"integrity":"sha512-tYBerMJlaf+QzXjz1Ckh2t1MqA6lCVMWvmmqyoVHckJ1rS2p8FstgY0G1WSsRz5sa++5VspPhmsuspiyea38bg==","mode":420,"size":2548},".travis.yml":{"checkedAt":1678883672883,"integrity":"sha512-srDT8/7PY3rE25k8mwWzfJ8NIhzRrZG//0FYVtU7vmaaaJPsyGGoj1DekuLjz2L2+AByZauakI1cx+DMhsdTfg==","mode":420,"size":456}}}
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var names = require('./');
|
||||
var assert = require('assert');
|
||||
|
||||
assert.deepEqual(names.red, [255,0,0]);
|
||||
assert.deepEqual(names.aliceblue, [240,248,255]);
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","2":"J D CC","129":"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:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB 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 vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},D:{"1":"1 2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 I v J D E F A B C K L G M N O w g x y z"},E:{"1":"D E F A B C K L G KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J HC zB IC JC"},F:{"1":"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","129":"F B PC QC RC SC qB AC TC"},G:{"1":"E XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"zB UC BC VC WC"},H:{"1":"oC"},I:{"1":"f tC uC","2":"tB I pC qC rC sC BC"},J:{"2":"D A"},K:{"1":"h rB","2":"A B C qB AC"},L:{"1":"H"},M:{"2":"H"},N:{"1":"A B"},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:{"2":"AD BD"}},B:2,C:"CSS widows & orphans"};
|
||||
@@ -0,0 +1,895 @@
|
||||
/**
|
||||
* @license Fraction.js v4.2.0 23/05/2021
|
||||
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
||||
*
|
||||
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This class offers the possibility to calculate fractions.
|
||||
* You can pass a fraction in different formats. Either as array, as double, as string or as an integer.
|
||||
*
|
||||
* Array/Object form
|
||||
* [ 0 => <nominator>, 1 => <denominator> ]
|
||||
* [ n => <nominator>, d => <denominator> ]
|
||||
*
|
||||
* Integer form
|
||||
* - Single integer value
|
||||
*
|
||||
* Double form
|
||||
* - Single double value
|
||||
*
|
||||
* String form
|
||||
* 123.456 - a simple double
|
||||
* 123/456 - a string fraction
|
||||
* 123.'456' - a double with repeating decimal places
|
||||
* 123.(456) - synonym
|
||||
* 123.45'6' - a double with repeating last place
|
||||
* 123.45(6) - synonym
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* let f = new Fraction("9.4'31'");
|
||||
* f.mul([-4, 3]).div(4.9);
|
||||
*
|
||||
*/
|
||||
|
||||
(function(root) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// Set Identity function to downgrade BigInt to Number if needed
|
||||
if (!BigInt) BigInt = function(n) { if (isNaN(n)) throw new Error(""); return n; };
|
||||
|
||||
const C_ONE = BigInt(1);
|
||||
const C_ZERO = BigInt(0);
|
||||
const C_TEN = BigInt(10);
|
||||
const C_TWO = BigInt(2);
|
||||
const C_FIVE = BigInt(5);
|
||||
|
||||
// Maximum search depth for cyclic rational numbers. 2000 should be more than enough.
|
||||
// Example: 1/7 = 0.(142857) has 6 repeating decimal places.
|
||||
// If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits
|
||||
const MAX_CYCLE_LEN = 2000;
|
||||
|
||||
// Parsed data to avoid calling "new" all the time
|
||||
const P = {
|
||||
"s": C_ONE,
|
||||
"n": C_ZERO,
|
||||
"d": C_ONE
|
||||
};
|
||||
|
||||
function assign(n, s) {
|
||||
|
||||
try {
|
||||
n = BigInt(n);
|
||||
} catch (e) {
|
||||
throw Fraction['InvalidParameter'];
|
||||
}
|
||||
return n * s;
|
||||
}
|
||||
|
||||
// Creates a new Fraction internally without the need of the bulky constructor
|
||||
function newFraction(n, d) {
|
||||
|
||||
if (d === C_ZERO) {
|
||||
throw Fraction['DivisionByZero'];
|
||||
}
|
||||
|
||||
const f = Object.create(Fraction.prototype);
|
||||
f["s"] = n < C_ZERO ? -C_ONE : C_ONE;
|
||||
|
||||
n = n < C_ZERO ? -n : n;
|
||||
|
||||
const a = gcd(n, d);
|
||||
|
||||
f["n"] = n / a;
|
||||
f["d"] = d / a;
|
||||
return f;
|
||||
}
|
||||
|
||||
function factorize(num) {
|
||||
|
||||
const factors = {};
|
||||
|
||||
let n = num;
|
||||
let i = C_TWO;
|
||||
let s = C_FIVE - C_ONE;
|
||||
|
||||
while (s <= n) {
|
||||
|
||||
while (n % i === C_ZERO) {
|
||||
n/= i;
|
||||
factors[i] = (factors[i] || C_ZERO) + C_ONE;
|
||||
}
|
||||
s+= C_ONE + C_TWO * i++;
|
||||
}
|
||||
|
||||
if (n !== num) {
|
||||
if (n > 1)
|
||||
factors[n] = (factors[n] || C_ZERO) + C_ONE;
|
||||
} else {
|
||||
factors[num] = (factors[num] || C_ZERO) + C_ONE;
|
||||
}
|
||||
return factors;
|
||||
}
|
||||
|
||||
const parse = function(p1, p2) {
|
||||
|
||||
let n = C_ZERO, d = C_ONE, s = C_ONE;
|
||||
|
||||
if (p1 === undefined || p1 === null) {
|
||||
/* void */
|
||||
} else if (p2 !== undefined) {
|
||||
n = BigInt(p1);
|
||||
d = BigInt(p2);
|
||||
s = n * d;
|
||||
|
||||
if (n % C_ONE !== C_ZERO || d % C_ONE !== C_ZERO) {
|
||||
throw Fraction['NonIntegerParameter'];
|
||||
}
|
||||
|
||||
} else if (typeof p1 === "object") {
|
||||
if ("d" in p1 && "n" in p1) {
|
||||
n = BigInt(p1["n"]);
|
||||
d = BigInt(p1["d"]);
|
||||
if ("s" in p1)
|
||||
n*= BigInt(p1["s"]);
|
||||
} else if (0 in p1) {
|
||||
n = BigInt(p1[0]);
|
||||
if (1 in p1)
|
||||
d = BigInt(p1[1]);
|
||||
} else if (p1 instanceof BigInt) {
|
||||
n = BigInt(p1);
|
||||
} else {
|
||||
throw Fraction['InvalidParameter'];
|
||||
}
|
||||
s = n * d;
|
||||
} else if (typeof p1 === "bigint") {
|
||||
n = p1;
|
||||
s = p1;
|
||||
d = BigInt(1);
|
||||
} else if (typeof p1 === "number") {
|
||||
|
||||
if (isNaN(p1)) {
|
||||
throw Fraction['InvalidParameter'];
|
||||
}
|
||||
|
||||
if (p1 < 0) {
|
||||
s = -C_ONE;
|
||||
p1 = -p1;
|
||||
}
|
||||
|
||||
if (p1 % 1 === 0) {
|
||||
n = BigInt(p1);
|
||||
} else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow
|
||||
|
||||
let z = 1;
|
||||
|
||||
let A = 0, B = 1;
|
||||
let C = 1, D = 1;
|
||||
|
||||
let N = 10000000;
|
||||
|
||||
if (p1 >= 1) {
|
||||
z = 10 ** Math.floor(1 + Math.log10(p1));
|
||||
p1/= z;
|
||||
}
|
||||
|
||||
// Using Farey Sequences
|
||||
|
||||
while (B <= N && D <= N) {
|
||||
let M = (A + C) / (B + D);
|
||||
|
||||
if (p1 === M) {
|
||||
if (B + D <= N) {
|
||||
n = A + C;
|
||||
d = B + D;
|
||||
} else if (D > B) {
|
||||
n = C;
|
||||
d = D;
|
||||
} else {
|
||||
n = A;
|
||||
d = B;
|
||||
}
|
||||
break;
|
||||
|
||||
} else {
|
||||
|
||||
if (p1 > M) {
|
||||
A+= C;
|
||||
B+= D;
|
||||
} else {
|
||||
C+= A;
|
||||
D+= B;
|
||||
}
|
||||
|
||||
if (B > N) {
|
||||
n = C;
|
||||
d = D;
|
||||
} else {
|
||||
n = A;
|
||||
d = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
n = BigInt(n) * BigInt(z);
|
||||
d = BigInt(d);
|
||||
|
||||
}
|
||||
|
||||
} else if (typeof p1 === "string") {
|
||||
|
||||
let ndx = 0;
|
||||
|
||||
let v = C_ZERO, w = C_ZERO, x = C_ZERO, y = C_ONE, z = C_ONE;
|
||||
|
||||
let match = p1.match(/\d+|./g);
|
||||
|
||||
if (match === null)
|
||||
throw Fraction['InvalidParameter'];
|
||||
|
||||
if (match[ndx] === '-') {// Check for minus sign at the beginning
|
||||
s = -C_ONE;
|
||||
ndx++;
|
||||
} else if (match[ndx] === '+') {// Check for plus sign at the beginning
|
||||
ndx++;
|
||||
}
|
||||
|
||||
if (match.length === ndx + 1) { // Check if it's just a simple number "1234"
|
||||
w = assign(match[ndx++], s);
|
||||
} else if (match[ndx + 1] === '.' || match[ndx] === '.') { // Check if it's a decimal number
|
||||
|
||||
if (match[ndx] !== '.') { // Handle 0.5 and .5
|
||||
v = assign(match[ndx++], s);
|
||||
}
|
||||
ndx++;
|
||||
|
||||
// Check for decimal places
|
||||
if (ndx + 1 === match.length || match[ndx + 1] === '(' && match[ndx + 3] === ')' || match[ndx + 1] === "'" && match[ndx + 3] === "'") {
|
||||
w = assign(match[ndx], s);
|
||||
y = C_TEN ** BigInt(match[ndx].length);
|
||||
ndx++;
|
||||
}
|
||||
|
||||
// Check for repeating places
|
||||
if (match[ndx] === '(' && match[ndx + 2] === ')' || match[ndx] === "'" && match[ndx + 2] === "'") {
|
||||
x = assign(match[ndx + 1], s);
|
||||
z = C_TEN ** BigInt(match[ndx + 1].length) - C_ONE;
|
||||
ndx+= 3;
|
||||
}
|
||||
|
||||
} else if (match[ndx + 1] === '/' || match[ndx + 1] === ':') { // Check for a simple fraction "123/456" or "123:456"
|
||||
w = assign(match[ndx], s);
|
||||
y = assign(match[ndx + 2], C_ONE);
|
||||
ndx+= 3;
|
||||
} else if (match[ndx + 3] === '/' && match[ndx + 1] === ' ') { // Check for a complex fraction "123 1/2"
|
||||
v = assign(match[ndx], s);
|
||||
w = assign(match[ndx + 2], s);
|
||||
y = assign(match[ndx + 4], C_ONE);
|
||||
ndx+= 5;
|
||||
}
|
||||
|
||||
if (match.length <= ndx) { // Check for more tokens on the stack
|
||||
d = y * z;
|
||||
s = /* void */
|
||||
n = x + d * v + z * w;
|
||||
} else {
|
||||
throw Fraction['InvalidParameter'];
|
||||
}
|
||||
|
||||
} else {
|
||||
throw Fraction['InvalidParameter'];
|
||||
}
|
||||
|
||||
if (d === C_ZERO) {
|
||||
throw Fraction['DivisionByZero'];
|
||||
}
|
||||
|
||||
P["s"] = s < C_ZERO ? -C_ONE : C_ONE;
|
||||
P["n"] = n < C_ZERO ? -n : n;
|
||||
P["d"] = d < C_ZERO ? -d : d;
|
||||
};
|
||||
|
||||
function modpow(b, e, m) {
|
||||
|
||||
let r = C_ONE;
|
||||
for (; e > C_ZERO; b = (b * b) % m, e >>= C_ONE) {
|
||||
|
||||
if (e & C_ONE) {
|
||||
r = (r * b) % m;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function cycleLen(n, d) {
|
||||
|
||||
for (; d % C_TWO === C_ZERO;
|
||||
d/= C_TWO) {
|
||||
}
|
||||
|
||||
for (; d % C_FIVE === C_ZERO;
|
||||
d/= C_FIVE) {
|
||||
}
|
||||
|
||||
if (d === C_ONE) // Catch non-cyclic numbers
|
||||
return C_ZERO;
|
||||
|
||||
// If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem:
|
||||
// 10^(d-1) % d == 1
|
||||
// However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone,
|
||||
// as we want to translate the numbers to strings.
|
||||
|
||||
let rem = C_TEN % d;
|
||||
let t = 1;
|
||||
|
||||
for (; rem !== C_ONE; t++) {
|
||||
rem = rem * C_TEN % d;
|
||||
|
||||
if (t > MAX_CYCLE_LEN)
|
||||
return C_ZERO; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1`
|
||||
}
|
||||
return BigInt(t);
|
||||
}
|
||||
|
||||
function cycleStart(n, d, len) {
|
||||
|
||||
let rem1 = C_ONE;
|
||||
let rem2 = modpow(C_TEN, len, d);
|
||||
|
||||
for (let t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE)
|
||||
// Solve 10^s == 10^(s+t) (mod d)
|
||||
|
||||
if (rem1 === rem2)
|
||||
return BigInt(t);
|
||||
|
||||
rem1 = rem1 * C_TEN % d;
|
||||
rem2 = rem2 * C_TEN % d;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function gcd(a, b) {
|
||||
|
||||
if (!a)
|
||||
return b;
|
||||
if (!b)
|
||||
return a;
|
||||
|
||||
while (1) {
|
||||
a%= b;
|
||||
if (!a)
|
||||
return b;
|
||||
b%= a;
|
||||
if (!b)
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module constructor
|
||||
*
|
||||
* @constructor
|
||||
* @param {number|Fraction=} a
|
||||
* @param {number=} b
|
||||
*/
|
||||
function Fraction(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
|
||||
if (this instanceof Fraction) {
|
||||
a = gcd(P["d"], P["n"]); // Abuse a
|
||||
this["s"] = P["s"];
|
||||
this["n"] = P["n"] / a;
|
||||
this["d"] = P["d"] / a;
|
||||
} else {
|
||||
return newFraction(P['s'] * P['n'], P['d']);
|
||||
}
|
||||
}
|
||||
|
||||
Fraction['DivisionByZero'] = new Error("Division by Zero");
|
||||
Fraction['InvalidParameter'] = new Error("Invalid argument");
|
||||
Fraction['NonIntegerParameter'] = new Error("Parameters must be integer");
|
||||
|
||||
Fraction.prototype = {
|
||||
|
||||
"s": C_ONE,
|
||||
"n": C_ZERO,
|
||||
"d": C_ONE,
|
||||
|
||||
/**
|
||||
* Calculates the absolute value
|
||||
*
|
||||
* Ex: new Fraction(-4).abs() => 4
|
||||
**/
|
||||
"abs": function() {
|
||||
|
||||
return newFraction(this["n"], this["d"]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Inverts the sign of the current fraction
|
||||
*
|
||||
* Ex: new Fraction(-4).neg() => 4
|
||||
**/
|
||||
"neg": function() {
|
||||
|
||||
return newFraction(-this["s"] * this["n"], this["d"]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds two rational numbers
|
||||
*
|
||||
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
|
||||
**/
|
||||
"add": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return newFraction(
|
||||
this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"],
|
||||
this["d"] * P["d"]
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Subtracts two rational numbers
|
||||
*
|
||||
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
|
||||
**/
|
||||
"sub": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return newFraction(
|
||||
this["s"] * this["n"] * P["d"] - P["s"] * this["d"] * P["n"],
|
||||
this["d"] * P["d"]
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Multiplies two rational numbers
|
||||
*
|
||||
* Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
|
||||
**/
|
||||
"mul": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return newFraction(
|
||||
this["s"] * P["s"] * this["n"] * P["n"],
|
||||
this["d"] * P["d"]
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Divides two rational numbers
|
||||
*
|
||||
* Ex: new Fraction("-17.(345)").inverse().div(3)
|
||||
**/
|
||||
"div": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return newFraction(
|
||||
this["s"] * P["s"] * this["n"] * P["d"],
|
||||
this["d"] * P["n"]
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Clones the actual object
|
||||
*
|
||||
* Ex: new Fraction("-17.(345)").clone()
|
||||
**/
|
||||
"clone": function() {
|
||||
return newFraction(this['s'] * this['n'], this['d']);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the modulo of two rational numbers - a more precise fmod
|
||||
*
|
||||
* Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
|
||||
**/
|
||||
"mod": function(a, b) {
|
||||
|
||||
if (a === undefined) {
|
||||
return newFraction(this["s"] * this["n"] % this["d"], C_ONE);
|
||||
}
|
||||
|
||||
parse(a, b);
|
||||
if (0 === P["n"] && 0 === this["d"]) {
|
||||
throw Fraction['DivisionByZero'];
|
||||
}
|
||||
|
||||
/*
|
||||
* First silly attempt, kinda slow
|
||||
*
|
||||
return that["sub"]({
|
||||
"n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)),
|
||||
"d": num["d"],
|
||||
"s": this["s"]
|
||||
});*/
|
||||
|
||||
/*
|
||||
* New attempt: a1 / b1 = a2 / b2 * q + r
|
||||
* => b2 * a1 = a2 * b1 * q + b1 * b2 * r
|
||||
* => (b2 * a1 % a2 * b1) / (b1 * b2)
|
||||
*/
|
||||
return newFraction(
|
||||
this["s"] * (P["d"] * this["n"]) % (P["n"] * this["d"]),
|
||||
P["d"] * this["d"]
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the fractional gcd of two rational numbers
|
||||
*
|
||||
* Ex: new Fraction(5,8).gcd(3,7) => 1/56
|
||||
*/
|
||||
"gcd": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
|
||||
// gcd(a / b, c / d) = gcd(a, c) / lcm(b, d)
|
||||
|
||||
return newFraction(gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]), P["d"] * this["d"]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the fractional lcm of two rational numbers
|
||||
*
|
||||
* Ex: new Fraction(5,8).lcm(3,7) => 15
|
||||
*/
|
||||
"lcm": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
|
||||
// lcm(a / b, c / d) = lcm(a, c) / gcd(b, d)
|
||||
|
||||
if (P["n"] === C_ZERO && this["n"] === C_ZERO) {
|
||||
return newFraction(C_ZERO, C_ONE);
|
||||
}
|
||||
return newFraction(P["n"] * this["n"], gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]));
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the inverse of the fraction, means numerator and denominator are exchanged
|
||||
*
|
||||
* Ex: new Fraction([-3, 4]).inverse() => -4 / 3
|
||||
**/
|
||||
"inverse": function() {
|
||||
return newFraction(this["s"] * this["d"], this["n"]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the fraction to some integer exponent
|
||||
*
|
||||
* Ex: new Fraction(-1,2).pow(-3) => -8
|
||||
*/
|
||||
"pow": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
|
||||
// Trivial case when exp is an integer
|
||||
|
||||
if (P['d'] === C_ONE) {
|
||||
|
||||
if (P['s'] < C_ZERO) {
|
||||
return newFraction((this['s'] * this["d"]) ** P['n'], this["n"] ** P['n']);
|
||||
} else {
|
||||
return newFraction((this['s'] * this["n"]) ** P['n'], this["d"] ** P['n']);
|
||||
}
|
||||
}
|
||||
|
||||
// Negative roots become complex
|
||||
// (-a/b)^(c/d) = x
|
||||
// <=> (-1)^(c/d) * (a/b)^(c/d) = x
|
||||
// <=> (cos(pi) + i*sin(pi))^(c/d) * (a/b)^(c/d) = x
|
||||
// <=> (cos(c*pi/d) + i*sin(c*pi/d)) * (a/b)^(c/d) = x # DeMoivre's formula
|
||||
// From which follows that only for c=0 the root is non-complex
|
||||
if (this['s'] < C_ZERO) return null;
|
||||
|
||||
// Now prime factor n and d
|
||||
let N = factorize(this['n']);
|
||||
let D = factorize(this['d']);
|
||||
|
||||
// Exponentiate and take root for n and d individually
|
||||
let n = C_ONE;
|
||||
let d = C_ONE;
|
||||
for (let k in N) {
|
||||
if (k === '1') continue;
|
||||
if (k === '0') {
|
||||
n = C_ZERO;
|
||||
break;
|
||||
}
|
||||
N[k]*= P['n'];
|
||||
|
||||
if (N[k] % P['d'] === C_ZERO) {
|
||||
N[k]/= P['d'];
|
||||
} else return null;
|
||||
n*= BigInt(k) ** N[k];
|
||||
}
|
||||
|
||||
for (let k in D) {
|
||||
if (k === '1') continue;
|
||||
D[k]*= P['n'];
|
||||
|
||||
if (D[k] % P['d'] === C_ZERO) {
|
||||
D[k]/= P['d'];
|
||||
} else return null;
|
||||
d*= BigInt(k) ** D[k];
|
||||
}
|
||||
|
||||
if (P['s'] < C_ZERO) {
|
||||
return newFraction(d, n);
|
||||
}
|
||||
return newFraction(n, d);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if two rational numbers are the same
|
||||
*
|
||||
* Ex: new Fraction(19.6).equals([98, 5]);
|
||||
**/
|
||||
"equals": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return this["s"] * this["n"] * P["d"] === P["s"] * P["n"] * this["d"]; // Same as compare() === 0
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if two rational numbers are the same
|
||||
*
|
||||
* Ex: new Fraction(19.6).equals([98, 5]);
|
||||
**/
|
||||
"compare": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
let t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]);
|
||||
|
||||
return (C_ZERO < t) - (t < C_ZERO);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the ceil of a rational number
|
||||
*
|
||||
* Ex: new Fraction('4.(3)').ceil() => (5 / 1)
|
||||
**/
|
||||
"ceil": function(places) {
|
||||
|
||||
places = C_TEN ** BigInt(places || 0);
|
||||
|
||||
return newFraction(this["s"] * places * this["n"] / this["d"] +
|
||||
(places * this["n"] % this["d"] > C_ZERO && this["s"] >= C_ZERO ? C_ONE : C_ZERO),
|
||||
places);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculates the floor of a rational number
|
||||
*
|
||||
* Ex: new Fraction('4.(3)').floor() => (4 / 1)
|
||||
**/
|
||||
"floor": function(places) {
|
||||
|
||||
places = C_TEN ** BigInt(places || 0);
|
||||
|
||||
return newFraction(this["s"] * places * this["n"] / this["d"] -
|
||||
(places * this["n"] % this["d"] > C_ZERO && this["s"] < C_ZERO ? C_ONE : C_ZERO),
|
||||
places);
|
||||
},
|
||||
|
||||
/**
|
||||
* Rounds a rational numbers
|
||||
*
|
||||
* Ex: new Fraction('4.(3)').round() => (4 / 1)
|
||||
**/
|
||||
"round": function(places) {
|
||||
|
||||
places = C_TEN ** BigInt(places || 0);
|
||||
|
||||
/* Derivation:
|
||||
|
||||
s >= 0:
|
||||
round(n / d) = trunc(n / d) + (n % d) / d >= 0.5 ? 1 : 0
|
||||
= trunc(n / d) + 2(n % d) >= d ? 1 : 0
|
||||
s < 0:
|
||||
round(n / d) =-trunc(n / d) - (n % d) / d > 0.5 ? 1 : 0
|
||||
=-trunc(n / d) - 2(n % d) > d ? 1 : 0
|
||||
|
||||
=>:
|
||||
|
||||
round(s * n / d) = s * trunc(n / d) + s * (C + 2(n % d) > d ? 1 : 0)
|
||||
where C = s >= 0 ? 1 : 0, to fix the >= for the positve case.
|
||||
*/
|
||||
|
||||
return newFraction(this["s"] * places * this["n"] / this["d"] +
|
||||
this["s"] * ((this["s"] >= C_ZERO ? C_ONE : C_ZERO) + C_TWO * (places * this["n"] % this["d"]) > this["d"] ? C_ONE : C_ZERO),
|
||||
places);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if two rational numbers are divisible
|
||||
*
|
||||
* Ex: new Fraction(19.6).divisible(1.5);
|
||||
*/
|
||||
"divisible": function(a, b) {
|
||||
|
||||
parse(a, b);
|
||||
return !(!(P["n"] * this["d"]) || ((this["n"] * P["d"]) % (P["n"] * this["d"])));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a decimal representation of the fraction
|
||||
*
|
||||
* Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
|
||||
**/
|
||||
'valueOf': function() {
|
||||
// Best we can do so far
|
||||
return Number(this["s"] * this["n"]) / Number(this["d"]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a string representation of a fraction with all digits
|
||||
*
|
||||
* Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
|
||||
**/
|
||||
'toString': function(dec) {
|
||||
|
||||
let N = this["n"];
|
||||
let D = this["d"];
|
||||
|
||||
dec = dec || 15; // 15 = decimal places when no repitation
|
||||
|
||||
let cycLen = cycleLen(N, D); // Cycle length
|
||||
let cycOff = cycleStart(N, D, cycLen); // Cycle start
|
||||
|
||||
let str = this['s'] < C_ZERO ? "-" : "";
|
||||
|
||||
// Append integer part
|
||||
str+= N / D;
|
||||
|
||||
N%= D;
|
||||
N*= C_TEN;
|
||||
|
||||
if (N)
|
||||
str+= ".";
|
||||
|
||||
if (cycLen) {
|
||||
|
||||
for (let i = cycOff; i--;) {
|
||||
str+= N / D;
|
||||
N%= D;
|
||||
N*= C_TEN;
|
||||
}
|
||||
str+= "(";
|
||||
for (let i = cycLen; i--;) {
|
||||
str+= N / D;
|
||||
N%= D;
|
||||
N*= C_TEN;
|
||||
}
|
||||
str+= ")";
|
||||
} else {
|
||||
for (let i = dec; N && i--;) {
|
||||
str+= N / D;
|
||||
N%= D;
|
||||
N*= C_TEN;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a string-fraction representation of a Fraction object
|
||||
*
|
||||
* Ex: new Fraction("1.'3'").toFraction() => "4 1/3"
|
||||
**/
|
||||
'toFraction': function(excludeWhole) {
|
||||
|
||||
let n = this["n"];
|
||||
let d = this["d"];
|
||||
let str = this['s'] < C_ZERO ? "-" : "";
|
||||
|
||||
if (d === C_ONE) {
|
||||
str+= n;
|
||||
} else {
|
||||
let whole = n / d;
|
||||
if (excludeWhole && whole > C_ZERO) {
|
||||
str+= whole;
|
||||
str+= " ";
|
||||
n%= d;
|
||||
}
|
||||
|
||||
str+= n;
|
||||
str+= '/';
|
||||
str+= d;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a latex representation of a Fraction object
|
||||
*
|
||||
* Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
|
||||
**/
|
||||
'toLatex': function(excludeWhole) {
|
||||
|
||||
let n = this["n"];
|
||||
let d = this["d"];
|
||||
let str = this['s'] < C_ZERO ? "-" : "";
|
||||
|
||||
if (d === C_ONE) {
|
||||
str+= n;
|
||||
} else {
|
||||
let whole = n / d;
|
||||
if (excludeWhole && whole > C_ZERO) {
|
||||
str+= whole;
|
||||
n%= d;
|
||||
}
|
||||
|
||||
str+= "\\frac{";
|
||||
str+= n;
|
||||
str+= '}{';
|
||||
str+= d;
|
||||
str+= '}';
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of continued fraction elements
|
||||
*
|
||||
* Ex: new Fraction("7/8").toContinued() => [0,1,7]
|
||||
*/
|
||||
'toContinued': function() {
|
||||
|
||||
let a = this['n'];
|
||||
let b = this['d'];
|
||||
let res = [];
|
||||
|
||||
do {
|
||||
res.push(a / b);
|
||||
let t = a % b;
|
||||
a = b;
|
||||
b = t;
|
||||
} while (a !== C_ONE);
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
"simplify": function(eps) {
|
||||
|
||||
eps = eps || 0.001;
|
||||
|
||||
const thisABS = this['abs']();
|
||||
const cont = thisABS['toContinued']();
|
||||
|
||||
for (let i = 1; i < cont.length; i++) {
|
||||
|
||||
let s = newFraction(cont[i - 1], C_ONE);
|
||||
for (let k = i - 2; k >= 0; k--) {
|
||||
s = s['inverse']()['add'](cont[k]);
|
||||
}
|
||||
|
||||
if (s['sub'](thisABS)['abs']().valueOf() < eps) {
|
||||
return s['mul'](this['s']);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof define === "function" && define["amd"]) {
|
||||
define([], function() {
|
||||
return Fraction;
|
||||
});
|
||||
} else if (typeof exports === "object") {
|
||||
Object.defineProperty(exports, "__esModule", { 'value': true });
|
||||
Fraction['default'] = Fraction;
|
||||
Fraction['Fraction'] = Fraction;
|
||||
module['exports'] = Fraction;
|
||||
} else {
|
||||
root['Fraction'] = Fraction;
|
||||
}
|
||||
|
||||
})(this);
|
||||
@@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for csv2json/testNew/testCSVConverter2.ts</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">csv2json/testNew</a> testCSVConverter2.ts
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">98% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>98/100</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>15/15</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">98% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>98/100</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a></td><td class="line-coverage quiet"><span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span>
|
||||
<span class="cline-any cline-no">0</span></td><td class="text"><pre class="prettyprint lang-js">Unable to lookup source: /Users/kxiang/work/projects/csv2json/testNew/testCSVConverter2.ts(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/testNew/testCSVConverter2.ts')
|
||||
Error: Unable to lookup source: /Users/kxiang/work/projects/csv2json/testNew/testCSVConverter2.ts(ENOENT: no such file or directory, open '/Users/kxiang/work/projects/csv2json/testNew/testCSVConverter2.ts')
|
||||
at Context.defaultSourceLookup [as sourceFinder] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:15:15)
|
||||
at Context.getSource (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/context.js:74:17)
|
||||
at Object.annotateSourceCode (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/annotator.js:172:38)
|
||||
at HtmlReport.onDetail (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/html/index.js:237:39)
|
||||
at LcovReport.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-reports/lib/lcov/index.js:24:24)
|
||||
at Visitor.(anonymous function) [as onDetail] (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:34:30)
|
||||
at ReportNode.Node.visit (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:123:17)
|
||||
at /Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:116:23
|
||||
at Array.forEach (native)
|
||||
at visitChildren (/Users/kxiang/work/projects/csv2json/node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:115:32)</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri May 11 2018 21:20:20 GMT+0100 (IST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
<script src="../../block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,457 @@
|
||||
/* global host, bridge, data, context */
|
||||
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Object: localObject,
|
||||
Array: localArray,
|
||||
Error: LocalError,
|
||||
Reflect: localReflect,
|
||||
Proxy: LocalProxy,
|
||||
WeakMap: LocalWeakMap,
|
||||
Function: localFunction,
|
||||
Promise: localPromise,
|
||||
eval: localEval
|
||||
} = global;
|
||||
|
||||
const {
|
||||
freeze: localObjectFreeze
|
||||
} = localObject;
|
||||
|
||||
const {
|
||||
getPrototypeOf: localReflectGetPrototypeOf,
|
||||
apply: localReflectApply,
|
||||
deleteProperty: localReflectDeleteProperty,
|
||||
has: localReflectHas,
|
||||
defineProperty: localReflectDefineProperty,
|
||||
setPrototypeOf: localReflectSetPrototypeOf,
|
||||
getOwnPropertyDescriptor: localReflectGetOwnPropertyDescriptor
|
||||
} = localReflect;
|
||||
|
||||
const {
|
||||
isArray: localArrayIsArray
|
||||
} = localArray;
|
||||
|
||||
const {
|
||||
ensureThis,
|
||||
ReadOnlyHandler,
|
||||
from,
|
||||
fromWithFactory,
|
||||
readonlyFactory,
|
||||
connect,
|
||||
addProtoMapping,
|
||||
VMError,
|
||||
ReadOnlyMockHandler
|
||||
} = bridge;
|
||||
|
||||
const {
|
||||
allowAsync,
|
||||
GeneratorFunction,
|
||||
AsyncFunction,
|
||||
AsyncGeneratorFunction
|
||||
} = data;
|
||||
|
||||
const {
|
||||
get: localWeakMapGet,
|
||||
set: localWeakMapSet
|
||||
} = LocalWeakMap.prototype;
|
||||
|
||||
function localUnexpected() {
|
||||
return new VMError('Should not happen');
|
||||
}
|
||||
|
||||
// global is originally prototype of host.Object so it can be used to climb up from the sandbox.
|
||||
if (!localReflectSetPrototypeOf(context, localObject.prototype)) throw localUnexpected();
|
||||
|
||||
Object.defineProperties(global, {
|
||||
global: {value: global, writable: true, configurable: true, enumerable: true},
|
||||
globalThis: {value: global, writable: true, configurable: true},
|
||||
GLOBAL: {value: global, writable: true, configurable: true},
|
||||
root: {value: global, writable: true, configurable: true},
|
||||
Error: {value: LocalError}
|
||||
});
|
||||
|
||||
if (!localReflectDefineProperty(global, 'VMError', {
|
||||
__proto__: null,
|
||||
value: VMError,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
})) throw localUnexpected();
|
||||
|
||||
// Fixes buffer unsafe allocation
|
||||
/* eslint-disable no-use-before-define */
|
||||
class BufferHandler extends ReadOnlyHandler {
|
||||
|
||||
apply(target, thiz, args) {
|
||||
if (args.length > 0 && typeof args[0] === 'number') {
|
||||
return LocalBuffer.alloc(args[0]);
|
||||
}
|
||||
return localReflectApply(LocalBuffer.from, LocalBuffer, args);
|
||||
}
|
||||
|
||||
construct(target, args, newTarget) {
|
||||
if (args.length > 0 && typeof args[0] === 'number') {
|
||||
return LocalBuffer.alloc(args[0]);
|
||||
}
|
||||
return localReflectApply(LocalBuffer.from, LocalBuffer, args);
|
||||
}
|
||||
|
||||
}
|
||||
/* eslint-enable no-use-before-define */
|
||||
|
||||
const LocalBuffer = fromWithFactory(obj => new BufferHandler(obj), host.Buffer);
|
||||
|
||||
|
||||
if (!localReflectDefineProperty(global, 'Buffer', {
|
||||
__proto__: null,
|
||||
value: LocalBuffer,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
})) throw localUnexpected();
|
||||
|
||||
addProtoMapping(LocalBuffer.prototype, host.Buffer.prototype, 'Uint8Array');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} size Size of new buffer
|
||||
* @this LocalBuffer
|
||||
* @return {LocalBuffer}
|
||||
*/
|
||||
function allocUnsafe(size) {
|
||||
return LocalBuffer.alloc(size);
|
||||
}
|
||||
|
||||
connect(allocUnsafe, host.Buffer.allocUnsafe);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} size Size of new buffer
|
||||
* @this LocalBuffer
|
||||
* @return {LocalBuffer}
|
||||
*/
|
||||
function allocUnsafeSlow(size) {
|
||||
return LocalBuffer.alloc(size);
|
||||
}
|
||||
|
||||
connect(allocUnsafeSlow, host.Buffer.allocUnsafeSlow);
|
||||
|
||||
/**
|
||||
* Replacement for Buffer inspect
|
||||
*
|
||||
* @param {*} recurseTimes
|
||||
* @param {*} ctx
|
||||
* @this LocalBuffer
|
||||
* @return {string}
|
||||
*/
|
||||
function inspect(recurseTimes, ctx) {
|
||||
// Mimic old behavior, could throw but didn't pass a test.
|
||||
const max = host.INSPECT_MAX_BYTES;
|
||||
const actualMax = Math.min(max, this.length);
|
||||
const remaining = this.length - max;
|
||||
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
|
||||
if (remaining > 0) str += ` ... ${remaining} more byte${remaining > 1 ? 's' : ''}`;
|
||||
return `<${this.constructor.name} ${str}>`;
|
||||
}
|
||||
|
||||
connect(inspect, host.Buffer.prototype.inspect);
|
||||
|
||||
connect(localFunction.prototype.bind, host.Function.prototype.bind);
|
||||
|
||||
connect(localObject.prototype.__defineGetter__, host.Object.prototype.__defineGetter__);
|
||||
connect(localObject.prototype.__defineSetter__, host.Object.prototype.__defineSetter__);
|
||||
connect(localObject.prototype.__lookupGetter__, host.Object.prototype.__lookupGetter__);
|
||||
connect(localObject.prototype.__lookupSetter__, host.Object.prototype.__lookupSetter__);
|
||||
|
||||
/*
|
||||
* PrepareStackTrace sanitization
|
||||
*/
|
||||
|
||||
const oldPrepareStackTraceDesc = localReflectGetOwnPropertyDescriptor(LocalError, 'prepareStackTrace');
|
||||
|
||||
let currentPrepareStackTrace = LocalError.prepareStackTrace;
|
||||
const wrappedPrepareStackTrace = new LocalWeakMap();
|
||||
if (typeof currentPrepareStackTrace === 'function') {
|
||||
wrappedPrepareStackTrace.set(currentPrepareStackTrace, currentPrepareStackTrace);
|
||||
}
|
||||
|
||||
let OriginalCallSite;
|
||||
LocalError.prepareStackTrace = (e, sst) => {
|
||||
OriginalCallSite = sst[0].constructor;
|
||||
};
|
||||
new LocalError().stack;
|
||||
if (typeof OriginalCallSite === 'function') {
|
||||
LocalError.prepareStackTrace = undefined;
|
||||
|
||||
function makeCallSiteGetters(list) {
|
||||
const callSiteGetters = [];
|
||||
for (let i=0; i<list.length; i++) {
|
||||
const name = list[i];
|
||||
const func = OriginalCallSite.prototype[name];
|
||||
callSiteGetters[i] = {__proto__: null,
|
||||
name,
|
||||
propName: '_' + name,
|
||||
func: (thiz) => {
|
||||
return localReflectApply(func, thiz, []);
|
||||
}
|
||||
};
|
||||
}
|
||||
return callSiteGetters;
|
||||
}
|
||||
|
||||
function applyCallSiteGetters(thiz, callSite, getters) {
|
||||
for (let i=0; i<getters.length; i++) {
|
||||
const getter = getters[i];
|
||||
localReflectDefineProperty(thiz, getter.propName, {
|
||||
__proto__: null,
|
||||
value: getter.func(callSite)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const callSiteGetters = makeCallSiteGetters([
|
||||
'getTypeName',
|
||||
'getFunctionName',
|
||||
'getMethodName',
|
||||
'getFileName',
|
||||
'getLineNumber',
|
||||
'getColumnNumber',
|
||||
'getEvalOrigin',
|
||||
'isToplevel',
|
||||
'isEval',
|
||||
'isNative',
|
||||
'isConstructor',
|
||||
'isAsync',
|
||||
'isPromiseAll',
|
||||
'getPromiseIndex'
|
||||
]);
|
||||
|
||||
class CallSite {
|
||||
constructor(callSite) {
|
||||
applyCallSiteGetters(this, callSite, callSiteGetters);
|
||||
}
|
||||
getThis() {
|
||||
return undefined;
|
||||
}
|
||||
getFunction() {
|
||||
return undefined;
|
||||
}
|
||||
toString() {
|
||||
return 'CallSite {}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let i=0; i<callSiteGetters.length; i++) {
|
||||
const name = callSiteGetters[i].name;
|
||||
const funcProp = localReflectGetOwnPropertyDescriptor(OriginalCallSite.prototype, name);
|
||||
if (!funcProp) continue;
|
||||
const propertyName = callSiteGetters[i].propName;
|
||||
const func = {func() {
|
||||
return this[propertyName];
|
||||
}}.func;
|
||||
const nameProp = localReflectGetOwnPropertyDescriptor(func, 'name');
|
||||
if (!nameProp) throw localUnexpected();
|
||||
nameProp.value = name;
|
||||
if (!localReflectDefineProperty(func, 'name', nameProp)) throw localUnexpected();
|
||||
funcProp.value = func;
|
||||
if (!localReflectDefineProperty(CallSite.prototype, name, funcProp)) throw localUnexpected();
|
||||
}
|
||||
|
||||
if (!localReflectDefineProperty(LocalError, 'prepareStackTrace', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
get() {
|
||||
return currentPrepareStackTrace;
|
||||
},
|
||||
set(value) {
|
||||
if (typeof(value) !== 'function') {
|
||||
currentPrepareStackTrace = value;
|
||||
return;
|
||||
}
|
||||
const wrapped = localReflectApply(localWeakMapGet, wrappedPrepareStackTrace, [value]);
|
||||
if (wrapped) {
|
||||
currentPrepareStackTrace = wrapped;
|
||||
return;
|
||||
}
|
||||
const newWrapped = (error, sst) => {
|
||||
if (localArrayIsArray(sst)) {
|
||||
for (let i=0; i < sst.length; i++) {
|
||||
const cs = sst[i];
|
||||
if (typeof cs === 'object' && localReflectGetPrototypeOf(cs) === OriginalCallSite.prototype) {
|
||||
sst[i] = new CallSite(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value(error, sst);
|
||||
};
|
||||
localReflectApply(localWeakMapSet, wrappedPrepareStackTrace, [value, newWrapped]);
|
||||
localReflectApply(localWeakMapSet, wrappedPrepareStackTrace, [newWrapped, newWrapped]);
|
||||
currentPrepareStackTrace = newWrapped;
|
||||
}
|
||||
})) throw localUnexpected();
|
||||
} else if (oldPrepareStackTraceDesc) {
|
||||
localReflectDefineProperty(LocalError, 'prepareStackTrace', oldPrepareStackTraceDesc);
|
||||
} else {
|
||||
localReflectDeleteProperty(LocalError, 'prepareStackTrace');
|
||||
}
|
||||
|
||||
/*
|
||||
* Exception sanitization
|
||||
*/
|
||||
|
||||
const withProxy = localObjectFreeze({
|
||||
__proto__: null,
|
||||
has(target, key) {
|
||||
if (key === host.INTERNAL_STATE_NAME) return false;
|
||||
return localReflectHas(target, key);
|
||||
}
|
||||
});
|
||||
|
||||
const interanState = localObjectFreeze({
|
||||
__proto__: null,
|
||||
wrapWith(x) {
|
||||
if (x === null || x === undefined) return x;
|
||||
return new LocalProxy(localObject(x), withProxy);
|
||||
},
|
||||
handleException: ensureThis,
|
||||
import(what) {
|
||||
throw new VMError('Dynamic Import not supported');
|
||||
}
|
||||
});
|
||||
|
||||
if (!localReflectDefineProperty(global, host.INTERNAL_STATE_NAME, {
|
||||
__proto__: null,
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: interanState
|
||||
})) throw localUnexpected();
|
||||
|
||||
/*
|
||||
* Eval sanitization
|
||||
*/
|
||||
|
||||
function throwAsync() {
|
||||
return new VMError('Async not available');
|
||||
}
|
||||
|
||||
function makeFunction(inputArgs, isAsync, isGenerator) {
|
||||
const lastArgs = inputArgs.length - 1;
|
||||
let code = lastArgs >= 0 ? `${inputArgs[lastArgs]}` : '';
|
||||
let args = lastArgs > 0 ? `${inputArgs[0]}` : '';
|
||||
for (let i = 1; i < lastArgs; i++) {
|
||||
args += `,${inputArgs[i]}`;
|
||||
}
|
||||
try {
|
||||
code = host.transformAndCheck(args, code, isAsync, isGenerator, allowAsync);
|
||||
} catch (e) {
|
||||
throw bridge.from(e);
|
||||
}
|
||||
return localEval(code);
|
||||
}
|
||||
|
||||
const FunctionHandler = {
|
||||
__proto__: null,
|
||||
apply(target, thiz, args) {
|
||||
return makeFunction(args, this.isAsync, this.isGenerator);
|
||||
},
|
||||
construct(target, args, newTarget) {
|
||||
return makeFunction(args, this.isAsync, this.isGenerator);
|
||||
}
|
||||
};
|
||||
|
||||
const EvalHandler = {
|
||||
__proto__: null,
|
||||
apply(target, thiz, args) {
|
||||
if (args.length === 0) return undefined;
|
||||
let code = `${args[0]}`;
|
||||
try {
|
||||
code = host.transformAndCheck(null, code, false, false, allowAsync);
|
||||
} catch (e) {
|
||||
throw bridge.from(e);
|
||||
}
|
||||
return localEval(code);
|
||||
}
|
||||
};
|
||||
|
||||
const AsyncErrorHandler = {
|
||||
__proto__: null,
|
||||
apply(target, thiz, args) {
|
||||
throw throwAsync();
|
||||
},
|
||||
construct(target, args, newTarget) {
|
||||
throw throwAsync();
|
||||
}
|
||||
};
|
||||
|
||||
function makeCheckFunction(isAsync, isGenerator) {
|
||||
if (isAsync && !allowAsync) return AsyncErrorHandler;
|
||||
return {
|
||||
__proto__: FunctionHandler,
|
||||
isAsync,
|
||||
isGenerator
|
||||
};
|
||||
}
|
||||
|
||||
function overrideWithProxy(obj, prop, value, handler) {
|
||||
const proxy = new LocalProxy(value, handler);
|
||||
if (!localReflectDefineProperty(obj, prop, {__proto__: null, value: proxy})) throw localUnexpected();
|
||||
return proxy;
|
||||
}
|
||||
|
||||
const proxiedFunction = overrideWithProxy(localFunction.prototype, 'constructor', localFunction, makeCheckFunction(false, false));
|
||||
if (GeneratorFunction) {
|
||||
if (!localReflectSetPrototypeOf(GeneratorFunction, proxiedFunction)) throw localUnexpected();
|
||||
overrideWithProxy(GeneratorFunction.prototype, 'constructor', GeneratorFunction, makeCheckFunction(false, true));
|
||||
}
|
||||
if (AsyncFunction) {
|
||||
if (!localReflectSetPrototypeOf(AsyncFunction, proxiedFunction)) throw localUnexpected();
|
||||
overrideWithProxy(AsyncFunction.prototype, 'constructor', AsyncFunction, makeCheckFunction(true, false));
|
||||
}
|
||||
if (AsyncGeneratorFunction) {
|
||||
if (!localReflectSetPrototypeOf(AsyncGeneratorFunction, proxiedFunction)) throw localUnexpected();
|
||||
overrideWithProxy(AsyncGeneratorFunction.prototype, 'constructor', AsyncGeneratorFunction, makeCheckFunction(true, true));
|
||||
}
|
||||
|
||||
global.Function = proxiedFunction;
|
||||
global.eval = new LocalProxy(localEval, EvalHandler);
|
||||
|
||||
/*
|
||||
* Promise sanitization
|
||||
*/
|
||||
|
||||
if (localPromise && !allowAsync) {
|
||||
|
||||
const PromisePrototype = localPromise.prototype;
|
||||
|
||||
overrideWithProxy(PromisePrototype, 'then', PromisePrototype.then, AsyncErrorHandler);
|
||||
// This seems not to work, and will produce
|
||||
// UnhandledPromiseRejectionWarning: TypeError: Method Promise.prototype.then called on incompatible receiver [object Object].
|
||||
// This is likely caused since the host.Promise.prototype.then cannot use the VM Proxy object.
|
||||
// Contextify.connect(host.Promise.prototype.then, Promise.prototype.then);
|
||||
|
||||
if (PromisePrototype.finally) {
|
||||
overrideWithProxy(PromisePrototype, 'finally', PromisePrototype.finally, AsyncErrorHandler);
|
||||
// Contextify.connect(host.Promise.prototype.finally, Promise.prototype.finally);
|
||||
}
|
||||
if (Promise.prototype.catch) {
|
||||
overrideWithProxy(PromisePrototype, 'catch', PromisePrototype.catch, AsyncErrorHandler);
|
||||
// Contextify.connect(host.Promise.prototype.catch, Promise.prototype.catch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function readonly(other, mock) {
|
||||
// Note: other@other(unsafe) mock@other(unsafe) returns@this(unsafe) throws@this(unsafe)
|
||||
if (!mock) return fromWithFactory(readonlyFactory, other);
|
||||
const tmock = from(mock);
|
||||
return fromWithFactory(obj=>new ReadOnlyMockHandler(obj, tmock), other);
|
||||
}
|
||||
|
||||
return {
|
||||
__proto__: null,
|
||||
readonly,
|
||||
global
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Fork } from "../types";
|
||||
export interface Scope {
|
||||
path: any;
|
||||
node: any;
|
||||
isGlobal: boolean;
|
||||
depth: number;
|
||||
parent: any;
|
||||
bindings: any;
|
||||
types: any;
|
||||
didScan: boolean;
|
||||
declares(name: any): any;
|
||||
declaresType(name: any): any;
|
||||
declareTemporary(prefix?: any): any;
|
||||
injectTemporary(identifier: any, init: any): any;
|
||||
scan(force?: any): any;
|
||||
getBindings(): any;
|
||||
getTypes(): any;
|
||||
lookup(name: any): any;
|
||||
lookupType(name: any): any;
|
||||
getGlobalScope(): Scope;
|
||||
}
|
||||
export interface ScopeConstructor {
|
||||
new (path: any, parentScope: any): Scope;
|
||||
isEstablishedBy(node: any): any;
|
||||
}
|
||||
export default function scopePlugin(fork: Fork): ScopeConstructor;
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').omit;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* This method returns `true`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {boolean} Returns `true`.
|
||||
* @example
|
||||
*
|
||||
* _.times(2, _.stubTrue);
|
||||
* // => [true, true]
|
||||
*/
|
||||
function stubTrue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = stubTrue;
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "supports-color",
|
||||
"version": "7.2.0",
|
||||
"description": "Detect whether a terminal supports color",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/supports-color",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"browser.js"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"ansi",
|
||||
"styles",
|
||||
"tty",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"support",
|
||||
"supports",
|
||||
"capability",
|
||||
"detect",
|
||||
"truecolor",
|
||||
"16m"
|
||||
],
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"import-fresh": "^3.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"browser": "browser.js"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"41":0.01098,"43":0.00732,"46":0.0183,"48":0.0183,"50":0.04757,"51":0.04025,"63":0.00732,"65":0.00732,"67":0.01464,"68":0.00732,"70":0.02195,"78":0.0183,"85":0.17197,"88":0.01464,"90":0.01464,"91":0.0183,"102":0.00732,"104":0.00732,"108":0.00732,"109":0.34761,"110":0.06586,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 42 44 45 47 49 52 53 54 55 56 57 58 59 60 61 62 64 66 69 71 72 73 74 75 76 77 79 80 81 82 83 84 86 87 89 92 93 94 95 96 97 98 99 100 101 103 105 106 107 111 112 3.5 3.6"},D:{"44":0.00732,"49":0.01464,"61":0.02927,"65":0.00732,"66":0.00732,"67":0.00732,"73":0.05123,"77":0.03293,"78":0.01098,"79":0.12807,"80":0.02195,"81":0.0183,"84":0.01464,"86":0.03293,"87":0.00732,"88":0.15368,"89":0.01464,"91":0.03293,"92":0.02195,"93":0.0183,"94":0.02927,"95":0.00732,"96":0.0183,"97":0.02927,"98":0.04757,"99":0.0183,"100":0.13904,"101":0.03659,"102":0.04757,"103":0.05123,"104":0.01098,"105":0.12441,"106":0.06586,"107":0.33663,"108":0.53056,"109":24.60678,"110":3.63339,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 50 51 52 53 54 55 56 57 58 59 60 62 63 64 68 69 70 71 72 74 75 76 83 85 90 111 112 113"},F:{"42":0.00732,"62":0.00732,"65":0.00732,"73":0.01464,"75":0.00732,"79":0.00732,"82":0.00732,"85":0.06586,"86":0.00732,"93":0.0183,"94":0.10977,"95":0.15734,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 63 64 66 67 68 69 70 71 72 74 76 77 78 80 81 83 84 87 88 89 90 91 92 9.5-9.6 10.5 10.6 11.1 11.5 11.6 12.1","10.0-10.1":0},B:{"84":0.01098,"88":0.00732,"89":0.04757,"90":0.00732,"92":0.03293,"99":0.04025,"108":0.00732,"109":0.05123,"110":0.09879,_:"12 13 14 15 16 17 18 79 80 81 83 85 86 87 91 93 94 95 96 97 98 100 101 102 103 104 105 106 107"},E:{"4":0,"8":0.01098,"9":0.00732,_:"0 5 6 7 10 11 12 13 14 15 3.1 3.2 5.1 7.1 10.1 11.1 12.1 13.1 15.1 15.2-15.3 15.4 15.5 16.4","6.1":0.00732,"9.1":0.01098,"14.1":0.00732,"15.6":0.0183,"16.0":0.01464,"16.1":0.04025,"16.2":0.01098,"16.3":0.13538},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0,"9.3":0,"10.0-10.2":0,"10.3":0,"11.0-11.2":0,"11.3-11.4":0,"12.0-12.1":0.00285,"12.2-12.5":0.13858,"13.0-13.1":0,"13.2":0,"13.3":0.00285,"13.4-13.7":0.00285,"14.0-14.4":0.01397,"14.5-14.8":0.01397,"15.0-15.1":0.01369,"15.2-15.3":0.53523,"15.4":0.03336,"15.5":0.01397,"15.6":0.06644,"16.0":1.01513,"16.1":0.35786,"16.2":0.20531,"16.3":0.3744,"16.4":0},P:{"4":0.11125,"20":0.21239,"5.0-5.4":0.01011,"6.2-6.4":0.03084,"7.2-7.4":0.23262,"8.2":0.01016,"9.2":0.0103,"10.1":0.01011,"11.1-11.2":0.03034,"12.0":0.07134,"13.0":0.12137,"14.0":0.04112,"15.0":0.03034,"16.0":0.13148,"17.0":0.09103,"18.0":0.06068,"19.0":0.5057},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00149,"4.4":0,"4.4.3-4.4.4":0.01119},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"10":0.0805,_:"6 7 8 9 11 5.5"},N:{"10":0.03712,"11":0.07423},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.20294},H:{"0":0.07805},L:{"0":60.48154},R:{_:"0"},M:{"0":0.01903},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
Returns a boolean for whether given two types are equal.
|
||||
|
||||
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
||||
*/
|
||||
type IsEqual<T, U> =
|
||||
(<G>() => G extends T ? 1 : 2) extends
|
||||
(<G>() => G extends U ? 1 : 2)
|
||||
? true
|
||||
: false;
|
||||
|
||||
/**
|
||||
Returns a boolean for whether the given array includes the given item.
|
||||
|
||||
This can be useful if another type wants to make a decision based on whether the array includes that item.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Includes} from 'type-fest';
|
||||
|
||||
type hasRed<array extends any[]> = Includes<array, 'red'>;
|
||||
```
|
||||
|
||||
@category Utilities
|
||||
*/
|
||||
export type Includes<Value extends any[], Item> =
|
||||
IsEqual<Value[0], Item> extends true
|
||||
? true
|
||||
: Value extends [Value[0], ...infer rest]
|
||||
? Includes<rest, Item>
|
||||
: false;
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype
|
||||
|
||||
module.exports = function IsUnsignedElementType(type) {
|
||||
return type === 'Uint8'
|
||||
|| type === 'Uint8C'
|
||||
|| type === 'Uint16'
|
||||
|| type === 'Uint32'
|
||||
|| type === 'BigUint64';
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/internal/observable/generate.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAuUjE,MAAM,UAAU,QAAQ,CACtB,qBAAgD,EAChD,SAA4B,EAC5B,OAAwB,EACxB,yBAA4D,EAC5D,SAAyB;;IAEzB,IAAI,cAAgC,CAAC;IACrC,IAAI,YAAe,CAAC;IAIpB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAG1B,CAAC,KAMG,qBAA8C,EALhD,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA,EACP,sBAA6C,EAA7C,cAAc,mBAAG,QAA4B,KAAA,EAC7C,SAAS,eAAA,CACwC,CAAC;KACrD;SAAM;QAGL,YAAY,GAAG,qBAA0B,CAAC;QAC1C,IAAI,CAAC,yBAAyB,IAAI,WAAW,CAAC,yBAAyB,CAAC,EAAE;YACxE,cAAc,GAAG,QAA4B,CAAC;YAC9C,SAAS,GAAG,yBAA0C,CAAC;SACxD;aAAM;YACL,cAAc,GAAG,yBAA6C,CAAC;SAChE;KACF;IAGD,SAAU,GAAG;;;;;oBACF,KAAK,GAAG,YAAY;;;yBAAE,CAAA,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,CAAA;oBAC3D,WAAM,cAAc,CAAC,KAAK,CAAC,EAAA;;oBAA3B,SAA2B,CAAC;;;oBADiC,KAAK,GAAG,OAAQ,CAAC,KAAK,CAAC,CAAA;;;;;KAGvF;IAGD,OAAO,KAAK,CACV,CAAC,SAAS;QACR,CAAC;YAEC,cAAM,OAAA,gBAAgB,CAAC,GAAG,EAAE,EAAE,SAAU,CAAC,EAAnC,CAAmC;QAC3C,CAAC;YAEC,GAAG,CAA6B,CACrC,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"merge2","version":"1.4.1","files":{"LICENSE":{"checkedAt":1678883670842,"integrity":"sha512-GAeTRMmgYSZzL81yOKnAB5FUbEyfLSQeQmYfw0FImjjoRfVsQbsxzF4MACYOhRFrYSbF1CgDHyhclVYtgj84Gg==","mode":420,"size":1082},"package.json":{"checkedAt":1678883670843,"integrity":"sha512-sFGsH1bdqKAdBrfIKgdoIwB3abTnTcbgmRf7p0M8C8j1vg/WxX2bj1SwJ4E8u+46tMY7laV6Vsd82H3t7BOILA==","mode":420,"size":830},"index.js":{"checkedAt":1678883670843,"integrity":"sha512-fpEPGlPaNwS3g0GrR/z5r4Ehn/80/ePRiawpg8/BAlXxKBZK8vwA3E9ZFaI4snR3Qqy/SJoNDGRRLqB7uEPB5A==","mode":420,"size":3241},"README.md":{"checkedAt":1678883670843,"integrity":"sha512-2aRZ7ik2A95SmkQ8gW8a+85hg6jpVwG/s/qvDukqSIXOi51YgXN/nGWCtwUfHM/fQ5Vu10mhf0TuXR+XI7Z3VA==","mode":420,"size":3744}}}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
module.exports = function(
|
||||
Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
||||
var util = require("./util");
|
||||
|
||||
var raceLater = function (promise) {
|
||||
return promise.then(function(array) {
|
||||
return race(array, promise);
|
||||
});
|
||||
};
|
||||
|
||||
function race(promises, parent) {
|
||||
var maybePromise = tryConvertToPromise(promises);
|
||||
|
||||
if (maybePromise instanceof Promise) {
|
||||
return raceLater(maybePromise);
|
||||
} else {
|
||||
promises = util.asArray(promises);
|
||||
if (promises === null)
|
||||
return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
|
||||
}
|
||||
|
||||
var ret = new Promise(INTERNAL);
|
||||
if (parent !== undefined) {
|
||||
ret._propagateFrom(parent, 3);
|
||||
}
|
||||
var fulfill = ret._fulfill;
|
||||
var reject = ret._reject;
|
||||
for (var i = 0, len = promises.length; i < len; ++i) {
|
||||
var val = promises[i];
|
||||
|
||||
if (val === undefined && !(i in promises)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Promise.race = function (promises) {
|
||||
return race(promises, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.race = function () {
|
||||
return race(this, undefined);
|
||||
};
|
||||
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').cargo;
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
Create a type with the keys of the given type changed to `string` type.
|
||||
|
||||
Use-case: Changing interface values to strings in order to use them in a form model.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Stringified} from 'type-fest';
|
||||
|
||||
type Car {
|
||||
model: string;
|
||||
speed: number;
|
||||
}
|
||||
|
||||
const carForm: Stringified<Car> = {
|
||||
model: 'Foo',
|
||||
speed: '101'
|
||||
};
|
||||
```
|
||||
|
||||
@category Utilities
|
||||
*/
|
||||
export type Stringified<ObjectType> = {[KeyType in keyof ObjectType]: string};
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var SymbolPolyfill = require("../polyfill");
|
||||
|
||||
module.exports = function (t, a) {
|
||||
a(t(undefined), false, "Undefined");
|
||||
a(t(null), false, "Null");
|
||||
a(t(true), false, "Primitive");
|
||||
a(t("raz"), false, "String");
|
||||
a(t({}), false, "Object");
|
||||
a(t([]), false, "Array");
|
||||
if (typeof Symbol !== "undefined") {
|
||||
a(t(Symbol("foo")), true, "Native");
|
||||
}
|
||||
a(t(SymbolPolyfill()), true, "Polyfill");
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../../src/internal/observable/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAqDhC,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,KAAc,EAAE,SAAyB;IAC5E,IAAI,KAAK,IAAI,IAAI,EAAE;QAEjB,KAAK,GAAG,KAAK,CAAC;QACd,KAAK,GAAG,CAAC,CAAC;KACX;IAED,IAAI,KAAK,IAAI,CAAC,EAAE;QAEd,OAAO,KAAK,CAAC;KACd;IAGD,IAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC;IAE1B,OAAO,IAAI,UAAU,CACnB,SAAS;QACP,CAAC;YACC,UAAC,UAAU;gBACT,IAAI,CAAC,GAAG,KAAK,CAAC;gBACd,OAAO,SAAS,CAAC,QAAQ,CAAC;oBACxB,IAAI,CAAC,GAAG,GAAG,EAAE;wBACX,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;wBACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;qBACjB;yBAAM;wBACL,UAAU,CAAC,QAAQ,EAAE,CAAC;qBACvB;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;YACC,UAAC,UAAU;gBACT,IAAI,CAAC,GAAG,KAAK,CAAC;gBACd,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;oBACpC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;iBACtB;gBACD,UAAU,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC,CACN,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"QueueAction.js","sourceRoot":"","sources":["../../../../src/internal/scheduler/QueueAction.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C;IAAoC,+BAAc;IAChD,qBAAsB,SAAyB,EAAY,IAAmD;QAA9G,YACE,kBAAM,SAAS,EAAE,IAAI,CAAC,SACvB;QAFqB,eAAS,GAAT,SAAS,CAAgB;QAAY,UAAI,GAAJ,IAAI,CAA+C;;IAE9G,CAAC;IAEM,8BAAQ,GAAf,UAAgB,KAAS,EAAE,KAAiB;QAAjB,sBAAA,EAAA,SAAiB;QAC1C,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,iBAAM,QAAQ,YAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,6BAAO,GAAd,UAAe,KAAQ,EAAE,KAAa;QACpC,OAAO,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAM,OAAO,YAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC;IAES,oCAAc,GAAxB,UAAyB,SAAyB,EAAE,EAAgB,EAAE,KAAiB;QAAjB,sBAAA,EAAA,SAAiB;QAKrF,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE;YACrE,OAAO,iBAAM,cAAc,YAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;SACnD;QAGD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAMtB,OAAO,CAAC,CAAC;IACX,CAAC;IACH,kBAAC;AAAD,CAAC,AArCD,CAAoC,WAAW,GAqC9C"}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var re = /foo/;
|
||||
|
||||
module.exports = function () {
|
||||
if (typeof re.match !== "function") return false;
|
||||
return re.match("barfoobar") && !re.match("elo");
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
var createFind = require('./_createFind'),
|
||||
findLastIndex = require('./findLastIndex');
|
||||
|
||||
/**
|
||||
* This method is like `_.find` except that it iterates over elements of
|
||||
* `collection` from right to left.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 2.0.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to inspect.
|
||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||||
* @param {number} [fromIndex=collection.length-1] The index to search from.
|
||||
* @returns {*} Returns the matched element, else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* _.findLast([1, 2, 3, 4], function(n) {
|
||||
* return n % 2 == 1;
|
||||
* });
|
||||
* // => 3
|
||||
*/
|
||||
var findLast = createFind(findLastIndex);
|
||||
|
||||
module.exports = findLast;
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"execa","version":"5.1.1","files":{"license":{"checkedAt":1678883669302,"integrity":"sha512-0fM2/ycrxrltyaBKfQ748Ck23VlPUUBgNAR47ldf4B1V/HoXTfWBSk+vcshGKwEpmOynu4mOP5o+hyBfuRNa8g==","mode":420,"size":1117},"lib/command.js":{"checkedAt":1678883671522,"integrity":"sha512-W095IKZ4bFShM/6Ov88U7ZVspyHGRaHrxOuOCEkaKJ6iUbuKbuDxrwVTGzWgbVW01cqOmXlbScNOn8R34nLMNA==","mode":420,"size":1189},"lib/error.js":{"checkedAt":1678883671522,"integrity":"sha512-Ypjkj1U27TDxNryv47Khaw68QtQX3DRTArRPcnytMUZ9gTEa/GVL3T8K4CPaHfbix49j2w4A/x+6bA/XPxPrig==","mode":420,"size":2169},"index.js":{"checkedAt":1678883671522,"integrity":"sha512-iSR6XKz3OYm7I2ozMLud1tQoV7GzaSkLahCAnr0JTZieX/Usb1cM+Bcf6Nh4VEg+++GIxkBxPgL3fFCkZGZlLg==","mode":420,"size":6516},"lib/kill.js":{"checkedAt":1678883671528,"integrity":"sha512-FkokQnJq5corE7v0qu7nF7zo7NRnO/mmW3ECqdDWVX12tJXxF7hPx1PrvdFnagiJ1poibSklFvSLFIVIJAMYGA==","mode":420,"size":3095},"lib/stdio.js":{"checkedAt":1678883671528,"integrity":"sha512-+7ZxuDt0fKsHrucItYC3/2fMGsaoKcjtKG7qYMu19OGYyKfI2jWPuDLMv4uWLPMbCGUa8ge+ktJvqjuzaxjZPQ==","mode":420,"size":1186},"lib/promise.js":{"checkedAt":1678883671528,"integrity":"sha512-2TdOa1uVMWeNKIHffnDXm3ZxqI8Wd3OCwQtZuLqmSXpxqRO3f9EaJpr3QiTMWqZRdkVkcRNcMDkHImFsWLBnFw==","mode":420,"size":1150},"lib/stream.js":{"checkedAt":1678883671528,"integrity":"sha512-cLAQlUhnilhuKB6YpQK19n8Zt5ZPJPKoqHpf3caCjEfxULkh0eoOeGKEuljBlrGIW/ZmwTmalcc3VAIt+gmWTQ==","mode":420,"size":2400},"package.json":{"checkedAt":1678883671528,"integrity":"sha512-mCmz4+vgMTIQhsIkEWHvrz5TuHZjsL54n10QRdul0RJwbgqfDsWwipXm4nQBE4KfFDJLB1AQCaENAUH8/vV0Wg==","mode":420,"size":1282},"readme.md":{"checkedAt":1678883671533,"integrity":"sha512-CXXSp3g1zWdqvl446IzS5PO/G22jjwHGVGDb5sKlnydFWciKrcvtqXsqCym1fck26w8L91Zq/UChci48vxVI1A==","mode":420,"size":19747},"index.d.ts":{"checkedAt":1678883671540,"integrity":"sha512-M3zLcPxhfoTf61x6bgYh2p1TcFTrpu9x1LlDtXdFyEGjKMH/teBAqSTAPwKqeB4w0xFcUbuI6yuLsOB51NOjcA==","mode":420,"size":17674}}}
|
||||
@@ -0,0 +1,15 @@
|
||||
function normalizer (config) {
|
||||
if (typeof config === 'string') {
|
||||
return {
|
||||
module: config
|
||||
}
|
||||
}
|
||||
return config;
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
if (Array.isArray(config)) {
|
||||
return config.map(normalizer);
|
||||
}
|
||||
return normalizer(config);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
||||
* @param str string to convert
|
||||
*/
|
||||
function toUpperCase(str) {
|
||||
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
|
||||
}
|
||||
var NOT_A_Z_REGEX = /[^A-Z]/;
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
|
||||
*/
|
||||
export function IsWellFormedCurrencyCode(currency) {
|
||||
currency = toUpperCase(currency);
|
||||
if (currency.length !== 3) {
|
||||
return false;
|
||||
}
|
||||
if (NOT_A_Z_REGEX.test(currency)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "callsites",
|
||||
"version": "3.1.0",
|
||||
"description": "Get callsites from the V8 stack trace API",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/callsites",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"stacktrace",
|
||||
"v8",
|
||||
"callsite",
|
||||
"callsites",
|
||||
"stack",
|
||||
"trace",
|
||||
"function",
|
||||
"file",
|
||||
"line",
|
||||
"debug"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user