alias-keys

    1.0.4 • Public • Published

    alias-keys

    npm package

    A simple method for aliasing values in objects

    Usage

    First, install the package and add it to your dependencies.

    $ npm install alias-keys

    Then, require the module within your project,

    const { alias } = require('alias-keys');

    and create an object with alias keys in an aliases array property of the corresponding value.

    let object = {
      'javascript': {
        fileExtension: '.js',
        aliases: ['js']
      },
      'c-sharp': {
        fileExtension: '.cs',
        aliases: ['c#']
      }
    }
     
    console.log(alias(object)('javascript'))
    // -> { fileExtension: '.js', aliases: ['js'] }
     
    console.log(alias(object)('js'))
    // -> { fileExtension: '.js', aliases: ['js'] }

    Keywords

    Install

    npm i alias-keys

    DownloadsWeekly Downloads

    3

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    1.66 kB

    Total Files

    3

    Last publish

    Collaborators

    • jajaperson