Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gabrieljmj/power2

Get what power two numbers has
https://github.com/gabrieljmj/power2

Last synced: about 2 months ago
JSON representation

Get what power two numbers has

Awesome Lists containing this project

README

        

power2
=======
Get what power two numbers has.

## Usage
For Node.JS:
```js
var Power2 = require('power2');
```
For HTML:
```html

```
### Basic
```js
console.log(Power2(50)); //32, 16, 2
```

### Util example
```js
var Person = {
Options: {
HAIR: 1
, MOUTH: 2
, EYES: 4
, NOSE: 8
}
, create: function (options) {
options = Power2(options);
var features = [];

if (options.contains(this.Options.HAIR)) {
features.push('HAIR');
}

if (options.contains(this.Options.MOUTH)) {
features.push('MOUTH');
}

if (options.contains(this.Options.EYES)) {
features.push('EYES');
}

if (options.contains(this.Options.NOSE)) {
features.push('NOSE');
}

return features;
}
}

var person = Person.create(Person.Options.HAIR | Person.Options.MOUTH | Person.Options.EYES);

Array.prototype.contains = function (value) {
for (var k in this) {
if (this[k] == value) {
return true;
}
}

return false;
}
```