Created
July 14, 2014 12:28
-
-
Save dgmike/ce3eb0205d1077c098d1 to your computer and use it in GitHub Desktop.
node: creating an object of constants and extending it
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
| "use strict"; | |
| var status, status_type; | |
| status = { | |
| OFFLINE: 0, | |
| ONLINE: 1 | |
| }; | |
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze | |
| status_type = Object.freeze(status); | |
| export.status_type = status_type; |
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
| var _, status_type, status_type_intermetent; | |
| _ = require('lodash'); // only for help pourpose | |
| status_type = require('./status_type'); | |
| // status_type = { OFFLINE: 0, ONLINE: 1, CONNECTING: 2 } | |
| status_type_intermetent = Object.freeze( | |
| _.extend( | |
| _.clone(status_type), | |
| { CONNECTING: 2 } | |
| ) | |
| ); | |
| export.status_type_intermetent = status_type_intermetent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment