This package has been deprecated

    Author message:

    Deprecated, not maintained

    hackee
    TypeScript icon, indicating that this package has built-in type declarations

    3.2.2 • Public • Published

    hackee

    Module to build node.js configuration using files, environment variables and command line arguments

    require("hackee")

    Motivation: I'd like to not use relative path to require configuration

    Examples:

    • javascript

      const assert = require('assert')
      const hackee = require('hackee')
       
      process.env['a'] = 'one' // argv: --a=one
      process.env['b#c'] = '2' // argv: --b#c=2
      process.env['d#e[0]'] = 'true' // argv: --d#e[0]=true
       
      const config = hackee({
        a: undefined,
        b: { c: undefined },
        d: { e: [undefined] }
      })
    • typescript

      import * as assert from 'assert'
      import * as hackee from 'hackee'
       
      process.env['a'] = 'one' // argv: --a=one
      process.env['b#c'] = '2' // argv: --b#c=2
      process.env['d#e[0]'] = 'true' // argv: --d#e[0]=true
       
      interface Config extends hackee.Hackee {
        a: string;
        b: { c: number; };
        d: { e: boolean[]; };
        f: { g: number; };
        h: { i: boolean[]; };
      }
       
      const config = hackee<Config>({
        a: undefined,
        b: { c: undefined },
        d: { e: [undefined] }
      })
    • test:

      assert(config.a === 'one')
      assert(config.b.c === 2)
      assert(config.d.e[0] === true)
      assert(hackee.a === 'one')
      assert(hackee.b.c === 2)
      assert(hackee.d.e[0] === true)
       
      assert(config.set('f.g', 3) === 3)
      assert(config.get('f.g') === 3)
      assert(hackee.f.g === 3)
      assert(config.setIndexOf('h.i', 0, false) === false)
      assert(config.getIndexOf('h.i', 0) === false)
      assert(hackee.h.i[0] === false)
      assert(hackee.set('f.g', 4) === 4)
      assert(hackee.get('f.g') === 4)
      assert(config.f.g === 4)
      assert(hackee.setIndexOf('h.i', 0, true) === true)
      assert(hackee.getIndexOf('h.i', 0) === true)
      assert(config.h.i[0] === true)
       
      assert(config.a === hackee.a)
      assert.deepStrictEqual(config.b, hackee.b)
      assert.deepStrictEqual(config.d, hackee.d)
      assert.deepStrictEqual(config.f, hackee.f)
      assert.deepStrictEqual(config.h, hackee.h)

    Install

    npm i hackee

    DownloadsWeekly Downloads

    18

    Version

    3.2.2

    License

    ISC

    Unpacked Size

    43 kB

    Total Files

    33

    Last publish

    Collaborators

    • avatar