@abcnews/base-36-props 中文文档教程
base-36-props
用于将 JavaScript 对象编码/解码为 base36 字符串的工具。
Usage
As a CLI
使用 npm i -g @abcnews/base-36-props
全局安装以使用 b36p
可执行文件,或使用 npx:
npx @abcnews/base-36-props encode '{ x: [true, 1, "1", null] }'
> 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
npx @abcnews/base-36-props decode 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
> { x: [true, 1, '1', null] }
As a library (node or browser)
npm i @abcnews/base-36-props
import { encode, decode } from '@abcnews/base-36-props';
encode({ x: [true, 1, '1', null] });
// > 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
decode('3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd');
// > { x: [ true, 1, '1', null ] }
此项目包含一个浏览器使用示例。 尝试一下:
git clone https://github.com/abcnews/base-36-props
cd base-36-props
npm run example
...然后在打开的浏览器窗口中打开控制台,然后尝试 b36p.encode()
和 b36p.decode()
。
Hosted tool
base-36-props
Tools for encoding / decoding JavaScript objects to / from base36 strings.
Usage
As a CLI
Install globally with npm i -g @abcnews/base-36-props
to use the b36p
executable, or use npx:
npx @abcnews/base-36-props encode '{ x: [true, 1, "1", null] }'
> 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
npx @abcnews/base-36-props decode 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
> { x: [true, 1, '1', null] }
As a library (node or browser)
npm i @abcnews/base-36-props
import { encode, decode } from '@abcnews/base-36-props';
encode({ x: [true, 1, '1', null] });
// > 3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd
decode('3zo7wx3dtlini74hp4rl9mo1n8ns65v1mkcd');
// > { x: [ true, 1, '1', null ] }
A browser usage example is included with this project. To try it:
git clone https://github.com/abcnews/base-36-props
cd base-36-props
npm run example
…then open the console in the browser window that opens, and try out b36p.encode()
and b36p.decode()
.
Hosted tool
A standalone web-based converter is also available here.