nv-cli-unsum-int

1.0.3 • Public • Published

nv-cli-unsum-int

  • cli-tool
  • split a int(capacity) to sum-of-ints(subtype | incomplete-subtype-prefix | incomplete-subtype-suffix)
  • please see the examples below
  • the tool is USED to generate switch case

install

  • npm install nv-cli-unsum-int -g

usage

	Usage: nv_cli_unsum_int [options] 
	Options:
	    -c, --capacity                  capactity  int >0
	    -t, --types                     
		     type-name length type-name length .....;
			type-name must be valid js-identifier           AND 
			type-name CANT includes lodash "_"              AND
			type-name CANT includes dollar "$"              

	    -i, --include_incomplete        include incomplete prefix_types and suffix_types,     default false
	    -p, --permit_padding            permit padding: the-sum-of-subtype-must-eq-capacity,  default false
	    -h, --help                      usage

example

split a-type-of-length-6 to sub-type-of-4 and sub-type-of-2; disallow-padding AND disallow-incomplete-type

        #nv_cli_unsum_int -c 6 -t U4 4 U2 2  

	{
	  capacity: 6,
	  subtyped: { 
        	 U4_U2:    [ 4, 2 ], 
     		 U2_U4:    [ 2, 4 ], 
		 U2_U2_U2: [ 2, 2, 2 ] 
	  }
	}

split a-type-of-length-6 to sub-type-of-4 and sub-type-of-2; allow-padding BUT disallow-incomplete-type

        #nv_cli_unsum_int -c 6 -t U4 4 U2 2 -p  

			{
			  capacity: 6,
			  subtyped: {
			    U4: [ 4 ],
			    U4_U2: [ 4, 2 ],
			    U2: [ 2 ],                    //---need-padding  
			    U2_U4: [ 2, 4 ],
			    U2_U2: [ 2, 2 ],              //---need-padding  
			    U2_U2_U2: [ 2, 2, 2 ]
			  }
			}

split a-type-of-length-6 to sub-type-of-4 and sub-type-of-2; allow-padding AND allow-incomplete-type

        #nv_cli_unsum_int -c 6 -t U4 4 U2 2 -p -i 

	{
	  capacity: 6,
	  subtyped: {
	    U4: [ 4 ],
	    U4_U2: [ 4, 2 ],
	    'U4_U4$2_': [ 4, 2 ],                  // incomplete at tail 
	    U2: [ 2 ],
	    '_U4$2': [ 2 ],                        // incomplete at head  AND need padding
	    U2_U4: [ 2, 4 ],
	    '_U4$2_U4': [ 2, 4 ],                  //  incomplete at head
	    U2_U2: [ 2, 2 ],
	    '_U4$2_U2': [ 2, 2 ],                  // incomplete at head AND need padding
	    U2_U2_U2: [ 2, 2, 2 ],
	    'U2_U2_U4$2_': [ 2, 2, 2 ],             // incomplete at tail 
	    '_U4$2_U2_U2': [ 2, 2, 2 ],             //incomplete at head 
	    '_U4$2_U2_U4$2_': [ 2, 2, 2 ]           // incomplete BOTH at head AND at tail
	  }
	}

split a-type-of-length-6 to sub-type-of-4 and sub-type-of-2; disallow-padding AND allow-incomplete-type

        #nv_cli_unsum_int -c 6 -t U4 4 U2 2 -i


		{
		  capacity: 6,
		  subtyped: {
		    U4_U2: [ 4, 2 ],
		    'U4_U4$2_': [ 4, 2 ],
		    U2_U4: [ 2, 4 ],
		    '_U4$2_U4': [ 2, 4 ],
		    U2_U2_U2: [ 2, 2, 2 ],
		    'U2_U2_U4$2_': [ 2, 2, 2 ],
		    '_U4$2_U2_U2': [ 2, 2, 2 ],
		    '_U4$2_U2_U4$2_': [ 2, 2, 2 ]
		  }
		}

LICENSE

  • ISC

Readme

Keywords

none

Package Sidebar

Install

npm i nv-cli-unsum-int

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

11.7 kB

Total Files

4

Last publish

Collaborators

  • ihgazni2