Permalink
Cannot retrieve contributors at this time
40 lines (32 sloc)
1.03 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/promise.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 DEEP_EQUAL = constants.DEEP_EQUAL | |
const UNEQUAL = constants.UNEQUAL | |
function describe (props) { | |
return new DescribedPromiseValue(props) | |
} | |
exports.describe = describe | |
function deserialize (props) { | |
return new DeserializedPromiseValue(props) | |
} | |
exports.deserialize = deserialize | |
const tag = Symbol('PromiseValue') | |
exports.tag = tag | |
class PromiseValue extends object.ObjectValue {} | |
Object.defineProperty(PromiseValue.prototype, 'tag', { value: tag }) | |
class DescribedPromiseValue extends object.DescribedMixin(PromiseValue) { | |
compare (expected) { | |
// When comparing described promises, require them to be the exact same | |
// object. | |
return super.compare(expected) === DEEP_EQUAL | |
? DEEP_EQUAL | |
: UNEQUAL | |
} | |
} | |
class DeserializedPromiseValue extends object.DeserializedMixin(PromiseValue) { | |
compare (expected) { | |
// Deserialized promises can never be compared using object references. | |
return super.compare(expected) | |
} | |
} |