nv-string-size
v1.0.4
Published
nv-string-size ======================= - same as String'length , But with more info - String'length is very boring
Downloads
6
Readme
nv-string-size
- same as String'length , But with more info
- String'length is very boring
install
- npm install nv-string-size
usage
const { size} = require("nv-string-size");
example
0
var s =`\x00 \b\t\n\f\r ' " \\ a \xff 我 𝑒`;
var sz = size(s);
console.log(sz)
Size {
nul: 1,
btnfr_esc_q: 7,
_1to7_11_14to31: 0,
_32_33_35to38: 8,
sq: 1,
_40to91_93to127: 1,
_128to255: 1,
_256to2047: 0,
_2048to55295: 1,
hi: 1,
lo: 1,
_57344to65535: 0
}
/*
> sz.u81
18
> sz.u82
1
> sz.u83
1
> sz.u84
1
> sz.u8_blen
27
>
> Buffer.from(s).length
27
>
> sz.is_u813_only ()
false
> sz.is_u81_only()
false
>
*/
/*
> sz.latin1
19
>
*/
/*
sz.u16_2
sz.u16_4
sz.is_perfect_u16()
*/
/*
> sz.is_perfect_json()
false
> sz.json_slen
34
>
> JSON.stringify(s)
`"\\u0000 \\b\\t\\n\\f\\r ' \\" \\\\ a ÿ 我 𝑒"`
>
> JSON.stringify(s).length -2
34
>
> sz.json_blen
39
> Buffer.from(JSON.stringify(s)).length -2
39
>
*/
/*
sz.is_valid_pg()
false //coz has \x00
*/
/*
> s="a ' b"
"a ' b"
>
> sz = size(s)
Size {
nul: 0,
btnfr_esc_q: 0,
_1to7_11_14to31: 0,
_32_33_35to38: 2,
sq: 1,
_40to91_93to127: 2,
_128to255: 0,
_256to2047: 0,
_2048to55295: 0,
hi: 0,
lo: 0,
_57344to65535: 0
}
>
> sz.is_perfect_pg() // coz has '
false
> sz.pg_blen
6
> sz.pg_slen
6
>
*/
/*
*/
METHODS
sz.is_perfect_json sz.is_perfect_pg sz.is_perfect_u16 sz.is_u813_only sz.is_u81_only
sz.is_valid_pg sz.json_blen sz.json_slen sz.latin1 sz.pg_blen sz.pg_slen
sz.u16_2 sz.u16_4 sz.u81 sz.u82 sz.u83 sz.u84
sz.u8_blen
sz._128to255 sz._1to7_11_14to31 sz._2048to55295 sz._256to2047 sz._32_33_35to38 sz._40to91_93to127
sz._57344to65535 sz.btnfr_esc_q sz.hi sz.lo sz.nul sz.sq
APIS
{
size: [Function: size],
patch: [Function: patch],
depatch: [Function: depatch]
}
LICENSE
- ISC