nv-cli-gir-leaf0

1.0.17 • Public • Published

nv-cli-gir-leaf0

  • cli-tool
  • for creat l0 built-in api name compatible-with nvlang
  • leaf0 function NO need parser, all one-line, JUST str split IS OK
  • nvlang has a DSL-SERDE mode:
  • which NOT support infix operators, this is used to TEST this feature
    
  •     for creat SAFE subset of language AND 
    
  •          transer/save IN a special DATABSE  
    
  •             the DATABASE is a simplified-S-expression-flat-ast                               
    
  • normally USELESS

install

  • npm install nv-cli-gir-leaf0 -g

usage

    Usage: nv_cli_gir_leaf0 [options] 
    Options:
        -s, --slct        select and generate code
        -l, --list        list all l0 gir names
        -m, --mirr        name map mirror
        -h, --help        usage

example

select some

        nv-cli-gir-leaf0# node cli.js -s add sub mul div qr quo mod
        const _G = globalThis;
              _G._add = (a,b) => a+b;                              
              _G._sub = (a,b) => a-b;                              
              _G._mul = (a,b) => a*b;                              
              _G._div = (a,b) => a/b;                              
              _G._qr  = (a,b) => {let r=a%b;return([((a-r)/b),r])};
              _G._quo = (a,b) => (a-a%b)/b;                        
              _G._mod = (a,b) => a%b;                              
        nv-cli-gir-leaf0# 
        nv-cli-gir-leaf0# node cli.js -s not and or
        const _G = globalThis;
              _G._not  = (o)   => !o;              
              _G._bnot = (o)   => ~o;              
              _G._and  = (a,b) => a&&b;            
              _G._band = (a,b) => a&b;             
              _G._or   = (a,b) => a||b;            
              _G._xor  = (a,b) => (!a&&b)||(a&&!b);
              _G._bor  = (a,b) => a|b;             
              _G._bxor = (a,b) => a^b;             
        nv-cli-gir-leaf0# 


        nv-cli-gir-leaf0# nv_cli_gir_leaf0 -s intv
        const _G = globalThis;
              _G._clr_intvl = clearInterval;
              _G._set_intvl = setInterval;
        nv-cli-gir-leaf0# 

        nv-cli-gir-leaf0# nv_cli_gir_leaf0 -s un D
        const _G = globalThis;
              _G._un         = undefined;
              _G._html_unesc = unescape;
              _G._DT         = Date;
              _G._DV         = DataView;
              _G._TXTENCD    = TextEncoder;
              _G._TXTDECD    = TextDecoder;
        nv-cli-gir-leaf0# 
        nv-cli-gir-leaf0# nv_cli_gir_leaf0 -s un de
        const _G = globalThis;
              _G._un           = undefined;
              _G._html_unesc   = unescape;
              _G._decd_url     = decodeURI;
              _G._decd_url_com = decodeURIComponent;
        nv-cli-gir-leaf0# 
        nv-cli-gir-leaf0# nv_cli_gir_leaf0 -s f
        const _G = globalThis;
              _G._f       = false;
              _G._infi    = Infinity;
              _G._is_fin  = isFinite;
              _G._parse_f = parseFloat;
              _G._fs      = require("fs");
              _G._buf     = require("buffer");
        nv-cli-gir-leaf0# 	

all

    #nv_cli_gir_leaf0 -s


        const _G = globalThis;
              _G._un             = undefined;                              
              _G._nu             = null;                                   
              _G._t              = true;                                   
              _G._f              = false;                                  
              _G._pos            = (o)                                      => +o;                               
              _G._neg            = (o)                                      => -o;                               
              _G._eq             = (a,b)                                    => a===b;                            
              _G._neq            = (a,b)                                    => a!==b;                            
              _G._deq            = (a,b)                                    => a==b;                             
              _G._ndeq           = (a,b)                                    => a!=b;                             
              _G._not            = (o)                                      => !o;                               
              _G._or             = (a,b)                                    => a||b;                             
              _G._and            = (a,b)                                    => a&&b;                             
              _G._xor            = (a,b)                                    => (!a&&b)||(a&&!b);                 
              _G._ter            = (cond,tv,fv)                             => cond?tv:fv;                       
              _G._bnot           = (o)                                      => ~o;                               
              _G._bor            = (a,b)                                    => a|b;                              
              _G._band           = (a,b)                                    => a&b;                              
              _G._bxor           = (a,b)                                    => a^b;                              
              _G._add            = (a,b)                                    => a+b;                              
              _G._sub            = (a,b)                                    => a-b;                              
              _G._mul            = (a,b)                                    => a*b;                              
              _G._div            = (a,b)                                    => a/b;                              
              _G._mod            = (a,b)                                    => a%b;                              
              _G._pow            = (a,b)                                    => a**b;                             
              _G._qr             = (a,b)                                    => {let r=a%b;return([((a-r)/b),r])};
              _G._quo            = (a,b)                                    => (a-a%b)/b;                        
              _G._lt             = (a,b)                                    => a<b;                              
              _G._le             = (a,b)                                    => a<=b;                             
              _G._ge             = (a,b)                                    => a>=b;                             
              _G._gt             = (a,b)                                    => a>b;                              
              _G._lshft          = (a,b)                                    => a<<b;                             
              _G._rshft          = (a,b)                                    => a>>b;                             
              _G._urshft         = (a,b)                                    => a>>>b;                            
              _G._dot            = (o,name)                                 => o[name];                          
              _G._setp           = (o,k,v)                                  => o[k]=v;                           
              _G._del            = (o,name)                                 => delete o[name];                   
              _G._nc             = (a,b)                                    => a??b;                             
              _G._oc             = (o,prop)                                 => o?.[prop];                        
              _G._oc_call        = (o,prop,...args)                         => o[prop]?.(...args);               
              _G._oc_aply        = (o,prop,pary)                            => o[prop]?.(...pary);               
              _G._void           = (   )                                    => void(0);                          
              _G._typof          = (o,tname)                                => typeof(o)===tname;                
              _G._istof          = (a,b)                                    => (a instanceof b);                 
              _G._coma_fst       = (...params)                              => params[0];                        
              _G._coma_lst       = (...params)                              => params[params.length-1];          
              _G._pair           = (a,b)                                    => [a,b];                            
              _G._ary            = (...eles)                                => eles;                             
              _G._incr           = (o)                                      => ++o;                              
              _G._decr           = (o)                                      => --o;                              
              _G._new_call       = (a,...b)                                 => new a(...b);                      
              _G._new_aply       = (a,b)                                    => new a(...b);                      
              _G._B              = Boolean;                                
              _G._N              = Number;                                 
              _G._S              = String;                                 
              _G._BI             = BigInt;                                 
              _G._Y              = Symbol;                                 
              _G._A              = Array;                                  
              _G._F              = Function;                               
              _G._P              = Promise;                                
              _G._X              = Proxy;                                  
              _G._J              = JSON;                                   
              _G._O              = Object;                                 
              _G._R              = Reflect;                                
              _G._MP             = Map;                                    
              _G._ST             = Set;                                    
              _G._WMP            = WeakMap;                                
              _G._WST            = WeakSet;                                
              _G._WREF           = WeakRef;                                
              _G._RE             = RegExp;                                 
              _G._DT             = Date;                                   
              _G._AB             = ArrayBuffer;                            
              _G._BUF            = Buffer;                                 
              _G._U8A            = Uint8Array;                             
              _G._U8CA           = Uint8ClampedArray;                      
              _G._U16A           = Uint16Array;                            
              _G._U32A           = Uint32Array;                            
              _G._I8A            = Int8Array;                              
              _G._I16A           = Int16Array;                             
              _G._I32A           = Int32Array;                             
              _G._F32A           = Float32Array;                           
              _G._F64A           = Float64Array;                           
              _G._BU64A          = BigUint64Array;                         
              _G._BI64A          = BigInt64Array;                          
              _G._DV             = DataView;                               
              _G._EV             = Event;                                  
              _G._EVT            = EventTarget;                            
              _G._EE             = require("events").EventEmitter;         
              _G._URL            = URL;                                    
              _G._URLSRCHP       = URLSearchParams;                        
              _G._html_esc       = escape;                                 
              _G._html_unesc     = unescape;                               
              _G._decd_url       = decodeURI;                              
              _G._decd_url_com   = decodeURIComponent;                     
              _G._encd_url       = encodeURI;                              
              _G._encd_url_com   = encodeURIComponent;                     
              _G._ATOM           = Atomics;                                
              _G._ER             = Error;                                  
              _G._AGGER          = AggregateError;                         
              _G._EVLER          = EvalError;                              
              _G._REFER          = ReferenceError;                         
              _G._RNGER          = RangeError;                             
              _G._STXER          = SyntaxError;                            
              _G._TYPER          = TypeError;                              
              _G._URIER          = URIError;                               
              _G._FINREG         = FinalizationRegistry;                   
              _G._ABRT_CTRL      = AbortController;                        
              _G._ABRT_SIG       = AbortSignal;                            
              _G._MSG_CHAN       = MessageChannel;                         
              _G._MSG_PORT       = MessagePort;                            
              _G._MSGEV          = MessageEvent;                           
              _G._TXTENCD        = TextEncoder;                            
              _G._TXTDECD        = TextDecoder;                            
              _G._WASM           = WebAssembly;                            
              _G._MATH           = Math;                                   
              _G._infi           = Infinity;                               
              _G._nan            = NaN;                                    
              _G._pos_infi       = +Infinity;                              
              _G._neg_infi       = -Infinity;                              
              _G._is_fin         = isFinite;                               
              _G._is_infi        = (o)                                      => (o===+Infinity)||(o===-Infinity); 
              _G._is_nan         = isNaN;                                  
              _G._is_pos_zero    = (z)                                      => (1/z)===+Infinity;                
              _G._is_neg_zero    = (z)                                      => (1/z)===-Infinity;                
              _G._is_ary_idx     = (i)                                      => i>=0&&i<=2**32-2;                 
              _G._is_ary_len     = (i)                                      => i>=0&&i<=2**32-1;                 
              _G._parse_f        = parseFloat;                             
              _G._parse_i        = parseInt;                               
              _G._impt_meta      = import.meta;                            
              _G._clr_intvl      = clearInterval;                          
              _G._set_intvl      = setInterval;                            
              _G._clr_tmout      = clearTimeout;                           
              _G._set_tmout      = setTimeout;                             
              _G._clr_imme       = clearImmediate;                         
              _G._set_imme       = setImmediate;                           
              _G._q_micro_tsk    = queueMicroTask;                         
              _G._ntick          = process.nextTick;                       
              _G._prms_set_intvl = require("timers/promises").setInterval; 
              _G._prms_set_tmout = require("timers/promises").setTimeout;  
              _G._prms_set_imme  = require("timers/promises").setImmediate;
              _G._INTL           = Intl;                                   
              _G._PERF           = performance;                            
              _G._MOD            = module.constructor;                     
              _G._fslib          = require("fs");                          
              _G._fs_prms_lib    = require("fs/promises");                 
              _G._pathlib        = require("path");                        
              _G._buflib         = require("buffer");                      
              _G._urlib          = require("url");                         
              _G._cnslib         = console;                                
              _G._crptlib        = require("crypto");                      
              _G._worklib        = require("worker_threads");     

unsafe (those use require)

    {
      _EE: [ '_dot', [ 'require', 'events' ], 'EventEmitter' ],
      _buflib: [ 'require', 'buffer' ],
      _fs_prms_lib: [ 'require', 'fs/promises' ],
      _fslib: [ 'require', 'fs' ],
      _pathlib: [ 'require', 'path' ],
      _urlib: [ 'require', 'url' ],
      _crptlib: [ 'require', 'crypto' ],
      _prms_set_intvl: [ '_dot', [ 'require', 'timers/promises' ], 'setInterval' ],
      _prms_set_imme: [ '_dot', [ 'require', 'timers/promises' ], 'setImmediate' ],
      _prms_set_tmout: [ '_dot', [ 'require', 'timers/promises' ], 'setTimeout' ],
      _worklib: [ 'require', 'worker_threads' ]
    }


        > Object.getOwnPropertyDescriptor(global,"process")
        {
          get: [Function: get],
          set: [Function: set],
          enumerable: false,
          configurable: true
        }
        >
  {
      _ntick: process.nextTick
  }

LICENSE

  • ISC

Readme

Keywords

none

Package Sidebar

Install

npm i nv-cli-gir-leaf0

Weekly Downloads

1

Version

1.0.17

License

ISC

Unpacked Size

38.2 kB

Total Files

161

Last publish

Collaborators

  • ihgazni2