Simple library to find the smallest power of 2 with magnitude greater than or equal to input, unless 0.
No non-dev dependencies.
npm install --save smallest-power-of-two
# Or yarn
yarn add smallest-power-of-two
# Alternatively, install from Github directly
npm install --save cinderblock/smallest-power-of-two// const smallestPowerOfTwo = require('smallest-power-of-two').default;
import smallestPowerOfTwo from 'smallest-power-of-two';
smallestPowerOfTwo(1); // 1
smallestPowerOfTwo(2); // 2
smallestPowerOfTwo(3); // 4
smallestPowerOfTwo(4); // 4
smallestPowerOfTwo(5); // 8
// 0 is special
smallestPowerOfTwo(0); // 0
// Negative numbers work too!
smallestPowerOfTwo(-5); // -8Assumes VS Code. Insignificant errors if not.
npm inpm testThis will run the jest test suite.
Ensure code is formatted with our style.
npm run formatThis is generally unnecessary with "Format On Save" features of most editors. VS Code should work immediately.
Start a repl with functions smallestPowerOfTwo loaded into the running context.
npm run replJust run any single npm/yarn version command.
# Any of these work. Other variations work too.
npm version major
yarn version
yarn version --minorThis will automatically run prettier and tests, ensure git worktree is clean, update version number, git commit and tag, build, publish, and git push to origin in a single command.
Build ES3 and .d.ts files from source.
Done automatically before publishing.
Useful for finding bugs in code before committing.
npm run build- Export modules
- Npm@7