Some funny stuff ;)
convert your json into bytes.. !!
convert your json into bytes.. !!
This file contains 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 bytes = function(s) { | |
return ~-encodeURI(s).split(/%..|./).length | |
} | |
const jsonSize = function(s){ | |
return bytes(JSON.stringify(s)) | |
} | |
console.log(jsonSize({foo: 'bar'})) //=> 13 |
No comments:
Post a Comment