Permalink
Cannot retrieve contributors at this time
48 lines (38 sloc)
1.35 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/concordance/lib/complexValues/arguments.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const constants = require('../constants') | |
const object = require('./object') | |
const AMBIGUOUS = constants.AMBIGUOUS | |
const UNEQUAL = constants.UNEQUAL | |
function describe (props) { | |
return new DescribedArgumentsValue(Object.assign({ | |
// Treat as an array, to allow comparisons with arrays | |
isArray: true, | |
isList: true, | |
}, props, { ctor: 'Arguments' })) | |
} | |
exports.describe = describe | |
function deserialize (state, recursor) { | |
return new DeserializedArgumentsValue(state, recursor) | |
} | |
exports.deserialize = deserialize | |
const tag = Symbol('ArgumentsValue') | |
exports.tag = tag | |
class ArgumentsValue extends object.ObjectValue { | |
compare (expected) { | |
if (expected.isComplex !== true) return UNEQUAL | |
// When used on the left-hand side of a comparison, argument values may be | |
// compared to arrays. | |
if (expected.stringTag === 'Array') return AMBIGUOUS | |
return super.compare(expected) | |
} | |
} | |
Object.defineProperty(ArgumentsValue.prototype, 'tag', { value: tag }) | |
const DescribedArgumentsValue = object.DescribedMixin(ArgumentsValue) | |
class DeserializedArgumentsValue extends object.DeserializedMixin(ArgumentsValue) { | |
compare (expected) { | |
// Deserialized argument values may only be compared to argument values. | |
return expected.isComplex === true && expected.stringTag === 'Array' | |
? UNEQUAL | |
: super.compare(expected) | |
} | |
} |