Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

4
node_modules/concordance/README.md generated vendored
View file

@ -1,6 +1,6 @@
# concordance
Compare, format, diff and serialize any JavaScript value. Built for Node.js 6
Compare, format, diff and serialize any JavaScript value. Built for Node.js 10
and above.
## Behavior
@ -14,7 +14,7 @@ means Concordance's behavior is consistent, no matter how you use it.
### Comparison details
* [Object wrappers](https://github.com/getify/You-Dont-Know-JS/blob/master/types%20%26%20grammar/ch3.md#boxing-wrappers)
* [Object wrappers](https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/types%20%26%20grammar/ch3.md#boxing-wrappers)
are compared both as objects and unwrapped values. Thus Concordance always
treats `Object(1)` as different from `1`.
* `-0` is distinct from `0`.

Binary file not shown.

View file

@ -16,7 +16,7 @@ class Registry {
alloc (value) {
const index = ++this.counter
const pointer = {descriptor: null, index}
const pointer = { descriptor: null, index }
this.map.set(value, pointer)
return pointer
}

View file

@ -1,11 +1,11 @@
'use strict'
const Circular = require('./Circular')
const constants = require('./constants')
const describe = require('./describe')
const recursorUtils = require('./recursorUtils')
const shouldCompareDeep = require('./shouldCompareDeep')
const symbolProperties = require('./symbolProperties')
const Circular = require('./Circular')
const AMBIGUOUS = constants.AMBIGUOUS
const DEEP_EQUAL = constants.DEEP_EQUAL

View file

@ -10,7 +10,7 @@ function describe (props) {
return new DescribedArgumentsValue(Object.assign({
// Treat as an array, to allow comparisons with arrays
isArray: true,
isList: true
isList: true,
}, props, { ctor: 'Arguments' }))
}
exports.describe = describe

View file

@ -7,7 +7,7 @@ function describe (props) {
buffer: Buffer.from(props.value),
// Set isArray and isList so the property recursor excludes the byte accessors
isArray: true,
isList: true
isList: true,
}, props))
}
exports.describe = describe

View file

@ -1,7 +1,7 @@
'use strict'
const recursorUtils = require('../recursorUtils')
const stringPrimitive = require('../primitiveValues/string').tag
const recursorUtils = require('../recursorUtils')
const object = require('./object')
function describe (props) {
@ -18,7 +18,7 @@ const tag = Symbol('BoxedValue')
exports.tag = tag
class BoxedValue extends object.ObjectValue {}
Object.defineProperty(BoxedValue.prototype, 'tag', {value: tag})
Object.defineProperty(BoxedValue.prototype, 'tag', { value: tag })
class DescribedBoxedValue extends object.DescribedMixin(BoxedValue) {
constructor (props) {

View file

@ -7,7 +7,7 @@ function describe (props) {
buffer: typedArray.getBuffer(props.value),
// Set isArray and isList so the property recursor excludes the byte accessors
isArray: true,
isList: true
isList: true,
}, props))
}
exports.describe = describe

View file

@ -13,7 +13,7 @@ const UNEQUAL = constants.UNEQUAL
function describe (props) {
const date = props.value
const invalid = isNaN(date.valueOf())
return new DescribedDateValue(Object.assign({}, props, {invalid}))
return new DescribedDateValue(Object.assign({}, props, { invalid }))
}
exports.describe = describe
@ -32,7 +32,7 @@ function formatDate (date) {
date,
local: false,
showTimeZone: true,
showMilliseconds: true
showMilliseconds: true,
})
}
@ -61,13 +61,13 @@ class DateValue extends object.ObjectValue {
return innerLines.isEmpty
? lineBuilder.single(string + theme.object.closeBracket)
: lineBuilder.first(string)
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
},
maxDepth () {
return lineBuilder.single(string + ' ' + theme.maxDepth + ' ' + theme.object.closeBracket)
}
},
})
}

View file

@ -1,8 +1,8 @@
'use strict'
const constants = require('../constants')
const isEnumerable = require('../isEnumerable')
const formatUtils = require('../formatUtils')
const isEnumerable = require('../isEnumerable')
const lineBuilder = require('../lineBuilder')
const NOOP_RECURSOR = require('../recursorUtils').NOOP_RECURSOR
const object = require('./object')
@ -15,7 +15,7 @@ function describe (props) {
nameIsEnumerable: isEnumerable(error, 'name'),
name: error.name,
messageIsEnumerable: isEnumerable(error, 'message'),
message: error.message
message: error.message,
}, props))
}
exports.describe = describe
@ -59,13 +59,13 @@ class ErrorValue extends object.ObjectValue {
return innerLines.isEmpty
? lineBuilder.single(string + theme.object.closeBracket)
: lineBuilder.first(string)
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
},
maxDepth () {
return lineBuilder.single(string + ' ' + theme.maxDepth + ' ' + theme.object.closeBracket)
}
},
})
}

View file

@ -1,8 +1,8 @@
'use strict'
const constants = require('../constants')
const isEnumerable = require('../isEnumerable')
const formatUtils = require('../formatUtils')
const isEnumerable = require('../isEnumerable')
const lineBuilder = require('../lineBuilder')
const NOOP_RECURSOR = require('../recursorUtils').NOOP_RECURSOR
const object = require('./object')
@ -14,7 +14,7 @@ function describe (props) {
const fn = props.value
return new DescribedFunctionValue(Object.assign({
nameIsEnumerable: isEnumerable(fn, 'name'),
name: typeof fn.name === 'string' ? fn.name : null
name: typeof fn.name === 'string' ? fn.name : null,
}, props))
}
exports.describe = describe
@ -43,13 +43,13 @@ class FunctionValue extends object.ObjectValue {
return innerLines.isEmpty
? lineBuilder.single(string + theme.object.closeBracket)
: lineBuilder.first(string)
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
.concat(innerLines.withFirstPrefixed(indent.increase()).stripFlags())
.append(lineBuilder.last(indent + theme.object.closeBracket))
},
maxDepth () {
return lineBuilder.single(string + ' ' + theme.maxDepth + ' ' + theme.object.closeBracket)
}
},
})
}
}

View file

@ -9,7 +9,7 @@ const UNEQUAL = constants.UNEQUAL
function describe (props) {
return new DescribedMapValue(Object.assign({
size: props.value.size
size: props.value.size,
}, props))
}
exports.describe = describe
@ -39,7 +39,7 @@ class MapValue extends object.ObjectValue {
prepareDiff (expected) {
// Maps should be compared, even if they have a different number of entries.
return {compareResult: super.compare(expected)}
return { compareResult: super.compare(expected) }
}
serialize () {

View file

@ -1,11 +1,11 @@
'use strict'
const constants = require('../constants')
const getObjectKeys = require('../getObjectKeys')
const ObjectFormatter = require('../formatUtils').ObjectFormatter
const getObjectKeys = require('../getObjectKeys')
const hasLength = require('../hasLength')
const recursorUtils = require('../recursorUtils')
const stats = require('../metaDescriptors/stats')
const recursorUtils = require('../recursorUtils')
const DEEP_EQUAL = constants.DEEP_EQUAL
const SHALLOW_EQUAL = constants.SHALLOW_EQUAL
@ -17,7 +17,7 @@ function describe (props) {
return new DescribedObjectValue(Object.assign({
isArray,
isIterable: object[Symbol.iterator] !== undefined,
isList: isArray || hasLength(object)
isList: isArray || hasLength(object),
}, props))
}
exports.describe = describe
@ -58,7 +58,7 @@ class ObjectValue {
serialize () {
return [
this.ctor, this.pointer, this.stringTag,
this.isArray, this.isIterable, this.isList
this.isArray, this.isIterable, this.isList,
]
}
}
@ -231,7 +231,7 @@ function DeserializedMixin (base) {
stringTag: state[2],
isArray: state[3],
isIterable: state[4],
isList: state[5]
isList: state[5],
})
this.deserializedRecursor = recursor

View file

@ -11,7 +11,7 @@ function describe (props) {
const regexp = props.value
return new DescribedRegexpValue(Object.assign({
flags: getSortedFlags(regexp),
source: regexp.source
source: regexp.source,
}, props))
}
exports.describe = describe
@ -69,7 +69,7 @@ class RegexpValue extends object.ObjectValue {
regexp + ' ' +
theme.maxDepth + ' ' +
theme.object.closeBracket)
}
},
})
}

View file

@ -9,7 +9,7 @@ const UNEQUAL = constants.UNEQUAL
function describe (props) {
return new DescribedSetValue(Object.assign({
size: props.value.size
size: props.value.size,
}, props))
}
exports.describe = describe
@ -39,7 +39,7 @@ class SetValue extends object.ObjectValue {
prepareDiff (expected) {
// Sets should be compared, even if they have a different number of items.
return {compareResult: super.compare(expected)}
return { compareResult: super.compare(expected) }
}
serialize () {

View file

@ -3,8 +3,8 @@
const constants = require('../constants')
const formatUtils = require('../formatUtils')
const lineBuilder = require('../lineBuilder')
const recursorUtils = require('../recursorUtils')
const propertyStatsTag = require('../metaDescriptors/stats').propertyTag
const recursorUtils = require('../recursorUtils')
const object = require('./object')
const DEEP_EQUAL = constants.DEEP_EQUAL
@ -23,7 +23,7 @@ function describe (props) {
buffer: getBuffer(props.value),
// Set isArray and isList so the property recursor excludes the byte accessors
isArray: true,
isList: true
isList: true,
}, props))
}
exports.describe = describe
@ -103,7 +103,7 @@ class TypedArrayValue extends object.ObjectValue {
if (subject.isProperty === true) return subject.key.value !== 'byteLength'
if (subject.tag === bytesTag) return subject.buffer.byteLength > 0
return true
}
},
})
}
}

View file

@ -9,5 +9,5 @@ module.exports = {
AMBIGUOUS,
DEEP_EQUAL,
SHALLOW_EQUAL,
UNEQUAL
UNEQUAL,
}

View file

@ -1,5 +1,6 @@
'use strict'
const Registry = require('./Registry')
const argumentsValue = require('./complexValues/arguments')
const arrayBufferValue = require('./complexValues/arrayBuffer')
const boxedValue = require('./complexValues/boxed')
@ -15,23 +16,21 @@ const regexpValue = require('./complexValues/regexp')
const setValue = require('./complexValues/set')
const typedArrayValue = require('./complexValues/typedArray')
const getCtor = require('./getCtor')
const getStringTag = require('./getStringTag')
const itemDescriptor = require('./metaDescriptors/item')
const mapEntryDescriptor = require('./metaDescriptors/mapEntry')
const propertyDescriptor = require('./metaDescriptors/property')
const booleanValue = require('./primitiveValues/boolean')
const pluginRegistry = require('./pluginRegistry')
const bigIntValue = require('./primitiveValues/bigInt')
const booleanValue = require('./primitiveValues/boolean')
const nullValue = require('./primitiveValues/null')
const numberValue = require('./primitiveValues/number')
const stringValue = require('./primitiveValues/string')
const symbolValue = require('./primitiveValues/symbol')
const undefinedValue = require('./primitiveValues/undefined')
const getCtor = require('./getCtor')
const getStringTag = require('./getStringTag')
const pluginRegistry = require('./pluginRegistry')
const Registry = require('./Registry')
const SpecializedComplexes = new Map([
['Arguments', argumentsValue.describe],
['ArrayBuffer', arrayBufferValue.describe],
@ -53,7 +52,7 @@ const SpecializedComplexes = new Map([
['Uint16Array', typedArrayValue.describe],
['Uint32Array', typedArrayValue.describe],
['Uint8Array', typedArrayValue.describe],
['Uint8ClampedArray', typedArrayValue.describe]
['Uint8ClampedArray', typedArrayValue.describe],
])
function describePrimitive (value) {
@ -127,12 +126,22 @@ function describeComplex (value, registry, tryPlugins, describeAny, describeItem
pointer: pointer.index,
stringTag,
unboxed,
value
value,
})
pointer.descriptor = descriptor
return descriptor
}
const describeItem = (index, valueDescriptor) => {
return valueDescriptor.isPrimitive === true
? itemDescriptor.describePrimitive(index, valueDescriptor)
: itemDescriptor.describeComplex(index, valueDescriptor)
}
const describeMapEntry = (keyDescriptor, valueDescriptor) => {
return mapEntryDescriptor.describe(keyDescriptor, valueDescriptor)
}
function describe (value, options) {
const primitive = describePrimitive(value)
if (primitive !== null) return primitive
@ -150,16 +159,6 @@ function describe (value, options) {
: curriedComplex(any)
}
const describeItem = (index, valueDescriptor) => {
return valueDescriptor.isPrimitive === true
? itemDescriptor.describePrimitive(index, valueDescriptor)
: itemDescriptor.describeComplex(index, valueDescriptor)
}
const describeMapEntry = (keyDescriptor, valueDescriptor) => {
return mapEntryDescriptor.describe(keyDescriptor, valueDescriptor)
}
const describeProperty = (key, valueDescriptor) => {
const keyDescriptor = describePrimitive(key)
return valueDescriptor.isPrimitive === true

20
node_modules/concordance/lib/diff.js generated vendored
View file

@ -1,5 +1,7 @@
'use strict'
const Circular = require('./Circular')
const Indenter = require('./Indenter')
const constants = require('./constants')
const describe = require('./describe')
const lineBuilder = require('./lineBuilder')
@ -7,8 +9,6 @@ const recursorUtils = require('./recursorUtils')
const shouldCompareDeep = require('./shouldCompareDeep')
const symbolProperties = require('./symbolProperties')
const themeUtils = require('./themeUtils')
const Circular = require('./Circular')
const Indenter = require('./Indenter')
const AMBIGUOUS = constants.AMBIGUOUS
const DEEP_EQUAL = constants.DEEP_EQUAL
@ -75,7 +75,7 @@ function diffDescriptors (lhs, rhs, options) {
const isCircular = descriptor => lhsCircular.has(descriptor) || rhsCircular.has(descriptor)
const format = (builder, subject, circular) => {
const format = (builder, subject, circular, depthOffset = 0) => {
if (diffIndex >= 0 && !diffStack[diffIndex].shouldFormat(subject)) return
if (circular.has(subject)) {
@ -113,7 +113,7 @@ function diffDescriptors (lhs, rhs, options) {
const formatter = subject.formatShallow(themeUtils.applyModifiers(subject, theme), indent)
const recursor = subject.createRecursor()
if (formatter.increaseIndent && maxDepth > 0 && indent.level === maxDepth) {
if (formatter.increaseIndent && maxDepth > 0 && indent.level === (maxDepth + depthOffset)) {
const isEmpty = recursor() === null
let formatted = !isEmpty && typeof formatter.maxDepth === 'function'
? formatter.maxDepth()
@ -131,7 +131,7 @@ function diffDescriptors (lhs, rhs, options) {
recursor,
decreaseIndent: formatter.increaseIndent,
shouldFormat: formatter.shouldFormat || alwaysFormat,
subject
subject,
})
formatIndex++
@ -277,7 +277,7 @@ function diffDescriptors (lhs, rhs, options) {
origin: lhs,
decreaseIndent: formatter.increaseIndent,
exceedsMaxDepth: formatter.increaseIndent && maxDepth > 0 && indent.level >= maxDepth,
shouldFormat: formatter.shouldFormat || alwaysFormat
shouldFormat: formatter.shouldFormat || alwaysFormat,
})
diffIndex++
@ -289,7 +289,7 @@ function diffDescriptors (lhs, rhs, options) {
decreaseIndent: formatter.increaseIndent,
exceedsMaxDepth: formatter.increaseIndent && maxDepth > 0 && indent.level >= maxDepth,
shouldFormat: formatter.shouldFormat || alwaysFormat,
subject: lhs
subject: lhs,
})
diffIndex++
@ -304,7 +304,7 @@ function diffDescriptors (lhs, rhs, options) {
topIndex++
} else {
const diffed = typeof lhs.diffDeep === 'function'
? lhs.diffDeep(rhs, themeUtils.applyModifiers(lhs, theme), indent)
? lhs.diffDeep(rhs, themeUtils.applyModifiers(lhs, theme), indent, invert)
: null
if (diffed === null) {
@ -374,14 +374,14 @@ function diffDescriptors (lhs, rhs, options) {
}
do {
format(builder, subject, circular)
format(builder, subject, circular, indent.level)
subject = stack[topIndex].recursor()
} while (subject !== null)
}
}
} while (topIndex >= 0)
return buffer.toString({diff: true, invert, theme})
return buffer.toString({ diff: true, invert, theme })
}
exports.diffDescriptors = diffDescriptors

View file

@ -1,11 +1,11 @@
'use strict'
const flattenDeep = require('lodash.flattendeep')
const flattenDeep = require('lodash/flattenDeep')
// Indexes are hexadecimal to make reading the binary output easier.
const valueTypes = {
zero: 0x00,
int8: 0x01, // Note that the hex value equals the number of bytes required
int8: 0x01, // Note that the hex value equals the number of bytes required
int16: 0x02, // to store the integer.
int24: 0x03,
int32: 0x04,
@ -24,7 +24,7 @@ const valueTypes = {
utf8: 0x11,
bytes: 0x12,
list: 0x13,
descriptor: 0x14
descriptor: 0x14,
}
const descriptorSymbol = Symbol('descriptor')
@ -83,7 +83,7 @@ function encodeValue (value) {
return [
value[descriptorSymbol] === true ? valueTypes.descriptor : valueTypes.list,
encodeValue(value.length),
value.map(encodeValue)
value.map(x => encodeValue(x)),
]
}
@ -170,15 +170,15 @@ function buildBuffer (numberOrArray) {
const array = flattenDeep(numberOrArray)
const buffers = new Array(array.length)
let byteLength = 0
for (let index = 0; index < array.length; index++) {
if (typeof array[index] === 'number') {
for (const [index, element] of array.entries()) {
if (typeof element === 'number') {
byteLength += 1
const byte = Buffer.alloc(1)
byte.writeUInt8(array[index])
byte.writeUInt8(element)
buffers[index] = byte
} else {
byteLength += array[index].byteLength
buffers[index] = array[index]
byteLength += element.byteLength
buffers[index] = element
}
}
return Buffer.concat(buffers, byteLength)
@ -205,7 +205,7 @@ function encode (serializerVersion, rootRecord, usedPlugins) {
const plugin = usedPlugins.get(name)
const record = buildBuffer([
encodeValue(name),
encodeValue(plugin.serializerVersion)
encodeValue(plugin.serializerVersion),
])
buffers.push(record)
byteOffset += record.byteLength
@ -220,7 +220,7 @@ function encode (serializerVersion, rootRecord, usedPlugins) {
const recordHeader = buildBuffer([
encodeValue(record.pluginIndex),
encodeValue(record.id),
encodeValue(record.children.length)
encodeValue(record.children.length),
])
buffers.push(recordHeader)
byteOffset += recordHeader.byteLength
@ -258,7 +258,7 @@ function decodePlugins (buffer) {
byteOffset = $name.byteOffset
const serializerVersion = decodeValue(buffer, byteOffset).value
usedPlugins.set(index, {name, serializerVersion})
usedPlugins.set(index, { name, serializerVersion })
}
return usedPlugins
@ -285,7 +285,7 @@ function decodeRecord (buffer, byteOffset) {
}
const state = decodeValue(buffer, byteOffset).value
return {id, pluginIndex, state, pointerAddresses}
return { id, pluginIndex, state, pointerAddresses }
}
exports.decodeRecord = decodeRecord
@ -298,6 +298,6 @@ function decode (buffer) {
const rootOffset = buffer.readUInt32LE(2)
const pluginBuffer = buffer.slice(6, rootOffset)
const rootRecord = decodeRecord(buffer, rootOffset)
return {pluginBuffer, rootRecord}
return { pluginBuffer, rootRecord }
}
exports.decode = decode

View file

@ -1,10 +1,10 @@
'use strict'
const Circular = require('./Circular')
const Indenter = require('./Indenter')
const describe = require('./describe')
const lineBuilder = require('./lineBuilder')
const themeUtils = require('./themeUtils')
const Circular = require('./Circular')
const Indenter = require('./Indenter')
const alwaysFormat = () => true
const fixedIndent = new Indenter(0, ' ')
@ -13,7 +13,7 @@ function formatDescriptor (subject, options) {
const theme = themeUtils.normalize(options)
if (subject.isPrimitive === true) {
const formatted = subject.formatDeep(themeUtils.applyModifiers(subject, theme), fixedIndent)
return formatted.toString({diff: false})
return formatted.toString({ diff: false })
}
const circular = new Circular()
@ -58,7 +58,7 @@ function formatDescriptor (subject, options) {
recursor,
decreaseIndent: formatter.increaseIndent,
shouldFormat: formatter.shouldFormat || alwaysFormat,
subject
subject,
})
topIndex++
@ -91,7 +91,7 @@ function formatDescriptor (subject, options) {
}
} while (topIndex >= 0)
return buffer.toString({diff: false})
return buffer.toString({ diff: false })
}
exports.formatDescriptor = formatDescriptor

View file

@ -10,13 +10,11 @@ function getObjectKeys (obj, excludeListItemAccessorsBelowLength) {
// possible.
const symbolCandidates = Object.getOwnPropertySymbols(obj)
for (let i = 0; i < nameCandidates.length; i++) {
const name = nameCandidates[i]
for (const name of nameCandidates) {
let accept = true
if (excludeListItemAccessorsBelowLength > 0) {
const index = Number(name)
accept = (index % 1 !== 0) || index >= excludeListItemAccessorsBelowLength
accept = !Number.isInteger(index) || index < 0 || index >= excludeListItemAccessorsBelowLength
}
if (accept && Object.getOwnPropertyDescriptor(obj, name).enumerable) {
@ -24,8 +22,7 @@ function getObjectKeys (obj, excludeListItemAccessorsBelowLength) {
}
}
for (let i = 0; i < symbolCandidates.length; i++) {
const symbol = symbolCandidates[i]
for (const symbol of symbolCandidates) {
if (Object.getOwnPropertyDescriptor(obj, symbol).enumerable) {
keys[size++] = symbol
}

View file

@ -12,7 +12,7 @@ const isPromise = value => {
try {
return fts.call(value.constructor) === promiseCtorString
} catch (err) {
} catch {
return false
}
}

View file

@ -1,6 +1,6 @@
'use strict'
const isLength = require('lodash.islength')
const isLength = require('lodash/isLength')
const hop = Object.prototype.hasOwnProperty

View file

@ -86,7 +86,7 @@ class Line {
.decompose()
}
}
Object.defineProperty(Line.prototype, 'isLine', {value: true})
Object.defineProperty(Line.prototype, 'isLine', { value: true })
class Collection {
constructor () {
@ -206,8 +206,8 @@ class Collection {
}
decompose () {
const first = {actual: new Collection(), expected: new Collection()}
const last = {actual: new Collection(), expected: new Collection()}
const first = { actual: new Collection(), expected: new Collection() }
const last = { actual: new Collection(), expected: new Collection() }
const remaining = new Collection()
for (const line of this) {
@ -224,10 +224,10 @@ class Collection {
}
}
return {first, last, remaining}
return { first, last, remaining }
}
}
Object.defineProperty(Collection.prototype, 'isCollection', {value: true})
Object.defineProperty(Collection.prototype, 'isCollection', { value: true })
function setDefaultGutter (iterable, gutter) {
return new Collection()
@ -282,7 +282,7 @@ module.exports = {
setDefaultGutter (lineOrCollection) {
return setDefaultGutter(lineOrCollection, ACTUAL)
}
},
},
expected: {
@ -304,6 +304,6 @@ module.exports = {
setDefaultGutter (lineOrCollection) {
return setDefaultGutter(lineOrCollection, EXPECTED)
}
}
},
},
}

View file

@ -65,7 +65,7 @@ class ComplexItem {
prepareDiff (expected, lhsRecursor, rhsRecursor, compareComplexShape, isCircular) {
// Circular values cannot be compared. They must be treated as being unequal when diffing.
if (isCircular(this.value) || isCircular(expected.value)) return {compareResult: UNEQUAL}
if (isCircular(this.value) || isCircular(expected.value)) return { compareResult: UNEQUAL }
// Try to line up this or remaining items with the expected items.
const lhsFork = recursorUtils.fork(lhsRecursor)
@ -113,7 +113,7 @@ class ComplexItem {
next.index++
return next
})
}),
}
}
@ -128,7 +128,7 @@ class ComplexItem {
next.index++
return next
}),
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}
@ -138,7 +138,7 @@ class ComplexItem {
mustRecurse,
isUnequal: !mustRecurse,
lhsRecursor: lhsFork.recursor,
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}
@ -179,14 +179,14 @@ class PrimitiveItem {
prepareDiff (expected, lhsRecursor, rhsRecursor, compareComplexShape, isCircular) {
const compareResult = this.compare(expected)
// Short-circuit when values are deeply equal.
if (compareResult === DEEP_EQUAL) return {compareResult}
if (compareResult === DEEP_EQUAL) return { compareResult }
// Short-circut when values can be diffed directly.
if (
expected.tag === primitiveTag &&
this.value.tag === expected.value.tag && typeof this.value.diffDeep === 'function'
) {
return {compareResult}
return { compareResult }
}
// Try to line up this or remaining items with the expected items.
@ -204,7 +204,7 @@ class PrimitiveItem {
next.index++
return next
})
}),
}
}
@ -219,7 +219,7 @@ class PrimitiveItem {
next.index++
return next
}),
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}
@ -227,7 +227,7 @@ class PrimitiveItem {
} while (true)
}
diffDeep (expected, theme, indent) {
diffDeep (expected, theme, indent, invert) {
// Verify a diff can be returned.
if (this.tag !== expected.tag || typeof this.value.diffDeep !== 'function') return null
@ -236,7 +236,7 @@ class PrimitiveItem {
// Since the value is diffed directly, modifiers are not applied. Apply
// modifiers to the item descriptor instead.
const diff = this.value.diffDeep(expected.value, theme, valueIndent)
const diff = this.value.diffDeep(expected.value, theme, valueIndent, invert)
if (diff === null) return null
if (typeof theme.item.customFormat === 'function') {

View file

@ -113,11 +113,11 @@ class MapEntry {
},
finalize () {
return mergeWithKey(theme, key, values)
}
},
}
}
diffDeep (expected, theme, indent) {
diffDeep (expected, theme, indent, invert) {
// Verify a diff can be returned.
if (this.tag !== expected.tag || typeof this.value.diffDeep !== 'function') return null
// Only use this logic to format value diffs when the keys are primitive and equal.
@ -127,7 +127,7 @@ class MapEntry {
// Since formatShallow() would result in theme modifiers being applied
// before the key and value are formatted, do the same here.
const diff = this.value.diffDeep(expected.value, themeUtils.applyModifiersToOriginal(this.value, theme), indent)
const diff = this.value.diffDeep(expected.value, themeUtils.applyModifiersToOriginal(this.value, theme), indent, invert)
if (diff === null) return null
const key = this.key.formatDeep(themeUtils.applyModifiersToOriginal(this.key, theme), indent, '')
@ -136,12 +136,12 @@ class MapEntry {
prepareDiff (expected, lhsRecursor, rhsRecursor, compareComplexShape, isCircular) {
// Circular values cannot be compared. They must be treated as being unequal when diffing.
if (isCircular(this.value) || isCircular(expected.value)) return {compareResult: UNEQUAL}
if (isCircular(this.value) || isCircular(expected.value)) return { compareResult: UNEQUAL }
const compareResult = this.compare(expected)
const keysAreEqual = this.tag === expected.tag && this.key.compare(expected.key) === DEEP_EQUAL
// Short-circuit when keys and/or values are deeply equal.
if (compareResult === DEEP_EQUAL || keysAreEqual) return {compareResult}
if (compareResult === DEEP_EQUAL || keysAreEqual) return { compareResult }
// Try to line up this or remaining map entries with the expected entries.
const lhsFork = recursorUtils.fork(lhsRecursor)
@ -186,7 +186,7 @@ class MapEntry {
return {
actualIsExtraneous: true,
lhsRecursor: lhsFork.recursor,
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected)
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected),
}
}
@ -194,7 +194,7 @@ class MapEntry {
return {
expectedIsMissing: true,
lhsRecursor: recursorUtils.unshift(lhsFork.recursor, this),
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}
@ -211,7 +211,7 @@ class MapEntry {
mustRecurse,
isUnequal: !mustRecurse,
lhsRecursor: lhsFork.recursor,
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}

View file

@ -2,8 +2,8 @@
const constants = require('../constants')
const formatUtils = require('../formatUtils')
const recursorUtils = require('../recursorUtils')
const symbolPrimitive = require('../primitiveValues/symbol').tag
const recursorUtils = require('../recursorUtils')
const AMBIGUOUS = constants.AMBIGUOUS
const DEEP_EQUAL = constants.DEEP_EQUAL
@ -56,7 +56,7 @@ class Property {
prepareDiff (expected, lhsRecursor, rhsRecursor, compareComplexShape, isCircular) {
// Circular values cannot be compared. They must be treated as being unequal when diffing.
if (isCircular(this.value) || isCircular(expected.value)) return {compareResult: UNEQUAL}
if (isCircular(this.value) || isCircular(expected.value)) return { compareResult: UNEQUAL }
// Try to line up this or remaining properties with the expected properties.
const rhsFork = recursorUtils.fork(rhsRecursor)
@ -66,7 +66,7 @@ class Property {
if (expected === null || expected.isProperty !== true) {
return {
actualIsExtraneous: true,
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected)
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected),
}
} else if (this.key.compare(expected.key) === DEEP_EQUAL) {
if (expected === initialExpected) {
@ -75,7 +75,7 @@ class Property {
return {
expectedIsMissing: true,
lhsRecursor: recursorUtils.unshift(lhsRecursor, this),
rhsRecursor: rhsFork.recursor
rhsRecursor: rhsFork.recursor,
}
}
}
@ -160,7 +160,7 @@ class PrimitiveProperty extends Property {
.withLastPostfixed(theme.property.after)
}
diffDeep (expected, theme, indent) {
diffDeep (expected, theme, indent, invert) {
// Verify a diff can be returned.
if (this.tag !== expected.tag || typeof this.value.diffDeep !== 'function') return null
// Only use this logic to diff values when the keys are the same.
@ -171,7 +171,7 @@ class PrimitiveProperty extends Property {
// Since the key and value are diffed directly, modifiers are not
// applied. Apply modifiers to the property descriptor instead.
const diff = this.value.diffDeep(expected.value, theme, valueIndent)
const diff = this.value.diffDeep(expected.value, theme, valueIndent, invert)
if (diff === null) return null
if (typeof theme.property.customFormat === 'function') {

View file

@ -75,7 +75,7 @@ class Stats {
lhsRecursor: recursorUtils.unshift(lhsRecursor, this),
// Use original `rhsRecursor`, not `rhsFork`, since the consumed
// descriptors are returned with the `missing` array.
rhsRecursor: recursorUtils.unshift(rhsRecursor, expected)
rhsRecursor: recursorUtils.unshift(rhsRecursor, expected),
}
}
@ -95,7 +95,7 @@ class Stats {
// Use original `lhsRecursor`, not `lhsFork`, since the consumed
// descriptors are returned with the `extraneous` array.
lhsRecursor: recursorUtils.unshift(lhsRecursor, actual),
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected)
rhsRecursor: recursorUtils.unshift(rhsFork.recursor, initialExpected),
}
}

View file

@ -3,10 +3,10 @@
const semver = require('semver')
const pkg = require('../package.json')
const constants = require('./constants')
const object = require('./complexValues/object')
const lineBuilder = require('./lineBuilder')
const constants = require('./constants')
const formatUtils = require('./formatUtils')
const lineBuilder = require('./lineBuilder')
const itemDescriptor = require('./metaDescriptors/item')
const propertyDescriptor = require('./metaDescriptors/property')
const stringDescriptor = require('./primitiveValues/string')
@ -94,7 +94,7 @@ const publicDescriptorTags = Object.freeze({
complexItem: itemDescriptor.complexTag,
primitiveItem: itemDescriptor.primitiveTag,
primitiveProperty: propertyDescriptor.primitiveTag,
string: stringDescriptor.tag
string: stringDescriptor.tag,
})
// Don't expose `setDefaultGutter()`.
@ -109,15 +109,15 @@ const publicLineBuilder = Object.freeze({
first: lineBuilder.actual.first,
last: lineBuilder.actual.last,
line: lineBuilder.actual.line,
single: lineBuilder.actual.single
single: lineBuilder.actual.single,
}),
expected: Object.freeze({
buffer: lineBuilder.expected.buffer,
first: lineBuilder.expected.first,
last: lineBuilder.expected.last,
line: lineBuilder.expected.line,
single: lineBuilder.expected.single
})
single: lineBuilder.expected.single,
}),
})
function modifyTheme (descriptor, modifier) {
@ -158,7 +158,7 @@ function add (plugin) {
lineBuilder: publicLineBuilder,
mapRecursor: recursorUtils.map,
modifyTheme,
wrapFromTheme: formatUtils.wrap
wrapFromTheme: formatUtils.wrap,
})
const registered = {
@ -167,7 +167,7 @@ function add (plugin) {
name,
tag2id,
theme: plugin.theme || {},
tryDescribeValue
tryDescribeValue,
}
registry.set(name, registered)
@ -185,7 +185,7 @@ function getDeserializers (plugins) {
return {
id2deserialize: registered.id2deserialize,
name: registered.name,
serializerVersion: registered.serializerVersion
serializerVersion: registered.serializerVersion,
}
})
}
@ -196,7 +196,7 @@ function getThemes (plugins) {
const registered = add(plugin)
return {
name: registered.name,
theme: registered.theme
theme: registered.theme,
}
})
}
@ -215,8 +215,8 @@ function resolveDescriptorRef (tag) {
id: registered.tag2id.get(tag),
name: registered.name,
serialization: {
serializerVersion: registered.serializerVersion
}
serializerVersion: registered.serializerVersion,
},
}
}
exports.resolveDescriptorRef = resolveDescriptorRef

View file

@ -1,7 +1,7 @@
'use strict'
const fastDiff = require('fast-diff')
const keyword = require('esutils').keyword
const fastDiff = require('fast-diff')
const constants = require('../constants')
const formatUtils = require('../formatUtils')
@ -61,7 +61,7 @@ function includesLinebreaks (string) {
return string.includes('\r') || string.includes('\n')
}
function diffLine (theme, actual, expected) {
function diffLine (theme, actual, expected, invert) {
const outcome = fastDiff(actual, expected)
// TODO: Compute when line is mostly unequal (80%? 90%?) and treat it as being
@ -83,9 +83,14 @@ function diffLine (theme, actual, expected) {
let stringExpected = ''
const noopWrap = { open: '', close: '' }
const deleteWrap = isPartiallyEqual ? theme.string.diff.delete : noopWrap
const insertWrap = isPartiallyEqual ? theme.string.diff.insert : noopWrap
let deleteWrap = isPartiallyEqual ? theme.string.diff.delete : noopWrap
let insertWrap = isPartiallyEqual ? theme.string.diff.insert : noopWrap
const equalWrap = isPartiallyEqual ? theme.string.diff.equal : noopWrap
if (invert) {
[deleteWrap, insertWrap] = [insertWrap, deleteWrap]
}
for (const diff of outcome) {
if (diff[0] === fastDiff.DELETE) {
stringActual += formatUtils.wrap(deleteWrap, diff[1])
@ -99,8 +104,11 @@ function diffLine (theme, actual, expected) {
}
if (!isPartiallyEqual) {
stringActual = formatUtils.wrap(theme.string.diff.deleteLine, stringActual)
stringExpected = formatUtils.wrap(theme.string.diff.insertLine, stringExpected)
const deleteLineWrap = invert ? theme.string.diff.insertLine : theme.string.diff.deleteLine
const insertLineWrap = invert ? theme.string.diff.deleteLine : theme.string.diff.insertLine
stringActual = formatUtils.wrap(deleteLineWrap, stringActual)
stringExpected = formatUtils.wrap(insertLineWrap, stringExpected)
}
return [stringActual, stringExpected]
@ -170,7 +178,7 @@ class StringValue {
return formatUtils.wrap(theme.string.line, formatUtils.wrap(theme.string, escaped))
}
diffDeep (expected, theme, indent) {
diffDeep (expected, theme, indent, invert) {
if (expected.tag !== tag) return null
const escapedActual = basicEscape(this.value)
@ -179,7 +187,9 @@ class StringValue {
if (!includesLinebreaks(escapedActual) && !includesLinebreaks(escapedExpected)) {
const result = diffLine(theme,
escapeQuotes(theme.string.line, escapedActual),
escapeQuotes(theme.string.line, escapedExpected))
escapeQuotes(theme.string.line, escapedExpected),
invert,
)
return lineBuilder.actual.single(formatUtils.wrap(theme.string.line, result[0]))
.concat(lineBuilder.expected.single(formatUtils.wrap(theme.string.line, result[1])))
@ -241,7 +251,8 @@ class StringValue {
}
if (actualIsExtraneous && !expectedIsMissing) {
const string = formatUtils.wrap(theme.string.diff.deleteLine, actualLines[actualIndex])
const wrap = invert ? theme.string.diff.insertLine : theme.string.diff.deleteLine
const string = formatUtils.wrap(wrap, actualLines[actualIndex])
if (actualIndex === 0) {
actualBuffer.push(lineBuilder.actual.first(theme.string.multiline.start + string))
@ -255,7 +266,8 @@ class StringValue {
actualIndex++
extraneousOffset++
} else if (expectedIsMissing && !actualIsExtraneous) {
const string = formatUtils.wrap(theme.string.diff.insertLine, expectedLines[expectedIndex])
const wrap = invert ? theme.string.diff.deleteLine : theme.string.diff.insertLine
const string = formatUtils.wrap(wrap, expectedLines[expectedIndex])
if (mustOpenNextExpected) {
expectedBuffer.push(lineBuilder.expected.first(theme.string.multiline.start + string))
@ -268,7 +280,7 @@ class StringValue {
expectedIndex++
} else {
const result = diffLine(theme, actualLines[actualIndex], expectedLines[expectedIndex])
const result = diffLine(theme, actualLines[actualIndex], expectedLines[expectedIndex], invert)
if (actualIndex === 0) {
actualBuffer.push(lineBuilder.actual.first(theme.string.multiline.start + result[0]))

View file

@ -22,7 +22,7 @@ function describe (value) {
return new SymbolValue({
stringCompare,
value
value,
})
}
exports.describe = describe
@ -34,7 +34,7 @@ function deserialize (state) {
return new DeserializedSymbolValue({
string,
stringCompare,
value: null
value: null,
})
}
exports.deserialize = deserialize

View file

@ -2,7 +2,7 @@
const NOOP_RECURSOR = {
size: 0,
next () { return null }
next () { return null },
}
exports.NOOP_RECURSOR = NOOP_RECURSOR
@ -19,11 +19,27 @@ function fork (recursor) {
recursor () {
if (buffer.length > 0) return buffer.shift()
return recursor()
}
},
}
}
exports.fork = fork
function consumeDeep (recursor) {
const stack = [recursor]
while (stack.length > 0) {
const subject = stack[stack.length - 1]()
if (subject === null) {
stack.pop()
continue
}
if (typeof subject.createRecursor === 'function') {
stack.push(subject.createRecursor())
}
}
}
exports.consumeDeep = consumeDeep
function map (recursor, mapFn) {
return () => {
const next = recursor()
@ -42,12 +58,12 @@ function replay (state, create) {
} else {
state = Object.assign({
buffer: [],
done: false
done: false,
}, recursor)
}
}
if (state === NOOP_RECURSOR) return {state, recursor: state}
if (state === NOOP_RECURSOR) return { state, recursor: state }
let done = false
let index = 0
@ -66,7 +82,7 @@ function replay (state, create) {
return retval
}
return {state, recursor: {next, size: state.size}}
return { state, recursor: { next, size: state.size } }
}
exports.replay = replay

View file

@ -2,9 +2,6 @@
const md5hex = require('md5-hex')
const encoder = require('./encoder')
const pluginRegistry = require('./pluginRegistry')
const argumentsValue = require('./complexValues/arguments')
const arrayBufferValue = require('./complexValues/arrayBuffer')
const boxedValue = require('./complexValues/boxed')
@ -20,12 +17,16 @@ const regexpValue = require('./complexValues/regexp')
const setValue = require('./complexValues/set')
const typedArrayValue = require('./complexValues/typedArray')
const encoder = require('./encoder')
const itemDescriptor = require('./metaDescriptors/item')
const mapEntryDescriptor = require('./metaDescriptors/mapEntry')
const pointerDescriptor = require('./metaDescriptors/pointer')
const propertyDescriptor = require('./metaDescriptors/property')
const statsDescriptors = require('./metaDescriptors/stats')
const pluginRegistry = require('./pluginRegistry')
const bigIntValue = require('./primitiveValues/bigInt')
const booleanValue = require('./primitiveValues/boolean')
const nullValue = require('./primitiveValues/null')
@ -34,6 +35,8 @@ const stringValue = require('./primitiveValues/string')
const symbolValue = require('./primitiveValues/symbol')
const undefinedValue = require('./primitiveValues/undefined')
const recursorUtils = require('./recursorUtils')
// Increment if encoding layout, descriptor IDs, or value types change. Previous
// Concordance versions will not be able to decode buffers generated by a newer
// version, so changing this value will require a major version bump of
@ -78,7 +81,7 @@ const mappings = [
[0x1C, regexpValue.tag, regexpValue.deserialize],
[0x1D, setValue.tag, setValue.deserialize],
[0x1E, typedArrayValue.tag, typedArrayValue.deserialize],
[0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes]
[0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes],
]
const tag2id = new Map(mappings.map(mapping => [mapping[1], mapping[0]]))
const id2deserialize = new Map(mappings.map(mapping => [mapping[0], mapping[2]]))
@ -116,7 +119,7 @@ class UnsupportedPluginError extends Error {
}
}
class UnsupportedVersion extends Error {
class UnsupportedVersion extends Error { // eslint-disable-line unicorn/custom-error-definition
constructor (serializerVersion) {
super('Could not deserialize buffer: a different serialization was expected')
this.name = 'UnsupportedVersion'
@ -131,7 +134,7 @@ function shallowSerializeDescriptor (descriptor, resolvePluginRef) {
}
function serializeState (state, resolvePluginRef) {
if (Array.isArray(state)) return state.map(serializeState)
if (Array.isArray(state)) return state.map(x => serializeState(x))
if (state && state.tag) {
let id, pluginIndex
@ -165,12 +168,12 @@ function serialize (descriptor) {
if (!usedPlugins.has(ref.name)) {
// Start at 1, since 0 is reserved for Concordance's descriptors.
const index = usedPlugins.size + 1
usedPlugins.set(ref.name, Object.assign({index}, ref.serialization))
usedPlugins.set(ref.name, Object.assign({ index }, ref.serialization))
}
return {
id: ref.id,
pluginIndex: usedPlugins.get(ref.name).index
pluginIndex: usedPlugins.get(ref.name).index,
}
}
@ -205,7 +208,7 @@ function serialize (descriptor) {
id,
pluginIndex,
children: [],
state: shallowSerializeDescriptor(descriptor, resolvePluginRef)
state: shallowSerializeDescriptor(descriptor, resolvePluginRef),
}
if (!rootRecord) {
rootRecord = record
@ -318,12 +321,27 @@ function deserialize (buffer, options) {
const descriptorsByPointerIndex = new Map()
const mapPointerDescriptor = descriptor => {
if (descriptor.isPointer === true) {
if (!descriptorsByPointerIndex.has(descriptor.index)) throw new PointerLookupError(descriptor.index)
if (descriptorsByPointerIndex.has(descriptor.index)) {
return descriptorsByPointerIndex.get(descriptor.index)
}
return descriptorsByPointerIndex.get(descriptor.index)
} else if (descriptor.isComplex === true) {
if (typeof rootDescriptor.createRecursor === 'function') {
// The descriptor we're pointing to may be elsewhere in the serialized
// structure. Consume the entire structure and check again.
recursorUtils.consumeDeep(rootDescriptor.createRecursor())
if (descriptorsByPointerIndex.has(descriptor.index)) {
return descriptorsByPointerIndex.get(descriptor.index)
}
}
throw new PointerLookupError(descriptor.index)
}
if (descriptor.isComplex === true) {
descriptorsByPointerIndex.set(descriptor.pointer, descriptor)
}
return descriptor
}
@ -336,6 +354,8 @@ function deserialize (buffer, options) {
return mapPointerDescriptor(deserializeDescriptor(state, recursor))
}
}
return deserializeRecord(decoded.rootRecord, getDescriptorDeserializer, buffer)
const rootDescriptor = deserializeRecord(decoded.rootRecord, getDescriptorDeserializer, buffer)
return rootDescriptor
}
exports.deserialize = deserialize

View file

@ -74,7 +74,7 @@ class Comparable {
}
expected.ordered = ordered.concat(missingProperties)
return {mustRecurse: true}
return { mustRecurse: true }
}
}
Object.defineProperty(Comparable.prototype, 'isSymbolPropertiesComparable', { value: true })

View file

@ -1,7 +1,7 @@
'use strict'
const cloneDeep = require('lodash.clonedeep')
const merge = require('lodash.merge')
const cloneDeep = require('lodash/cloneDeep')
const merge = require('lodash/merge')
const pluginRegistry = require('./pluginRegistry')
@ -28,31 +28,31 @@ const defaultTheme = freezeTheme({
circular: '[Circular]',
date: {
invalid: 'invalid',
value: { open: '', close: '' }
value: { open: '', close: '' },
},
diffGutters: {
actual: '- ',
expected: '+ ',
padding: ' '
padding: ' ',
},
error: {
ctor: { open: '(', close: ')' },
name: { open: '', close: '' }
name: { open: '', close: '' },
},
function: {
name: { open: '', close: '' },
stringTag: { open: '', close: '' }
stringTag: { open: '', close: '' },
},
global: { open: '', close: '' },
item: {
after: ',',
customFormat: null,
increaseValueIndent: false
increaseValueIndent: false,
},
list: { openBracket: '[', closeBracket: ']' },
mapEntry: {
after: ',',
separator: ' => '
separator: ' => ',
},
maxDepth: '…',
null: { open: '', close: '' },
@ -62,40 +62,40 @@ const defaultTheme = freezeTheme({
closeBracket: '}',
ctor: { open: '', close: '' },
stringTag: { open: '@', close: '' },
secondaryStringTag: { open: '@', close: '' }
secondaryStringTag: { open: '@', close: '' },
},
property: {
after: ',',
customFormat: null,
keyBracket: { open: '[', close: ']' },
separator: ': ',
increaseValueIndent: false
increaseValueIndent: false,
},
regexp: {
source: { open: '/', close: '/' },
flags: { open: '', close: '' },
separator: '---'
separator: '---',
},
stats: { separator: '---' },
string: {
open: '',
close: '',
line: { open: "'", close: "'", escapeQuote: "'" },
multiline: { start: '`', end: '`', escapeQuote: '``' },
multiline: { start: '`', end: '`', escapeQuote: '`' },
controlPicture: { open: '', close: '' },
diff: {
insert: { open: '', close: '' },
delete: { open: '', close: '' },
equal: { open: '', close: '' },
insertLine: { open: '', close: '' },
deleteLine: { open: '', close: '' }
}
deleteLine: { open: '', close: '' },
},
},
symbol: { open: '', close: '' },
typedArray: {
bytes: { open: '', close: '' }
bytes: { open: '', close: '' },
},
undefined: { open: '', close: '' }
undefined: { open: '', close: '' },
})
const pluginRefs = new Map()
@ -119,7 +119,7 @@ function normalizePlugins (plugins) {
if (normalizedPluginThemes.has(ref)) {
return {
ref,
theme: normalizedPluginThemes.get(ref)
theme: normalizedPluginThemes.get(ref),
}
}
@ -127,19 +127,19 @@ function normalizePlugins (plugins) {
return merge(acc, pluginTheme)
}, cloneDeep(defaultTheme)))
normalizedPluginThemes.set(ref, theme)
return {ref, theme}
return { ref, theme }
}
const normalizedCache = new WeakMap()
function normalize (options) {
options = Object.assign({plugins: [], theme: null}, options)
options = Object.assign({ plugins: [], theme: null }, options)
const normalizedPlugins = normalizePlugins(options.plugins)
if (!options.theme) {
return normalizedPlugins ? normalizedPlugins.theme : defaultTheme
}
const entry = normalizedCache.get(options.theme) || {theme: null, withPlugins: new Map()}
const entry = normalizedCache.get(options.theme) || { theme: null, withPlugins: new Map() }
if (!normalizedCache.has(options.theme)) normalizedCache.set(options.theme, entry)
if (normalizedPlugins) {

View file

@ -1 +0,0 @@
../semver/bin/semver

View file

@ -1,10 +0,0 @@
'use strict';
const md5OMatic = require('md5-o-matic');
module.exports = input => {
if (Array.isArray(input)) {
input = input.join('');
}
return md5OMatic(input);
};

View file

@ -1,23 +0,0 @@
'use strict';
const crypto = require('crypto');
module.exports = function (input) {
const hash = crypto.createHash('md5');
const update = buf => {
const inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
hash.update(buf, inputEncoding);
};
if (arguments.length > 1) {
throw new Error('Too many arguments. Try specifying an array.');
}
if (Array.isArray(input)) {
input.forEach(update);
} else {
update(input);
}
return hash.digest('hex');
};

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View file

@ -1,39 +0,0 @@
{
"name": "md5-hex",
"version": "2.0.0",
"description": "Create a MD5 hash with hex encoding",
"license": "MIT",
"repository": "sindresorhus/md5-hex",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"browser.js"
],
"keywords": [
"hash",
"crypto",
"md5",
"hex",
"buffer",
"browser",
"browserify"
],
"dependencies": {
"md5-o-matic": "^0.1.1"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"browser": "browser.js"
}

View file

@ -1,46 +0,0 @@
# md5-hex [![Build Status](https://travis-ci.org/sindresorhus/md5-hex.svg?branch=master)](https://travis-ci.org/sindresorhus/md5-hex)
> Create a MD5 hash with hex encoding
*Please don't use MD5 hashes for anything sensitive!*
Works in the browser too, when used with browserify/webpack.
Checkout [`hasha`](https://github.com/sindresorhus/hasha) if you need something more flexible.
## Install
```
$ npm install --save md5-hex
```
## Usage
```js
const fs = require('fs');
const md5Hex = require('md5-hex');
const buffer = fs.readFileSync('unicorn.png');
md5Hex(buffer);
//=> '1abcb33beeb811dca15f0ac3e47b88d9'
```
## API
### md5Hex(input)
#### input
Type: `Buffer` `string` `Buffer[]` `string[]`
Prefer buffers as they're faster to hash, but strings can be useful for small things.
Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View file

@ -1,39 +0,0 @@
# changes log
## 5.7
* Add `minVersion` method
## 5.6
* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.
## 5.5
* Add version coercion capabilities
## 5.4
* Add intersection checking
## 5.3
* Add `minSatisfying` method
## 5.2
* Add `prerelease(v)` that returns prerelease components
## 5.1
* Add Backus-Naur for ranges
* Remove excessively cute inspection methods
## 5.0
* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier

View file

@ -1,15 +0,0 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View file

@ -1,412 +0,0 @@
semver(1) -- The semantic versioner for npm
===========================================
## Install
```bash
npm install --save semver
````
## Usage
As a node module:
```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
As a command-line utility:
```
$ semver -h
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)
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.
```
## Versions
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.
## Ranges
A `version range` is a set of `comparators` which specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version. The
version `3.4.5` *would* satisfy the range, because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose for this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range matching
semantics.
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any version satisfies)
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero digit in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0`
* `^0.2.3` := `>=0.2.3 <0.3.0`
* `^0.0.3` := `>=0.0.3 <0.0.4`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0`
* `^0.0.x` := `>=0.0.0 <0.1.0`
* `^0.0` := `>=0.0.0 <0.1.0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
### Range Grammar
Putting all this together, here is a Backus-Naur grammar for ranges,
for the benefit of parser authors:
```bnf
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
```
## Functions
All methods and classes take a final `options` object argument. All
options in this object are `false` by default. The options supported
are:
- `loose` Be more forgiving about not-quite-valid semver strings.
(Any resulting output will always be 100% strict compliant, of
course.) For backwards compatibility reasons, if the `options`
argument is a boolean value instead of an object, it is interpreted
to be the `loose` param.
- `includePrerelease` Set to suppress the [default
behavior](https://github.com/npm/node-semver#prerelease-tags) of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into.
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)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), 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.
* If called from a non-prerelease version, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `prerelease(v)`: Returns an array of prerelease components, or null
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Comparators
* `intersects(comparator)`: Return true if the comparators intersect
### Ranges
* `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
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
* `intersects(range)`: Return true if any of the ranges comparators intersect
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so the version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string, and consumes all
remaining characters which satisfy at least a partial semver (e.g., `1`,
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).

View file

@ -1,160 +0,0 @@
#!/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.
var argv = process.argv.slice(2)
var versions = []
var range = []
var inc = null
var version = require('../package.json').version
var loose = false
var includePrerelease = false
var coerce = false
var identifier
var semver = require('../semver')
var reverse = false
var options = {}
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
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 '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
var options = { loose: loose, includePrerelease: includePrerelease }
versions = versions.map(function (v) {
return coerce ? (semver.coerce(v) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error('--inc can only be used on a single version with no range')
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v, i, _) { console.log(v) })
}
function 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)',
'',
'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.'
].join('\n'))
}

View file

@ -1,28 +0,0 @@
{
"name": "semver",
"version": "5.7.1",
"description": "The semantic version parser used by npm.",
"main": "semver.js",
"scripts": {
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags"
},
"devDependencies": {
"tap": "^13.0.0-rc.18"
},
"license": "ISC",
"repository": "https://github.com/npm/node-semver",
"bin": {
"semver": "./bin/semver"
},
"files": [
"bin",
"range.bnf",
"semver.js"
],
"tap": {
"check-coverage": true
}
}

View file

@ -1,16 +0,0 @@
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | [1-9] ( [0-9] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "concordance",
"version": "4.0.0",
"version": "5.0.4",
"description": "Compare, format, diff and serialize any JavaScript value",
"main": "index.js",
"files": [
@ -8,11 +8,10 @@
"index.js"
],
"engines": {
"node": ">=6.12.3 <7 || >=8.9.4 <9 || >=10.0.0"
"node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14"
},
"scripts": {
"lint": "as-i-preach",
"test": "npm run -s lint && nyc ava"
"test": "as-i-preach && c8 ava"
},
"repository": {
"type": "git",
@ -25,40 +24,27 @@
},
"homepage": "https://github.com/concordancejs/concordance#readme",
"dependencies": {
"date-time": "^2.1.0",
"esutils": "^2.0.2",
"fast-diff": "^1.1.2",
"date-time": "^3.1.0",
"esutils": "^2.0.3",
"fast-diff": "^1.2.0",
"js-string-escape": "^1.0.1",
"lodash.clonedeep": "^4.5.0",
"lodash.flattendeep": "^4.4.0",
"lodash.islength": "^4.0.1",
"lodash.merge": "^4.6.1",
"md5-hex": "^2.0.0",
"semver": "^5.5.1",
"lodash": "^4.17.15",
"md5-hex": "^3.0.1",
"semver": "^7.3.2",
"well-known-symbols": "^2.0.0"
},
"devDependencies": {
"@novemberborn/as-i-preach": "^10.0.1",
"ava": "1.0.0-beta.8",
"benchmark": "^2.1.3",
"chalk": "^2.4.1",
"codecov": "^3.1.0",
"lodash.isequal": "^4.5.0",
"nyc": "^13.0.1",
"pretty-format": "^23.6.0"
},
"as-i-preach": {
"allowDevDependencies": [
"perf/**/*.js",
"test/**/*.js"
]
},
"nyc": {
"reporter": [
"html",
"lcov",
"text"
]
},
"standard-engine": "@novemberborn/as-i-preach"
"@novemberborn/eslint-plugin-as-i-preach": "^12.0.0",
"ava": "^3.15.0",
"c8": "^7.1.2",
"eslint": "^6.8.0",
"eslint-plugin-ava": "^10.3.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-unicorn": "^17.2.0",
"proxyquire": "^2.1.3"
}
}