app-defines

    1.0.2 • Public • Published

    app-defines

    npm version npm license travis build

    const defines = require('app-defines');
     
    // Set all defines once for the lifetime of the process
    defines.someConstant = 42;
    defines.someOtherConstant = {luck: 'good'};
     
    // Finalize the defines
    defines.freeze();
     
    // Defines are now irreversibly read-only (including nested properties)
    defines.someOtherProperty.luck = 'bad'; // Throws TypeError
     
    // The read-only defines object can now be required from anywhere in the app

    The object is frozen with the technique used in deep-freeze.

    This module is rather trivial, but useful to have as an external module, so that the defines can be required from any file in the project without the need of relative requires.

    This module is intended for use in application code only and should not be used in dependencies!

    Keywords

    none

    Install

    npm i app-defines

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • tvdstaaij