Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enum

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enum - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

enum-0.2.3.js

36

lib/enum.js

@@ -100,3 +100,3 @@ (function (root, module, global, define) {

for (var member in map) {
if ((this._options.name && member === 'name') || member === '_options' || member === 'get' || member === 'getKey' || member === 'getValue' || member === 'enums') {
if ((this._options.name && member === 'name') || member === '_options' || member === 'get' || member === 'getKey' || member === 'getValue' || member === 'enums' || member === 'isFlaggable') {
throw new Error('Enum key "' + member + '" is a reserved word!');

@@ -111,2 +111,17 @@ }

}
var self = this;
function isFlaggable() {
for (var i = 0, len = self.enums.length; i < len; i++) {
var e = self.enums[i];
if (!((e.value !== 0) && !(e.value & (e.value - 1)))) {
return false;
}
}
return true;
}
this.isFlaggable = isFlaggable();
}

@@ -177,11 +192,14 @@

var result = null;
for (var n in this) {
if (this.hasOwnProperty(n)) {
if ((key & this[n].value) !== 0) {
if (result) {
result += this._options.separator;
} else {
result = '';
if (this.isFlaggable) {
for (var n in this) {
if (this.hasOwnProperty(n)) {
if ((key & this[n].value) !== 0) {
if (result) {
result += this._options.separator;
} else {
result = '';
}
result += n;
}
result += n;
}

@@ -188,0 +206,0 @@ }

{
"author": "adrai",
"name": "enum",
"version": "0.2.2",
"version": "0.2.3",
"private": false,

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -15,4 +15,4 @@ # Introduction

|:------------|:----------------|:---------|
| `enum-0.2.2.js` | *uncompressed, with comments* | [Download](https://raw.github.com/adrai/enum/master/enum-0.2.2.js) |
| `enum-0.2.2.min.js` | *compressed, without comments* | [Download](https://raw.github.com/adrai/enum/master/enum-0.2.2.min.js) |
| `enum-0.2.3.js` | *uncompressed, with comments* | [Download](https://raw.github.com/adrai/enum/master/enum-0.2.3.js) |
| `enum-0.2.3.min.js` | *compressed, without comments* | [Download](https://raw.github.com/adrai/enum/master/enum-0.2.3.min.js) |

@@ -112,3 +112,3 @@ # Installation (node.js)

myItem.valueOf() // returns A | C
JSON.stringify(myItem) // returns A | C

@@ -115,0 +115,0 @@

@@ -299,4 +299,50 @@ var expect = expect || require('expect.js'),

describe('beeing flagged', function() {
var myFlaggedEnum;
before(function() {
myFlaggedEnum = new e({'A': 1, 'B': 2, 'C': 4});
});
it('it should not get the flagged value', function() {
expect(myFlaggedEnum.get(1).is(myFlaggedEnum.A));
expect(myFlaggedEnum.get(2).is(myFlaggedEnum.B));
expect(myFlaggedEnum.get(3).is('B | B2'));
});
});
describe('not beeing flagged', function() {
var myFlaggedEnum;
before(function() {
myFlaggedEnum = new e({'A': 1, 'B': 2, 'B2': 3, 'C': 4});
});
it('it should not get the flagged value', function() {
expect(myFlaggedEnum.get(1).is(myFlaggedEnum.A));
expect(myFlaggedEnum.get(2).is(myFlaggedEnum.B));
expect(myFlaggedEnum.get(3).is(myFlaggedEnum.B2));
});
describe('getting a non matching value', function() {
it('it should return undefined', function() {
expect(myFlaggedEnum.get(5)).to.not.be.ok();
});
});
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc