smallest-power-of-two v1.2.7
smallest-power-of-two
Simple library to find the smallest power of 2 with magnitude greater than or equal to input, unless 0.
No non-dev dependencies.
Usage
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); // -8Development
Setup
Assumes VS Code. Insignificant errors if not.
npm iTesting
npm testThis will run the jest test suite.
Formatting
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.
REPL
Start a repl with functions smallestPowerOfTwo loaded into the running context.
npm run replVersioning and Publishing
Just 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
Build ES3 and .d.ts files from source.
Done automatically before publishing.
Useful for finding bugs in code before committing.
npm run buildChangelog
v1.2.0
- Export modules
- Npm@7
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
6 years ago
6 years ago
7 years ago
7 years ago