1.0.1 • Published 2 years ago

nv-arg-basic v1.0.1

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

nv-arg-basic

  • nv-arg-basic
  • util for build single-param function-params

install

  • npm install nv-arg-basic

usage

  const {creat_paramd,creat_ctx,creat_onetime_ctx} = require("nv-arg-basic");

example

PARAMD

        var paramd = creat_paramd()

        > paramd.a = 100
        100
        > paramd.b = 200
        200
        > paramd["...args"] = [300,400,500]
        [ 300, 400, 500 ]
        >

        > paramd.json()
        { a: 100, b: 200, args: _RestElement(3) [ 300, 400, 500 ] }
        >

        > console.log(paramd.argufy())
        (a,b,...args)
        >

        > console.log(paramd.letify('ctx'))
        let {a,b,args} = ctx;

        > console.log(paramd.funcify())
        function func (a,b,...args) {}




        > paramd.reset()
        > paramd.json()
        { a: undefined, b: undefined, args: undefined }

CTX PARAMD + COMPLETION

    var ctx = creat_ctx()
    > ctx.a =100
    100
    > ctx.b =100
    100
    > ctx["...args"] = [300,400,500]
    [ 300, 400, 500 ]
    >

    /*
    > console.log(ctx.funcify())

    function func (ctx) {
        let {a,b,args} = ctx;;
        ////<your-code>
        ////</your-code>
        return(ctx)
    }

    undefined

    */


    > ctx.params_
    { a: 100, b: 100, args: _RestElement(3) [ 300, 400, 500 ] }
    >
    > ctx.is_rtrned()
    false
    > ctx.completion()
    { rslt: _Pending [pending] {}, err: _Pending [pending] {} }
    >
    >

    > ctx.rtrn('succ')

    > ctx.is_rtrned()
    true
    > ctx.completion()
    { rslt: 'succ', err: null }
    >

    > ctx.reset_completion()

    > ctx.completion()
    { rslt: _Pending [pending] {}, err: _Pending [pending] {} }
    >

    > ctx.params_
    { a: 100, b: 100, args: _RestElement(3) [ 300, 400, 500 ] }
    >
    > ctx.is_thrwed()
    true
    >
    > ctx.completion()
    {
      rslt: null,
      err: Error: err
          at REPL54:1:10
          at Script.runInThisContext (node:vm:129:12)
          at REPLServer.defaultEval (node:repl:562:29)
          at bound (node:domain:421:15)
          at REPLServer.runBound [as eval] (node:domain:432:12)
          at REPLServer.onLine (node:repl:889:10)
          at REPLServer.emit (node:events:402:35)
          at REPLServer.emit (node:domain:475:12)
          at REPLServer.Interface._onLine (node:readline:487:10)
          at REPLServer.Interface._line (node:readline:864:8)
    }


    > ctx.reset()
    > ctx.params_
    { a: undefined, b: undefined, args: undefined }
    > ctx.completion()
    { rslt: _Pending [pending] {}, err: _Pending [pending] {} }
    >

ONE-TIME-CTX CTX CANT BE RESETED

    var ctx = creat_onetime_ctx()
    ctx.a =100
    ctx.b =100
    ctx["...args"] = [300,400,500]

    > ctx.rtrn(999)
    > ctx.rtrn(999)
    Uncaught 'is_already_fullfilled'
    >

    > ctx.reset()
    Uncaught 'unreachable'
    >

METHODS

PARAMD

    paramd.json
    paramd.reset

    paramd.argufy
    paramd.letify
    paramd.funcify

CTX

 ctx.argufy
 ctx.letify
 ctx.funcify

 ctx.params_
 ctx.rslt_
 ctx.exception_
 ctx.completion


 ctx.is_pending
 ctx.is_rtrned
 ctx.is_thrwed

 ctx.rtrn
 ctx.thrw

 ctx.reset
 ctx.reset_args
 ctx.reset_completion

API

    {
      creat_paramd: [Function: creat_paramd],
      creat_ctx: [Function: creat_ctx],
      creat_onetime_ctx: [Function: creat_onetime_ctx],
      base: {
        NO_ENUM_PREFIX_SET: Set(1) { '#' },
        _list_enum_props: [Function: _list_enum_props],
        _is_enum_prop: [Function: _is_enum_prop],
        _R: Object [Reflect] {},
        _is_rest_prop: [Function: _is_rest_prop],
        _fmt_prop: [Function: _fmt_prop],
        _RestElement: [class _RestElement extends Array],
        _PD: { get: [Function: get], set: [Function: set] },
        Base: [class Base],
        creat_base: [Function: creat_base]
      }
    }

LICENSE

  • ISC