Permalink
Cannot retrieve contributors at this time
51 lines (40 sloc)
1.26 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/boxed.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 stringPrimitive = require('../primitiveValues/string').tag | |
const recursorUtils = require('../recursorUtils') | |
const object = require('./object') | |
function describe (props) { | |
return new DescribedBoxedValue(props) | |
} | |
exports.describe = describe | |
function deserialize (state, recursor) { | |
return new DeserializedBoxedValue(state, recursor) | |
} | |
exports.deserialize = deserialize | |
const tag = Symbol('BoxedValue') | |
exports.tag = tag | |
class BoxedValue extends object.ObjectValue {} | |
Object.defineProperty(BoxedValue.prototype, 'tag', { value: tag }) | |
class DescribedBoxedValue extends object.DescribedMixin(BoxedValue) { | |
constructor (props) { | |
super(props) | |
this.unboxed = props.unboxed | |
} | |
createListRecursor () { | |
return recursorUtils.NOOP_RECURSOR | |
} | |
createPropertyRecursor () { | |
if (this.unboxed.tag !== stringPrimitive) return super.createPropertyRecursor() | |
// Just so that createPropertyRecursor() skips the index-based character | |
// properties. | |
try { | |
this.isList = true | |
return super.createPropertyRecursor() | |
} finally { | |
this.isList = false | |
} | |
} | |
createRecursor () { | |
return recursorUtils.unshift(super.createRecursor(), this.unboxed) | |
} | |
} | |
const DeserializedBoxedValue = object.DeserializedMixin(BoxedValue) |