Quark #

Modules #

Quark v1.4.0 Documentation

Contents

quark/_common #

currentTimezone #

Current time zone

const currentTimezone

clone(obj) #

Clone an Object

clone(obj: any): any

Parameters:

  • obj — The Object to be cloned

extend(obj,extd,top?) #

extend(obj: any, extd: any, top?: any): any

noop() #

Empty function

noop()

isNull(value) #

isNull(value: any): boolean

extendClass(cls,extds,top?) #

EXT class prototype objects

extendClass(cls: Function, extds: Function[] | Function, top?: any): Function

scopeLock(mutex,cb) #

scopeLock(mutex: any, cb: Function): Promise

getProp(name,self) #

Get object value by name

getProp(name: string, self: any): any

setProp(name,value,self) #

Setting object value by name

setProp(name: string, value: any, self: any): any

removeProp(name,self) #

Delete object value by name

removeProp(name: string, self: any): void

random(start?,end?) #

Creating random numbers

random(start?: any, end?: any)

Parameters:

  • start? — Numbers of begin
  • end? — Numbers of end

randomFloat(start?,end?) #

Creating random float numbers

randomFloat(start?: any, end?: any)

Parameters:

  • start? — Numbers of begin
  • end? — Numbers of end

fixRandom(arg0,...args) #

  • Fixed random value, specified probability to return a constant

  • Get a random number from 0 to the passed probability number arguments.length by probability

  • The sum of the passed probabilities cannot be zero

fixRandom(arg0: number, args: number[], arg: number): Uint

Parameters:

  • arg0 — Enter percentage
  • args — Enter percentage

Example:

// Prints: 3 5 9
console.log(util.random(0, 10))
console.log(util.random(0, 10))
console.log(util.random(0, 10))
// Prints 0 3 2
console.log(util.fixRandom(10, 20, 30, 40))
console.log(util.fixRandom(10, 20, 30, 40))
console.log(util.fixRandom(10, 20, 30, 40))

filter(obj,exp,non?) #

Filter object attrs

filter(obj: any, exp: string[] | Function, non?: boolean): any

Parameters:

  • exp — filter exp
  • non? — take non

update(obj,extd) #

Update object property value

update(obj: any, extd: any): any

Parameters:

  • obj — need to be updated for as
  • extd — update object Type parameters: T

select(default,value) #

select(default: any, value: any, default_: T): any

Type parameters: T

equalsClass(baseclass,subclass) #

Whether this type of sub-types

equalsClass(baseclass: any, subclass: any): boolean

assert(condition,arg?,extMsg?) #

Asserts that value is not null or undefined.

assert(condition: T, arg?: number | ErrorNewArg, extMsg?: string): void

Parameters:

  • condition — The value to check.
  • arg? — Optional code or message for the error thrown.
  • extMsg? — Optional message for the error thrown.

Returns: nothing Type parameters: T

promise(executor) #

promise(executor: Function): Promise