1.0.12 • Published 2 years ago

nv-cli-diject v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

nv-cli-diject

  • nv-cli-diject
  • cli tool, generate a object with normal-prop/getter/setter/method

install

  • npm install nv-cli-diject -g

usage

suffix AND simple-syntax

    nv-cli-diject# nv_cli_diject -f


    PROP FORMAT
    -----------

        <name>@<suffix>   .....

        <name>@gt
        <name>@st
        <name>@gtst
        <name>@method    param_name0 param_name1 param_name2 ....



    SUFFIX
    -------

        @gt    :   means getter
        @st    :   means setter
        @gtst  :   means getter AND setter
        @method:   means a  method-to-impl

    EXAMPLE
    -------

         nv_cli_diject -p a@gt b@st c@gtst  pub0 pub1

example

         nv_cli_diject -p a@gt b@st c@gtst  pub0 pub1   login@method

output

    //[ 'a', 'b', 'c', 'pub0', 'pub1', 'login' ]

    let d = {
        ["#a"]: undefined,
        ["#b"]: undefined,
        ["#c"]: undefined,
        ////

        get a()    {return(this["#a"])},


        set b(v)   {this["#b"]=v},


        get c()    {return(this["#c"])},
        set c(v)   {this["#c"]=v},

        ////
        pub0:undefined,
        pub1:undefined,
        ////
        login()    {/*impl*/},


    }
    //
    const _UNENUM = {enumerable:false}
    const OD = Object.defineProperty;
    ["#a","a","#b","b","#c","c"].forEach(prop=>{OD(d,prop,_UNENUM)});

copy AND paste it

    > d
    { pub0: undefined, pub1: undefined, login: [Function: login] }
    >
    > d.c=999
    999
    > d.c
    999
    >
    > d.pub0='ex0'
    'ex0'
    > d.pub1='ex1'
    'ex1'
    > d
    { pub0: 'ex0', pub1: 'ex1', login: [Function: login] }
    >
    > JSON.stringify(d)
    '{"pub0":"ex0","pub1":"ex1"}'
    >

LICENSE

  • ISC