First adaptation pass
This commit is contained in:
+856
-24
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -8,7 +8,7 @@ npm install bare-events
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
```js
|
||||
const EventEmitter = require('bare-events')
|
||||
|
||||
const e = new EventEmitter()
|
||||
|
||||
+95
-72
@@ -1,24 +1,24 @@
|
||||
const errors = require('./lib/errors')
|
||||
|
||||
class EventListener {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.list = []
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
append (ctx, name, fn, once) {
|
||||
append(ctx, name, fn, once) {
|
||||
this.count++
|
||||
ctx.emit('newListener', name, fn) // Emit BEFORE adding
|
||||
this.list.push([fn, once])
|
||||
}
|
||||
|
||||
prepend (ctx, name, fn, once) {
|
||||
prepend(ctx, name, fn, once) {
|
||||
this.count++
|
||||
ctx.emit('newListener', name, fn) // Emit BEFORE adding
|
||||
this.list.unshift([fn, once])
|
||||
}
|
||||
|
||||
remove (ctx, name, fn) {
|
||||
remove(ctx, name, fn) {
|
||||
for (let i = 0, n = this.list.length; i < n; i++) {
|
||||
const l = this.list[i]
|
||||
|
||||
@@ -35,7 +35,7 @@ class EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
removeAll (ctx, name) {
|
||||
removeAll(ctx, name) {
|
||||
const list = [...this.list]
|
||||
this.list = []
|
||||
|
||||
@@ -48,7 +48,7 @@ class EventListener {
|
||||
this.count -= list.length
|
||||
}
|
||||
|
||||
emit (ctx, name, ...args) {
|
||||
emit(ctx, name, ...args) {
|
||||
const list = [...this.list]
|
||||
|
||||
for (let i = 0, n = list.length; i < n; i++) {
|
||||
@@ -56,32 +56,35 @@ class EventListener {
|
||||
|
||||
if (l[1] === true) this.remove(ctx, name, l[0])
|
||||
|
||||
l[0].call(ctx, ...args)
|
||||
Reflect.apply(l[0], ctx, args)
|
||||
}
|
||||
|
||||
return list.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
function appendListener (ctx, name, fn, once) {
|
||||
function appendListener(ctx, name, fn, once) {
|
||||
if (ctx._events === undefined) ctx._events = Object.create(null)
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener())
|
||||
e.append(ctx, name, fn, once)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function prependListener (ctx, name, fn, once) {
|
||||
function prependListener(ctx, name, fn, once) {
|
||||
if (ctx._events === undefined) ctx._events = Object.create(null)
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener())
|
||||
e.prepend(ctx, name, fn, once)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function removeListener (ctx, name, fn) {
|
||||
function removeListener(ctx, name, fn) {
|
||||
if (ctx._events === undefined) return ctx
|
||||
const e = ctx._events[name]
|
||||
if (e !== undefined) e.remove(ctx, name, fn)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function throwUnhandledError (...args) {
|
||||
function throwUnhandledError(...args) {
|
||||
let err
|
||||
|
||||
if (args.length > 0) err = args[0]
|
||||
@@ -92,69 +95,77 @@ function throwUnhandledError (...args) {
|
||||
Error.captureStackTrace(err, exports.prototype.emit)
|
||||
}
|
||||
|
||||
queueMicrotask(() => { throw err })
|
||||
queueMicrotask(() => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = exports = class EventEmitter {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this._events = Object.create(null)
|
||||
}
|
||||
|
||||
addListener (name, fn) {
|
||||
addListener(name, fn) {
|
||||
return appendListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
addOnceListener (name, fn) {
|
||||
addOnceListener(name, fn) {
|
||||
return appendListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
prependListener (name, fn) {
|
||||
prependListener(name, fn) {
|
||||
return prependListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
prependOnceListener (name, fn) {
|
||||
prependOnceListener(name, fn) {
|
||||
return prependListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
removeListener (name, fn) {
|
||||
removeListener(name, fn) {
|
||||
return removeListener(this, name, fn)
|
||||
}
|
||||
|
||||
on (name, fn) {
|
||||
on(name, fn) {
|
||||
return appendListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
once (name, fn) {
|
||||
once(name, fn) {
|
||||
return appendListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
off (name, fn) {
|
||||
off(name, fn) {
|
||||
return removeListener(this, name, fn)
|
||||
}
|
||||
|
||||
emit (name, ...args) {
|
||||
if (name === 'error' && this._events.error === undefined) throwUnhandledError(...args)
|
||||
emit(name, ...args) {
|
||||
if (name === 'error' && this._events !== undefined && this._events.error === undefined) {
|
||||
throwUnhandledError(...args)
|
||||
}
|
||||
|
||||
if (this._events === undefined) return false
|
||||
const e = this._events[name]
|
||||
return e === undefined ? false : e.emit(this, name, ...args)
|
||||
}
|
||||
|
||||
listeners (name) {
|
||||
listeners(name) {
|
||||
if (this._events === undefined) return []
|
||||
const e = this._events[name]
|
||||
return e === undefined ? [] : [...e.list]
|
||||
}
|
||||
|
||||
listenerCount (name) {
|
||||
listenerCount(name) {
|
||||
if (this._events === undefined) return 0
|
||||
const e = this._events[name]
|
||||
return e === undefined ? 0 : e.list.length
|
||||
}
|
||||
|
||||
getMaxListeners () {
|
||||
getMaxListeners() {
|
||||
return EventEmitter.defaultMaxListeners
|
||||
}
|
||||
|
||||
setMaxListeners (n) {}
|
||||
setMaxListeners(n) {}
|
||||
|
||||
removeAllListeners (name) {
|
||||
removeAllListeners(name) {
|
||||
if (arguments.length === 0) {
|
||||
for (const key of Reflect.ownKeys(this._events)) {
|
||||
if (key === 'removeListener') continue
|
||||
@@ -175,10 +186,8 @@ exports.errors = errors
|
||||
|
||||
exports.defaultMaxListeners = 10
|
||||
|
||||
exports.on = function on (emitter, name, opts = {}) {
|
||||
const {
|
||||
signal
|
||||
} = opts
|
||||
exports.on = function on(emitter, name, opts = {}) {
|
||||
const { signal } = opts
|
||||
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason)
|
||||
@@ -197,7 +206,7 @@ exports.on = function on (emitter, name, opts = {}) {
|
||||
if (signal) signal.addEventListener('abort', onabort)
|
||||
|
||||
return {
|
||||
next () {
|
||||
next() {
|
||||
if (events.length) {
|
||||
return Promise.resolve({ value: events.shift(), done: false })
|
||||
}
|
||||
@@ -212,25 +221,23 @@ exports.on = function on (emitter, name, opts = {}) {
|
||||
|
||||
if (done) return onclose()
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
promises.push({ resolve, reject })
|
||||
)
|
||||
return new Promise((resolve, reject) => promises.push({ resolve, reject }))
|
||||
},
|
||||
|
||||
return () {
|
||||
return() {
|
||||
return onclose()
|
||||
},
|
||||
|
||||
throw (err) {
|
||||
throw(err) {
|
||||
return onerror(err)
|
||||
},
|
||||
|
||||
[Symbol.asyncIterator] () {
|
||||
[Symbol.asyncIterator]() {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
function onevent (...args) {
|
||||
function onevent(...args) {
|
||||
if (promises.length) {
|
||||
promises.shift().resolve({ value: args, done: false })
|
||||
} else {
|
||||
@@ -238,7 +245,7 @@ exports.on = function on (emitter, name, opts = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
function onerror (err) {
|
||||
function onerror(err) {
|
||||
if (promises.length) {
|
||||
promises.shift().reject(err)
|
||||
} else {
|
||||
@@ -248,11 +255,11 @@ exports.on = function on (emitter, name, opts = {}) {
|
||||
return Promise.resolve({ done: true })
|
||||
}
|
||||
|
||||
function onabort () {
|
||||
function onabort() {
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason))
|
||||
}
|
||||
|
||||
function onclose () {
|
||||
function onclose() {
|
||||
emitter.off(name, onevent)
|
||||
|
||||
if (name !== 'error') emitter.off('error', onerror)
|
||||
@@ -267,10 +274,8 @@ exports.on = function on (emitter, name, opts = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
exports.once = function once (emitter, name, opts = {}) {
|
||||
const {
|
||||
signal
|
||||
} = opts
|
||||
exports.once = function once(emitter, name, opts = {}) {
|
||||
const { signal } = opts
|
||||
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason)
|
||||
@@ -289,13 +294,13 @@ exports.once = function once (emitter, name, opts = {}) {
|
||||
resolve(args)
|
||||
})
|
||||
|
||||
function onerror (err) {
|
||||
function onerror(err) {
|
||||
emitter.off('error', onerror)
|
||||
|
||||
reject(err)
|
||||
}
|
||||
|
||||
function onabort () {
|
||||
function onabort() {
|
||||
signal.removeEventListener('abort', onabort)
|
||||
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason))
|
||||
@@ -303,34 +308,52 @@ exports.once = function once (emitter, name, opts = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
exports.forward = function forward (from, to, names, opts = {}) {
|
||||
exports.forward = function forward(from, to, names, opts = {}) {
|
||||
if (typeof names === 'string') names = [names]
|
||||
|
||||
const {
|
||||
emit = to.emit.bind(to)
|
||||
} = opts
|
||||
const { emit = to.emit.bind(to) } = opts
|
||||
|
||||
const listeners = names.map((name) => function onevent (...args) {
|
||||
emit(name, ...args)
|
||||
const listeners = names.map(
|
||||
(name) =>
|
||||
function onevent(...args) {
|
||||
emit(name, ...args)
|
||||
}
|
||||
)
|
||||
|
||||
to.on('newListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i])
|
||||
}
|
||||
}).on('removeListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i])
|
||||
}
|
||||
})
|
||||
|
||||
to
|
||||
.on('newListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i])
|
||||
}
|
||||
})
|
||||
.on('removeListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.listenerCount = function listenerCount (emitter, name) {
|
||||
exports.listenerCount = function listenerCount(emitter, name) {
|
||||
return emitter.listenerCount(name)
|
||||
}
|
||||
|
||||
exports.getMaxListeners = function getMaxListeners(emitter) {
|
||||
if (typeof emitter.getMaxListeners === 'function') {
|
||||
return emitter.getMaxListeners()
|
||||
}
|
||||
|
||||
return exports.defaultMaxListeners
|
||||
}
|
||||
|
||||
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
|
||||
if (emitters.length === 0) exports.defaultMaxListeners = n
|
||||
else {
|
||||
for (const emitter of emitters) {
|
||||
if (typeof emitter.setMaxListeners === 'function') {
|
||||
emitter.setMaxListeners(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -1,5 +1,5 @@
|
||||
module.exports = class EventEmitterError extends Error {
|
||||
constructor (msg, code, fn = EventEmitterError, opts) {
|
||||
constructor(msg, code, fn = EventEmitterError, opts) {
|
||||
super(`${code}: ${msg}`, opts)
|
||||
this.code = code
|
||||
|
||||
@@ -8,15 +8,19 @@ module.exports = class EventEmitterError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
get name () {
|
||||
get name() {
|
||||
return 'EventEmitterError'
|
||||
}
|
||||
|
||||
static OPERATION_ABORTED (cause, msg = 'Operation aborted') {
|
||||
return new EventEmitterError(msg, 'OPERATION_ABORTED', EventEmitterError.OPERATION_ABORTED, { cause })
|
||||
static OPERATION_ABORTED(cause, msg = 'Operation aborted') {
|
||||
return new EventEmitterError(msg, 'OPERATION_ABORTED', EventEmitterError.OPERATION_ABORTED, {
|
||||
cause
|
||||
})
|
||||
}
|
||||
|
||||
static UNHANDLED_ERROR (cause, msg = 'Unhandled error') {
|
||||
return new EventEmitterError(msg, 'UNHANDLED_ERROR', EventEmitterError.UNHANDLED_ERROR, { cause })
|
||||
static UNHANDLED_ERROR(cause, msg = 'Unhandled error') {
|
||||
return new EventEmitterError(msg, 'UNHANDLED_ERROR', EventEmitterError.UNHANDLED_ERROR, {
|
||||
cause
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+31
-4
@@ -1,21 +1,37 @@
|
||||
{
|
||||
"name": "bare-events",
|
||||
"version": "2.5.0",
|
||||
"version": "2.8.1",
|
||||
"description": "Event emitters for JavaScript",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package": "./package.json",
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./global": {
|
||||
"types": "./global.d.ts",
|
||||
"default": "./global.js"
|
||||
},
|
||||
"./web": {
|
||||
"types": "./web.d.ts",
|
||||
"default": "./web.js"
|
||||
},
|
||||
"./errors": "./lib/errors.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"global.js",
|
||||
"global.d.ts",
|
||||
"web.js",
|
||||
"web.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run test:bare && npm run test:node",
|
||||
"test:bare": "bare test.js",
|
||||
"test:node": "node test.js",
|
||||
"lint": "standard"
|
||||
"lint": "prettier . --check"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -28,7 +44,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/bare-events#readme",
|
||||
"devDependencies": {
|
||||
"bare-abort-controller": "^1.0.0",
|
||||
"brittle": "^3.3.2",
|
||||
"standard": "^17.0.0"
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-config-holepunch": "^2.0.0",
|
||||
"uncaughts": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-abort-controller": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-abort-controller": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"version": "4.3.7",
|
||||
"version": "4.4.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/debug-js/debug.git"
|
||||
@@ -26,7 +26,7 @@
|
||||
"scripts": {
|
||||
"lint": "xo",
|
||||
"test": "npm run test:node && npm run test:browser && npm run lint",
|
||||
"test:node": "istanbul cover _mocha -- test.js test.node.js",
|
||||
"test:node": "mocha test.js test.node.js",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls"
|
||||
},
|
||||
@@ -37,7 +37,6 @@
|
||||
"brfs": "^2.0.1",
|
||||
"browserify": "^16.2.3",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.1.4",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
@@ -56,5 +55,10 @@
|
||||
"browser": "./src/browser.js",
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"import/extensions": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -129,6 +129,7 @@ function useColors() {
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
// eslint-disable-next-line no-return-assign
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
@@ -218,7 +219,7 @@ function save(namespaces) {
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
|
||||
+58
-40
@@ -166,26 +166,64 @@ function setup(env) {
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '')
|
||||
.trim()
|
||||
.replace(/\s+/g, ',')
|
||||
.split(',')
|
||||
.filter(Boolean);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
||||
for (const ns of split) {
|
||||
if (ns[0] === '-') {
|
||||
createDebug.skips.push(ns.slice(1));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
createDebug.names.push(ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string matches a namespace template, honoring
|
||||
* asterisks as wildcards.
|
||||
*
|
||||
* @param {String} search
|
||||
* @param {String} template
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function matchesTemplate(search, template) {
|
||||
let searchIndex = 0;
|
||||
let templateIndex = 0;
|
||||
let starIndex = -1;
|
||||
let matchIndex = 0;
|
||||
|
||||
while (searchIndex < search.length) {
|
||||
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
||||
// Match character or proceed with wildcard
|
||||
if (template[templateIndex] === '*') {
|
||||
starIndex = templateIndex;
|
||||
matchIndex = searchIndex;
|
||||
templateIndex++; // Skip the '*'
|
||||
} else {
|
||||
searchIndex++;
|
||||
templateIndex++;
|
||||
}
|
||||
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
||||
// Backtrack to the last '*' and try to match more characters
|
||||
templateIndex = starIndex + 1;
|
||||
matchIndex++;
|
||||
searchIndex = matchIndex;
|
||||
} else {
|
||||
return false; // No match
|
||||
}
|
||||
}
|
||||
|
||||
// Handle trailing '*' in template
|
||||
while (templateIndex < template.length && template[templateIndex] === '*') {
|
||||
templateIndex++;
|
||||
}
|
||||
|
||||
return templateIndex === template.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
@@ -194,8 +232,8 @@ function setup(env) {
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
...createDebug.names,
|
||||
...createDebug.skips.map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
@@ -209,21 +247,14 @@ function setup(env) {
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
for (const skip of createDebug.skips) {
|
||||
if (matchesTemplate(name, skip)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
for (const ns of createDebug.names) {
|
||||
if (matchesTemplate(name, ns)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -231,19 +262,6 @@ function setup(env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
name: Build Status
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x]
|
||||
os: [ubuntu-16.04, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 Mathias Buus
|
||||
|
||||
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.
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
# queue-tick
|
||||
|
||||
Next tick shim that prefers process.nextTick over queueMicrotask for compat
|
||||
|
||||
```
|
||||
npm install queue-tick
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
const queueTick = require('queue-tick')
|
||||
|
||||
// in Node it uses process.nextTick, in browsers it uses queueMicrotask
|
||||
queueTick(() => console.log('laters'))
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "queue-tick",
|
||||
"version": "1.0.1",
|
||||
"description": "Next tick shim that prefers process.nextTick over queueMicrotask for compat",
|
||||
"main": "./process-next-tick.js",
|
||||
"browser": "./queue-microtask.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^16.0.3",
|
||||
"tape": "^5.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/queue-tick.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/queue-tick/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/queue-tick"
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
module.exports = (typeof process !== 'undefined' && typeof process.nextTick === 'function')
|
||||
? process.nextTick.bind(process)
|
||||
: require('./queue-microtask')
|
||||
-1
@@ -1 +0,0 @@
|
||||
module.exports = typeof queueMicrotask === 'function' ? queueMicrotask : (fn) => Promise.resolve().then(fn)
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
const tape = require('tape')
|
||||
const queueTick = require('./')
|
||||
const js = require('./queue-microtask')
|
||||
|
||||
tape('basic', function (t) {
|
||||
t.plan(2)
|
||||
|
||||
queueTick(() => t.pass('tick'))
|
||||
js(() => t.pass('tock'))
|
||||
})
|
||||
+14
-4
@@ -100,7 +100,7 @@ Options:
|
||||
-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'.
|
||||
prepatch, prerelease, or release. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
@@ -141,6 +141,8 @@ A "version" is described by the `v2.0.0` specification found at
|
||||
<https://semver.org/>.
|
||||
|
||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
||||
Support for stripping a leading "v" is kept for compatibility with `v1.0.0` of the SemVer
|
||||
specification but should not be used anymore.
|
||||
|
||||
## Ranges
|
||||
|
||||
@@ -237,6 +239,13 @@ $ semver 1.2.4-beta.0 -i prerelease
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
To get out of the prerelease phase, use the `release` option:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.4-beta.1 -i release
|
||||
1.2.4
|
||||
```
|
||||
|
||||
#### Prerelease Identifier Base
|
||||
|
||||
The method `.inc` takes an optional parameter 'identifierBase' string
|
||||
@@ -415,10 +424,10 @@ Strict-mode Comparators and Ranges will be strict about the SemVer
|
||||
strings that they parse.
|
||||
|
||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
||||
* `inc(v, release, options, identifier, identifierBase)`:
|
||||
* `inc(v, releaseType, options, identifier, identifierBase)`:
|
||||
Return the version incremented by the release
|
||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
||||
`prepatch`, or `prerelease`), or null if it's not valid
|
||||
`prepatch`, `prerelease`, or `release`), or null if it's not valid
|
||||
* `premajor` in one call will bump the version up to the next major
|
||||
version and down to a prerelease of that major version.
|
||||
`preminor`, and `prepatch` work the same way.
|
||||
@@ -426,6 +435,7 @@ strings that they parse.
|
||||
same as `prepatch`. It increments the patch version and then makes a
|
||||
prerelease. If the input version is already a prerelease it simply
|
||||
increments it.
|
||||
* `release` will remove any prerelease part of the version.
|
||||
* `identifier` can be used to prefix `premajor`, `preminor`,
|
||||
`prepatch`, or `prerelease` version increments. `identifierBase`
|
||||
is the base to be used for the `prerelease` identifier.
|
||||
@@ -477,7 +487,7 @@ strings that they parse.
|
||||
|
||||
### Ranges
|
||||
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid.
|
||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
||||
range.
|
||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
||||
|
||||
+4
-1
@@ -3,6 +3,8 @@
|
||||
// Exits successfully and prints matching version(s) if
|
||||
// any supplied version is valid and passes all tests.
|
||||
|
||||
'use strict'
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
|
||||
let versions = []
|
||||
@@ -61,6 +63,7 @@ const main = () => {
|
||||
switch (argv[0]) {
|
||||
case 'major': case 'minor': case 'patch': case 'prerelease':
|
||||
case 'premajor': case 'preminor': case 'prepatch':
|
||||
case 'release':
|
||||
inc = argv.shift()
|
||||
break
|
||||
default:
|
||||
@@ -149,7 +152,7 @@ Options:
|
||||
-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'.
|
||||
prepatch, prerelease, or release. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const ANY = Symbol('SemVer ANY')
|
||||
// hoisted class for cyclic dependency
|
||||
class Comparator {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
SemVer: require('./semver.js'),
|
||||
Range: require('./range.js'),
|
||||
|
||||
+3
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SPACE_CHARACTERS = /\s+/g
|
||||
|
||||
// hoisted class for cyclic dependency
|
||||
@@ -253,6 +255,7 @@ const isSatisfiable = (comparators, options) => {
|
||||
// already replaced the hyphen ranges
|
||||
// turn into a set of JUST comparators.
|
||||
const parseComparator = (comp, options) => {
|
||||
comp = comp.replace(re[t.BUILD], '')
|
||||
debug('comp', comp, options)
|
||||
comp = replaceCarets(comp, options)
|
||||
debug('caret', comp)
|
||||
|
||||
+41
-10
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const debug = require('../internal/debug')
|
||||
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
@@ -10,7 +12,7 @@ class SemVer {
|
||||
|
||||
if (version instanceof SemVer) {
|
||||
if (version.loose === !!options.loose &&
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
return version
|
||||
} else {
|
||||
version = version.version
|
||||
@@ -109,11 +111,25 @@ class SemVer {
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
return (
|
||||
compareIdentifiers(this.major, other.major) ||
|
||||
compareIdentifiers(this.minor, other.minor) ||
|
||||
compareIdentifiers(this.patch, other.patch)
|
||||
)
|
||||
if (this.major < other.major) {
|
||||
return -1
|
||||
}
|
||||
if (this.major > other.major) {
|
||||
return 1
|
||||
}
|
||||
if (this.minor < other.minor) {
|
||||
return -1
|
||||
}
|
||||
if (this.minor > other.minor) {
|
||||
return 1
|
||||
}
|
||||
if (this.patch < other.patch) {
|
||||
return -1
|
||||
}
|
||||
if (this.patch > other.patch) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
comparePre (other) {
|
||||
@@ -176,6 +192,19 @@ class SemVer {
|
||||
// preminor will bump the version up to the next minor release, and immediately
|
||||
// down to pre-release. premajor and prepatch work the same way.
|
||||
inc (release, identifier, identifierBase) {
|
||||
if (release.startsWith('pre')) {
|
||||
if (!identifier && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier is empty')
|
||||
}
|
||||
// Avoid an invalid semver results
|
||||
if (identifier) {
|
||||
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
|
||||
if (!match || match[1] !== identifier) {
|
||||
throw new Error(`invalid identifier: ${identifier}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (release) {
|
||||
case 'premajor':
|
||||
this.prerelease.length = 0
|
||||
@@ -206,6 +235,12 @@ class SemVer {
|
||||
}
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
case 'release':
|
||||
if (this.prerelease.length === 0) {
|
||||
throw new Error(`version ${this.raw} is not a prerelease`)
|
||||
}
|
||||
this.prerelease.length = 0
|
||||
break
|
||||
|
||||
case 'major':
|
||||
// If this is a pre-major version, bump up to the same major version.
|
||||
@@ -249,10 +284,6 @@ class SemVer {
|
||||
case 'pre': {
|
||||
const base = Number(identifierBase) ? 1 : 0
|
||||
|
||||
if (!identifier && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier is empty')
|
||||
}
|
||||
|
||||
if (this.prerelease.length === 0) {
|
||||
this.prerelease = [base]
|
||||
} else {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse')
|
||||
const clean = (version, options) => {
|
||||
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const eq = require('./eq')
|
||||
const neq = require('./neq')
|
||||
const gt = require('./gt')
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const parse = require('./parse')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const compareBuild = (a, b, loose) => {
|
||||
const versionA = new SemVer(a, loose)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const compareLoose = (a, b) => compare(a, b, true)
|
||||
module.exports = compareLoose
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const compare = (a, b, loose) =>
|
||||
new SemVer(a, loose).compare(new SemVer(b, loose))
|
||||
|
||||
+7
-12
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse.js')
|
||||
|
||||
const diff = (version1, version2) => {
|
||||
@@ -27,20 +29,13 @@ const diff = (version1, version2) => {
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// Otherwise it can be determined by checking the high version
|
||||
|
||||
if (highVersion.patch) {
|
||||
// anything higher than a patch bump would result in the wrong version
|
||||
// If the main part has no difference
|
||||
if (lowVersion.compareMain(highVersion) === 0) {
|
||||
if (lowVersion.minor && !lowVersion.patch) {
|
||||
return 'minor'
|
||||
}
|
||||
return 'patch'
|
||||
}
|
||||
|
||||
if (highVersion.minor) {
|
||||
// anything higher than a minor bump would result in the wrong version
|
||||
return 'minor'
|
||||
}
|
||||
|
||||
// bumping major/minor/patch all have same result
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// add the `pre` prefix if we are going to a prerelease version
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const eq = (a, b, loose) => compare(a, b, loose) === 0
|
||||
module.exports = eq
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const gt = (a, b, loose) => compare(a, b, loose) > 0
|
||||
module.exports = gt
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const gte = (a, b, loose) => compare(a, b, loose) >= 0
|
||||
module.exports = gte
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
|
||||
const inc = (version, release, options, identifier, identifierBase) => {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const lt = (a, b, loose) => compare(a, b, loose) < 0
|
||||
module.exports = lt
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const lte = (a, b, loose) => compare(a, b, loose) <= 0
|
||||
module.exports = lte
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const major = (a, loose) => new SemVer(a, loose).major
|
||||
module.exports = major
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const minor = (a, loose) => new SemVer(a, loose).minor
|
||||
module.exports = minor
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const neq = (a, b, loose) => compare(a, b, loose) !== 0
|
||||
module.exports = neq
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const parse = (version, options, throwErrors = false) => {
|
||||
if (version instanceof SemVer) {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const patch = (a, loose) => new SemVer(a, loose).patch
|
||||
module.exports = patch
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse')
|
||||
const prerelease = (version, options) => {
|
||||
const parsed = parse(version, options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const rcompare = (a, b, loose) => compare(b, a, loose)
|
||||
module.exports = rcompare
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compareBuild = require('./compare-build')
|
||||
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
|
||||
module.exports = rsort
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Range = require('../classes/range')
|
||||
const satisfies = (version, range, options) => {
|
||||
try {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compareBuild = require('./compare-build')
|
||||
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
|
||||
module.exports = sort
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse')
|
||||
const valid = (version, options) => {
|
||||
const v = parse(version, options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
// just pre-load all the stuff that index.js lazily exports
|
||||
const internalRe = require('./internal/re')
|
||||
const constants = require('./internal/constants')
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
// Note: this is the semver.org version of the spec that it implements
|
||||
// Not necessarily the package version of this code.
|
||||
const SEMVER_SPEC_VERSION = '2.0.0'
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const debug = (
|
||||
typeof process === 'object' &&
|
||||
process.env &&
|
||||
|
||||
+6
@@ -1,5 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const numeric = /^[0-9]+$/
|
||||
const compareIdentifiers = (a, b) => {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a === b ? 0 : a < b ? -1 : 1
|
||||
}
|
||||
|
||||
const anum = numeric.test(a)
|
||||
const bnum = numeric.test(b)
|
||||
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
class LRUCache {
|
||||
constructor () {
|
||||
this.max = 1000
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
// parse out just the options we care about
|
||||
const looseOption = Object.freeze({ loose: true })
|
||||
const emptyOpts = Object.freeze({ })
|
||||
|
||||
+10
-4
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const {
|
||||
MAX_SAFE_COMPONENT_LENGTH,
|
||||
MAX_SAFE_BUILD_LENGTH,
|
||||
@@ -10,6 +12,7 @@ exports = module.exports = {}
|
||||
const re = exports.re = []
|
||||
const safeRe = exports.safeRe = []
|
||||
const src = exports.src = []
|
||||
const safeSrc = exports.safeSrc = []
|
||||
const t = exports.t = {}
|
||||
let R = 0
|
||||
|
||||
@@ -42,6 +45,7 @@ const createToken = (name, value, isGlobal) => {
|
||||
debug(name, index, value)
|
||||
t[name] = index
|
||||
src[index] = value
|
||||
safeSrc[index] = safe
|
||||
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
|
||||
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
|
||||
}
|
||||
@@ -74,12 +78,14 @@ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
||||
|
||||
// ## Pre-release Version Identifier
|
||||
// A numeric identifier, or a non-numeric identifier.
|
||||
// Non-numberic identifiers include numberic identifiers but can be longer.
|
||||
// Therefore non-numberic identifiers must go first.
|
||||
|
||||
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
||||
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
||||
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
|
||||
}|${src[t.NUMERICIDENTIFIER]})`)
|
||||
|
||||
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
||||
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
||||
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
|
||||
}|${src[t.NUMERICIDENTIFIERLOOSE]})`)
|
||||
|
||||
// ## Pre-release Version
|
||||
// Hyphen, followed by one or more dot-separated pre-release version
|
||||
|
||||
+8
-7
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"name": "semver",
|
||||
"version": "7.6.3",
|
||||
"version": "7.7.3",
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"snap": "tap",
|
||||
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
||||
"lint": "npm run eslint",
|
||||
"postlint": "template-oss-check",
|
||||
"lintfix": "npm run lint -- --fix",
|
||||
"lintfix": "npm run eslint -- --fix",
|
||||
"posttest": "npm run lint",
|
||||
"template-oss-apply": "template-oss-apply --force"
|
||||
"template-oss-apply": "template-oss-apply --force",
|
||||
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@npmcli/eslint-config": "^4.0.0",
|
||||
"@npmcli/template-oss": "4.22.0",
|
||||
"@npmcli/eslint-config": "^5.0.0",
|
||||
"@npmcli/template-oss": "4.25.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"tap": "^16.0.0"
|
||||
},
|
||||
@@ -51,7 +52,7 @@
|
||||
"author": "GitHub Inc.",
|
||||
"templateOSS": {
|
||||
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
||||
"version": "4.22.0",
|
||||
"version": "4.25.1",
|
||||
"engines": ">=10",
|
||||
"distPaths": [
|
||||
"classes/",
|
||||
|
||||
+2
@@ -1,2 +1,4 @@
|
||||
'use strict'
|
||||
|
||||
// XXX remove in v8 or beyond
|
||||
module.exports = require('./index.js')
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
// Determine if version is greater than all the versions possible in the range.
|
||||
const outside = require('./outside')
|
||||
const gtr = (version, range, options) => outside(version, range, '>', options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Range = require('../classes/range')
|
||||
const intersects = (r1, r2, options) => {
|
||||
r1 = new Range(r1, options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const outside = require('./outside')
|
||||
// Determine if version is less than all the versions possible in the range
|
||||
const ltr = (version, range, options) => outside(version, range, '<', options)
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const Range = require('../classes/range')
|
||||
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const Range = require('../classes/range')
|
||||
const minSatisfying = (versions, range, options) => {
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const Range = require('../classes/range')
|
||||
const gt = require('../functions/gt')
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const Comparator = require('../classes/comparator')
|
||||
const { ANY } = Comparator
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
// given a set of versions and a range, create a "simplified" range
|
||||
// that includes the same versions that the original range does
|
||||
// If the original range is shorter than the simplified one, return that.
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Range = require('../classes/range.js')
|
||||
const Comparator = require('../classes/comparator.js')
|
||||
const { ANY } = Comparator
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Range = require('../classes/range')
|
||||
|
||||
// Mostly just for testing and legacy API reasons
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Range = require('../classes/range')
|
||||
const validRange = (range, options) => {
|
||||
try {
|
||||
|
||||
+20
-6
@@ -1,11 +1,13 @@
|
||||
const { EventEmitter } = require('events')
|
||||
const { EventEmitter } = require('events-universal')
|
||||
const STREAM_DESTROYED = new Error('Stream was destroyed')
|
||||
const PREMATURE_CLOSE = new Error('Premature close')
|
||||
|
||||
const queueTick = require('queue-tick')
|
||||
const FIFO = require('fast-fifo')
|
||||
const TextDecoder = require('text-decoder')
|
||||
|
||||
// if we do a future major, expect queue microtask to be there always, for now a bit defensive
|
||||
const qmt = typeof queueMicrotask === 'undefined' ? fn => global.process.nextTick(fn) : queueMicrotask
|
||||
|
||||
/* eslint-disable no-multi-spaces */
|
||||
|
||||
// 29 bits used total (4 from shared, 14 from read, and 11 from write)
|
||||
@@ -98,6 +100,7 @@ const READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | RE
|
||||
const SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH | READ_READ_AHEAD
|
||||
const READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE
|
||||
const READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY
|
||||
const READ_NEXT_TICK_OR_OPENING = READ_NEXT_TICK | OPENING
|
||||
|
||||
// Combined write state
|
||||
const WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE
|
||||
@@ -232,7 +235,7 @@ class WritableState {
|
||||
updateNextTick () {
|
||||
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return
|
||||
this.stream._duplexState |= WRITE_NEXT_TICK
|
||||
if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
|
||||
if ((this.stream._duplexState & WRITE_UPDATING) === 0) qmt(this.afterUpdateNextTick)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,10 +420,16 @@ class ReadableState {
|
||||
else this.updateNextTick()
|
||||
}
|
||||
|
||||
updateNextTickIfOpen () {
|
||||
if ((this.stream._duplexState & READ_NEXT_TICK_OR_OPENING) !== 0) return
|
||||
this.stream._duplexState |= READ_NEXT_TICK
|
||||
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick)
|
||||
}
|
||||
|
||||
updateNextTick () {
|
||||
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return
|
||||
this.stream._duplexState |= READ_NEXT_TICK
|
||||
if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
|
||||
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,12 +737,12 @@ class Readable extends Stream {
|
||||
}
|
||||
|
||||
push (data) {
|
||||
this._readableState.updateNextTick()
|
||||
this._readableState.updateNextTickIfOpen()
|
||||
return this._readableState.push(data)
|
||||
}
|
||||
|
||||
unshift (data) {
|
||||
this._readableState.updateNextTick()
|
||||
this._readableState.updateNextTickIfOpen()
|
||||
return this._readableState.unshift(data)
|
||||
}
|
||||
|
||||
@@ -1134,6 +1143,10 @@ function isReadStreamx (stream) {
|
||||
return isStreamx(stream) && stream.readable
|
||||
}
|
||||
|
||||
function isDisturbed (stream) {
|
||||
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0
|
||||
}
|
||||
|
||||
function isTypedArray (data) {
|
||||
return typeof data === 'object' && data !== null && typeof data.byteLength === 'number'
|
||||
}
|
||||
@@ -1159,6 +1172,7 @@ module.exports = {
|
||||
isStreamx,
|
||||
isEnded,
|
||||
isFinished,
|
||||
isDisturbed,
|
||||
getStreamError,
|
||||
Stream,
|
||||
Writable,
|
||||
|
||||
+4
-12
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "streamx",
|
||||
"version": "2.20.2",
|
||||
"version": "2.23.0",
|
||||
"description": "An iteration of the Node.js core streams with a series of improvements",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"events-universal": "^1.0.0",
|
||||
"fast-fifo": "^1.3.2",
|
||||
"queue-tick": "^1.0.1",
|
||||
"text-decoder": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -14,20 +14,12 @@
|
||||
"end-of-stream": "^1.4.4",
|
||||
"standard": "^17.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bare-events": "^2.2.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"imports": {
|
||||
"events": {
|
||||
"bare": "bare-events",
|
||||
"default": "events"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && brittle test/*.js"
|
||||
"test": "standard && node test/all.js",
|
||||
"test:bare": "standard && bare test/all.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user