Last active
July 12, 2017 18:10
-
-
Save binki/c75c9387f616ad6f6bda20d4afe1f7fa to your computer and use it in GitHub Desktop.
Subtle behavior change in primitive-enum with Enum.defaultArrayTransform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
if (process.env.different === '1') { | |
require('./mod2'); | |
} | |
const mod1 = require('./mod1'); | |
const mod2 = require('./mod2'); | |
console.log(mod1.enum1+''); | |
console.log(mod2.enum2+''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Enum = require('primitive-enum'); | |
module.exports.enum1 = Enum(['a', 'b', 'c']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Enum = require('primitive-enum'); | |
Enum.defaultArrayTransform = Enum.identity; | |
module.exports.enum2 = Enum(['z', 'y', 'x']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ohnob@DESKTOP-A4G2C0J MSYS ~/repos/primitive-enum-play | |
$ /c/Program\ Files/Node.js_64_bit-6.10.3/node index.js | |
[Function: PrimitiveEnum] a,b,c|1,2,3|0 | |
[Function: PrimitiveEnum] z,y,x|z,y,x|0 | |
ohnob@DESKTOP-A4G2C0J MSYS ~/repos/primitive-enum-play | |
$ DIFFERENT=1 /c/Program\ Files/Node.js_64_bit-6.10.3/node index.js | |
[Function: PrimitiveEnum] a,b,c|a,b,c|0 | |
[Function: PrimitiveEnum] z,y,x|z,y,x|0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "primitive-enum-play", | |
"dependencies": { | |
"primitive-enum": "^0.9.6" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
evan-king/node-primitive-enum#5