enumerated-type
Advanced tools
Comparing version 0.5.16 to 0.5.18
56
index.js
@@ -169,5 +169,5 @@ 'use strict'; | ||
if (displayKeyName !== UNDEFINED) { | ||
dropdownValues.push({value:value[keyName], label: value[displayKeyName]}) | ||
dropdownValues.push({value: value[keyName], label: value[displayKeyName]}); | ||
} else { | ||
dropdownValues.push({value:value[keyName], label: name }) | ||
dropdownValues.push({value: value[keyName], label: name}); | ||
} | ||
@@ -184,5 +184,5 @@ } else { | ||
if (displayKeyName !== UNDEFINED) { | ||
dropdownValues.push({value:value, label: value[displayKeyName]}) | ||
dropdownValues.push({value: value, label: value[displayKeyName]}); | ||
} else { | ||
dropdownValues.push({value:value, label: name }) | ||
dropdownValues.push({value: value, label: name}); | ||
} | ||
@@ -241,2 +241,26 @@ } | ||
if (keyName !== UNDEFINED) { | ||
Object.defineProperty(this, 'dropdownChoicesExcluding', { | ||
value: function () { | ||
if (arguments.length === 0) return dropdownValues; | ||
let result = []; | ||
const exclude = {}; | ||
forEach.call(arguments, (arg) => { | ||
const item = this.value(arg); | ||
if (item) exclude[item[keyName]] = true; | ||
}); | ||
forEach.call(dropdownValues, (item) => { | ||
if (!exclude.hasOwnProperty(item.value)) { | ||
result.push(item); | ||
} | ||
}); | ||
return result; | ||
}, | ||
writable: false, | ||
enumerable: true, | ||
}); | ||
const enumKeys = enumValues.map(value => value[keyName]); | ||
@@ -275,2 +299,26 @@ Object.freeze(enumKeys); | ||
} else { | ||
Object.defineProperty(this, 'dropdownChoicesExcluding', { | ||
value: function () { | ||
if (arguments.length === 0) return dropdownValues; | ||
let result = []; | ||
const exclude = {}; | ||
forEach.call(arguments, (arg) => { | ||
const item = this.value(arg); | ||
if (item) exclude[item.value] = true; | ||
}); | ||
forEach.call(dropdownValues, (item) => { | ||
if (!exclude.hasOwnProperty(item.value)) { | ||
result.push(item); | ||
} | ||
}); | ||
return result; | ||
}, | ||
writable: false, | ||
enumerable: true, | ||
}); | ||
const enumKeys = enumValues.map(value => value.value); | ||
@@ -277,0 +325,0 @@ Object.defineProperty(this, 'keys', { |
{ | ||
"name": "enumerated-type", | ||
"version": "0.5.16", | ||
"version": "0.5.18", | ||
"description": "enum type for javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,3 @@ # Version History | ||
- [0.5.18](#0518) | ||
- [0.5.16](#0516) | ||
@@ -21,2 +22,7 @@ - [0.5.14](#0514) | ||
## 0.5.18 | ||
* Add: `dropdownChoicesExcluding(vararg exclude)` to return choices array but without the | ||
choices for the given enum items in the choice list | ||
## 0.5.16 | ||
@@ -23,0 +29,0 @@ |
26387
335