new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IsSanctionedSimpleUnitIdentifier = exports.SIMPLE_UNITS = exports.removeUnitNamespace = exports.SANCTIONED_UNITS = void 0;
|
||||
/**
|
||||
* https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
|
||||
*/
|
||||
exports.SANCTIONED_UNITS = [
|
||||
'angle-degree',
|
||||
'area-acre',
|
||||
'area-hectare',
|
||||
'concentr-percent',
|
||||
'digital-bit',
|
||||
'digital-byte',
|
||||
'digital-gigabit',
|
||||
'digital-gigabyte',
|
||||
'digital-kilobit',
|
||||
'digital-kilobyte',
|
||||
'digital-megabit',
|
||||
'digital-megabyte',
|
||||
'digital-petabyte',
|
||||
'digital-terabit',
|
||||
'digital-terabyte',
|
||||
'duration-day',
|
||||
'duration-hour',
|
||||
'duration-millisecond',
|
||||
'duration-minute',
|
||||
'duration-month',
|
||||
'duration-second',
|
||||
'duration-week',
|
||||
'duration-year',
|
||||
'length-centimeter',
|
||||
'length-foot',
|
||||
'length-inch',
|
||||
'length-kilometer',
|
||||
'length-meter',
|
||||
'length-mile-scandinavian',
|
||||
'length-mile',
|
||||
'length-millimeter',
|
||||
'length-yard',
|
||||
'mass-gram',
|
||||
'mass-kilogram',
|
||||
'mass-ounce',
|
||||
'mass-pound',
|
||||
'mass-stone',
|
||||
'temperature-celsius',
|
||||
'temperature-fahrenheit',
|
||||
'volume-fluid-ounce',
|
||||
'volume-gallon',
|
||||
'volume-liter',
|
||||
'volume-milliliter',
|
||||
];
|
||||
// In CLDR, the unit name always follows the form `namespace-unit` pattern.
|
||||
// For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
|
||||
function removeUnitNamespace(unit) {
|
||||
return unit.slice(unit.indexOf('-') + 1);
|
||||
}
|
||||
exports.removeUnitNamespace = removeUnitNamespace;
|
||||
/**
|
||||
* https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
|
||||
*/
|
||||
exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
|
||||
/**
|
||||
* https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
|
||||
*/
|
||||
function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
|
||||
return exports.SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
|
||||
}
|
||||
exports.IsSanctionedSimpleUnitIdentifier = IsSanctionedSimpleUnitIdentifier;
|
||||
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
const path_1 = require("path");
|
||||
/**
|
||||
* File URI to Path function.
|
||||
*
|
||||
* @param {String} uri
|
||||
* @return {String} path
|
||||
* @api public
|
||||
*/
|
||||
function fileUriToPath(uri) {
|
||||
if (typeof uri !== 'string' ||
|
||||
uri.length <= 7 ||
|
||||
uri.substring(0, 7) !== 'file://') {
|
||||
throw new TypeError('must pass in a file:// URI to convert to a file path');
|
||||
}
|
||||
const rest = decodeURI(uri.substring(7));
|
||||
const firstSlash = rest.indexOf('/');
|
||||
let host = rest.substring(0, firstSlash);
|
||||
let path = rest.substring(firstSlash + 1);
|
||||
// 2. Scheme Definition
|
||||
// As a special case, <host> can be the string "localhost" or the empty
|
||||
// string; this is interpreted as "the machine from which the URL is
|
||||
// being interpreted".
|
||||
if (host === 'localhost') {
|
||||
host = '';
|
||||
}
|
||||
if (host) {
|
||||
host = path_1.sep + path_1.sep + host;
|
||||
}
|
||||
// 3.2 Drives, drive letters, mount points, file system root
|
||||
// Drive letters are mapped into the top of a file URI in various ways,
|
||||
// depending on the implementation; some applications substitute
|
||||
// vertical bar ("|") for the colon after the drive letter, yielding
|
||||
// "file:///c|/tmp/test.txt". In some cases, the colon is left
|
||||
// unchanged, as in "file:///c:/tmp/test.txt". In other cases, the
|
||||
// colon is simply omitted, as in "file:///c/tmp/test.txt".
|
||||
path = path.replace(/^(.+)\|/, '$1:');
|
||||
// for Windows, we need to invert the path separators from what a URI uses
|
||||
if (path_1.sep === '\\') {
|
||||
path = path.replace(/\//g, '\\');
|
||||
}
|
||||
if (/^.+:/.test(path)) {
|
||||
// has Windows drive at beginning of path
|
||||
}
|
||||
else {
|
||||
// unix path…
|
||||
path = path_1.sep + path;
|
||||
}
|
||||
return host + path;
|
||||
}
|
||||
module.exports = fileUriToPath;
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var whichTypedArray = require('which-typed-array');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-typedarrayelementtype
|
||||
|
||||
var table71 = {
|
||||
__proto__: null,
|
||||
$Int8Array: 'Int8',
|
||||
$Uint8Array: 'Uint8',
|
||||
$Uint8ClampedArray: 'Uint8C',
|
||||
$Int16Array: 'Int16',
|
||||
$Uint16Array: 'Uint16',
|
||||
$Int32Array: 'Int32',
|
||||
$Uint32Array: 'Uint32',
|
||||
$BigInt64Array: 'BigInt64',
|
||||
$BigUint64Array: 'BigUint64',
|
||||
$Float32Array: 'Float32',
|
||||
$Float64Array: 'Float64'
|
||||
};
|
||||
|
||||
module.exports = function TypedArrayElementType(O) {
|
||||
var type = whichTypedArray(O);
|
||||
if (type === false) {
|
||||
throw new $TypeError('Assertion failed: `O` must be a TypedArray');
|
||||
}
|
||||
var result = table71['$' + type];
|
||||
if (typeof result !== 'string') {
|
||||
throw new $SyntaxError('Assertion failed: Unknown TypedArray type `' + type + '`');
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"glob-parent","version":"6.0.2","files":{"LICENSE":{"checkedAt":1678883673209,"integrity":"sha512-uk8DZVjFcWdJt5QlC/M7V5EvcJOkhGSccT1uO6bimI/WUiQ64lFnNTe3Be8jOF8XNwS727dxl1fKP2uE0UEy2A==","mode":420,"size":857},"README.md":{"checkedAt":1678883673209,"integrity":"sha512-6+f/LOX8jy9mu4ln57QTcsuhXSkED0WJ5nyZS6hFEwDWgXOIekSt6iE4D4A54EodKAorDCPkkmr9Ewu6VMJGcA==","mode":420,"size":4198},"package.json":{"checkedAt":1678883673209,"integrity":"sha512-+XfA+SK7fQcEQMFvhcrEb6Zunl2wiCzU+Do0LImZv/frVgDL7Z107BAxUUC28Ew8sZv4WmTZsno4D4tiQMshwA==","mode":420,"size":1050},"index.js":{"checkedAt":1678883673209,"integrity":"sha512-TX5nhCPDEHTpB2h3Y+5to6RTZWgkfuZoFSTQIGzAfYw+ykJuqnB7taJT1/fCNjG2eU3B7oKIv3V4I2gE0Ejq1w==","mode":420,"size":1614}}}
|
||||
@@ -0,0 +1,201 @@
|
||||
// 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.
|
||||
// a transform stream is a readable/writable stream where you do
|
||||
// something with the data. Sometimes it's called a "filter",
|
||||
// but that's not a great name for it, since that implies a thing where
|
||||
// some bits pass through, and others are simply ignored. (That would
|
||||
// be a valid example of a transform, of course.)
|
||||
//
|
||||
// While the output is causally related to the input, it's not a
|
||||
// necessarily symmetric or synchronous transformation. For example,
|
||||
// a zlib stream might take multiple plain-text writes(), and then
|
||||
// emit a single compressed chunk some time in the future.
|
||||
//
|
||||
// Here's how this works:
|
||||
//
|
||||
// The Transform stream has all the aspects of the readable and writable
|
||||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||||
// internally, and returns false if there's a lot of pending writes
|
||||
// buffered up. When you call read(), that calls _read(n) until
|
||||
// there's enough pending readable data buffered up.
|
||||
//
|
||||
// In a transform stream, the written data is placed in a buffer. When
|
||||
// _read(n) is called, it transforms the queued up data, calling the
|
||||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||||
// written chunk would result in multiple output chunks, then the first
|
||||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||||
//
|
||||
// This way, back-pressure is actually determined by the reading side,
|
||||
// since _read has to be called to start processing a new chunk. However,
|
||||
// a pathological inflate type of transform can cause excessive buffering
|
||||
// here. For example, imagine a stream where every byte of input is
|
||||
// interpreted as an integer from 0-255, and then results in that many
|
||||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||||
// 1kb of data being output. In this case, you could write a very small
|
||||
// amount of input, and end up with a very large amount of output. In
|
||||
// such a pathological inflating mechanism, there'd be no way to tell
|
||||
// the system to stop doing the transform. A single 4MB write could
|
||||
// cause the system to run out of memory.
|
||||
//
|
||||
// However, even in such a pathological case, only a single written chunk
|
||||
// would be consumed, and then the rest would wait (un-transformed) until
|
||||
// the results of the previous transformed chunk were consumed.
|
||||
'use strict';
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
var _require$codes = require('../errors').codes,
|
||||
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
||||
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
||||
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
||||
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
||||
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
require('inherits')(Transform, Duplex);
|
||||
|
||||
function afterTransform(er, data) {
|
||||
var ts = this._transformState;
|
||||
ts.transforming = false;
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (cb === null) {
|
||||
return this.emit('error', new ERR_MULTIPLE_CALLBACK());
|
||||
}
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
this.push(data);
|
||||
cb(er);
|
||||
var rs = this._readableState;
|
||||
rs.reading = false;
|
||||
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
this._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
Duplex.call(this, options);
|
||||
this._transformState = {
|
||||
afterTransform: afterTransform.bind(this),
|
||||
needTransform: false,
|
||||
transforming: false,
|
||||
writecb: null,
|
||||
writechunk: null,
|
||||
writeencoding: null
|
||||
}; // start out asking for a readable event once data is transformed.
|
||||
|
||||
this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
|
||||
// that Readable wants before the first _read call, so unset the
|
||||
// sync guard flag.
|
||||
|
||||
this._readableState.sync = false;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.transform === 'function') this._transform = options.transform;
|
||||
if (typeof options.flush === 'function') this._flush = options.flush;
|
||||
} // When the writable side finishes, then flush out anything remaining.
|
||||
|
||||
|
||||
this.on('prefinish', prefinish);
|
||||
}
|
||||
|
||||
function prefinish() {
|
||||
var _this = this;
|
||||
|
||||
if (typeof this._flush === 'function' && !this._readableState.destroyed) {
|
||||
this._flush(function (er, data) {
|
||||
done(_this, er, data);
|
||||
});
|
||||
} else {
|
||||
done(this, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Transform.prototype.push = function (chunk, encoding) {
|
||||
this._transformState.needTransform = false;
|
||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||
}; // This is the part where you do stuff!
|
||||
// override this function in implementation classes.
|
||||
// 'chunk' is an input chunk.
|
||||
//
|
||||
// Call `push(newChunk)` to pass along transformed output
|
||||
// to the readable side. You may call 'push' zero or more times.
|
||||
//
|
||||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||||
// an error, then that'll put the hurt on the whole operation. If you
|
||||
// never call cb(), then you'll never get another chunk.
|
||||
|
||||
|
||||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||||
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
|
||||
};
|
||||
|
||||
Transform.prototype._write = function (chunk, encoding, cb) {
|
||||
var ts = this._transformState;
|
||||
ts.writecb = cb;
|
||||
ts.writechunk = chunk;
|
||||
ts.writeencoding = encoding;
|
||||
|
||||
if (!ts.transforming) {
|
||||
var rs = this._readableState;
|
||||
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
||||
}
|
||||
}; // Doesn't matter what the args are here.
|
||||
// _transform does all the work.
|
||||
// That we got here means that the readable side wants more data.
|
||||
|
||||
|
||||
Transform.prototype._read = function (n) {
|
||||
var ts = this._transformState;
|
||||
|
||||
if (ts.writechunk !== null && !ts.transforming) {
|
||||
ts.transforming = true;
|
||||
|
||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||
} else {
|
||||
// mark that we need a transform, so that any data that comes in
|
||||
// will get processed, now that we've asked for it.
|
||||
ts.needTransform = true;
|
||||
}
|
||||
};
|
||||
|
||||
Transform.prototype._destroy = function (err, cb) {
|
||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||
cb(err2);
|
||||
});
|
||||
};
|
||||
|
||||
function done(stream, er, data) {
|
||||
if (er) return stream.emit('error', er);
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
|
||||
if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
|
||||
if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
|
||||
return stream.push(null);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
var test = require('tape');
|
||||
var inspect = require('../');
|
||||
|
||||
var obj = { x: 'a\r\nb', y: '\x05! \x1f \x12' };
|
||||
|
||||
test('interpolate low bytes', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(
|
||||
inspect(obj),
|
||||
"{ x: 'a\\r\\nb', y: '\\x05! \\x1F \\x12' }"
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,436 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import postcssrc from 'postcss-load-config'
|
||||
import { lilconfig } from 'lilconfig'
|
||||
import loadPlugins from 'postcss-load-config/src/plugins' // Little bit scary, looking at private/internal API
|
||||
import loadOptions from 'postcss-load-config/src/options' // Little bit scary, looking at private/internal API
|
||||
|
||||
import tailwind from '../../../processTailwindFeatures'
|
||||
import { loadPostcss, loadPostcssImport, lightningcss } from './deps'
|
||||
import { formatNodes, drainStdin, outputFile } from './utils'
|
||||
import { env } from '../../../lib/sharedState'
|
||||
import resolveConfig from '../../../../resolveConfig'
|
||||
import getModuleDependencies from '../../../lib/getModuleDependencies'
|
||||
import { parseCandidateFiles } from '../../../lib/content'
|
||||
import { createWatcher } from './watching'
|
||||
import fastGlob from 'fast-glob'
|
||||
import { findAtConfigPath } from '../../../lib/findAtConfigPath'
|
||||
import log from '../../../util/log'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} [customPostCssPath ]
|
||||
* @returns
|
||||
*/
|
||||
async function loadPostCssPlugins(customPostCssPath) {
|
||||
let config = customPostCssPath
|
||||
? await (async () => {
|
||||
let file = path.resolve(customPostCssPath)
|
||||
|
||||
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
||||
// @ts-ignore
|
||||
let { config = {} } = await lilconfig('postcss').load(file)
|
||||
if (typeof config === 'function') {
|
||||
config = config()
|
||||
} else {
|
||||
config = Object.assign({}, config)
|
||||
}
|
||||
|
||||
if (!config.plugins) {
|
||||
config.plugins = []
|
||||
}
|
||||
|
||||
return {
|
||||
file,
|
||||
plugins: loadPlugins(config, file),
|
||||
options: loadOptions(config, file),
|
||||
}
|
||||
})()
|
||||
: await postcssrc()
|
||||
|
||||
let configPlugins = config.plugins
|
||||
|
||||
let configPluginTailwindIdx = configPlugins.findIndex((plugin) => {
|
||||
if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
let beforePlugins =
|
||||
configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx)
|
||||
let afterPlugins =
|
||||
configPluginTailwindIdx === -1
|
||||
? configPlugins
|
||||
: configPlugins.slice(configPluginTailwindIdx + 1)
|
||||
|
||||
return [beforePlugins, afterPlugins, config.options]
|
||||
}
|
||||
|
||||
function loadBuiltinPostcssPlugins() {
|
||||
let postcss = loadPostcss()
|
||||
let IMPORT_COMMENT = '__TAILWIND_RESTORE_IMPORT__: '
|
||||
return [
|
||||
[
|
||||
(root) => {
|
||||
root.walkAtRules('import', (rule) => {
|
||||
if (rule.params.slice(1).startsWith('tailwindcss/')) {
|
||||
rule.after(postcss.comment({ text: IMPORT_COMMENT + rule.params }))
|
||||
rule.remove()
|
||||
}
|
||||
})
|
||||
},
|
||||
loadPostcssImport(),
|
||||
(root) => {
|
||||
root.walkComments((rule) => {
|
||||
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
||||
rule.after(
|
||||
postcss.atRule({
|
||||
name: 'import',
|
||||
params: rule.text.replace(IMPORT_COMMENT, ''),
|
||||
})
|
||||
)
|
||||
rule.remove()
|
||||
}
|
||||
})
|
||||
},
|
||||
],
|
||||
[],
|
||||
{},
|
||||
]
|
||||
}
|
||||
|
||||
let state = {
|
||||
/** @type {any} */
|
||||
context: null,
|
||||
|
||||
/** @type {ReturnType<typeof createWatcher> | null} */
|
||||
watcher: null,
|
||||
|
||||
/** @type {{content: string, extension: string}[]} */
|
||||
changedContent: [],
|
||||
|
||||
configDependencies: new Set(),
|
||||
contextDependencies: new Set(),
|
||||
|
||||
/** @type {import('../../lib/content.js').ContentPath[]} */
|
||||
contentPaths: [],
|
||||
|
||||
refreshContentPaths() {
|
||||
this.contentPaths = parseCandidateFiles(this.context, this.context?.tailwindConfig)
|
||||
},
|
||||
|
||||
get config() {
|
||||
return this.context.tailwindConfig
|
||||
},
|
||||
|
||||
get contentPatterns() {
|
||||
return {
|
||||
all: this.contentPaths.map((contentPath) => contentPath.pattern),
|
||||
dynamic: this.contentPaths
|
||||
.filter((contentPath) => contentPath.glob !== undefined)
|
||||
.map((contentPath) => contentPath.pattern),
|
||||
}
|
||||
},
|
||||
|
||||
loadConfig(configPath, content) {
|
||||
if (this.watcher && configPath) {
|
||||
this.refreshConfigDependencies(configPath)
|
||||
}
|
||||
|
||||
let config = configPath ? require(configPath) : {}
|
||||
|
||||
// @ts-ignore
|
||||
config = resolveConfig(config, { content: { files: [] } })
|
||||
|
||||
// Override content files if `--content` has been passed explicitly
|
||||
if (content?.length > 0) {
|
||||
config.content.files = content
|
||||
}
|
||||
|
||||
return config
|
||||
},
|
||||
|
||||
refreshConfigDependencies(configPath) {
|
||||
env.DEBUG && console.time('Module dependencies')
|
||||
|
||||
for (let file of this.configDependencies) {
|
||||
delete require.cache[require.resolve(file)]
|
||||
}
|
||||
|
||||
if (configPath) {
|
||||
let deps = getModuleDependencies(configPath).map(({ file }) => file)
|
||||
|
||||
for (let dependency of deps) {
|
||||
this.configDependencies.add(dependency)
|
||||
}
|
||||
}
|
||||
|
||||
env.DEBUG && console.timeEnd('Module dependencies')
|
||||
},
|
||||
|
||||
readContentPaths() {
|
||||
let content = []
|
||||
|
||||
// Resolve globs from the content config
|
||||
// TODO: When we make the postcss plugin async-capable this can become async
|
||||
let files = fastGlob.sync(this.contentPatterns.all)
|
||||
|
||||
for (let file of files) {
|
||||
if (env.OXIDE) {
|
||||
content.push({
|
||||
file,
|
||||
extension: path.extname(file).slice(1),
|
||||
})
|
||||
} else {
|
||||
content.push({
|
||||
content: fs.readFileSync(path.resolve(file), 'utf8'),
|
||||
extension: path.extname(file).slice(1),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve raw content in the tailwind config
|
||||
let rawContent = this.config.content.files.filter((file) => {
|
||||
return file !== null && typeof file === 'object'
|
||||
})
|
||||
|
||||
for (let { raw: htmlContent, extension = 'html' } of rawContent) {
|
||||
content.push({ content: htmlContent, extension })
|
||||
}
|
||||
|
||||
return content
|
||||
},
|
||||
|
||||
getContext({ createContext, cliConfigPath, root, result, content }) {
|
||||
if (this.context) {
|
||||
this.context.changedContent = this.changedContent.splice(0)
|
||||
|
||||
return this.context
|
||||
}
|
||||
|
||||
env.DEBUG && console.time('Searching for config')
|
||||
let configPath = findAtConfigPath(root, result) ?? cliConfigPath
|
||||
env.DEBUG && console.timeEnd('Searching for config')
|
||||
|
||||
env.DEBUG && console.time('Loading config')
|
||||
let config = this.loadConfig(configPath, content)
|
||||
env.DEBUG && console.timeEnd('Loading config')
|
||||
|
||||
env.DEBUG && console.time('Creating context')
|
||||
this.context = createContext(config, [])
|
||||
Object.assign(this.context, {
|
||||
userConfigPath: configPath,
|
||||
})
|
||||
env.DEBUG && console.timeEnd('Creating context')
|
||||
|
||||
env.DEBUG && console.time('Resolving content paths')
|
||||
this.refreshContentPaths()
|
||||
env.DEBUG && console.timeEnd('Resolving content paths')
|
||||
|
||||
if (this.watcher) {
|
||||
env.DEBUG && console.time('Watch new files')
|
||||
this.watcher.refreshWatchedFiles()
|
||||
env.DEBUG && console.timeEnd('Watch new files')
|
||||
}
|
||||
|
||||
for (let file of this.readContentPaths()) {
|
||||
this.context.changedContent.push(file)
|
||||
}
|
||||
|
||||
return this.context
|
||||
},
|
||||
}
|
||||
|
||||
export async function createProcessor(args, cliConfigPath) {
|
||||
let postcss = loadPostcss()
|
||||
|
||||
let input = args['--input']
|
||||
let output = args['--output']
|
||||
let includePostCss = args['--postcss']
|
||||
let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined
|
||||
|
||||
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss
|
||||
? await loadPostCssPlugins(customPostCssPath)
|
||||
: loadBuiltinPostcssPlugins()
|
||||
|
||||
if (args['--purge']) {
|
||||
log.warn('purge-flag-deprecated', [
|
||||
'The `--purge` flag has been deprecated.',
|
||||
'Please use `--content` instead.',
|
||||
])
|
||||
|
||||
if (!args['--content']) {
|
||||
args['--content'] = args['--purge']
|
||||
}
|
||||
}
|
||||
|
||||
let content = args['--content']?.split(/(?<!{[^}]+),/) ?? []
|
||||
|
||||
let tailwindPlugin = () => {
|
||||
return {
|
||||
postcssPlugin: 'tailwindcss',
|
||||
Once(root, { result }) {
|
||||
env.DEBUG && console.time('Compiling CSS')
|
||||
tailwind(({ createContext }) => {
|
||||
console.error()
|
||||
console.error('Rebuilding...')
|
||||
|
||||
return () => {
|
||||
return state.getContext({
|
||||
createContext,
|
||||
cliConfigPath,
|
||||
root,
|
||||
result,
|
||||
content,
|
||||
})
|
||||
}
|
||||
})(root, result)
|
||||
env.DEBUG && console.timeEnd('Compiling CSS')
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
tailwindPlugin.postcss = true
|
||||
|
||||
let plugins = [
|
||||
...beforePlugins,
|
||||
tailwindPlugin,
|
||||
!args['--minify'] && formatNodes,
|
||||
...afterPlugins,
|
||||
].filter(Boolean)
|
||||
|
||||
/** @type {import('postcss').Processor} */
|
||||
// @ts-ignore
|
||||
let processor = postcss(plugins)
|
||||
|
||||
async function readInput() {
|
||||
// Piping in data, let's drain the stdin
|
||||
if (input === '-') {
|
||||
return drainStdin()
|
||||
}
|
||||
|
||||
// Input file has been provided
|
||||
if (input) {
|
||||
return fs.promises.readFile(path.resolve(input), 'utf8')
|
||||
}
|
||||
|
||||
// No input file provided, fallback to default atrules
|
||||
return '@tailwind base; @tailwind components; @tailwind utilities'
|
||||
}
|
||||
|
||||
async function build() {
|
||||
let start = process.hrtime.bigint()
|
||||
|
||||
return readInput()
|
||||
.then((css) => processor.process(css, { ...postcssOptions, from: input, to: output }))
|
||||
.then((result) => lightningcss(!!args['--minify'], result))
|
||||
.then((result) => {
|
||||
if (!state.watcher) {
|
||||
return result
|
||||
}
|
||||
|
||||
env.DEBUG && console.time('Recording PostCSS dependencies')
|
||||
for (let message of result.messages) {
|
||||
if (message.type === 'dependency') {
|
||||
state.contextDependencies.add(message.file)
|
||||
}
|
||||
}
|
||||
env.DEBUG && console.timeEnd('Recording PostCSS dependencies')
|
||||
|
||||
// TODO: This needs to be in a different spot
|
||||
env.DEBUG && console.time('Watch new files')
|
||||
state.watcher.refreshWatchedFiles()
|
||||
env.DEBUG && console.timeEnd('Watch new files')
|
||||
|
||||
return result
|
||||
})
|
||||
.then((result) => {
|
||||
if (!output) {
|
||||
process.stdout.write(result.css)
|
||||
return
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
outputFile(result.opts.to, result.css),
|
||||
result.map && outputFile(result.opts.to + '.map', result.map.toString()),
|
||||
])
|
||||
})
|
||||
.then(() => {
|
||||
let end = process.hrtime.bigint()
|
||||
console.error()
|
||||
console.error('Done in', (end - start) / BigInt(1e6) + 'ms.')
|
||||
})
|
||||
.then(
|
||||
() => {},
|
||||
(err) => {
|
||||
// TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
|
||||
// that were collected before the error occurred
|
||||
// The result is not stored on the error so we have to store it externally
|
||||
// and pull the messages off of it here somehow
|
||||
|
||||
// This results in a less than ideal DX because the watcher will not pick up
|
||||
// changes to imported CSS if one of them caused an error during the initial build
|
||||
// If you fix it and then save the main CSS file so there's no error
|
||||
// The watcher will start watching the imported CSS files and will be
|
||||
// resilient to future errors.
|
||||
|
||||
console.error(err)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
||||
*/
|
||||
async function parseChanges(changes) {
|
||||
return Promise.all(
|
||||
changes.map(async (change) => ({
|
||||
content: await change.content(),
|
||||
extension: change.extension,
|
||||
}))
|
||||
)
|
||||
}
|
||||
|
||||
if (input !== undefined && input !== '-') {
|
||||
state.contextDependencies.add(path.resolve(input))
|
||||
}
|
||||
|
||||
return {
|
||||
build,
|
||||
watch: async () => {
|
||||
state.watcher = createWatcher(args, {
|
||||
state,
|
||||
|
||||
/**
|
||||
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
||||
*/
|
||||
async rebuild(changes) {
|
||||
let needsNewContext = changes.some((change) => {
|
||||
return (
|
||||
state.configDependencies.has(change.file) ||
|
||||
state.contextDependencies.has(change.file)
|
||||
)
|
||||
})
|
||||
|
||||
if (needsNewContext) {
|
||||
state.context = null
|
||||
} else {
|
||||
for (let change of await parseChanges(changes)) {
|
||||
state.changedContent.push(change)
|
||||
}
|
||||
}
|
||||
|
||||
return build()
|
||||
},
|
||||
})
|
||||
|
||||
await build()
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
/***
|
||||
* Node External Editor
|
||||
*
|
||||
* Kevin Gravier <kevin@mrkmg.com>
|
||||
* MIT 2018
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var LaunchEditorError = /** @class */ (function (_super) {
|
||||
__extends(LaunchEditorError, _super);
|
||||
function LaunchEditorError(originalError) {
|
||||
var _newTarget = this.constructor;
|
||||
var _this = _super.call(this, "Failed launch editor") || this;
|
||||
_this.originalError = originalError;
|
||||
var proto = _newTarget.prototype;
|
||||
if (Object.setPrototypeOf) {
|
||||
Object.setPrototypeOf(_this, proto);
|
||||
}
|
||||
else {
|
||||
_this.__proto__ = _newTarget.prototype;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
return LaunchEditorError;
|
||||
}(Error));
|
||||
exports.LaunchEditorError = LaunchEditorError;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.00261,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00261,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0.00261,"68":0,"69":0,"70":0,"71":0,"72":0.00261,"73":0,"74":0,"75":0.00261,"76":0,"77":0,"78":0.00261,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.04961,"101":0,"102":0.01044,"103":0,"104":0.0235,"105":0.00261,"106":0.00261,"107":0.02089,"108":0.02089,"109":0.28721,"110":0.16188,"111":0.00261,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0.00261,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00261,"57":0,"58":0.00261,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0.00261,"65":0,"66":0,"67":0,"68":0,"69":0.00522,"70":0.00261,"71":0.00261,"72":0.00261,"73":0,"74":0.01044,"75":0.00261,"76":0.00261,"77":0.00261,"78":0.00522,"79":0.01828,"80":0.00522,"81":0.01044,"83":0.01044,"84":0.00261,"85":0.01044,"86":0.00261,"87":0.01828,"88":0.00522,"89":0.00783,"90":0.00261,"91":0.00783,"92":0.01044,"93":0.00261,"94":0.00522,"95":0.04178,"96":0.00783,"97":0.00261,"98":0.00522,"99":0.00261,"100":0.01306,"101":0.00783,"102":0.00522,"103":0.02872,"104":0.02872,"105":0.13838,"106":0.01828,"107":0.03655,"108":0.10705,"109":2.16452,"110":1.0679,"111":0.00261,"112":0.00261,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0.00261,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00261,"57":0,"58":0,"60":0.00783,"62":0,"63":0.02089,"64":0.00261,"65":0.00261,"66":0.01044,"67":0.03133,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.00261,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0.00522,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0.047,"95":0.07311,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00261,"13":0,"14":0,"15":0.00522,"16":0,"17":0,"18":0.01044,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0.00261,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00522,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0.00261,"106":0.00261,"107":0.00522,"108":0.0235,"109":0.25327,"110":0.31854},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.02611,"15":0.00261,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0.00261,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.01044,"14.1":0.01306,"15.1":0,"15.2-15.3":0,"15.4":0.00261,"15.5":0.00522,"15.6":0.01828,"16.0":0.00522,"16.1":0.00783,"16.2":0.02611,"16.3":0.02089,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.00797,"6.0-6.1":0,"7.0-7.1":0.01593,"8.1-8.4":0.01062,"9.0-9.2":0,"9.3":0.04779,"10.0-10.2":0,"10.3":0.36642,"11.0-11.2":0.06107,"11.3-11.4":0.02921,"12.0-12.1":0.41156,"12.2-12.5":6.52128,"13.0-13.1":0.01328,"13.2":0.01593,"13.3":0.1248,"13.4-13.7":0.23101,"14.0-14.4":0.89747,"14.5-14.8":1.10724,"15.0-15.1":0.6585,"15.2-15.3":0.6346,"15.4":0.65319,"15.5":0.72223,"15.6":1.13113,"16.0":2.18261,"16.1":2.50389,"16.2":2.77207,"16.3":2.56231,"16.4":0.02921},P:{"4":0.10273,"20":0.19518,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.17463,"8.2":0,"9.2":0.03082,"10.1":0,"11.1-11.2":0.02055,"12.0":0,"13.0":0.03082,"14.0":0.08218,"15.0":0.09245,"16.0":0.12327,"17.0":0.03082,"18.0":0.14382,"19.0":0.65744},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00396,"4.2-4.3":0.00712,"4.4":0,"4.4.3-4.4.4":0.06808},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00261,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0.03695,_:"3.0-3.1"},J:{"7":0,"10":0.02956},O:{"0":0.15517},H:{"0":1.2312},L:{"0":65.7265},R:{_:"0"},M:{"0":0.64284},Q:{"13.1":0.00739}};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env node
|
||||
// Standalone semver comparison program.
|
||||
// Exits successfully and prints matching version(s) if
|
||||
// any supplied version is valid and passes all tests.
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
|
||||
let versions = []
|
||||
|
||||
const range = []
|
||||
|
||||
let inc = null
|
||||
|
||||
const version = require('../package.json').version
|
||||
|
||||
let loose = false
|
||||
|
||||
let includePrerelease = false
|
||||
|
||||
let coerce = false
|
||||
|
||||
let rtl = false
|
||||
|
||||
let identifier
|
||||
|
||||
const semver = require('../')
|
||||
|
||||
let reverse = false
|
||||
|
||||
let options = {}
|
||||
|
||||
const main = () => {
|
||||
if (!argv.length) {
|
||||
return help()
|
||||
}
|
||||
while (argv.length) {
|
||||
let a = argv.shift()
|
||||
const indexOfEqualSign = a.indexOf('=')
|
||||
if (indexOfEqualSign !== -1) {
|
||||
const value = a.slice(indexOfEqualSign + 1)
|
||||
a = a.slice(0, indexOfEqualSign)
|
||||
argv.unshift(value)
|
||||
}
|
||||
switch (a) {
|
||||
case '-rv': case '-rev': case '--rev': case '--reverse':
|
||||
reverse = true
|
||||
break
|
||||
case '-l': case '--loose':
|
||||
loose = true
|
||||
break
|
||||
case '-p': case '--include-prerelease':
|
||||
includePrerelease = true
|
||||
break
|
||||
case '-v': case '--version':
|
||||
versions.push(argv.shift())
|
||||
break
|
||||
case '-i': case '--inc': case '--increment':
|
||||
switch (argv[0]) {
|
||||
case 'major': case 'minor': case 'patch': case 'prerelease':
|
||||
case 'premajor': case 'preminor': case 'prepatch':
|
||||
inc = argv.shift()
|
||||
break
|
||||
default:
|
||||
inc = 'patch'
|
||||
break
|
||||
}
|
||||
break
|
||||
case '--preid':
|
||||
identifier = argv.shift()
|
||||
break
|
||||
case '-r': case '--range':
|
||||
range.push(argv.shift())
|
||||
break
|
||||
case '-c': case '--coerce':
|
||||
coerce = true
|
||||
break
|
||||
case '--rtl':
|
||||
rtl = true
|
||||
break
|
||||
case '--ltr':
|
||||
rtl = false
|
||||
break
|
||||
case '-h': case '--help': case '-?':
|
||||
return help()
|
||||
default:
|
||||
versions.push(a)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
||||
|
||||
versions = versions.map((v) => {
|
||||
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
||||
}).filter((v) => {
|
||||
return semver.valid(v)
|
||||
})
|
||||
if (!versions.length) {
|
||||
return fail()
|
||||
}
|
||||
if (inc && (versions.length !== 1 || range.length)) {
|
||||
return failInc()
|
||||
}
|
||||
|
||||
for (let i = 0, l = range.length; i < l; i++) {
|
||||
versions = versions.filter((v) => {
|
||||
return semver.satisfies(v, range[i], options)
|
||||
})
|
||||
if (!versions.length) {
|
||||
return fail()
|
||||
}
|
||||
}
|
||||
return success(versions)
|
||||
}
|
||||
|
||||
const failInc = () => {
|
||||
console.error('--inc can only be used on a single version with no range')
|
||||
fail()
|
||||
}
|
||||
|
||||
const fail = () => process.exit(1)
|
||||
|
||||
const success = () => {
|
||||
const compare = reverse ? 'rcompare' : 'compare'
|
||||
versions.sort((a, b) => {
|
||||
return semver[compare](a, b, options)
|
||||
}).map((v) => {
|
||||
return semver.clean(v, options)
|
||||
}).map((v) => {
|
||||
return inc ? semver.inc(v, inc, options, identifier) : v
|
||||
}).forEach((v, i, _) => {
|
||||
console.log(v)
|
||||
})
|
||||
}
|
||||
|
||||
const help = () => console.log(
|
||||
`SemVer ${version}
|
||||
|
||||
A JavaScript implementation of the https://semver.org/ specification
|
||||
Copyright Isaac Z. Schlueter
|
||||
|
||||
Usage: semver [options] <version> [<version> [...]]
|
||||
Prints valid versions sorted by SemVer precedence
|
||||
|
||||
Options:
|
||||
-r --range <range>
|
||||
Print versions that match the specified range.
|
||||
|
||||
-i --increment [<level>]
|
||||
Increment a version by the specified level. Level can
|
||||
be one of: major, minor, patch, premajor, preminor,
|
||||
prepatch, or prerelease. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
Identifier to be used to prefix premajor, preminor,
|
||||
prepatch or prerelease version increments.
|
||||
|
||||
-l --loose
|
||||
Interpret versions and ranges loosely
|
||||
|
||||
-p --include-prerelease
|
||||
Always include prerelease versions in range matching
|
||||
|
||||
-c --coerce
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
--rtl
|
||||
Coerce version strings right to left
|
||||
|
||||
--ltr
|
||||
Coerce version strings left to right (default)
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no satisfying versions are found, then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.`)
|
||||
|
||||
main()
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scheduleArray.js","sourceRoot":"","sources":["../../../../src/internal/scheduled/scheduleArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,UAAU,aAAa,CAAI,KAAmB,EAAE,SAAwB;IAC5E,OAAO,IAAI,UAAU,CAAI,CAAC,UAAU,EAAE,EAAE;QAEtC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,SAAS,CAAC,QAAQ,CAAC;YACxB,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE;gBAGtB,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;iBAAM;gBAGL,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAI5B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;oBACtB,IAAI,CAAC,QAAQ,EAAE,CAAC;iBACjB;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { AsyncAction } from './AsyncAction';
|
||||
export class QueueAction extends AsyncAction {
|
||||
constructor(scheduler, work) {
|
||||
super(scheduler, work);
|
||||
this.scheduler = scheduler;
|
||||
this.work = work;
|
||||
}
|
||||
schedule(state, delay = 0) {
|
||||
if (delay > 0) {
|
||||
return super.schedule(state, delay);
|
||||
}
|
||||
this.delay = delay;
|
||||
this.state = state;
|
||||
this.scheduler.flush(this);
|
||||
return this;
|
||||
}
|
||||
execute(state, delay) {
|
||||
return delay > 0 || this.closed ? super.execute(state, delay) : this._execute(state, delay);
|
||||
}
|
||||
requestAsyncId(scheduler, id, delay = 0) {
|
||||
if ((delay != null && delay > 0) || (delay == null && this.delay > 0)) {
|
||||
return super.requestAsyncId(scheduler, id, delay);
|
||||
}
|
||||
scheduler.flush(this);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=QueueAction.js.map
|
||||
@@ -0,0 +1,79 @@
|
||||
let browserslist = require('browserslist')
|
||||
let { agents } = require('caniuse-lite/dist/unpacker/agents')
|
||||
|
||||
let utils = require('./utils')
|
||||
|
||||
class Browsers {
|
||||
/**
|
||||
* Return all prefixes for default browser data
|
||||
*/
|
||||
static prefixes() {
|
||||
if (this.prefixesCache) {
|
||||
return this.prefixesCache
|
||||
}
|
||||
|
||||
this.prefixesCache = []
|
||||
for (let name in agents) {
|
||||
this.prefixesCache.push(`-${agents[name].prefix}-`)
|
||||
}
|
||||
|
||||
this.prefixesCache = utils
|
||||
.uniq(this.prefixesCache)
|
||||
.sort((a, b) => b.length - a.length)
|
||||
|
||||
return this.prefixesCache
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is value contain any possible prefix
|
||||
*/
|
||||
static withPrefix(value) {
|
||||
if (!this.prefixesRegexp) {
|
||||
this.prefixesRegexp = new RegExp(this.prefixes().join('|'))
|
||||
}
|
||||
|
||||
return this.prefixesRegexp.test(value)
|
||||
}
|
||||
|
||||
constructor(data, requirements, options, browserslistOpts) {
|
||||
this.data = data
|
||||
this.options = options || {}
|
||||
this.browserslistOpts = browserslistOpts || {}
|
||||
this.selected = this.parse(requirements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return browsers selected by requirements
|
||||
*/
|
||||
parse(requirements) {
|
||||
let opts = {}
|
||||
for (let i in this.browserslistOpts) {
|
||||
opts[i] = this.browserslistOpts[i]
|
||||
}
|
||||
opts.path = this.options.from
|
||||
return browserslist(requirements, opts)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return prefix for selected browser
|
||||
*/
|
||||
prefix(browser) {
|
||||
let [name, version] = browser.split(' ')
|
||||
let data = this.data[name]
|
||||
|
||||
let prefix = data.prefix_exceptions && data.prefix_exceptions[version]
|
||||
if (!prefix) {
|
||||
prefix = data.prefix
|
||||
}
|
||||
return `-${prefix}-`
|
||||
}
|
||||
|
||||
/**
|
||||
* Is browser is selected by requirements
|
||||
*/
|
||||
isSelected(browser) {
|
||||
return this.selected.includes(browser)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Browsers
|
||||
@@ -0,0 +1,127 @@
|
||||
declare namespace cliBoxes {
|
||||
/**
|
||||
Style of the box border.
|
||||
*/
|
||||
interface BoxStyle {
|
||||
readonly topLeft: string;
|
||||
readonly top: string;
|
||||
readonly topRight: string;
|
||||
readonly right: string;
|
||||
readonly bottomRight: string;
|
||||
readonly bottom: string;
|
||||
readonly bottomLeft: string;
|
||||
readonly left: string;
|
||||
}
|
||||
|
||||
/**
|
||||
All box styles.
|
||||
*/
|
||||
interface Boxes {
|
||||
/**
|
||||
@example
|
||||
```
|
||||
┌────┐
|
||||
│ │
|
||||
└────┘
|
||||
```
|
||||
*/
|
||||
readonly single: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
╔════╗
|
||||
║ ║
|
||||
╚════╝
|
||||
```
|
||||
*/
|
||||
readonly double: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
╭────╮
|
||||
│ │
|
||||
╰────╯
|
||||
```
|
||||
*/
|
||||
readonly round: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
┏━━━━┓
|
||||
┃ ┃
|
||||
┗━━━━┛
|
||||
```
|
||||
*/
|
||||
readonly bold: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
╓────╖
|
||||
║ ║
|
||||
╙────╜
|
||||
```
|
||||
*/
|
||||
readonly singleDouble: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
╒════╕
|
||||
│ │
|
||||
╘════╛
|
||||
```
|
||||
*/
|
||||
readonly doubleSingle: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
+----+
|
||||
| |
|
||||
+----+
|
||||
```
|
||||
*/
|
||||
readonly classic: BoxStyle;
|
||||
|
||||
/**
|
||||
@example
|
||||
```
|
||||
↘↓↓↓↓↙
|
||||
→ ←
|
||||
↗↑↑↑↑↖
|
||||
```
|
||||
*/
|
||||
readonly arrow: BoxStyle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Boxes for use in the terminal.
|
||||
|
||||
@example
|
||||
```
|
||||
import cliBoxes = require('cli-boxes');
|
||||
|
||||
console.log(cliBoxes.single);
|
||||
// {
|
||||
// topLeft: '┌',
|
||||
// top: '─',
|
||||
// topRight: '┐',
|
||||
// right: '│',
|
||||
// bottomRight: '┘',
|
||||
// bottom: '─',
|
||||
// bottomLeft: '└',
|
||||
// left: '│'
|
||||
// }
|
||||
```
|
||||
*/
|
||||
declare const cliBoxes: cliBoxes.Boxes & {
|
||||
// TODO: Remove this for the next major release
|
||||
default: typeof cliBoxes;
|
||||
};
|
||||
|
||||
export = cliBoxes;
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(RegExp.prototype, "split", {
|
||||
value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./get');
|
||||
@@ -0,0 +1,26 @@
|
||||
var Marker = {
|
||||
ASTERISK: '*',
|
||||
AT: '@',
|
||||
BACK_SLASH: '\\',
|
||||
CARRIAGE_RETURN: '\r',
|
||||
CLOSE_CURLY_BRACKET: '}',
|
||||
CLOSE_ROUND_BRACKET: ')',
|
||||
CLOSE_SQUARE_BRACKET: ']',
|
||||
COLON: ':',
|
||||
COMMA: ',',
|
||||
DOUBLE_QUOTE: '"',
|
||||
EXCLAMATION: '!',
|
||||
FORWARD_SLASH: '/',
|
||||
INTERNAL: '-clean-css-',
|
||||
NEW_LINE_NIX: '\n',
|
||||
OPEN_CURLY_BRACKET: '{',
|
||||
OPEN_ROUND_BRACKET: '(',
|
||||
OPEN_SQUARE_BRACKET: '[',
|
||||
SEMICOLON: ';',
|
||||
SINGLE_QUOTE: '\'',
|
||||
SPACE: ' ',
|
||||
TAB: '\t',
|
||||
UNDERSCORE: '_'
|
||||
};
|
||||
|
||||
module.exports = Marker;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Observable } from '../../Observable';
|
||||
import { performanceTimestampProvider } from '../../scheduler/performanceTimestampProvider';
|
||||
import { animationFrameProvider } from '../../scheduler/animationFrameProvider';
|
||||
export function animationFrames(timestampProvider) {
|
||||
return timestampProvider ? animationFramesFactory(timestampProvider) : DEFAULT_ANIMATION_FRAMES;
|
||||
}
|
||||
function animationFramesFactory(timestampProvider) {
|
||||
return new Observable((subscriber) => {
|
||||
const provider = timestampProvider || performanceTimestampProvider;
|
||||
const start = provider.now();
|
||||
let id = 0;
|
||||
const run = () => {
|
||||
if (!subscriber.closed) {
|
||||
id = animationFrameProvider.requestAnimationFrame((timestamp) => {
|
||||
id = 0;
|
||||
const now = provider.now();
|
||||
subscriber.next({
|
||||
timestamp: timestampProvider ? now : timestamp,
|
||||
elapsed: now - start,
|
||||
});
|
||||
run();
|
||||
});
|
||||
}
|
||||
};
|
||||
run();
|
||||
return () => {
|
||||
if (id) {
|
||||
animationFrameProvider.cancelAnimationFrame(id);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
const DEFAULT_ANIMATION_FRAMES = animationFramesFactory();
|
||||
//# sourceMappingURL=animationFrames.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/internal/scheduler/queue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,eAAO,MAAM,cAAc,gBAAkC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,KAAK,gBAAiB,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Subject.js","sourceRoot":"","sources":["../../../src/internal/Subject.ts"],"names":[],"mappings":"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"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isIterable.js","sourceRoot":"","sources":["../../../../src/internal/util/isIterable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,UAAU,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,eAAe,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
||||
@@ -0,0 +1,40 @@
|
||||
interface WildcardMatchOptions {
|
||||
/** Separator to be used to split patterns and samples into segments */
|
||||
separator?: string | boolean;
|
||||
/** Flags to pass to the RegExp */
|
||||
flags?: string;
|
||||
}
|
||||
interface isMatch {
|
||||
/**
|
||||
* Tests if a sample string matches the pattern(s)
|
||||
*
|
||||
* ```js
|
||||
* isMatch('foo') //=> true
|
||||
* ```
|
||||
*/
|
||||
(sample: string): boolean;
|
||||
/** Compiled regular expression */
|
||||
regexp: RegExp;
|
||||
/** Original pattern or array of patterns that was used to compile the RegExp */
|
||||
pattern: string | string[];
|
||||
/** Options that were used to compile the RegExp */
|
||||
options: WildcardMatchOptions;
|
||||
}
|
||||
declare function isMatch(regexp: RegExp, sample: string): boolean;
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
declare function wildcardMatch(pattern: string | string[], options?: string | boolean | WildcardMatchOptions): isMatch;
|
||||
export = wildcardMatch;
|
||||
@@ -0,0 +1,410 @@
|
||||
# buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
|
||||
#### The buffer module from [node.js](https://nodejs.org/), for the browser.
|
||||
|
||||
[![saucelabs][saucelabs-image]][saucelabs-url]
|
||||
|
||||
[saucelabs-image]: https://saucelabs.com/browser-matrix/buffer.svg
|
||||
[saucelabs-url]: https://saucelabs.com/u/buffer
|
||||
|
||||
With [browserify](http://browserify.org), simply `require('buffer')` or use the `Buffer` global and you will get this module.
|
||||
|
||||
The goal is to provide an API that is 100% identical to
|
||||
[node's Buffer API](https://nodejs.org/api/buffer.html). Read the
|
||||
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
|
||||
instance methods, and class methods that are supported.
|
||||
|
||||
## features
|
||||
|
||||
- Manipulate binary data like a boss, in all browsers!
|
||||
- Super fast. Backed by Typed Arrays (`Uint8Array`/`ArrayBuffer`, not `Object`)
|
||||
- Extremely small bundle size (**6.75KB minified + gzipped**, 51.9KB with comments)
|
||||
- Excellent browser support (Chrome, Firefox, Edge, Safari 11+, iOS 11+, Android, etc.)
|
||||
- Preserves Node API exactly, with one minor difference (see below)
|
||||
- Square-bracket `buf[4]` notation works!
|
||||
- Does not modify any browser prototypes or put anything on `window`
|
||||
- Comprehensive test suite (including all buffer tests from node.js core)
|
||||
|
||||
## install
|
||||
|
||||
To use this module directly (without browserify), install it:
|
||||
|
||||
```bash
|
||||
npm install buffer
|
||||
```
|
||||
|
||||
This module was previously called **native-buffer-browserify**, but please use **buffer**
|
||||
from now on.
|
||||
|
||||
If you do not use a bundler, you can use the [standalone script](https://bundle.run/buffer).
|
||||
|
||||
## usage
|
||||
|
||||
The module's API is identical to node's `Buffer` API. Read the
|
||||
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
|
||||
instance methods, and class methods that are supported.
|
||||
|
||||
As mentioned above, `require('buffer')` or use the `Buffer` global with
|
||||
[browserify](http://browserify.org) and this module will automatically be included
|
||||
in your bundle. Almost any npm module will work in the browser, even if it assumes that
|
||||
the node `Buffer` API will be available.
|
||||
|
||||
To depend on this module explicitly (without browserify), require it like this:
|
||||
|
||||
```js
|
||||
var Buffer = require('buffer/').Buffer // note: the trailing slash is important!
|
||||
```
|
||||
|
||||
To require this module explicitly, use `require('buffer/')` which tells the node.js module
|
||||
lookup algorithm (also used by browserify) to use the **npm module** named `buffer`
|
||||
instead of the **node.js core** module named `buffer`!
|
||||
|
||||
|
||||
## how does it work?
|
||||
|
||||
The Buffer constructor returns instances of `Uint8Array` that have their prototype
|
||||
changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`,
|
||||
so the returned instances will have all the node `Buffer` methods and the
|
||||
`Uint8Array` methods. Square bracket notation works as expected -- it returns a
|
||||
single octet.
|
||||
|
||||
The `Uint8Array` prototype remains unmodified.
|
||||
|
||||
|
||||
## tracking the latest node api
|
||||
|
||||
This module tracks the Buffer API in the latest (unstable) version of node.js. The Buffer
|
||||
API is considered **stable** in the
|
||||
[node stability index](https://nodejs.org/docs/latest/api/documentation.html#documentation_stability_index),
|
||||
so it is unlikely that there will ever be breaking changes.
|
||||
Nonetheless, when/if the Buffer API changes in node, this module's API will change
|
||||
accordingly.
|
||||
|
||||
## related packages
|
||||
|
||||
- [`buffer-reverse`](https://www.npmjs.com/package/buffer-reverse) - Reverse a buffer
|
||||
- [`buffer-xor`](https://www.npmjs.com/package/buffer-xor) - Bitwise xor a buffer
|
||||
- [`is-buffer`](https://www.npmjs.com/package/is-buffer) - Determine if an object is a Buffer without including the whole `Buffer` package
|
||||
|
||||
## conversion packages
|
||||
|
||||
### convert typed array to buffer
|
||||
|
||||
Use [`typedarray-to-buffer`](https://www.npmjs.com/package/typedarray-to-buffer) to convert any kind of typed array to a `Buffer`. Does not perform a copy, so it's super fast.
|
||||
|
||||
### convert buffer to typed array
|
||||
|
||||
`Buffer` is a subclass of `Uint8Array` (which is a typed array). So there is no need to explicitly convert to typed array. Just use the buffer as a `Uint8Array`.
|
||||
|
||||
### convert blob to buffer
|
||||
|
||||
Use [`blob-to-buffer`](https://www.npmjs.com/package/blob-to-buffer) to convert a `Blob` to a `Buffer`.
|
||||
|
||||
### convert buffer to blob
|
||||
|
||||
To convert a `Buffer` to a `Blob`, use the `Blob` constructor:
|
||||
|
||||
```js
|
||||
var blob = new Blob([ buffer ])
|
||||
```
|
||||
|
||||
Optionally, specify a mimetype:
|
||||
|
||||
```js
|
||||
var blob = new Blob([ buffer ], { type: 'text/html' })
|
||||
```
|
||||
|
||||
### convert arraybuffer to buffer
|
||||
|
||||
To convert an `ArrayBuffer` to a `Buffer`, use the `Buffer.from` function. Does not perform a copy, so it's super fast.
|
||||
|
||||
```js
|
||||
var buffer = Buffer.from(arrayBuffer)
|
||||
```
|
||||
|
||||
### convert buffer to arraybuffer
|
||||
|
||||
To convert a `Buffer` to an `ArrayBuffer`, use the `.buffer` property (which is present on all `Uint8Array` objects):
|
||||
|
||||
```js
|
||||
var arrayBuffer = buffer.buffer.slice(
|
||||
buffer.byteOffset, buffer.byteOffset + buffer.byteLength
|
||||
)
|
||||
```
|
||||
|
||||
Alternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-arraybuffer) module.
|
||||
|
||||
## performance
|
||||
|
||||
See perf tests in `/perf`.
|
||||
|
||||
`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as a
|
||||
sanity check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will
|
||||
always be at least a bit faster). Finally, `NodeBuffer` is the node.js buffer module,
|
||||
which is included to compare against.
|
||||
|
||||
NOTE: Performance has improved since these benchmarks were taken. PR welcome to update the README.
|
||||
|
||||
### Chrome 38
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 11,457,464 ops/sec | ±0.86% | 66 | ✓ |
|
||||
| Uint8Array#bracket-notation | 10,824,332 ops/sec | ±0.74% | 65 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 450,532 ops/sec | ±0.76% | 68 | |
|
||||
| Uint8Array#concat | 1,368,911 ops/sec | ±1.50% | 62 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 903,001 ops/sec | ±0.96% | 67 | |
|
||||
| Uint8Array#copy(16000) | 1,422,441 ops/sec | ±1.04% | 66 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 11,431,358 ops/sec | ±0.46% | 69 | |
|
||||
| Uint8Array#copy(16) | 13,944,163 ops/sec | ±1.12% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 106,329 ops/sec | ±6.70% | 44 | |
|
||||
| Uint8Array#new(16000) | 131,001 ops/sec | ±2.85% | 31 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,554,491 ops/sec | ±1.60% | 65 | |
|
||||
| Uint8Array#new(16) | 6,623,930 ops/sec | ±1.66% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 112,830 ops/sec | ±0.51% | 69 | ✓ |
|
||||
| DataView#getFloat64 | 93,500 ops/sec | ±0.57% | 68 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 146,678 ops/sec | ±0.95% | 68 | ✓ |
|
||||
| DataView#getFloat32 | 99,311 ops/sec | ±0.41% | 67 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 843,214 ops/sec | ±0.70% | 69 | ✓ |
|
||||
| DataView#getUint32 | 103,024 ops/sec | ±0.64% | 67 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 1,013,941 ops/sec | ±0.75% | 67 | |
|
||||
| Uint8Array#subarray | 1,903,928 ops/sec | ±0.53% | 67 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 61,387 ops/sec | ±0.90% | 67 | |
|
||||
| DataView#setFloat32 | 141,249 ops/sec | ±0.40% | 66 | ✓ |
|
||||
|
||||
|
||||
### Firefox 33
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 20,800,421 ops/sec | ±1.84% | 60 | |
|
||||
| Uint8Array#bracket-notation | 20,826,235 ops/sec | ±2.02% | 61 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 153,076 ops/sec | ±2.32% | 61 | |
|
||||
| Uint8Array#concat | 1,255,674 ops/sec | ±8.65% | 52 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,105,312 ops/sec | ±1.16% | 63 | |
|
||||
| Uint8Array#copy(16000) | 1,615,911 ops/sec | ±0.55% | 66 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 16,357,599 ops/sec | ±0.73% | 68 | |
|
||||
| Uint8Array#copy(16) | 31,436,281 ops/sec | ±1.05% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 52,995 ops/sec | ±6.01% | 35 | |
|
||||
| Uint8Array#new(16000) | 87,686 ops/sec | ±5.68% | 45 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 252,031 ops/sec | ±1.61% | 66 | |
|
||||
| Uint8Array#new(16) | 8,477,026 ops/sec | ±0.49% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 99,871 ops/sec | ±0.41% | 69 | |
|
||||
| DataView#getFloat64 | 285,663 ops/sec | ±0.70% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 115,540 ops/sec | ±0.42% | 69 | |
|
||||
| DataView#getFloat32 | 288,722 ops/sec | ±0.82% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 633,926 ops/sec | ±1.08% | 67 | ✓ |
|
||||
| DataView#getUint32 | 294,808 ops/sec | ±0.79% | 64 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 349,425 ops/sec | ±0.46% | 69 | |
|
||||
| Uint8Array#subarray | 5,965,819 ops/sec | ±0.60% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 59,980 ops/sec | ±0.41% | 67 | |
|
||||
| DataView#setFloat32 | 317,634 ops/sec | ±0.63% | 68 | ✓ |
|
||||
|
||||
### Safari 8
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,279,729 ops/sec | ±2.25% | 56 | ✓ |
|
||||
| Uint8Array#bracket-notation | 10,030,767 ops/sec | ±2.23% | 59 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 144,138 ops/sec | ±1.38% | 65 | |
|
||||
| Uint8Array#concat | 4,950,764 ops/sec | ±1.70% | 63 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,058,548 ops/sec | ±1.51% | 64 | |
|
||||
| Uint8Array#copy(16000) | 1,409,666 ops/sec | ±1.17% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 6,282,529 ops/sec | ±1.88% | 58 | |
|
||||
| Uint8Array#copy(16) | 11,907,128 ops/sec | ±2.87% | 58 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 101,663 ops/sec | ±3.89% | 57 | |
|
||||
| Uint8Array#new(16000) | 22,050,818 ops/sec | ±6.51% | 46 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 176,072 ops/sec | ±2.13% | 64 | |
|
||||
| Uint8Array#new(16) | 24,385,731 ops/sec | ±5.01% | 51 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 41,341 ops/sec | ±1.06% | 67 | |
|
||||
| DataView#getFloat64 | 322,280 ops/sec | ±0.84% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 46,141 ops/sec | ±1.06% | 65 | |
|
||||
| DataView#getFloat32 | 337,025 ops/sec | ±0.43% | 69 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 151,551 ops/sec | ±1.02% | 66 | |
|
||||
| DataView#getUint32 | 308,278 ops/sec | ±0.94% | 67 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 197,365 ops/sec | ±0.95% | 66 | |
|
||||
| Uint8Array#subarray | 9,558,024 ops/sec | ±3.08% | 58 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 17,518 ops/sec | ±1.03% | 63 | |
|
||||
| DataView#setFloat32 | 319,751 ops/sec | ±0.48% | 68 | ✓ |
|
||||
|
||||
|
||||
### Node 0.11.14
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,489,828 ops/sec | ±3.25% | 90 | |
|
||||
| Uint8Array#bracket-notation | 10,534,884 ops/sec | ±0.81% | 92 | ✓ |
|
||||
| NodeBuffer#bracket-notation | 10,389,910 ops/sec | ±0.97% | 87 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 487,830 ops/sec | ±2.58% | 88 | |
|
||||
| Uint8Array#concat | 1,814,327 ops/sec | ±1.28% | 88 | ✓ |
|
||||
| NodeBuffer#concat | 1,636,523 ops/sec | ±1.88% | 73 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,073,665 ops/sec | ±0.77% | 90 | |
|
||||
| Uint8Array#copy(16000) | 1,348,517 ops/sec | ±0.84% | 89 | ✓ |
|
||||
| NodeBuffer#copy(16000) | 1,289,533 ops/sec | ±0.82% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 12,782,706 ops/sec | ±0.74% | 85 | |
|
||||
| Uint8Array#copy(16) | 14,180,427 ops/sec | ±0.93% | 92 | ✓ |
|
||||
| NodeBuffer#copy(16) | 11,083,134 ops/sec | ±1.06% | 89 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 141,678 ops/sec | ±3.30% | 67 | |
|
||||
| Uint8Array#new(16000) | 161,491 ops/sec | ±2.96% | 60 | |
|
||||
| NodeBuffer#new(16000) | 292,699 ops/sec | ±3.20% | 55 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,655,466 ops/sec | ±2.41% | 82 | |
|
||||
| Uint8Array#new(16) | 14,399,926 ops/sec | ±0.91% | 94 | ✓ |
|
||||
| NodeBuffer#new(16) | 3,894,696 ops/sec | ±0.88% | 92 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 109,582 ops/sec | ±0.75% | 93 | ✓ |
|
||||
| DataView#getFloat64 | 91,235 ops/sec | ±0.81% | 90 | |
|
||||
| NodeBuffer#readDoubleBE | 88,593 ops/sec | ±0.96% | 81 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 139,854 ops/sec | ±1.03% | 85 | ✓ |
|
||||
| DataView#getFloat32 | 98,744 ops/sec | ±0.80% | 89 | |
|
||||
| NodeBuffer#readFloatBE | 92,769 ops/sec | ±0.94% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 710,861 ops/sec | ±0.82% | 92 | |
|
||||
| DataView#getUint32 | 117,893 ops/sec | ±0.84% | 91 | |
|
||||
| NodeBuffer#readUInt32LE | 851,412 ops/sec | ±0.72% | 93 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 1,673,877 ops/sec | ±0.73% | 94 | |
|
||||
| Uint8Array#subarray | 6,919,243 ops/sec | ±0.67% | 90 | ✓ |
|
||||
| NodeBuffer#slice | 4,617,604 ops/sec | ±0.79% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 66,011 ops/sec | ±0.75% | 93 | |
|
||||
| DataView#setFloat32 | 127,760 ops/sec | ±0.72% | 93 | ✓ |
|
||||
| NodeBuffer#writeFloatBE | 103,352 ops/sec | ±0.83% | 93 | |
|
||||
|
||||
### iojs 1.8.1
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,990,488 ops/sec | ±1.11% | 91 | |
|
||||
| Uint8Array#bracket-notation | 11,268,757 ops/sec | ±0.65% | 97 | |
|
||||
| NodeBuffer#bracket-notation | 11,353,260 ops/sec | ±0.83% | 94 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 378,954 ops/sec | ±0.74% | 94 | |
|
||||
| Uint8Array#concat | 1,358,288 ops/sec | ±0.97% | 87 | |
|
||||
| NodeBuffer#concat | 1,934,050 ops/sec | ±1.11% | 78 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 894,538 ops/sec | ±0.56% | 84 | |
|
||||
| Uint8Array#copy(16000) | 1,442,656 ops/sec | ±0.71% | 96 | |
|
||||
| NodeBuffer#copy(16000) | 1,457,898 ops/sec | ±0.53% | 92 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 12,870,457 ops/sec | ±0.67% | 95 | |
|
||||
| Uint8Array#copy(16) | 16,643,989 ops/sec | ±0.61% | 93 | ✓ |
|
||||
| NodeBuffer#copy(16) | 14,885,848 ops/sec | ±0.74% | 94 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 109,264 ops/sec | ±4.21% | 63 | |
|
||||
| Uint8Array#new(16000) | 138,916 ops/sec | ±1.87% | 61 | |
|
||||
| NodeBuffer#new(16000) | 281,449 ops/sec | ±3.58% | 51 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,362,935 ops/sec | ±0.56% | 99 | |
|
||||
| Uint8Array#new(16) | 6,193,090 ops/sec | ±0.64% | 95 | ✓ |
|
||||
| NodeBuffer#new(16) | 4,745,425 ops/sec | ±1.56% | 90 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 118,127 ops/sec | ±0.59% | 93 | ✓ |
|
||||
| DataView#getFloat64 | 107,332 ops/sec | ±0.65% | 91 | |
|
||||
| NodeBuffer#readDoubleBE | 116,274 ops/sec | ±0.94% | 95 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 150,326 ops/sec | ±0.58% | 95 | ✓ |
|
||||
| DataView#getFloat32 | 110,541 ops/sec | ±0.57% | 98 | |
|
||||
| NodeBuffer#readFloatBE | 121,599 ops/sec | ±0.60% | 87 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 814,147 ops/sec | ±0.62% | 93 | |
|
||||
| DataView#getUint32 | 137,592 ops/sec | ±0.64% | 90 | |
|
||||
| NodeBuffer#readUInt32LE | 931,650 ops/sec | ±0.71% | 96 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 878,590 ops/sec | ±0.68% | 93 | |
|
||||
| Uint8Array#subarray | 2,843,308 ops/sec | ±1.02% | 90 | |
|
||||
| NodeBuffer#slice | 4,998,316 ops/sec | ±0.68% | 90 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 65,927 ops/sec | ±0.74% | 93 | |
|
||||
| DataView#setFloat32 | 139,823 ops/sec | ±0.97% | 89 | ✓ |
|
||||
| NodeBuffer#writeFloatBE | 135,763 ops/sec | ±0.65% | 96 | |
|
||||
| | | | |
|
||||
|
||||
## Testing the project
|
||||
|
||||
First, install the project:
|
||||
|
||||
npm install
|
||||
|
||||
Then, to run tests in Node.js, run:
|
||||
|
||||
npm run test-node
|
||||
|
||||
To test locally in a browser, you can run:
|
||||
|
||||
npm run test-browser-es5-local # For ES5 browsers that don't support ES6
|
||||
npm run test-browser-es6-local # For ES6 compliant browsers
|
||||
|
||||
This will print out a URL that you can then open in a browser to run the tests, using [airtap](https://www.npmjs.com/package/airtap).
|
||||
|
||||
To run automated browser tests using Saucelabs, ensure that your `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables are set, then run:
|
||||
|
||||
npm test
|
||||
|
||||
This is what's run in Travis, to check against various browsers. The list of browsers is kept in the `bin/airtap-es5.yml` and `bin/airtap-es6.yml` files.
|
||||
|
||||
## JavaScript Standard Style
|
||||
|
||||
This module uses [JavaScript Standard Style](https://github.com/feross/standard).
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
To test that the code conforms to the style, `npm install` and run:
|
||||
|
||||
./node_modules/.bin/standard
|
||||
|
||||
## credit
|
||||
|
||||
This was originally forked from [buffer-browserify](https://github.com/toots/buffer-browserify).
|
||||
|
||||
## Security Policies and Procedures
|
||||
|
||||
The `buffer` team and community take all security bugs in `buffer` seriously. Please see our [security policies and procedures](https://github.com/feross/security) document to learn how to report issues.
|
||||
|
||||
## license
|
||||
|
||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org), and other contributors. Originally forked from an MIT-licensed module by Romain Beauxis.
|
||||
@@ -0,0 +1,16 @@
|
||||
import { SubscriptionLog } from './SubscriptionLog';
|
||||
export class SubscriptionLoggable {
|
||||
constructor() {
|
||||
this.subscriptions = [];
|
||||
}
|
||||
logSubscribedFrame() {
|
||||
this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
|
||||
return this.subscriptions.length - 1;
|
||||
}
|
||||
logUnsubscribedFrame(index) {
|
||||
const subscriptionLogs = this.subscriptions;
|
||||
const oldSubscriptionLog = subscriptionLogs[index];
|
||||
subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SubscriptionLoggable.js.map
|
||||
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
var inspect = require("util").inspect;
|
||||
|
||||
|
||||
|
||||
function log(data)
|
||||
{
|
||||
console.log( inspect(data, {depth:null, colors:true}) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
function logAll(data)
|
||||
{
|
||||
console.log( inspect(data, {depth:null, showHidden:true, colors:true}) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports =
|
||||
{
|
||||
log: log,
|
||||
logAll: logAll
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")()
|
||||
? require("ext/global-this").Symbol
|
||||
: require("./polyfill");
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
stdout: false,
|
||||
stderr: false
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Error subclass to use when the source does not exist at the specified endpoint.
|
||||
*
|
||||
* @param {String} message optional "message" property to set
|
||||
* @api protected
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class NotFoundError extends Error {
|
||||
constructor(message) {
|
||||
super(message || 'File does not exist at the specified endpoint');
|
||||
this.code = 'ENOTFOUND';
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
}
|
||||
}
|
||||
exports.default = NotFoundError;
|
||||
//# sourceMappingURL=notfound.js.map
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@my-scope/package-a",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@my-scope/package-b": "^0.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{D:{"1":"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":"I v J D E F A B C K L G","33":"0 1 2 3 4 5 6 7 8 9 M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB"},L:{"1":"H"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"1":"QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB I v J D E F EC FC","33":"0 1 2 3 4 5 6 7 8 9 A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB"},M:{"1":"H"},A:{"2":"J D E F A B CC"},F:{"1":"BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C PC QC RC SC qB AC TC rB","33":"0 1 2 3 4 5 6 7 8 9 G M N O w g x y z AB"},K:{"1":"h","2":"A B C qB AC rB"},E:{"1":"B C K L G qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"I v HC zB IC OC","33":"J D E F A JC KC LC 0B"},G:{"1":"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","33":"E WC XC YC ZC aC bC cC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"}},B:6,C:"isolate from unicode-bidi"};
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var ensureStringifiable = require("../../object/validate-stringifiable-value");
|
||||
|
||||
module.exports = function () {
|
||||
var str = ensureStringifiable(this);
|
||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
||||
|
||||
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var SameValue = require('./SameValue');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-createmethodproperty
|
||||
|
||||
module.exports = function CreateMethodProperty(O, P, V) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
var newDesc = {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
};
|
||||
return DefineOwnProperty(
|
||||
IsDataDescriptor,
|
||||
SameValue,
|
||||
FromPropertyDescriptor,
|
||||
O,
|
||||
P,
|
||||
newDesc
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
(function(a){var c={},d=a.prototype.stopCallback;a.prototype.stopCallback=function(e,b,a,f){return this.paused?!0:c[a]||c[f]?!1:d.call(this,e,b,a)};a.prototype.bindGlobal=function(a,b,d){this.bind(a,b,d);if(a instanceof Array)for(b=0;b<a.length;b++)c[a[b]]=!0;else c[a]=!0};a.init()})(Mousetrap);
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"J D E F A B","2":"CC"},B:{"2":"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:{"2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB 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 PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C h qB AC rB"},L:{"2":"H"},M:{"2":"H"},N:{"2":"A B"},O:{"2":"vC"},P:{"2":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"2":"1B"},R:{"2":"9C"},S:{"2":"AD BD"}},B:7,C:"EOT - Embedded OpenType fonts"};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { concatAll } from '../operators/concatAll';
|
||||
import { popScheduler } from '../util/args';
|
||||
import { from } from './from';
|
||||
export function concat() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return concatAll()(from(args, popScheduler(args)));
|
||||
}
|
||||
//# sourceMappingURL=concat.js.map
|
||||
@@ -0,0 +1,95 @@
|
||||
import { OperatorFunction } from '../types';
|
||||
import { operate } from '../util/lift';
|
||||
import { scanInternals } from './scanInternals';
|
||||
|
||||
export function scan<V, A = V>(accumulator: (acc: A | V, value: V, index: number) => A): OperatorFunction<V, V | A>;
|
||||
export function scan<V, A>(accumulator: (acc: A, value: V, index: number) => A, seed: A): OperatorFunction<V, A>;
|
||||
export function scan<V, A, S>(accumulator: (acc: A | S, value: V, index: number) => A, seed: S): OperatorFunction<V, A>;
|
||||
|
||||
// TODO: link to a "redux pattern" section in the guide (location TBD)
|
||||
|
||||
/**
|
||||
* Useful for encapsulating and managing state. Applies an accumulator (or "reducer function")
|
||||
* to each value from the source after an initial state is established -- either via
|
||||
* a `seed` value (second argument), or from the first value from the source.
|
||||
*
|
||||
* <span class="informal">It's like {@link reduce}, but emits the current
|
||||
* accumulation state after each update</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* This operator maintains an internal state and emits it after processing each value as follows:
|
||||
*
|
||||
* 1. First value arrives
|
||||
* - If a `seed` value was supplied (as the second argument to `scan`), let `state = seed` and `value = firstValue`.
|
||||
* - If NO `seed` value was supplied (no second argument), let `state = firstValue` and go to 3.
|
||||
* 2. Let `state = accumulator(state, value)`.
|
||||
* - If an error is thrown by `accumulator`, notify the consumer of an error. The process ends.
|
||||
* 3. Emit `state`.
|
||||
* 4. Next value arrives, let `value = nextValue`, go to 2.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* An average of previous numbers. This example shows how
|
||||
* not providing a `seed` can prime the stream with the
|
||||
* first value from the source.
|
||||
*
|
||||
* ```ts
|
||||
* import { of, scan, map } from 'rxjs';
|
||||
*
|
||||
* const numbers$ = of(1, 2, 3);
|
||||
*
|
||||
* numbers$
|
||||
* .pipe(
|
||||
* // Get the sum of the numbers coming in.
|
||||
* scan((total, n) => total + n),
|
||||
* // Get the average by dividing the sum by the total number
|
||||
* // received so far (which is 1 more than the zero-based index).
|
||||
* map((sum, index) => sum / (index + 1))
|
||||
* )
|
||||
* .subscribe(console.log);
|
||||
* ```
|
||||
*
|
||||
* The Fibonacci sequence. This example shows how you can use
|
||||
* a seed to prime accumulation process. Also... you know... Fibonacci.
|
||||
* So important to like, computers and stuff that its whiteboarded
|
||||
* in job interviews. Now you can show them the Rx version! (Please don't, haha)
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, scan, map, startWith } from 'rxjs';
|
||||
*
|
||||
* const firstTwoFibs = [0, 1];
|
||||
* // An endless stream of Fibonacci numbers.
|
||||
* const fibonacci$ = interval(1000).pipe(
|
||||
* // Scan to get the fibonacci numbers (after 0, 1)
|
||||
* scan(([a, b]) => [b, a + b], firstTwoFibs),
|
||||
* // Get the second number in the tuple, it's the one you calculated
|
||||
* map(([, n]) => n),
|
||||
* // Start with our first two digits :)
|
||||
* startWith(...firstTwoFibs)
|
||||
* );
|
||||
*
|
||||
* fibonacci$.subscribe(console.log);
|
||||
* ```
|
||||
*
|
||||
* @see {@link expand}
|
||||
* @see {@link mergeScan}
|
||||
* @see {@link reduce}
|
||||
* @see {@link switchScan}
|
||||
*
|
||||
* @param accumulator A "reducer function". This will be called for each value after an initial state is
|
||||
* acquired.
|
||||
* @param seed The initial state. If this is not provided, the first value from the source will
|
||||
* be used as the initial state, and emitted without going through the accumulator. All subsequent values
|
||||
* will be processed by the accumulator function. If this is provided, all values will go through
|
||||
* the accumulator function.
|
||||
* @return A function that returns an Observable of the accumulated values.
|
||||
*/
|
||||
export function scan<V, A, S>(accumulator: (acc: V | A | S, value: V, index: number) => A, seed?: S): OperatorFunction<V, V | A> {
|
||||
// providing a seed of `undefined` *should* be valid and trigger
|
||||
// hasSeed! so don't use `seed !== undefined` checks!
|
||||
// For this reason, we have to check it here at the original call site
|
||||
// otherwise inside Operator/Subscriber we won't know if `undefined`
|
||||
// means they didn't provide anything or if they literally provided `undefined`
|
||||
return operate(scanInternals(accumulator, seed as S, arguments.length >= 2, true));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: standard
|
||||
versions:
|
||||
- 16.0.3
|
||||
@@ -0,0 +1,5 @@
|
||||
export type CreateFixedDonation = {
|
||||
amount: number;
|
||||
donor: number;
|
||||
paidAmount?: number;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
let { readFileSync } = require('fs')
|
||||
let { join } = require('path')
|
||||
|
||||
require('./check-npm-version')
|
||||
let updateDb = require('./')
|
||||
|
||||
const ROOT = __dirname
|
||||
|
||||
function getPackage() {
|
||||
return JSON.parse(readFileSync(join(ROOT, 'package.json')))
|
||||
}
|
||||
|
||||
let args = process.argv.slice(2)
|
||||
|
||||
let USAGE = 'Usage:\n npx update-browserslist-db\n'
|
||||
|
||||
function isArg(arg) {
|
||||
return args.some(i => i === arg)
|
||||
}
|
||||
|
||||
function error(msg) {
|
||||
process.stderr.write('update-browserslist-db: ' + msg + '\n')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (isArg('--help') || isArg('-h')) {
|
||||
process.stdout.write(getPackage().description + '.\n\n' + USAGE + '\n')
|
||||
} else if (isArg('--version') || isArg('-v')) {
|
||||
process.stdout.write('browserslist-lint ' + getPackage().version + '\n')
|
||||
} else {
|
||||
try {
|
||||
updateDb()
|
||||
} catch (e) {
|
||||
if (e.name === 'BrowserslistUpdateError') {
|
||||
error(e.message)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user