@gradecam/tsenum
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -18,2 +18,5 @@ /** | ||
* | ||
* You can also pass in multiple objects (or multiple enums created with this | ||
* helper) and the result will combine them with the actual value using Object.assign | ||
* | ||
* @param x Enum object to create a typed enum for | ||
@@ -20,0 +23,0 @@ */ |
@@ -1,6 +0,55 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function MakeEnum(...x) { | ||
return Object.freeze(Object.assign({}, ...x)); | ||
} | ||
exports.MakeEnum = MakeEnum; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var freeze = function freezeDefault(obj) { | ||
return Object.freeze.apply(Object, arguments); | ||
}; | ||
if (typeof Object.freeze !== 'function') { | ||
// Fallback in case Object.freeze isn't supported | ||
freeze = function (v) { return v; }; | ||
} | ||
// Object.assign polyfill taken from | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill | ||
if (typeof Object.assign !== 'function') { | ||
// Must be writable: true, enumerable: false, configurable: true | ||
Object.defineProperty(Object, "assign", { | ||
value: function assign(target, varArgs) { | ||
'use strict'; | ||
if (target === null || target === undefined) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var nextSource = arguments[index]; | ||
if (nextSource !== null && nextSource !== undefined) { | ||
for (var nextKey in nextSource) { | ||
// Avoid bugs when hasOwnProperty is shadowed | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
function MakeEnum() { | ||
var x = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
x[_i] = arguments[_i]; | ||
} | ||
return freeze(Object.assign.apply(Object, [{}].concat(x))); | ||
} | ||
exports.MakeEnum = MakeEnum; | ||
}); |
{ | ||
"name": "@gradecam/tsenum", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Super simple typescript library for string-compatible enums", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
9323
181