@tiaanduplessis/sizeof
v1.0.0
Published
Get approximate size of literal or variable in bytes
Downloads
3
Maintainers
Readme
@tiaanduplessis/sizeof
Get approximate size of literal or variable in bytes
Table of Contents
Install
This project uses node and npm.
$ npm install @tiaanduplessis/sizeof
$ # OR
$ yarn add @tiaanduplessis/sizeof
Usage
const sizeof = require('@tiaanduplessis/sizeof')
sizeof(1) // 8
sizeof('hello') // 10
sizeof(true) // 4
sizeof({
foo: 1,
bar: 1,
baz: {
yes: true,
foo: {
hello: 'world'
}
}
}) // 30
const m = new Map()
const s = new Set()
m.set('foo', 'foo').set('bar', 9)
s.add('true').add('false').add(1)
sizeof({
foo: 'true',
m,
s
}) // 48
Contribute
- Fork it and create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request
License
MIT