https://github.com/tiaanduplessis/sizeof
Get approximate size of literal or variable in bytes
https://github.com/tiaanduplessis/sizeof
memory sizeof
Last synced: 12 months ago
JSON representation
Get approximate size of literal or variable in bytes
- Host: GitHub
- URL: https://github.com/tiaanduplessis/sizeof
- Owner: tiaanduplessis
- License: mit
- Created: 2018-05-31T23:52:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T22:49:12.000Z (about 7 years ago)
- Last Synced: 2025-06-06T08:38:32.257Z (about 1 year ago)
- Topics: memory, sizeof
- Language: JavaScript
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @tiaanduplessis/sizeof
[](https://npmjs.org/package/@tiaanduplessis/sizeof)
[](https://npmjs.org/package/@tiaanduplessis/sizeof)
[](https://github.com/RichardLitt/standard-readme)
[](https://npmjs.org/package/@tiaanduplessis/sizeof)
[](http://makeapullrequest.com)
> Get approximate size of literal or variable in bytes
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)
## Install
This project uses [node](https://nodejs.org) and [npm](https://www.npmjs.com).
```sh
$ npm install @tiaanduplessis/sizeof
$ # OR
$ yarn add @tiaanduplessis/sizeof
```
## Usage
```js
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
1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature
4. Submit a pull request
## License
MIT