@uzykj/oop-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

oop-utils

Object oriented related tool classes

Install

npm i @uzykj/oop-utils

Used

API

Objects

import {Objects} from '@uzykj/oop-utils'

//equals
Objects.equals(1, 1);

//hashCode
Objects.hashCode(['1', '2']);

Hashes

import {Hashes} from '@uzykj/oop-utils'

Hashes.hashCode('hello') //number
Hashes.hashString({type: 'demo', name: 'Demo'}) //string
Hashes.hashBuffer(new Object('a')) //Buffer

Optional

import {Optional} from '@uzykj/oop-utils'

Optional.absent();
Optional.fromNullable('A').orNull();
Optional.fromUndefinedable(null).isPresent();
Optional.of(Object).get();

// Out:
// { [Function: Absent] INSTANCE: [Circular] }
// A
// false
// OptionalException: Optional item must be present.

Preconditions

import {Preconditions} from '@uzykj/oop-utils'
// 检查参数
Preconditions.checkArgument(false, 'Object Error', {size: 10234});
// 检查元素的索引
Preconditions.checkElementIndex(1, 10);
// 检查非空
Preconditions.checkNotNull(null, 'Error', true);
// 检查位置索引
Preconditions.checkPositionIndex(1, 0);
// 检查位置索引
Preconditions.checkPositionIndexes(1, 10, 1);
// 检查状态
Preconditions.checkState(false, 'Error', true);

LICENSE

Apache-2.0

Package Sidebar

Install

npm i @uzykj/oop-utils

Weekly Downloads

2

Version

0.0.6

License

Apache-2.0

Unpacked Size

62.2 kB

Total Files

52

Last publish

Collaborators

  • ghostxbh