1.3.1 • Published 4 years ago

com.siteblade.util v1.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago
com.siteblade.util

Enums

Defining enums:

import { Enum, FlagsEnum } from 'com.siteblade.util';

// simple enums

const E = Enum('E', [
	'FOO_CONST',

	// const definition can manually specify a (String, Number) pair
	['BAR_CONST', 1],
	['BAR2_CONST', 10, 'barTwo'],
]);

// flags enums

const E = FlagsEnum('E', [
	'FA',
	'FB',
]);

Applying enums:

class C {
	_e;

	get e() { return this._e }

	set e(v) { this._e = E(v) }
}

var o = new C;

o.e = 'fa';
o.e = ['fa', 'fb'];
o.e = undefined; // o.e = 0
o.e = E.FA;

console.log( o.e == 'fa' );
console.log( 'fa' in o.e );

Instance properties:

  • number:Number

FlagsEnum products > Instance methods:

  • set(arg:E):E
  • exclude(arg:E):E
  • toggle(arg:E):E
  • filter(arg:E):E
  • toString():String

Related utilities:

  • com.siteblade.util.JSON.stringify(value:*, options:* = undefined):String This will convert the enum to a Number.

Integer types

Int and UInt are 32-bit integer data types used as Number. Long and ULong are 64-bit integer data types used as BigInt.

Instance methods:

  • equals(arg):Boolean
  • add(arg)
  • subtract(arg)
  • multiply(arg)
  • divide(arg)
  • remainder(arg)
  • valueOf():BigInt
1.3.1

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.0

4 years ago

0.1.0-alpha.0

4 years ago