- 馃挬 npm:qs
- 馃挬 npm:query-string
- 馃挬 鈽笍 npm:querystring
- 馃挬
鈿狅笍 npm:search
Last active
June 12, 2024 23:01
-
-
Save metaory/9a7980d7a51cb76a711339db29721cd9 to your computer and use it in GitHub Desktop.
Pure Web API URL Query Strings
This file contains hidden or 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
const { log, assert } = console | |
// with only primitives: string number bigint boolean undefined symbol null | |
const data = { | |
cipher: '1eV6syzW', | |
engine: 'V8', | |
lexer: 'doctrine', | |
relay: null, | |
seed: 1710396609.2115135, | |
space: 'lab-d65', | |
tag: true, | |
token: 'Identifier', | |
} | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
const qs = new URLSearchParams(data).toString() | |
log('qs', '::', qs) | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
const parsed = Object.fromEntries(new URLSearchParams(qs).entries()) | |
log('parsed.space', '::', parsed.space) // lab-d65 | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
assert(parsed.space === 'lab-d65', '[FAILED]') |
This file contains hidden or 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
const { log, assert } = console | |
const data = { | |
cipher: '1eV6syzW', | |
engine: 'V8', | |
total: true, | |
resources: ['base.js'], | |
jobs: [ | |
{ | |
name: 'Proxies', | |
path: ['Proxies'], | |
main: 'run.js', | |
engine: 'V8', | |
tests: [{ name: 'GetStringWithoutTrap' }, { name: 'GetStrin' }], | |
}, | |
{ | |
vec: 991383901, | |
importance: 8.7, | |
cycle: { | |
distance: [true, -1259037374, { standard: false, or: 'purpose' }, 'wind'], | |
phrase: -274093901, | |
discover: 736843873.0780926, | |
token: 'Identifier', | |
}, | |
}, | |
], | |
count: 358638932.34953165, | |
void: ['realize', true, 268857211.96555376], | |
} | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
const qs = new URLSearchParams({ data: JSON.stringify(data) }).toString() | |
log('qs', '::', qs) | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
const res = Object.fromEntries(new URLSearchParams(qs).entries()) | |
log('res', '::', res) | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
const parsed = JSON.parse(res.data) | |
log('parsed', '::', parsed) | |
// 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 路 | |
assert(parsed.jobs[0].name === 'Proxies', '[FAILED]') |
This file contains hidden or 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
import querystring from 'node:querystring' | |
/* TODO: ? | |
querystring.decode() | |
querystring.encode() | |
querystring.escape(str) | |
querystring.parse(str[, sep[, eq[, options]]]) | |
querystring.stringify(obj[, sep[, eq[, options]]]) | |
querystring.unescape(str) | |
*/ | |
// WebAPI > Node ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment