Comparing version 0.1.0 to 0.2.0
@@ -1,2 +0,2 @@ | ||
const e=new Proxy({},{get:(e,r)=>r}),r=new Proxy({},{get:(e,r)=>r.toLowerCase()}),o=e=>{const r=[...Array(e).keys()];return new Proxy({},{get:(e,o)=>(r.push(o),r.indexOf(o))})},t=o(0),n=new Proxy({},{get:(e,r)=>Symbol(r)}),y={String:e,StringLower:r,Numeric:t,NumericAt:o,Symbol:n};export{t as Numeric,o as NumericAt,e as String,r as StringLower,n as Symbol,y as default}; | ||
const r=(r,t=0)=>{let e=t;const n={get(t,o){if("String"===r)return o;if("Numeric"===r){const r=e;return e++,r}return"Symbol"===r?Symbol(o):new Proxy({},n)}};return new Proxy({},n)};var t={String:()=>r("String"),Numeric:(t=0)=>r("Numeric",t),Symbol:()=>r("Symbol")};export{t as default}; | ||
//# sourceMappingURL=enum-xyz.modern.js.map |
@@ -1,2 +0,2 @@ | ||
var r=new Proxy({},{get:function(r,n){return n}}),n=new Proxy({},{get:function(r,n){return n.toLowerCase()}}),e=function(r){var n=[].concat(Array(r).keys());return new Proxy({},{get:function(r,e){return n.push(e),n.indexOf(e)}})},t=e(0),o=new Proxy({},{get:function(r,n){return Symbol(n)}}),u={String:r,StringLower:n,Numeric:t,NumericAt:e,Symbol:o};export{t as Numeric,e as NumericAt,r as String,n as StringLower,o as Symbol,u as default}; | ||
var r=function(r,n){void 0===n&&(n=0);var t=n,u={get:function(n,e){if("String"===r)return e;if("Numeric"===r){var i=t;return t++,i}return"Symbol"===r?Symbol(e):new Proxy({},u)}};return new Proxy({},u)},n={String:function(){return r("String")},Numeric:function(n){return void 0===n&&(n=0),r("Numeric",n)},Symbol:function(){return r("Symbol")}};export{n as default}; | ||
//# sourceMappingURL=enum-xyz.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).enumXyz={})}(this,function(e){var n=new Proxy({},{get:function(e,n){return n}}),t=new Proxy({},{get:function(e,n){return n.toLowerCase()}}),r=function(e){var n=[].concat(Array(e).keys());return new Proxy({},{get:function(e,t){return n.push(t),n.indexOf(t)}})},o=r(0),i=new Proxy({},{get:function(e,n){return Symbol(n)}}),u={String:n,StringLower:t,Numeric:o,NumericAt:r,Symbol:i};e.Numeric=o,e.NumericAt=r,e.String=n,e.StringLower=t,e.Symbol=i,e.default=u}); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n||self).enumXyz=e()}(this,function(){var n=function(n,e){void 0===e&&(e=0);var r=e,t={get:function(e,o){if("String"===n)return o;if("Numeric"===n){var i=r;return r++,i}return"Symbol"===n?Symbol(o):new Proxy({},t)}};return new Proxy({},t)};return{String:function(){return n("String")},Numeric:function(e){return void 0===e&&(e=0),n("Numeric",e)},Symbol:function(){return n("Symbol")}}}); | ||
//# sourceMappingURL=enum-xyz.umd.js.map |
{ | ||
"name": "enum-xyz", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "JavaScript enums using proxies.", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/chasefleming/enum-xyz", |
@@ -7,2 +7,6 @@ # enum-xyz | ||
[![ENUM-XYZ Continuous Integration](https://github.com/chasefleming/enum-xyz/actions/workflows/integrate.yml/badge.svg)](https://github.com/chasefleming/enum-xyz/actions/workflows/integrate.yml) | ||
> Note: This library is not yet at version 1.0.0. As such, breaking changes may occur in subsequent releases. Please ensure you read the release notes when updating. | ||
## Install | ||
@@ -16,52 +20,46 @@ | ||
### Strings | ||
### String Enums | ||
``` | ||
import Enum from 'enum-xyz' | ||
import Enum from "enum-xyz"; | ||
const { Summer, Autumn, Winter, Spring } = Enum.String | ||
const { Summer, Autumn, Winter, Spring } = Enum.String(); | ||
console.log(Summer) // 'Summer' | ||
console.log(Autumn) // 'Autumn' | ||
console.log(Winter) // 'Winter' | ||
console.log(Spring) // 'Spring' | ||
console.log(Summer); // Outputs: "Summer" | ||
console.log(Autumn); // Outputs: "Autumn" | ||
console.log(Winter); // Outputs: "Winter" | ||
console.log(Spring); // Outputs: "Spring" | ||
``` | ||
### Strings (lowercased) | ||
### Numeric Enums | ||
Starts from 0 by default: | ||
``` | ||
import Enum from 'enum-xyz' | ||
import Enum from "enum-xyz"; | ||
const { Summer, Autumn, Winter, Spring } = Enum.StringLower | ||
const { A, B, C, D } = Enum.Numeric(); | ||
console.log(Summer) // 'summer' | ||
console.log(Autumn) // 'autumn' | ||
console.log(Winter) // 'winter' | ||
console.log(Spring) // 'spring' | ||
console.log(A); // Outputs: 0 | ||
console.log(B); // Outputs: 1 | ||
console.log(C); // Outputs: 2 | ||
console.log(D); // Outputs: 3 | ||
``` | ||
### Numeric | ||
To start from a different index: | ||
``` | ||
import Enum from 'enum-xyz' | ||
const { A, B, C, D } = Enum.Numeric(5); | ||
console.log(A); // Outputs: 5 | ||
``` | ||
const { A, B, C, D } = Enum.Numeric | ||
### Symbol Enums | ||
console.log(A) // 0 | ||
console.log(B) // 1 | ||
console.log(C) // 2 | ||
console.log(D) // 3 | ||
``` | ||
import Enum from "enum-xyz"; | ||
### Numeric Starting at Index | ||
const { blue, red } = Enum.Symbol(); | ||
console.log(blue); // Outputs: Symbol(blue) | ||
console.log(red); // Outputs: Symbol(red) | ||
``` | ||
import Enum from 'enum-xyz' | ||
const { A, B, C, D } = Enum.NumericAt(1) | ||
console.log(A) // 1 | ||
console.log(B) // 2 | ||
console.log(C) // 3 | ||
console.log(D) // 4 | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9619
12
12
64