| ; | |
| var createNode = require('../doc/createNode.js'); | |
| var stringifyPair = require('../stringify/stringifyPair.js'); | |
| var addPairToJSMap = require('./addPairToJSMap.js'); | |
| var identity = require('./identity.js'); | |
| function createPair(key, value, ctx) { | |
| const k = createNode.createNode(key, undefined, ctx); | |
| const v = createNode.createNode(value, undefined, ctx); | |
| return new Pair(k, v); | |
| } | |
| class Pair { | |
| constructor(key, value = null) { | |
| Object.defineProperty(this, identity.NODE_TYPE, { value: identity.PAIR }); | |
| this.key = key; | |
| this.value = value; | |
| } | |
| clone(schema) { | |
| let { key, value } = this; | |
| if (identity.isNode(key)) | |
| key = key.clone(schema); | |
| if (identity.isNode(value)) | |
| value = value.clone(schema); | |
| return new Pair(key, value); | |
| } | |
| toJSON(_, ctx) { | |
| const pair = ctx?.mapAsMap ? new Map() : {}; | |
| return addPairToJSMap.addPairToJSMap(ctx, pair, this); | |
| } | |
| toString(ctx, onComment, onChompKeep) { | |
| return ctx?.doc | |
| ? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep) | |
| : JSON.stringify(this); | |
| } | |
| } | |
| exports.Pair = Pair; | |
| exports.createPair = createPair; | |
Xet Storage Details
- Size:
- 1.23 kB
- Xet hash:
- 66f29661c57321a83281e776883fe9fb544bc97b45d17dc3dfd2db3ed235f4c7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.