Comparing version 2.3.0 to 2.4.0
@@ -11,6 +11,11 @@ "use strict"; | ||
var isString = require("./isType").isString; | ||
var _isType = require("./isType"); | ||
var isString = _isType.isString; | ||
var isNumber = _isType.isNumber; | ||
var indexOf = require("./indexOf").indexOf; | ||
var isBuffer = _interopRequire(require("is-buffer")); | ||
var endianness = os.endianness(); | ||
@@ -135,3 +140,3 @@ | ||
} // Buffer instance support, part of the ref Type interface | ||
if (Buffer.isBuffer(key)) { | ||
if (isBuffer(key)) { | ||
key = key["readUInt32" + this._options.endianness](offset || 0); | ||
@@ -271,2 +276,20 @@ } | ||
/** | ||
* Return true whether the enumItem parameter passed in is an EnumItem object and | ||
* has been included as constant of this Enum | ||
* @param {EnumItem} enumItem | ||
*/ | ||
Enum.prototype.isDefined = function isDefined(enumItem) { | ||
var condition = function (e) { | ||
return e === enumItem; | ||
}; | ||
if (isString(enumItem) || isNumber(enumItem)) { | ||
condition = function (e) { | ||
return e.is(enumItem); | ||
}; | ||
} | ||
return this.enums.some(condition); | ||
}; | ||
/** | ||
* Returns JSON object representation of this Enum. | ||
@@ -273,0 +296,0 @@ * @return {String} JSON object representation of this Enum. |
@@ -15,2 +15,6 @@ "use strict"; | ||
}; | ||
exports.isString = isString; | ||
exports.isString = isString; | ||
var isNumber = function (value) { | ||
return isType("number", value); | ||
}; | ||
exports.isNumber = isNumber; |
{ | ||
"author": "adrai", | ||
"name": "enum", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"private": false, | ||
@@ -13,3 +13,5 @@ "main": "index.js", | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"is-buffer": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -16,0 +18,0 @@ "expect.js": ">= 0.1.2", |
@@ -24,4 +24,4 @@ # Introduction | ||
|:------------|:----------------|:---------| | ||
| `enum-2.2.0.js` | *uncompressed, with comments* | [Download](https://raw.github.com/adrai/enum/master/enum-2.2.0.js) | | ||
| `enum-2.2.0.min.js` | *compressed, without comments* | [Download](https://raw.github.com/adrai/enum/master/enum-2.2.0.min.js) | | ||
| `enum-2.3.0.js` | *uncompressed, with comments* | [Download](https://raw.github.com/adrai/enum/master/enum-2.3.0.js) | | ||
| `enum-2.3.0.min.js` | *compressed, without comments* | [Download](https://raw.github.com/adrai/enum/master/enum-2.3.0.min.js) | | ||
@@ -154,5 +154,2 @@ # Installation (node.js) | ||
// or | ||
myEnum.A == 'A' | ||
// or | ||
myEnum.A == myEnum.A | ||
@@ -159,0 +156,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
4
72838
1
967
225
+ Addedis-buffer@^1.1.0
+ Addedis-buffer@1.1.6(transitive)