File: src/packages/common/components/core/Constant.js

Recommend this page to a friend!
  Classes of Alien Fernandez   Seed Sails Angular   src/packages/common/components/core/Constant.js   Download  
File: src/packages/common/components/core/Constant.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Seed Sails Angular
Full stack framework based on Sails, Node, Angular
Author: By
Last change: Update of src/packages/common/components/core/Constant.js
Date: 3 years ago
Size: 655 bytes
 

Contents

Class file image Download
/** * Constant class */ class Constant { constructor(enumLiterals) { for (let key in enumLiterals) { if (Object.is(enumLiterals[key], undefined)) { throw new Error('Each property should have at least one value'); } Object.defineProperty(this, key, { get: function () { if (Object.is(enumLiterals[key], Object)) { return Object.freeze(enumLiterals[key]); } return enumLiterals[key]; } }); } Object.freeze(this); } } export default Constant;