Buckets:
ktongue/docker_container / .cache /opencode /node_modules /fast-json-stringify /test /surrogate.test.js
| const { test } = require('node:test') | |
| const validator = require('is-my-json-valid') | |
| const build = require('..') | |
| test('render a string with surrogate pairs as JSON:test 1', (t) => { | |
| t.plan(2) | |
| const schema = { | |
| title: 'surrogate', | |
| type: 'string' | |
| } | |
| const validate = validator(schema) | |
| const stringify = build(schema) | |
| const output = stringify('๐') | |
| t.assert.equal(output, '"๐"') | |
| t.assert.ok(validate(JSON.parse(output)), 'valid schema') | |
| }) | |
| test('render a string with surrogate pairs as JSON: test 2', (t) => { | |
| t.plan(2) | |
| const schema = { | |
| title: 'long', | |
| type: 'string' | |
| } | |
| const validate = validator(schema) | |
| const stringify = build(schema) | |
| const output = stringify('\uD834\uDF06') | |
| t.assert.equal(output, '"๐"') | |
| t.assert.ok(validate(JSON.parse(output)), 'valid schema') | |
| }) | |
| test('render a string with Unpaired surrogate code as JSON', (t) => { | |
| t.plan(2) | |
| const schema = { | |
| title: 'surrogate', | |
| type: 'string' | |
| } | |
| const validate = validator(schema) | |
| const stringify = build(schema) | |
| const output = stringify('\uDF06\uD834') | |
| t.assert.equal(output, JSON.stringify('\uDF06\uD834')) | |
| t.assert.ok(validate(JSON.parse(output)), 'valid schema') | |
| }) | |
| test('render a string with lone surrogate code as JSON', (t) => { | |
| t.plan(2) | |
| const schema = { | |
| title: 'surrogate', | |
| type: 'string' | |
| } | |
| const validate = validator(schema) | |
| const stringify = build(schema) | |
| const output = stringify('\uDEAD') | |
| t.assert.equal(output, JSON.stringify('\uDEAD')) | |
| t.assert.ok(validate(JSON.parse(output)), 'valid schema') | |
| }) | |
Xet Storage Details
- Size:
- 1.59 kB
- Xet hash:
- 3dce53f0a41cbb9b65166562bd3479d06ce2ffe6d29bdae11bfdcc293b9b8c5a
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.