| Members | Descriptions |
|---|---|
namespace assert |
Assertion test module, if testing result is false, you will get an error. The way of handling error can be set as continue or throw exception. |
namespace base32 |
base32 module with encode and decode operations. to use: |
namespace base64 |
base64 module with encode and decode operations. to use: |
namespace base64vlq |
base64vlq module with encode and decode operations. to use: |
namespace bson |
bson module with encode and decode operations. to use: |
namespace console |
console module |
namespace coroutine |
Concurrency control module. |
namespace crypto |
Encryption algorithm module. |
namespace db |
Database access module. |
namespace encoding |
module with encode and decode operations between hex and other format data. to use: |
namespace fs |
file system module |
namespace gd |
Image processing module. |
namespace global |
Global object, which can be accessed by all scripts. |
namespace hash |
Message digest calculation module, can be used to calculate the message digest and summary Signature. |
namespace hex |
module with encode and decode operations between hex and string. to use: |
namespace http |
HTTP transfer protocol module, handels http protocol. |
namespace iconv |
iconv Module with encode and decode operations between text and binary. to use: |
namespace io |
IO module. |
namespace json |
json module with encode and decode operations. to use: |
namespace mq |
Message queue module. |
namespace net |
Network module. |
namespace os |
Operating system and file system module. |
namespace path |
File path module. |
namespace process |
Process handle module, to manage current process resources. |
namespace profiler |
Memory profiler module. |
namespace re |
Regexp module. |
namespace rpc |
RPC module. |
namespace ssl |
ssl/tls module |
namespace test |
Test Suite module that defines the test suite management. |
namespace util |
Common tools module. |
namespace uuid |
uuid unique id module |
namespace vm |
Safe SandBox module, to isolate runtime based on safety level. |
namespace websocket |
websocket support module |
namespace xml |
xml module |
namespace zip |
Zip file processing module. |
namespace zlib |
zlib compression and decompression module |
class AsyncWait |
MessageHandler object for asynchronous waiting. |
class Buffer |
Binary buffer used in dealing with I/O reading and writing. |
Assertion test module, if testing result is false, you will get an error. The way of handling error can be set as continue or throw exception.
how to use:
var assert = require('assert');or using testing unit:
var test = require('test');
var assert = test.assert;or you can use test.setup to set up test:
require("test").setup();| Members | Descriptions |
|---|---|
public static static ok(Value actual,String msg) |
Return true when the testing result is ture, assertion failed when return false. |
public static static notOk(Value actual,String msg) |
Return true when the testing result is false, assertion failed when return true. |
public static static equal(Value actual,Value expected,String msg) |
Test value should match the expected one, assertion failed when not match. |
public static static notEqual(Value actual,Value expected,String msg) |
Test value should not have to match the expected one, assertion failed when match. |
public static static strictEqual(Value actual,Value expected,String msg) |
Test value should strictly match the expected one, assertion failed when not match. |
public static static notStrictEqual(Value actual,Value expected,String msg) |
Test value should not have to strictly match the expected one, assertion failed when match. |
public static static deepEqual(Value actual,Value expected,String msg) |
Test value should deeply match the expected one, assertion failed when not match. |
public static static notDeepEqual(Value actual,Value expected,String msg) |
Test value should not have to deeply match the expected one, assertion failed when match. |
public static static closeTo(Value actual,Value expected,Value delta,String msg) |
Test value should closely match the expected one, assertion failed when not match. |
public static static notCloseTo(Value actual,Value expected,Value delta,String msg) |
Test value should not have to closely match the expected one, assertion failed when match. |
public static static lessThan(Value actual,Value expected,String msg) |
Test value should less than the expected one, assertion failed when get a greater or equal one. |
public static static notLessThan(Value actual,Value expected,String msg) |
Test value should not have to less than the expected one, assertion failed when get a less one. |
public static static greaterThan(Value actual,Value expected,String msg) |
Test value should greater than the expected one, assertion failed when get a less or equal one. |
public static static notGreaterThan(Value actual,Value expected,String msg) |
Test value should not have to greater than the expected one, assertion failed when get a greater one. |
public static static exist(Value actual,String msg) |
Test value should be an existed one, assertion failed when the value is not existed. |
public static static notExist(Value actual,String msg) |
Test value should not be an existed one, assertion failed when the value is existed. |
public static static isTrue(Value actual,String msg) |
Test value should be the Boolean true, assertion failed when the value is false. |
public static static isNotTrue(Value actual,String msg) |
Test value should be the Boolean false, assertion failed when the value is true. |
public static static isFalse(Value actual,String msg) |
Test value should be the Boolean false, assertion failed when the value is true. |
public static static isNotFalse(Value actual,String msg) |
Test value should be the Boolean true, assertion failed when the value is false. |
public static static isNull(Value actual,String msg) |
Test value should be the null, assertion failed when the value is not null. |
public static static isNotNull(Value actual,String msg) |
Test value should not be the null, assertion failed when the value is null. |
public static static isUndefined(Value actual,String msg) |
Test value should be the undefined, assertion failed when the value is not undefined. |
public static static isDefined(Value actual,String msg) |
Test value should not be the undefined, assertion failed when the value is undefined. |
public static static isFunction(Value actual,String msg) |
The type of test value should be Function, assertion failed when the value is not a function. |
public static static isNotFunction(Value actual,String msg) |
The type of test value should not be Function, assertion failed when the value is a function. |
public static static isObject(Value actual,String msg) |
The type of test value should be Object, assertion failed when the value is not a object. |
public static static isNotObject(Value actual,String msg) |
The type of test value should not be Object, assertion failed when the value is a object. |
public static static isArray(Value actual,String msg) |
The type of test value should be Array, assertion failed when the value is not an array. |
public static static isNotArray(Value actual,String msg) |
The type of test value should not be Array, assertion failed when the value is an array. |
public static static isString(Value actual,String msg) |
The type of test value should be String, assertion failed when the value is not a string. |
public static static isNotString(Value actual,String msg) |
The type of test value should not be String, assertion failed when the value is a string. |
public static static isNumber(Value actual,String msg) |
The type of test value should be Number, assertion failed when the value is not a number. |
public static static isNotNumber(Value actual,String msg) |
The type of test value should not be Number, assertion failed when the value is a number. |
public static static isBoolean(Value actual,String msg) |
The type of test value should be Boolean, assertion failed when the value is not a boolean. |
public static static isNotBoolean(Value actual,String msg) |
The type of test value should not be Boolean, assertion failed when the value is a boolean. |
public static static typeOf(Value actual,String type,String msg) |
The type of test value should be the specified one, assertion failed when the value type is not match. |
public static static notTypeOf(Value actual,String type,String msg) |
The type of test value should not be the specified one, assertion failed when the value type is match. |
public static static property(Value object,Value prop,String msg) |
The test value should contain the specified property, assertion failed when the property not be contained. |
public static static notProperty(Value object,Value prop,String msg) |
The test value should not contain the specified property, assertion failed when the property contained. |
public static static deepProperty(Value object,Value prop,String msg) |
The test value should deeply contain the specified property, assertion failed when the property not be contained. |
public static static notDeepProperty(Value object,Value prop,String msg) |
The test value should not deeply contain the specified property, assertion failed when the property contained. |
public static static propertyVal(Value object,Value prop,Value value,String msg) |
The specified property of test value should equal the given one, assertion failed when not match. |
public static static propertyNotVal(Value object,Value prop,Value value,String msg) |
The specified property of test value should not equal the given one, assertion failed when match. |
public static static deepPropertyVal(Value object,Value prop,Value value,String msg) |
The specified property of test value should deeply equal the given one, assertion failed when not match. |
public static static deepPropertyNotVal(Value object,Value prop,Value value,String msg) |
The specified property of test value should not deeply equal the given one, assertion failed when match. |
public static static throws(Function block,String msg) |
The block code should throw an error, assertion failed when not throw one. |
public static static doesNotThrow(Function block,String msg) |
The block code should not throw an error, assertion failed when throw one. |
public static static ok(Value actual,String msg)
Return true when the testing result is ture, assertion failed when return false.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static notOk(Value actual,String msg)
Return true when the testing result is false, assertion failed when return true.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static equal(Value actual,Value expected,String msg)
Test value should match the expected one, assertion failed when not match.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static notEqual(Value actual,Value expected,String msg)
Test value should not have to match the expected one, assertion failed when match.
-
actualThe value need to be tested. -
expectedThe expected value. -
expectedexpected value from unittest -
msgThe message of assertion failed when return false.
public static static strictEqual(Value actual,Value expected,String msg)
Test value should strictly match the expected one, assertion failed when not match.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static notStrictEqual(Value actual,Value expected,String msg)
Test value should not have to strictly match the expected one, assertion failed when match.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static deepEqual(Value actual,Value expected,String msg)
Test value should deeply match the expected one, assertion failed when not match.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static notDeepEqual(Value actual,Value expected,String msg)
Test value should not have to deeply match the expected one, assertion failed when match.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static closeTo(Value actual,Value expected,Value delta,String msg)
Test value should closely match the expected one, assertion failed when not match.
-
actualThe value need to be tested. -
expectedThe expected value. -
deltaApproximate decimal precision. -
msgThe message of assertion failed when return false.
public static static notCloseTo(Value actual,Value expected,Value delta,String msg)
Test value should not have to closely match the expected one, assertion failed when match.
-
actualThe value need to be tested. -
expectedThe expected value. -
deltaApproximate decimal precision. -
msgThe message of assertion failed when return false.
public static static lessThan(Value actual,Value expected,String msg)
Test value should less than the expected one, assertion failed when get a greater or equal one.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static notLessThan(Value actual,Value expected,String msg)
Test value should not have to less than the expected one, assertion failed when get a less one.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static greaterThan(Value actual,Value expected,String msg)
Test value should greater than the expected one, assertion failed when get a less or equal one.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static notGreaterThan(Value actual,Value expected,String msg)
Test value should not have to greater than the expected one, assertion failed when get a greater one.
-
actualThe value need to be tested. -
expectedThe expected value. -
msgThe message of assertion failed when return false.
public static static exist(Value actual,String msg)
Test value should be an existed one, assertion failed when the value is not existed.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static notExist(Value actual,String msg)
Test value should not be an existed one, assertion failed when the value is existed.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isTrue(Value actual,String msg)
Test value should be the Boolean true, assertion failed when the value is false.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotTrue(Value actual,String msg)
Test value should be the Boolean false, assertion failed when the value is true.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isFalse(Value actual,String msg)
Test value should be the Boolean false, assertion failed when the value is true.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotFalse(Value actual,String msg)
Test value should be the Boolean true, assertion failed when the value is false.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNull(Value actual,String msg)
Test value should be the null, assertion failed when the value is not null.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotNull(Value actual,String msg)
Test value should not be the null, assertion failed when the value is null.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isUndefined(Value actual,String msg)
Test value should be the undefined, assertion failed when the value is not undefined.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isDefined(Value actual,String msg)
Test value should not be the undefined, assertion failed when the value is undefined.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isFunction(Value actual,String msg)
The type of test value should be Function, assertion failed when the value is not a function.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotFunction(Value actual,String msg)
The type of test value should not be Function, assertion failed when the value is a function.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isObject(Value actual,String msg)
The type of test value should be Object, assertion failed when the value is not a object.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotObject(Value actual,String msg)
The type of test value should not be Object, assertion failed when the value is a object.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isArray(Value actual,String msg)
The type of test value should be Array, assertion failed when the value is not an array.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotArray(Value actual,String msg)
The type of test value should not be Array, assertion failed when the value is an array.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isString(Value actual,String msg)
The type of test value should be String, assertion failed when the value is not a string.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotString(Value actual,String msg)
The type of test value should not be String, assertion failed when the value is a string.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNumber(Value actual,String msg)
The type of test value should be Number, assertion failed when the value is not a number.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotNumber(Value actual,String msg)
The type of test value should not be Number, assertion failed when the value is a number.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isBoolean(Value actual,String msg)
The type of test value should be Boolean, assertion failed when the value is not a boolean.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static isNotBoolean(Value actual,String msg)
The type of test value should not be Boolean, assertion failed when the value is a boolean.
-
actualThe value need to be tested. -
msgThe message of assertion failed when return false.
public static static typeOf(Value actual,String type,String msg)
The type of test value should be the specified one, assertion failed when the value type is not match.
-
actualThe value need to be tested. -
typeSpecified type. -
msgThe message of assertion failed when return false.
public static static notTypeOf(Value actual,String type,String msg)
The type of test value should not be the specified one, assertion failed when the value type is match.
-
actualThe value need to be tested. -
typeSpecified type. -
msgThe message of assertion failed when return false.
public static static property(Value object,Value prop,String msg)
The test value should contain the specified property, assertion failed when the property not be contained.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
msgThe message of assertion failed when return false.
public static static notProperty(Value object,Value prop,String msg)
The test value should not contain the specified property, assertion failed when the property contained.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
msgThe message of assertion failed when return false.
public static static deepProperty(Value object,Value prop,String msg)
The test value should deeply contain the specified property, assertion failed when the property not be contained.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
msgThe message of assertion failed when return false.
public static static notDeepProperty(Value object,Value prop,String msg)
The test value should not deeply contain the specified property, assertion failed when the property contained.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
msgThe message of assertion failed when return false.
public static static propertyVal(Value object,Value prop,Value value,String msg)
The specified property of test value should equal the given one, assertion failed when not match.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
valueGiven value -
msgThe message of assertion failed when return false.
public static static propertyNotVal(Value object,Value prop,Value value,String msg)
The specified property of test value should not equal the given one, assertion failed when match.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
valueGiven value -
msgThe message of assertion failed when return false.
public static static deepPropertyVal(Value object,Value prop,Value value,String msg)
The specified property of test value should deeply equal the given one, assertion failed when not match.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
valueGiven value -
msgThe message of assertion failed when return false.
public static static deepPropertyNotVal(Value object,Value prop,Value value,String msg)
The specified property of test value should not deeply equal the given one, assertion failed when match.
-
objectThe object to be tested. -
propProperty to be tested, fields terminated by '.' -
valueGiven value -
msgThe message of assertion failed when return false.
public static static throws(Function block,String msg)
The block code should throw an error, assertion failed when not throw one.
-
blockThe code need to be test that specified as function. -
msgThe message of assertion failed when return false.
public static static doesNotThrow(Function block,String msg)
The block code should not throw an error, assertion failed when throw one.
-
blockThe code need to be test that specified as function. -
msgThe message of assertion failed when return false.
base32 module with encode and decode operations. to use:
var encoding = require('encoding');
var base32 = encoding.base32;or:
var base32 = require('base32');| Members | Descriptions |
|---|---|
public static String encode(Buffer data) |
Encode buffer data to string with base32 format. |
public static Buffer decode(String data) |
Decode string to binary data with base32 format. |
Encode buffer data to string with base32 format.
dataBuffer data to be encoded.
The encoded result string.
Decode string to binary data with base32 format.
dataString to be decoded.
The decoded result binary data.
base64 module with encode and decode operations. to use:
var encoding = require('encoding');
var base64 = encoding.base64;or:
var base64 = require('base64');| Members | Descriptions |
|---|---|
public static String encode(Buffer data) |
Encode buffer data to string with base64 format. |
public static Buffer decode(String data) |
Decode string to binary data with base64 format. |
Encode buffer data to string with base64 format.
dataBuffer data to be encoded.
The encoded result string.
Decode string to binary data with base64 format.
dataString to be decoded.
The decoded result binary data.
base64vlq module with encode and decode operations. to use:
var encoding = require('encoding');
var base64vlq = encoding.base64vlq;or:
var base64vlq = require('base64vlq');| Members | Descriptions |
|---|---|
public static String encode(Integer data) |
Encode int data to string with base64vlq format. |
public static String encode(Array data) |
Encode array data to string with base64vlq format. |
public static Array decode(String data) |
Decode string to binary data with base64vlq format. |
public static String encode(Integer data)
Encode int data to string with base64vlq format.
dataInt data to be encoded.
The encoded result string.
public static String encode(Array data)
Encode array data to string with base64vlq format.
dataArray data to be encoded.
The encoded result string.
public static Array decode(String data)
Decode string to binary data with base64vlq format.
dataString data to be decoded.
The decoded result binary data.
bson module with encode and decode operations. to use:
var encoding = require('encoding');
var bson = encoding.bson;or:
var bson = require('bson');| Members | Descriptions |
|---|---|
public static Buffer encode(Object data) |
Encode object to binary data with bson format. |
public static Object decode(Buffer data) |
Decode binary data to object with bson format. |
Encode object to binary data with bson format.
dataObject to be encoded.
The encoded result binary data.
Decode binary data to object with bson format.
dataBinary data to be decoded.
The decoded result object.
console module
Global reference. Console can be used to log info, warnings and errors. Log can be trace on different device when initialized from config files for tracking. Console logs support formatted output, e.g.
console.log("%d + %d = %d", 100, 200, 100 + 200);-
s - string
-
d - number, including initeger and numbers
-
j - output in JSON
-
%% - output '' character
| Members | Descriptions |
|---|---|
public static static add(Array cfg) |
Batch add console output, supportted devices are console, syslog and file, maximum output number is 10. |
public static static add(Value cfg) |
Add console output, supportted devices are console, syslog and file, maximum output number is 10. |
public static static reset() |
initialize with default configuration, only output in console |
public static static log(String fmt,...) |
Record INFO log, Equivalent to the info function. |
public static static log(...) |
Record INFO log, Equivalent to the info function. |
public static static debug(String fmt,...) |
Record DEBUG log. |
public static static debug(...) |
Record DEBUG log. |
public static static info(String fmt,...) |
Record INFO log, Equivalent to the log function. |
public static static info(...) |
Record INFO log, Equivalent to the log function. |
public static static notice(String fmt,...) |
Record NOTICE log. |
public static static notice(...) |
Record NOTICE log. |
public static static warn(String fmt,...) |
Record WARN log. |
public static static warn(...) |
Record WARN log. |
public static static error(String fmt,...) |
Record ERROR log. |
public static static error(...) |
Record ERROR log. |
public static static crit(String fmt,...) |
Record CRIT log. |
public static static crit(...) |
Record CRIT log. |
public static static alert(String fmt,...) |
Record ALERT log. |
public static static alert(...) |
Record ALERT log. |
public static static dir(Value obj) |
Output object in JSON format. |
public static static time(String label) |
Start a timer. |
public static static timeEnd(String label) |
Value of specified timer. |
public static static trace(String label) |
Output the current used stack. |
public static static assert(Value value,String msg) |
Assertion test, which will throw error when testing result is false. |
public static static print(String fmt,...) |
Formatted text output to the console, the content will not be written to log system, and the output text does not wrap automatically, the output can output continuously. |
public static static print(...) |
Formatted text output to the console, the content will not be written to log system, and the output text does not wrap automatically, the output can output continuously. |
public static String readLine(String msg) |
Read the user input from the console. |
public static static add(Array cfg)
Batch add console output, supportted devices are console, syslog and file, maximum output number is 10.
Console can be configured to send program outputs and system errors to different devices, for collecting runtime information.
console.add(["console", {
type: "syslog",
levels: [console.INFO, console.ERROR]
}]);cfgAn array of console log config
public static static add(Value cfg)
Add console output, supportted devices are console, syslog and file, maximum output number is 10.
Console can be configured to send program outputs and system errors to different devices, for collecting runtime information.
Cfg is config which can be set as the string of devices name.
console.add("console");You can also configure console levels for one device
console.add({
type: "console",
levels: [console.INFO, console.ERROR] // options, output all level of log if skip this option.
});Syslog only works on posix platform:
console.add({
type: "syslog",
levels: [console.INFO, console.ERROR]
});file log dose not support simple calls
console.add({
type: "file",
levels: [console.INFO, console.ERROR],
path: "path/to/file", // required
split: "30m", //optional, options can be "day", "hour", "minute", "###k", "###m", "###g"
count: 10 //optional, options can be any integer between 2-128, this option requires the split option
});cfgOutput configuration
public static static reset()
initialize with default configuration, only output in console
public static static log(String fmt,...)
Record INFO log, Equivalent to the info function.
Record the INFO level of log information. Typically used to output the non-erroneous message.
-
fmtThe format string -
...Optional parameter list
public static static log(...)
Record INFO log, Equivalent to the info function.
Record the INFO level of log information. Typically used to output the non-erroneous message.
...Optional parameter list
public static static debug(String fmt,...)
Record DEBUG log.
Record the DEBUG level of log information. Typically used to output the debug message.
-
fmtThe format string -
...Optional parameter list
public static static debug(...)
Record DEBUG log.
Record the DEBUG level of log information. Typically used to output the debug message.
...Optional parameter list
public static static info(String fmt,...)
Record INFO log, Equivalent to the log function.
Record the INFO level of log information. Typically used to output the non-erroneous message.
-
fmtThe format string -
...Optional parameter list
public static static info(...)
Record INFO log, Equivalent to the log function.
Record the INFO level of log information. Typically used to output the non-erroneous message.
...Optional parameter list
public static static notice(String fmt,...)
Record NOTICE log.
Record the NOTICE level of log information. Typically used to output the suggestive debug message.
-
fmtThe format string -
...Optional parameter list
public static static notice(...)
Record NOTICE log.
Record the NOTICE level of log information. Typically used to output the suggestive debug message.
...Optional parameter list
public static static warn(String fmt,...)
Record WARN log.
Record the WARN level of log information. Typically used to output the warning debug message. Important.
-
fmtThe format string -
...Optional parameter list
public static static warn(...)
Record WARN log.
Record the WARN level of log information. Typically used to output the warning debug message. Important.
...Optional parameter list
public static static error(String fmt,...)
Record ERROR log.
Record the ERROR level of log information. Typically used to output the error message. Very important. System error message is also record in this level.
-
fmtThe format string -
...Optional parameter list
public static static error(...)
Record ERROR log.
Record the ERROR level of log information. Typically used to output the error message. Very important. System error message is also record in this level.
...Optional parameter list
public static static crit(String fmt,...)
Record CRIT log.
Record the CRIT level of log information. Typically used to output the critical error message. Very important.
-
fmtThe format string -
...Optional parameter list
public static static crit(...)
Record CRIT log.
Record the CRIT level of log information. Typically used to output the critical error message. Very important.
...Optional parameter list
public static static alert(String fmt,...)
Record ALERT log.
Record the ALERT level of log information. Typically used to output the alert error message. Very important. This level is the highest one.
-
fmtThe format string -
...Optional parameter list
public static static alert(...)
Record ALERT log.
Record the ALERT level of log information. Typically used to output the alert error message. Very important. This level is the highest one.
...Optional parameter list
public static static dir(Value obj)
Output object in JSON format.
objThe object given to display
public static static time(String label)
Start a timer.
labelTitle, default is an empty string.
public static static timeEnd(String label)
Value of specified timer.
labelTitle, default is an empty string.
public static static trace(String label)
Output the current used stack.
Output the current used stack by log.
labelTitle, default is an empty string.
public static static assert(Value value,String msg)
Assertion test, which will throw error when testing result is false.
-
valueThe value for test -
msgError message
public static static print(String fmt,...)
Formatted text output to the console, the content will not be written to log system, and the output text does not wrap automatically, the output can output continuously.
-
fmtThe format string -
...Optional parameter list
public static static print(...)
Formatted text output to the console, the content will not be written to log system, and the output text does not wrap automatically, the output can output continuously.
...Optional parameter list
public static String readLine(String msg)
Read the user input from the console.
msgPrompt information
Returns the user input information.
Concurrency control module.
The way to use: var coroutine = require('coroutine');
| Members | Descriptions |
|---|---|
public static Fiber start(Function func,...) |
Start a fibers and return the fiber Object. |
public static Array parallel(Array funcs,Integer fibers) |
Execute a set of functions parallel, and wait for the return. |
public static Array parallel(Array datas,Function func,Integer fibers) |
Execute a function deal with a set of data parallel, and wait for the return. |
public static Array parallel(...) |
Execute a set of functions parallel, and wait for the return. |
public static Fiber current() |
Returns the current fiber. |
public static static sleep(Integer ms) |
Pause the current fiber specified time. |
Start a fibers and return the fiber Object.
-
funcSet a function to be executed by the fibers. -
...Variable parameter sequence, the sequence will pass to function in fiber.
Returns the fiber object.
public static Array parallel(Array funcs,Integer fibers)
Execute a set of functions parallel, and wait for the return.
-
funcsAn array of function to be executed parallel -
fibersLimit the number of concurrent fiber, default -1 (the number of funcs size).
Returns the array of functions execute results
public static Array parallel(Array datas,Function func,Integer fibers)
Execute a function deal with a set of data parallel, and wait for the return.
-
datasAn array of params to be executed by function parallel. -
funcThe function executed parallel -
fibersLimit the number of concurrent fiber, default -1 (the number of datas size).
Returns the array of function execute results
public static Array parallel(...)
Execute a set of functions parallel, and wait for the return.
...A set of function to be execute parallel
Returns the array of functions execute results
Returns the current fiber.
Returns the current fiber object.
public static static sleep(Integer ms)
Pause the current fiber specified time.
msSpecify the suspend time in milliseconds, the default value is 0, which back to resume immediately.
Encryption algorithm module.
The way to use:
var crypto = require('crypto');| Members | Descriptions |
|---|---|
public static PKey loadPKey(String filename,String password) |
Load a PEM/DER format key file. |
public static X509Cert loadCert(String filename) |
Load a CRT/PEM/DER/TXT format certificate can be called multiple times. |
public static X509Crl loadCrl(String filename) |
Load a PEM/DER format revoked certificate can be called multiple times. |
public static X509Req loadReq(String filename) |
Load a PEM/DER format requested certificate can be called multiple times. |
public static Buffer randomBytes(Integer size) |
Generate the specified size of the random number, which use the havege generator. |
public static Buffer pseudoRandomBytes(Integer size) |
Generate the specified size of the pseudo-random number, which use the entropy generator. |
public static String randomArt(Buffer data,String title,Integer size) |
Generate a visual character image by use given data. |
Load a PEM/DER format key file.
-
filenameKey file name. -
passwordDecryption password.
Load a CRT/PEM/DER/TXT format certificate can be called multiple times.
LoadFile load mozilla certdata.txt, which can be download from http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
filenameCertificate file name.
Load a PEM/DER format revoked certificate can be called multiple times.
filenameThe cancellation certificate file name.
Load a PEM/DER format requested certificate can be called multiple times.
filenameThe requested certificate file name.
public static Buffer randomBytes(Integer size)
Generate the specified size of the random number, which use the havege generator.
sizeSpecify the size of the generated random number.
Return the generated random number.
public static Buffer pseudoRandomBytes(Integer size)
Generate the specified size of the pseudo-random number, which use the entropy generator.
sizeSpecify the size of the generated random number.
Return the generated random number.
Generate a visual character image by use given data.
-
dataSpecifies the data to display. -
titleThe title of the specified character image, multibyte characters can cause width error. -
sizeThe character image size.
Return the generated visual string image.
Database access module.
Basic module for create database and database operation, The way to use::
var db = require('db');| Members | Descriptions |
|---|---|
public static object open(String connString) |
This method offer a general entrance to open a database, call different engines according to the providing connString. |
public static MySQL openMySQL(String connString) |
Open a mysql database. |
public static SQLite openSQLite(String connString) |
Open a sqlite database. |
public static MongoDB openMongoDB(String connString) |
Open a mongodb database. |
public static LevelDB openLevelDB(String connString) |
Open a leveldb database. |
public static Redis openRedis(String connString) |
Open a Redis database. |
public static String format(String sql,...) |
Formatting a sql command, and returns the formatted results. |
public static String formatMySQL(String sql,...) |
Formatting a sql command, and returns the formatted results. |
public static String escape(String str,Boolean mysql) |
String encoded as security coded SQL strings. |
This method offer a general entrance to open a database, call different engines according to the providing connString.
connStringDatabase Description, For example: mysql://user:pass@host/db
Returns the database connection object.
Open a mysql database.
connStringDatabase Description, For example: mysql://user:pass@host/db
Returns the database connection object.
public static SQLite openSQLite(String connString)
Open a sqlite database.
connStringDatabase Description, For example: sqlite:test.db or test.db
Returns the database connection object.
public static MongoDB openMongoDB(String connString)
Open a mongodb database.
connStringDatabase Description
Returns the database connection object.
public static LevelDB openLevelDB(String connString)
Open a leveldb database.
connStringDatabase Description, For example: level:test.db or test.db
Returns the database connection object.
Open a Redis database.
connStringDatabase Description, For example: redis://server:port or "server"
Returns the database connection object.
public static String format(String sql,...)
Formatting a sql command, and returns the formatted results.
-
sqlFormat string, optional parameters can be specified as '?', for example: 'SELECT FROM TEST WHERE [id]=?' -
...Optional parameter list
Return the formatted sql command.
public static String formatMySQL(String sql,...)
Formatting a sql command, and returns the formatted results.
-
sqlFormat string, optional parameters can be specified as '?', for example: 'SELECT FROM TEST WHERE [id]=?' -
...Optional parameter list
Return the formatted sql command.
public static String escape(String str,Boolean mysql)
String encoded as security coded SQL strings.
-
strThe string that need to be encoded -
mysqlSpecify the Mysql encoding, the default value is false
Returns the encoded string
module with encode and decode operations between hex and other format data. to use:
var encoding = require('encoding');| Members | Descriptions |
|---|---|
public static String jsstr(String str,Boolean json) |
Encode the string to Javascript escaped string that can be contained in the javascript code. |
public static String encodeURI(String url) |
Url encoding. |
public static String encodeURIComponent(String url) |
Url component encoding. |
public static String decodeURI(String url) |
Url decoding. |
public static String jsstr(String str,Boolean json)
Encode the string to Javascript escaped string that can be contained in the javascript code.
-
strThe string to encode -
jsonSpecifies generate the string json compatible.
Returns the encoded string.
public static String encodeURI(String url)
Url encoding.
urlUrl to be encoded.
The encoded result string.
public static String encodeURIComponent(String url)
Url component encoding.
urlUrl to be encoded.
The encoded result string.
public static String decodeURI(String url)
Url decoding.
urlUrl to be decoded.
The decoded result string.
file system module
how to use
var fs = require('fs');| Members | Descriptions |
|---|---|
public static Boolean exists(String path) |
search if the file or directory exists |
public static Boolean existsSync(String path) |
search if the file or directory exists. Sync version of fs.exists(). |
public static static unlink(String path) |
the file you want to delete |
public static static unlinkSync(String path) |
the file you want to delete. Sync version of fs.unlink(). |
public static static mkdir(String path,Integer mode) |
create a directory |
public static static mkdirSync(String path,Integer mode) |
create a directory. Sync version of fs.mkdir(). |
public static static rmdir(String path) |
delete a directory |
public static static rmdirSync(String path) |
delete a directory. Sync version of fs.rmdir(). |
public static static rename(String from,String to) |
rename a file |
public static static renameSync(String from,String to) |
rename a file |
public static static copy(String from,String to) |
copy file |
public static static chmod(String path,Integer mode) |
check the permission of targeting file, Windows does not support this |
public static static chmodSync(String path,Integer mode) |
check the permission of targeting file, Windows does not support this. Sync version of fs.chmod(). |
public static Stat stat(String path) |
check file basic infomation/stat |
public static Stat statSync(String path) |
check file basic infomation/stat. Sync version of fs.stat(). |
public static List readdir(String path) |
read fileinfo inside target directory |
public static List readdirSync(String path) |
read fileinfo inside target directory. Sync version of fs.readdir(). |
public static SeekableStream open(String fname,String flags) |
open text file to read, write, or read and write |
public static SeekableStream openSync(String fname,String flags) |
open text file to read, write, or read and write. Sync version of fs.open(). |
public static BufferedStream openTextStream(String fname,String flags) |
open text file to read, write, or read and write |
public static String readTextFile(String fname) |
open file and read the conent. |
public static String readFile(String fname) |
open a file, read the content |
public static Buffer readFileSync(String fname) |
open a file, read the content. Sync version of fs.readFile(). |
public static Array readLines(String fname,Integer maxlines) |
open file, ready each line of text content intot an array, end of line is recognized based on EOL definition, by default, posix system: "\n"; windows system: "\r\n" |
public static static writeTextFile(String fname,String txt) |
create text file and write to file 创建文本文件,并写入内容 |
public static static writeFile(String fname,String txt) |
create file, and write new content |
public static static writeFileSync(String fname,Buffer data) |
create file, and write new content. Sync version of fs.writeFile(). |
public static Boolean exists(String path)
search if the file or directory exists
pathassign the search path
return True indicates the file or directory exists
public static Boolean existsSync(String path)
search if the file or directory exists. Sync version of fs.exists().
pathassign the search path
return True indicates the file or directory exists
public static static unlink(String path)
the file you want to delete
paththe path you want to delete
public static static unlinkSync(String path)
the file you want to delete. Sync version of fs.unlink().
paththe path you want to delete
public static static mkdir(String path,Integer mode)
create a directory
-
pathassign the name of directory -
modeassign file ownership, Windows user ignore this
public static static mkdirSync(String path,Integer mode)
create a directory. Sync version of fs.mkdir().
-
pathassign the name of directory -
modeassign file ownership, Windows user ignore this
public static static rmdir(String path)
delete a directory
paththe name of targeting directory
public static static rmdirSync(String path)
delete a directory. Sync version of fs.rmdir().
paththe name of targeting directory
public static static rename(String from,String to)
rename a file
-
fromthe targeting file name -
tothe name you want to change to
public static static renameSync(String from,String to)
rename a file
-
fromthe targeting file name. Sync version of fs.rename(). -
tothe name you want to change to
public static static copy(String from,String to)
copy file
-
fromfile path -
tonew file path
public static static chmod(String path,Integer mode)
check the permission of targeting file, Windows does not support this
-
paththe path to the targeting file -
modetargeting file permission
public static static chmodSync(String path,Integer mode)
check the permission of targeting file, Windows does not support this. Sync version of fs.chmod().
-
paththe path to the targeting file -
modetargeting file permission
check file basic infomation/stat
paththe path to the targeting file
return file basic infomation/stat
check file basic infomation/stat. Sync version of fs.stat().
paththe path to the targeting file
return file basic infomation/stat
read fileinfo inside target directory
paththe path to the directory
return a array of files' info in target directory
public static List readdirSync(String path)
read fileinfo inside target directory. Sync version of fs.readdir().
paththe path to the directory
return a array of files' info in target directory
public static SeekableStream open(String fname,String flags)
open text file to read, write, or read and write
-
fnamethe name of file -
flagsdefine the method for opening file, default is 'r', read only, other supported methods see below: -
'r' ready only, throw excption if file dose not exists
-
'r+' read and write, throw excption if file dose not exists
-
'w' write only, create new if file dose not exist, othewise overwrite
-
'w+' ready and write, create new if file dose not exist, othewise overwrite
-
'a' write only add file, create new if file dose not exist, othewise overwrite
-
'a+' read and write to add file, create new if file dose not exist, othewise overwrite
return opened file object
public static SeekableStream openSync(String fname,String flags)
open text file to read, write, or read and write. Sync version of fs.open().
-
fnamethe name of file -
flagsdefine the method for opening file, default is 'r', read only, other supported methods see below: -
'r' ready only, throw excption if file dose not exists
-
'r+' read and write, throw excption if file dose not exists
-
'w' write only, create new if file dose not exist, othewise overwrite
-
'w+' ready and write, create new if file dose not exist, othewise overwrite
-
'a' write only add file, create new if file dose not exist, othewise overwrite
-
'a+' read and write to add file, create new if file dose not exist, othewise overwrite
return opened file object
public static BufferedStream openTextStream(String fname,String flags)
open text file to read, write, or read and write
-
fnamethe name of file -
flagsdefine the method for opening file, default is 'r', read only, other supported methods see below: -
'r' ready only, throw excption if file dose not exists
-
'r+' read and write, throw excption if file dose not exists
-
'w' write only, create new if file dose not exist, othewise overwrite
-
'w+' ready and write, create new if file dose not exist, othewise overwrite
-
'a' write only add file, create new if file dose not exist, othewise overwrite
-
'a+' read and write to add file, create new if file dose not exist, othewise overwrite
return opened file object
public static String readTextFile(String fname)
open file and read the conent.
fnamethe name of file
file content
public static String readFile(String fname)
open a file, read the content
fnameassign file name
return content of opened file
public static Buffer readFileSync(String fname)
open a file, read the content. Sync version of fs.readFile().
fnameassign file name
return content of opened file
public static Array readLines(String fname,Integer maxlines)
open file, ready each line of text content intot an array, end of line is recognized based on EOL definition, by default, posix system: "\n"; windows system: "\r\n"
-
fnameassign file name -
maxlinesdefine the maximum number of line to read, read all lines by default
return the array containing every line of file content, if no content or connection is lost, then return an empty array
public static static writeTextFile(String fname,String txt)
create text file and write to file 创建文本文件,并写入内容
-
fnameassign file name -
txtsting to be written
public static static writeFile(String fname,String txt)
create file, and write new content
-
fnameassign file name -
txtthe content you are going to write into file
public static static writeFileSync(String fname,Buffer data)
create file, and write new content. Sync version of fs.writeFile().
-
fnameassign file name -
txtthe content you are going to write into file
Image processing module.
Base module. It can be used to create and manipulate image files. The way to use:
var gd = require('gd');| Members | Descriptions |
|---|---|
public static Image create(Integer width,Integer height,Integer color) |
Create a new image. |
public static Image load(Buffer data) |
Decoded image from the format data. |
public static Image load(SeekableStream stm) |
Decoded image from the stream object. |
public static Image load(String fname) |
Decoded image from the specified file. |
public static Integer rgb(Integer red,Integer green,Integer blue) |
Generating a combined color through rgb color components. |
public static Integer rgba(Integer red,Integer green,Integer blue,Number alpha) |
Generating a combined color through rgba color components. |
public static Integer hsl(Number hue,Number saturation,Number lightness) |
Generating a combined color through hsl color components. |
public static Integer hsla(Number hue,Number saturation,Number lightness,Number alpha) |
Generating a combined color through hsla color components. |
public static Integer hsb(Number hue,Number saturation,Number brightness) |
Generating a combined color through hsb color components. |
public static Integer hsba(Number hue,Number saturation,Number brightness,Number alpha) |
Generating a combined color through hsba color components. |
public static Integer color(String color) |
Generating a combined color by string. |
Create a new image.
-
widthSpecifies the width of the image. -
heightSpecifies the height of the image. -
colorSpecify the image type, the allowable value is gd.TRUECOLOR or gd.PALETTE
Returns the created image object of success.
Decoded image from the format data.
dataThe image data need decoded.
Return successfully decoded image object.
public static Image load(SeekableStream stm)
Decoded image from the stream object.
stmThe stream object of the specified image data.
Return successfully decoded image object.
Decoded image from the specified file.
fnameSpecify the file name.
Return successfully decoded image object.
public static Integer rgb(Integer red,Integer green,Integer blue)
Generating a combined color through rgb color components.
-
redRed component in the range of 0-255 -
greenGreen component in the range of 0-255 -
blueBlue component in the range of 0-255
Returns the combined color.
public static Integer rgba(Integer red,Integer green,Integer blue,Number alpha)
Generating a combined color through rgba color components.
-
redRed component in the range of 0-255 -
greenGreen component in the range of 0-255 -
blueBlue component in the range of 0-255 -
alphaTransparent component in the range of 0.0-1.0
Returns the combined color.
public static Integer hsl(Number hue,Number saturation,Number lightness)
Generating a combined color through hsl color components.
-
hueHue component in the range of 0-360. -
saturationSaturation components in the range of 0.0-1.0 -
lightnessLightness component in the range of 0.0-1.0
Returns the combined color.
public static Integer hsla(Number hue,Number saturation,Number lightness,Number alpha)
Generating a combined color through hsla color components.
-
hueHue component in the range of 0-360. -
saturationSaturation components in the range of 0.0-1.0 -
lightnessLightness component in the range of 0.0-1.0 -
alphaTransparent component in the range of 0.0-1.0
Returns the combined color.
public static Integer hsb(Number hue,Number saturation,Number brightness)
Generating a combined color through hsb color components.
-
hueHue component in the range of 0-360. -
saturationSaturation components in the range of 0.0-1.0 -
brightnessBrightness component in the range of 0.0-1.0
Returns the combined color.
public static Integer hsba(Number hue,Number saturation,Number brightness,Number alpha)
Generating a combined color through hsba color components.
-
hueHue component in the range of 0-360. -
saturationSaturation components in the range of 0.0-1.0 -
brightnessBrightness component in the range of 0.0-1.0 -
alphaTransparent component in the range of 0.0-1.0
Returns the combined color.
public static Integer color(String color)
Generating a combined color by string.
colorThe specified color string, e.g: "#ff0000", "ff0000", "#f00", "f00"
Returns the combined color.
Global object, which can be accessed by all scripts.
| Members | Descriptions |
|---|---|
public static static run(String fname,Array argv) |
Run a script. |
public static Value require(String id) |
Load a module and return module object, reference Module Management. |
public static static GC() |
Mandatory for garbage collection. |
public static static repl(Array cmds) |
Enter the interactive mode, you can interactively execute the internal commands and code which can only be referenced when js start. |
public static static repl(Stream out,Array cmds) |
Enter the interactive mode, you can interactively execute the internal commands and code which can only be referenced when js start. |
public static static run(String fname,Array argv)
Run a script.
-
fnameSpecifies the running path for script -
argvSpecify the run parameters, which can be caught in script by argv.
public static Value require(String id)
Load a module and return module object, reference Module Management.
require can be used to load the base module, such as file module.
Base module is initializing when the sandbox created, only need pass the id when referencing, e.g: require("net")。
File module is user-defined modules which required by the relative path beginning with './' or '../'. File module supports .js and .json file.
File module also supports the format package.json, system will first require the main in package.json when the module is a directory, then will try to load index.js or index.json in the path if failed.
If the path is not a reference beginning with ./ or ../, and the module is not non-base module, system will first require the match one in startup path, and then look for the .modules in current path, then try the parent directory.
idSpecifies the name of module to load
Returns the derivation of the load module
public static static GC()
Mandatory for garbage collection.
public static static repl(Array cmds)
Enter the interactive mode, you can interactively execute the internal commands and code which can only be referenced when js start.
cmdsAdd commands in the following format:
[
{
cmd: ".test",
help: "this is a test",
exec: function(argv) {
console.log(argv);
}
},
{
cmd: ".test1",
help: "this is an other test",
exec: function(argv) {
console.log(argv);
}
}
]Enter the interactive mode, you can interactively execute the internal commands and code which can only be referenced when js start.
At the same time allowed only a Stream repl, close the previous one when create a new Stream repl.
-
outInput/output stream object, usually for a network connection -
cmdsAdd commands in the following format:
[
{
cmd: ".test",
help: "this is a test",
exec: function(argv) {
console.log(argv);
}
},
{
cmd: ".test1",
help: "this is an other test",
exec: function(argv) {
console.log(argv);
}
}
]Message digest calculation module, can be used to calculate the message digest and summary Signature.
| Members | Descriptions |
|---|---|
public static Digest digest(Integer algo,Buffer data) |
Create a message digest object with the specified algorithm. |
public static Digest digest(Integer algo) |
Create a message digest object with the specified algorithm. |
public static Digest md2(Buffer data) |
Create a MD2 message digest object. |
public static Digest md4(Buffer data) |
Create a MD4 message digest object. |
public static Digest md5(Buffer data) |
Create a MD5 message digest object. |
public static Digest sha1(Buffer data) |
Create a SHA1 message digest object. |
public static Digest sha224(Buffer data) |
Create a SHA224 message digest object. |
public static Digest sha256(Buffer data) |
Create a SHA256 message digest object. |
public static Digest sha384(Buffer data) |
Create a SHA384 message digest object. |
public static Digest sha512(Buffer data) |
Create a SHA512 message digest object. |
public static Digest ripemd160(Buffer data) |
Create a RIPEMD160 message digest object. |
public static Digest hmac(Integer algo,Buffer key) |
Create a message signature digest object with the specified algorithm. |
public static Digest hmac_md2(Buffer key) |
Create a MD2 message digest signature object. |
public static Digest hmac_md4(Buffer key) |
Create a MD4 message digest signature object. |
public static Digest hmac_md5(Buffer key) |
Create a MD5 message digest signature object. |
public static Digest hmac_sha1(Buffer key) |
Create a SHA1 message digest signature object. |
public static Digest hmac_sha224(Buffer key) |
Create a SHA224 message digest signature object. |
public static Digest hmac_sha256(Buffer key) |
Create a SHA256 message digest signature object. |
public static Digest hmac_sha384(Buffer key) |
Create a SHA384 message digest signature object. |
public static Digest hmac_sha512(Buffer key) |
Create a SHA512 message digest signature object. |
public static Digest hmac_ripemd160(Buffer key) |
Create a RIPEMD160 message digest signature object. |
Create a message digest object with the specified algorithm.
-
algoSpecifies the digest algorithm. -
dataBinary data needs to be updated.
Returns the message digest object.
Create a message digest object with the specified algorithm.
algoSpecifies the digest algorithm.
Returns the message digest object.
Create a MD2 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a MD4 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a MD5 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a SHA1 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a SHA224 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a SHA256 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a SHA384 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a SHA512 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a RIPEMD160 message digest object.
dataBinary data needs to be updated.
Returns the message digest object.
Create a message signature digest object with the specified algorithm.
-
algoSpecifies the digest algorithm. -
keyBinary signature key.
Returns the message digest object.
Create a MD2 message digest signature object.
keyBinary signature key.
Returns the message digest object.
Create a MD4 message digest signature object.
keyBinary signature key.
Returns the message digest object.
Create a MD5 message digest signature object.
keyBinary signature key.
Returns the message digest object.
Create a SHA1 message digest signature object.
keyBinary signature key.
Returns the message digest object.
public static Digest hmac_sha224(Buffer key)
Create a SHA224 message digest signature object.
keyBinary signature key.
Returns the message digest object.
public static Digest hmac_sha256(Buffer key)
Create a SHA256 message digest signature object.
keyBinary signature key.
Returns the message digest object.
public static Digest hmac_sha384(Buffer key)
Create a SHA384 message digest signature object.
keyBinary signature key.
Returns the message digest object.
public static Digest hmac_sha512(Buffer key)
Create a SHA512 message digest signature object.
keyBinary signature key.
Returns the message digest object.
public static Digest hmac_ripemd160(Buffer key)
Create a RIPEMD160 message digest signature object.
keyBinary signature key.
Returns the message digest object.
module with encode and decode operations between hex and string. to use:
var encoding = require('encoding');
var hex = encoding.hex;or:
var hex = require('hex');| Members | Descriptions |
|---|---|
public static String encode(Buffer data) |
Encode data whith hex format. |
public static Buffer decode(String data) |
Decode string to binary data with hex format. |
Encode data whith hex format.
dataData to be encoded.
Encoded result string.
Decode string to binary data with hex format.
dataString to be decode.
Decoded binary data result.
HTTP transfer protocol module, handels http protocol.
| Members | Descriptions |
|---|---|
public static HttpRequestnewRequest() |
create a http request object,reference HttpRequest |
public static HttpResponsenewResponse() |
create a http response object,reference HttpResponse |
public static HttpCookienewCookie() |
create a http cookie object,reference HttpCookie |
public static HttpServernewServer() |
create a http server,reference HttpServer |
public static HttpsServernewHttpsServer() |
create a https server, reference HttpsServer |
public static HttpHandlernewHandler() |
create a http protocol handler,reference HttpHandler |
public static Handler fileHandler(String root,Object mimes) |
create a http static file processor, in case of using static file to respond http request |
public static HttpResponse request(Stream conn,HttpRequest req) |
send http request to connection object,return response |
public static HttpResponse request(String method,String url,Object headers) |
assign requested url, and return |
public static HttpResponse request(String method,String url,SeekableStream body,Object headers) |
Request the specified url, and get the response. |
public static HttpResponse request(String method,String url,SeekableStream body,Map headers) |
Request the specified url, and get the response. |
public static HttpResponse request(String method,String url,Buffer body,Object headers) |
Request the specified url, and get the response. |
public static HttpResponse get(String url,Object headers) |
reuqest url with GET method,and return response,same as request("GET", ...) |
public static HttpResponse post(String url,SeekableStream body,Object headers) |
reuqest url with POST method,and return response,same as request("POST", ...) |
public static HttpResponse post(String url,Buffer body,Object headers) |
reuqest url with POST method,and return response,same as request("POST", ...) |
public static HttpRequestnewRequest()
create a http request object,reference HttpRequest
public static HttpResponsenewResponse()
create a http response object,reference HttpResponse
public static HttpCookienewCookie()
create a http cookie object,reference HttpCookie
public static HttpServernewServer()
create a http server,reference HttpServer
public static HttpsServernewHttpsServer()
create a https server, reference HttpsServer
public static HttpHandlernewHandler()
create a http protocol handler,reference HttpHandler
public static Handler fileHandler(String root,Object mimes)
create a http static file processor, in case of using static file to respond http request
-
rootfile root folder -
mimesextends mime settings -
mimesextedns mime settings
return a static file processor to handle http request
fileHandler support gzip pre-compression,when accept gzip in content-typeand filename.ext.gz exists under same root,then return the file directly, to avoid extra load on server.
public static HttpResponse request(Stream conn,HttpRequest req)
send http request to connection object,return response
-
connassign requested connection object -
reqthe HttpRequest obejct need to be sent
return server response
public static HttpResponse request(String method,String url,Object headers)
assign requested url, and return
-
methoddefine http request method, such as: GET, POST -
urlassigned url,has to be full url with root path -
headersdefine http request header,default is None
reutrn server response
public static HttpResponse request(String method,String url,SeekableStream body,Object headers)
Request the specified url, and get the response.
-
methoddefine http method, such as: GET, POST -
urlassigned url,has to be full url with root path -
bodydefine http body content -
headersdefine http request header,default is None
reutrn server response
public static HttpResponse request(String method,String url,SeekableStream body,Map headers)
Request the specified url, and get the response.
-
methoddefine http method, such as: GET, POST -
urlassigned url,has to be full url with root path -
bodydefine http body content -
headersdefine http request header, default is None
reutrn server response
public static HttpResponse request(String method,String url,Buffer body,Object headers)
Request the specified url, and get the response.
-
methoddefine http method, such as: GET, POST -
urlassigned url,has to be full url with root path -
bodydefine http body content -
headersdefine http request header, default is None
reutrn server response
public static HttpResponse get(String url,Object headers)
reuqest url with GET method,and return response,same as request("GET", ...)
-
urlassigned url,has to be full url with root path -
headersdefine http request header,default is None
reutrn server response
public static HttpResponse post(String url,SeekableStream body,Object headers)
reuqest url with POST method,and return response,same as request("POST", ...)
-
urlassigned url,has to be full url with root path -
bodydefine http body content -
headersdefine http request header,default is None
reutrn server response
public static HttpResponse post(String url,Buffer body,Object headers)
reuqest url with POST method,and return response,same as request("POST", ...)
-
urlassigned url,has to be full url with root path -
bodydefine http body content -
headersdefine http request header,default is None
reutrn server response
iconv Module with encode and decode operations between text and binary. to use:
var encoding = require('encoding');
var iconv = encoding.iconv;or:
var iconv = require('iconv');| Members | Descriptions |
|---|---|
public static Buffer encode(String charset,String data) |
Convert text to binary with iconv. |
public static String decode(String charset,Buffer data) |
Convert binary to text with iconv. |
Convert text to binary with iconv.
-
charsetThe charset to be use. -
dataThe text to be converted.
The binary encoded result.
Convert binary to text with iconv.
-
charsetThe charset to be use. -
dataBinary to be converted.
The text decoded result.
IO module.
To use it:
var io = require('io');| Members | Descriptions |
|---|---|
public static MemoryStreamnewMemoryStream() |
Create a memory stream, see MemoryStream. |
public static BufferedStreamnewBufferedStream() |
Create a buffered read stream, see BufferedStream. |
public static MemoryStreamnewMemoryStream()
Create a memory stream, see MemoryStream.
public static BufferedStreamnewBufferedStream()
Create a buffered read stream, see BufferedStream.
json module with encode and decode operations. to use:
var encoding = require('encoding');
var json = encoding.json;or:
var json = require('json');| Members | Descriptions |
|---|---|
public static String encode(Value data) |
Encode a json variable to string with json format. |
public static Value decode(String data) |
Decode a string variable to json with json format. |
public static String encode(Value data)
Encode a json variable to string with json format.
dataValue to be encoded.
The encoded string result.
public static Value decode(String data)
Decode a string variable to json with json format.
dataString to be decoded.
Json value decoded result.
Message queue module.
| Members | Descriptions |
|---|---|
public static Handler jsHandler(Value hdlr) |
Create a javascript message handler, return immediately when pass by value. |
public static AsyncWait await() |
Create async handler. |
public static Handler nullHandler() |
Create a empty handler. |
public static static invoke(Handler hdlr,object v) |
Invoke a message or object to given handler. |
Create a javascript message handler, return immediately when pass by value.
hdlrbuiltin handler, function or javascript mapping object, handler will map be mapped automatically
Return handler of handle function
Syntax:
function func(v){
}Parameter v is the message to procee, there are three possibilities:
-
Object javascript object, used for mapping message
-
Function javascript function, used for next stage
-
Handler Builtin handler for next stage No return or other result will finish message processing.
Use message mapping handler to handle nested logic as follows:
hdlr = mq.jsHandler({
// fun1
fun1 : function(v){},
sub : {
// sub.fun2 or sub/fun2
fun2 : function(v){},
// sub.hdlr or sub/hdlr
hdlr: myHandler
}
});In the example, fun1 and fun2 are normal javascript handle function, sub is a sub-object, myHandler is a handler
Create async handler.
Return created handler
Wait handler async as follows:
function func(v){
var await = mq.await();
call_some_async_func(v1, v2, v3, function() {
await.end();
});
return await;
}Example uses javascript message handle function, when it returns, message handle engine will wait for await until await.end being called.
public static Handler nullHandler()
Create a empty handler.
Return empry handler
Invoke a message or object to given handler.
Unlike invoke method of handler, this will loop and wait every handler until reach null
Network module.
Used for create and operate netwrok resource, to use it:
var net = require('net');| Members | Descriptions |
|---|---|
public static String resolve(String name,Integer family) |
Resolve address of given host. |
public static String ip(String name) |
Quick query host address, same as resolve(name) |
public static String ipv6(String name) |
Quick query host ipv6 address, same as resolve(name, net.AF_INET6) |
public static Stream connect(String host,Integer port,Integer family) |
Create a Socket object and make connection, see Socket. |
public static Stream connect(String url) |
Create a Socket or SslSocket and make connection. |
public static Smtp openSmtp(String host,Integer port,Integer family) |
Create a Smtp object and make connection, see Smtp. |
public static String backend() |
Get system backend async network engine. |
public static String resolve(String name,Integer family)
Resolve address of given host.
-
nameHome name -
familyReturn type, default is AF_INET
Return IP result string
public static String ip(String name)
Quick query host address, same as resolve(name)
nameHost name
Return IP result string
public static String ipv6(String name)
Quick query host ipv6 address, same as resolve(name, net.AF_INET6)
nameHost name
Return IPv6 result string
Create a Socket object and make connection, see Socket.
-
hostTarget address or host name -
portTarget port number -
familyAddree type, default is AF_INE, ipv4
Return connected Socket object
Create a Socket or SslSocket and make connection.
urlURL with protocol, can be tcp://host:port or ssl://host:port
Return connected Socket or SslSocket object
Create a Smtp object and make connection, see Smtp.
-
hostTarget address or host name -
portTarget port number -
familyAddree type, default is AF_INE, ipv4
Return connected Smtp object
public static String backend()
Get system backend async network engine.
Return network engine name
Operating system and file system module.
To use it:
var os = require('os');| Members | Descriptions |
|---|---|
public static Number uptime() |
Get operating system time in seconds. |
public static Array loadavg() |
Get system load average, 1, 5 and 15 minutes. |
public static Long totalmem() |
Get system total memory in bytes. |
public static Long freemem() |
Get system free memory in bytes. |
public static Array CPUInfo() |
Get system CPU number and information. |
public static Integer CPUs() |
Get system CPU number. |
public static Object networkInfo() |
Get system network information. |
public static Date time(String tmString) |
Parse or get system time. |
public static Date dateAdd(Date d,Integer num,String part) |
Time calculation function, use part to indicate time. |
public static Object memoryUsage() |
Get current memory usage. |
public static Number uptime()
Get operating system time in seconds.
Return time in integer
public static Array loadavg()
Get system load average, 1, 5 and 15 minutes.
Return results array
public static Long totalmem()
Get system total memory in bytes.
Return total memory
public static Long freemem()
Get system free memory in bytes.
Return free memory
public static Array CPUInfo()
Get system CPU number and information.
Return CPU information array
public static Integer CPUs()
Get system CPU number.
Return CPU number
public static Object networkInfo()
Get system network information.
Return network information
public static Date time(String tmString)
Parse or get system time.
tmStringTime format, default is query current time
Return javascript Date object
public static Date dateAdd(Date d,Integer num,String part)
Time calculation function, use part to indicate time.
-
dDate object to calculate on -
numNumber to calculate -
partType to calculate, can be "year", "month", "day", "hour", "minute", "second"
Return javascript Date object
public static Object memoryUsage()
Get current memory usage.
Return memory usage
Usage includes:
{
"rss": 8622080,
"heapTotal": 4083456,
"heapUsed": 1621800,
"nativeObjects": 122
}Notes:
-
rss Physical memory being occupied by current process
-
heapTotal Return v8 engine heap memory size
-
heapUsed Return v8 engine heap memory size in use
-
nativeObjects Return number of memory objects
File path module.
To use it:
var path = require('path');| Members | Descriptions |
|---|---|
public static String normalize(String path) |
Normalize path. |
public static String basename(String path,String ext) |
Get file name in path, ignore extension with file has it. |
public static String extname(String path) |
Get file extension. |
public static String dirname(String path) |
Get directory in path. |
public static String fullpath(String path) |
Get full path. |
public static String join(...) |
Merge multiple paths to a single relative path. |
public static String resolve(...) |
Merge multiple paths to a single absolute path. |
public static String normalize(String path)
Normalize path.
pathOriginal path
Return normalized path
public static String basename(String path,String ext)
Get file name in path, ignore extension with file has it.
-
pathOriginal path -
extGiven extension
Return file name
public static String extname(String path)
Get file extension.
pathOriginal path
Return file extension
public static String dirname(String path)
Get directory in path.
pathOriginal path
Return directory
public static String fullpath(String path)
Get full path.
pathOriginal path
Return full path
public static String join(...)
Merge multiple paths to a single relative path.
...One or more relative paths
Return new relative path
public static String resolve(...)
Merge multiple paths to a single absolute path.
...One or more relative paths
Return new absolute path
Process handle module, to manage current process resources.
To use it:
var process = require('process');| Members | Descriptions |
|---|---|
public static Integer umask(Integer mask) |
change the current umask,Windows does't support this. |
public static Integer umask(String mask) |
change the current umask,Windows does't support this. |
public static Integer umask() |
return the current umask,Windows does't support this. |
public static static exit(Integer code) |
Exit current process, and return result. |
public static String cwd() |
Return current work path of the operating system. |
public static static chdir(String directory) |
Change the current work path of operating system. |
public static Number uptime() |
returns the system uptime in number of seconds. |
public static Object memoryUsage() |
Get report of memory the current process consumpt. |
public static static nextTick(Function func,...) |
start a fiber |
public static SubProcess open(String command,Array args,Object opts) |
Create chlid process taking charge of stdin and stdout and run bash command. |
public static SubProcess open(String command,Object opts) |
Create chlid process taking charge of stdin and stdout and run bash command. |
public static SubProcess start(String command,Array args,Object opts) |
Create chlid process and run bash command. |
public static SubProcess start(String command,Object opts) |
Create chlid process and run bash command. |
public static Integer run(String command,Array args,Object opts) |
Run bash command and return result code. |
public static Integer run(String command,Object opts) |
Run bash command and return result code. |
public static Integer umask(Integer mask)
change the current umask,Windows does't support this.
maskthe mask to set
the previous mask
public static Integer umask(String mask)
change the current umask,Windows does't support this.
maskoctonary string(e.g: "0664")
the previous mask
public static Integer umask()
return the current umask,Windows does't support this.
the current mask
public static static exit(Integer code)
Exit current process, and return result.
coderesult of process.
public static String cwd()
Return current work path of the operating system.
Work path.
public static static chdir(String directory)
Change the current work path of operating system.
directoryThe new work path.
public static Number uptime()
returns the system uptime in number of seconds.
seconds
public static Object memoryUsage()
Get report of memory the current process consumpt.
Memory report object.
Memory report like this:
{
"rss": 8622080,
"heapTotal": 4083456,
"heapUsed": 1621800
}among the report:
-
rss Occupation of physical memory.
-
heapTotal Total heap memory of v8.
-
heapUsed Heap memory occupied by v8.
public static static nextTick(Function func,...)
start a fiber
-
funcfunction to be executed in the new fiber. -
...params which will be passed to the func.
public static SubProcess open(String command,Array args,Object opts)
Create chlid process taking charge of stdin and stdout and run bash command.
-
commandBash command to be executed. -
argsArguments for bash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Enviroment variable of child process.
}Child process object containing result of command.
public static SubProcess open(String command,Object opts)
Create chlid process taking charge of stdin and stdout and run bash command.
-
commandBash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Environment variable of child process.
}Child process object containing result of command.
public static SubProcess start(String command,Array args,Object opts)
Create chlid process and run bash command.
-
commandBash command. -
argsArguments of bash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Environment variable of child process.
}Child process object containing result of the command.
public static SubProcess start(String command,Object opts)
Create chlid process and run bash command.
-
commandBash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Environment variable of child process.
}Child process object containing result of the command.
public static Integer run(String command,Array args,Object opts)
Run bash command and return result code.
-
commandBash command. -
argsArguments of bash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Environment variable of child process.
}Result code of bash command.
public static Integer run(String command,Object opts)
Run bash command and return result code.
-
commandBash command. -
optsOption of child process, such as:
{
"timeout": 100, // unit ms
"envs": [] // Environment variable of child process.
}Result code of bash command.
Memory profiler module.
The way to use:
var profiler = require('profiler');| Members | Descriptions |
|---|---|
public static static saveSnapshot(String fname) |
Save a HeapSnapshot with the specified name. |
public static HeapSnapshot loadSnapshot(String fname) |
Load a HeapSnapshot with the specified name. |
public static HeapSnapshot takeSnapshot() |
Get the current HeapSnapshot, HeapSnapshots record the state of the JS heap at some moment. |
public static static DeleteAllHeapSnapshots() |
Delete all HeapSnapshots. |
public static static saveSnapshot(String fname)
Save a HeapSnapshot with the specified name.
fnameHeapSnapshot name.
public static HeapSnapshot loadSnapshot(String fname)
Load a HeapSnapshot with the specified name.
fnameHeapSnapshot name.
Return the HeapSnapshot loaded.
public static HeapSnapshot takeSnapshot()
Get the current HeapSnapshot, HeapSnapshots record the state of the JS heap at some moment.
Returns the acquired HeapSnapshots.
public static static DeleteAllHeapSnapshots()
Delete all HeapSnapshots.
Regexp module.
| Members | Descriptions |
|---|---|
public static Regex compile(String pattern,String opt) |
Compile and return a template of regexp. |
Compile and return a template of regexp.
-
patternRegexp pattern -
optMatch type, can be "g", "i" or "gi"
Return regexp object
RPC module.
To use it:
var rpc = require('rpc');| Members | Descriptions |
|---|---|
public static Handler json(Value hdlr) |
Generate a json-rpc message converter. |
Generate a json-rpc message converter.
hdlrBuilt-in handler, handle function or javascript message mapping object, see mq.jsHandler
Return handler
ssl/tls module
| Members | Descriptions |
|---|---|
public static SslSocketnewSocket() |
Create a SslSocket object, see SslSocket. |
public static SslHandlernewHandler() |
Create a SslHandler object, see SslHandler. |
public static SslServernewServer() |
Create a SslServer object, see SslServer. |
public static Stream connect(String url) |
Create a SslSocket and make connection. |
public static static setClientCert(X509Cert crt,PKey key) |
Set the default client certificate. |
public static static loadClientCertFile(String crtFile,String keyFile,String password) |
Load the default client certificate from a file. |
Create a SslSocket object, see SslSocket.
public static SslHandlernewHandler()
Create a SslHandler object, see SslHandler.
Create a SslServer object, see SslServer.
Create a SslSocket and make connection.
urlSpecify URL and protocol, e.g.: ssl://host:port
Return SslSocket when succeed
public static static setClientCert(X509Cert crt,PKey key)
Set the default client certificate.
-
crt509Cert certificate for client authentication server. -
keyPKey The private key for the client session.
public static static loadClientCertFile(String crtFile,String keyFile,String password)
Load the default client certificate from a file.
-
crtFileX509Cert certificate file for client authentication server. -
keyFilePKey private key file for the client session. -
passwordDecryption password
Test Suite module that defines the test suite management.
To use it:
var test = require('test');| Members | Descriptions |
|---|---|
public static static describe(String name,Function block) |
The definition of a test module and can be nested definition. |
public static static xdescribe(String name,Function block) |
The definition of a test module to be stopped. |
public static static it(String name,Function block) |
Define a test project. |
public static static xit(String name,Function block) |
Prohibit test project definition. |
public static static before(Function func) |
Define the incident event for current test module. |
public static static after(Function func) |
Define the exit event for current test module. |
public static static beforeEach(Function func) |
Define the incident event for current test project. |
public static static afterEach(Function func) |
Define the exit event for current test project. |
public static Integer run(Integer loglevel) |
Module to start executing definition. |
public static Expect expect(Value actual,String msg) |
expect Grammar test engine |
public static static setup(Integer mode) |
The current test environment initialization script, the test module method to copy a global variable for the current script. |
public static static describe(String name,Function block)
The definition of a test module and can be nested definition.
-
nameModule name -
blockInitial code
public static static xdescribe(String name,Function block)
The definition of a test module to be stopped.
-
nameModule name -
blockInitial code
public static static it(String name,Function block)
Define a test project.
-
nameProject name -
blockTest block
public static static xit(String name,Function block)
Prohibit test project definition.
-
nameProject name -
blockTest block
public static static before(Function func)
Define the incident event for current test module.
funcEvent handler
public static static after(Function func)
Define the exit event for current test module.
funcEvent handler
public static static beforeEach(Function func)
Define the incident event for current test project.
funcEvent handler
public static static afterEach(Function func)
Define the exit event for current test project.
funcEvent handler
public static Integer run(Integer loglevel)
Module to start executing definition.
loglevelLog output level is specified when tested, ERROR, the project focused on the report the error message is displayed, below ERROR, output information displayed at any time, while higher than ERROR, display only reports
Return the statistical result of test case, return 0 when meet no error, return the error number of errors.
expect Grammar test engine
-
actualValue to test -
msgMessage when error occurs
Return Expect for chain operations
public static static setup(Integer mode)
The current test environment initialization script, the test module method to copy a global variable for the current script.
modeIndicates initial mode, default is BDD
Common tools module.
| Members | Descriptions |
|---|---|
public static String format(String fmt,...) |
Format string with variables. |
public static String format(...) |
Format variables. |
public static Boolean isEmpty(Value v) |
Check if variable is empty(no enumerable property) |
public static Boolean isArray(Value v) |
Check if variable is an array. |
public static Boolean isBoolean(Value v) |
Check if variable is Boolean. |
public static Boolean isNull(Value v) |
Check if variable is Null. |
public static Boolean isNullOrUndefined(Value v) |
Check if variable is Null or Undefined. |
public static Boolean isNumber(Value v) |
Check if variable is a number. |
public static Boolean isString(Value v) |
Check if variable is a string. |
public static Boolean isUndefined(Value v) |
Check if variable is Undefined. |
public static Boolean isRegExp(Value v) |
Check if variable is a regexp object. |
public static Boolean isObject(Value v) |
Check if variable is an object. |
public static Boolean isDate(Value v) |
Check if variable is date object. |
public static Boolean isFunction(Value v) |
Check if variable is a function. |
public static Boolean isBuffer(Value v) |
Check if variable is a Buffer object. |
public static Boolean has(Value v,String key) |
Check if object contains given key. |
public static Array keys(Value v) |
Get an array of all keys. |
public static Array values(Value v) |
Get an array of all values. |
public static Value clone(Value v) |
Clone a variable, copy internal content if it's an object or array. |
public static Value extend(Value v,...) |
Extend one or more values of objects to given object. |
public static Object pick(Value v,...) |
Return a copy of object with filtered attributes. |
public static Object omit(Value v,...) |
Return a copy of object, exclude given attributes. |
public static Value first(Value v) |
Get first element in array. |
public static Value first(Value v,Integer n) |
Get first number of elements in array. |
public static Value last(Value v) |
Get last element in array. |
public static Value last(Value v,Integer n) |
Get number of element in the end of array. |
public static Array unique(Value v,Boolean sorted) |
Get array without duplicates. |
public static Array union(...) |
Union one or more arrays into one unique array. |
public static Array intersection(...) |
Return intersections of arrays. |
public static Array flatten(Value arr,Boolean shallow) |
Convert multi-dimension arrays into one-dimension, only reduce one dimension if you pass shallow argument. |
public static Array without(Value arr,...) |
Return an array without given elements. |
public static Array difference(Array list,...) |
Return differences of arrays. |
public static Value each(Value list,Function iterator,Value context) |
Iterate list in order. If context is passed, then bind iterator to context. Each iteration will pass three arguments to context: element, index and list. |
public static Array map(Value list,Function iterator,Value context) |
Use iterator to map values to new array. If context is passed, then bind iterator to context. Each iteration will pass three arguments to context: element, index and list. |
public static Value reduce(Value list,Function iterator,Value memo,Value context) |
Reduce every element in list to a single number. If context is passed, then bind iterator to context. Each iteration will pass four arguments to context: memo, element, index and list. |
public static Object buildInfo() |
Get current engine and components information. |
public static String format(String fmt,...)
Format string with variables.
-
fmtFormat string -
...Aeguments
Return formatted string
public static String format(...)
Format variables.
...Aeguments
Return formatted string
public static Boolean isEmpty(Value v)
Check if variable is empty(no enumerable property)
vVariable to check
Return true when it's empty
public static Boolean isArray(Value v)
Check if variable is an array.
vVariable to check
Return true when it's an array
public static Boolean isBoolean(Value v)
Check if variable is Boolean.
vVariable to check
Return true when it's a Boolean
public static Boolean isNull(Value v)
Check if variable is Null.
vVariable to check
Return true when it's Null
public static Boolean isNullOrUndefined(Value v)
Check if variable is Null or Undefined.
vVariable to check
Return true when it's Null or Undefined
public static Boolean isNumber(Value v)
Check if variable is a number.
vVariable to check
Return true when it's a number
public static Boolean isString(Value v)
Check if variable is a string.
vVariable to check
Return true when it's a string
public static Boolean isUndefined(Value v)
Check if variable is Undefined.
vVariable to check
Return true when it's Undefined
public static Boolean isRegExp(Value v)
Check if variable is a regexp object.
vVariable to check
Return true when it's a regexp object
public static Boolean isObject(Value v)
Check if variable is an object.
vVariable to check
Return true when it's an object
public static Boolean isDate(Value v)
Check if variable is date object.
vVariable to check
Return true when it's date object
public static Boolean isFunction(Value v)
Check if variable is a function.
vVariable to check
Return true when it's a function
public static Boolean isBuffer(Value v)
Check if variable is a Buffer object.
vVariable to check
Return true when it's a Buffer object
public static Boolean has(Value v,String key)
Check if object contains given key.
-
vObject to check -
keyKey to query
Return true when it contains key
public static Array keys(Value v)
Get an array of all keys.
vObject to check
Return an array of all keys
public static Array values(Value v)
Get an array of all values.
vObject to check
Return an array of all keys
public static Value clone(Value v)
Clone a variable, copy internal content if it's an object or array.
vVariable to clone
Return cloned result
public static Value extend(Value v,...)
Extend one or more values of objects to given object.
-
vObject to be extended -
...One or more objects to extend
Return extended object
public static Object pick(Value v,...)
Return a copy of object with filtered attributes.
-
vObject to filter -
...One or more attributes
Return copy of object
public static Object omit(Value v,...)
Return a copy of object, exclude given attributes.
-
vObject to filter -
...One or more attributes to exclude
Return copy of object
public static Value first(Value v)
Get first element in array.
vArray to access
Return element
public static Value first(Value v,Integer n)
Get first number of elements in array.
-
vArray to access -
nNumber of elements to get
Return array of elements
public static Value last(Value v)
Get last element in array.
vArray to access
Return element
public static Value last(Value v,Integer n)
Get number of element in the end of array.
-
vArray to access -
nNumber of elements to get
Return array of elements
public static Array unique(Value v,Boolean sorted)
Get array without duplicates.
-
vArray to access -
sortedIndicates whether to sort or not, will use quick sort
Return unique array
public static Array union(...)
Union one or more arrays into one unique array.
...Arrays to union
Return unioned array
public static Array intersection(...)
Return intersections of arrays.
...Arrays to check
Return intersections
public static Array flatten(Value arr,Boolean shallow)
Convert multi-dimension arrays into one-dimension, only reduce one dimension if you pass shallow argument.
-
arrArray to convert -
shallowIndicates whether to reduce only one dimension or not, default is false
Return converted array
public static Array without(Value arr,...)
Return an array without given elements.
-
arrArray to access -
...Elements to exclude
Return result array
public static Array difference(Array list,...)
Return differences of arrays.
listArrays to check
Return differences
public static Value each(Value list,Function iterator,Value context)
Iterate list in order. If context is passed, then bind iterator to context. Each iteration will pass three arguments to context: element, index and list.
-
listList or object to iterate -
iteratorIterator callback -
contextContext object for binding
Return list itself
public static Array map(Value list,Function iterator,Value context)
Use iterator to map values to new array. If context is passed, then bind iterator to context. Each iteration will pass three arguments to context: element, index and list.
-
listList or object to iterate -
iteratorIterator callback -
contextContext object for binding
Return result array
public static Value reduce(Value list,Function iterator,Value memo,Value context)
Reduce every element in list to a single number. If context is passed, then bind iterator to context. Each iteration will pass four arguments to context: memo, element, index and list.
-
listList or object to iterate -
iteratorIterator callback -
memoInitial value -
contextContext object for binding
Return result array
public static Object buildInfo()
Get current engine and components information.
Struct info:
{
"fibjs": "0.1.0",
"svn": 1753,
"build": "Dec 10 2013 21:44:17",
"vender": {
"ev": "4.11",
"exif": "0.6.21",
"gd": "2.1.0-alpha",
"jpeg": "8.3",
"log4cpp": "1.0",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"sqlite": "3.8.1",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "3.23.17 (candidate)",
"zlib": "1.2.7",
"zmq": "3.1"
}
}uuid unique id module
Fundamental module, used for create uuid
var uuid = require('uuid');| Members | Descriptions |
|---|---|
public static uuidValue uuid(String s) |
Generate uuid by given string. |
public static uuidValue uuid(Buffer data) |
Generate uuid by given binary data. |
public static uuidValue node() |
Generate uuid by time and host name. |
public static uuidValue md5(Integer ns,String name) |
Generate uuid by given md5. |
public static uuidValue random() |
Generate uuid randomly. |
public static uuidValue sha1(Integer ns,String name) |
Generate uuid by given sha1. |
Generate uuid by given string.
sString to describe uuid
Return uuidValue object
Generate uuid by given binary data.
dataData to describe uuid
Return uuidValue object
Generate uuid by time and host name.
Return uuidValue object
Generate uuid by given md5.
Return uuidValue object
Generate uuid randomly.
Return uuidValue object
Generate uuid by given sha1.
Return uuidValue object
Safe SandBox module, to isolate runtime based on safety level.
By establishing a safe SandBox, you can limit the accessible resources when the script runs, and isolate different script execution environment, also can be customized for different environments base module to ensure the safety of the overall operating environment.
Following example demonstrates a sandbox which is only allowed for accessing assert module, and add a and b as customized modules.
var vm = require('vm');
var sbox = new vm.SandBox({
a: 100,
b: 200,
assert: require('assert')
});
var mod_in_sbox = sbox.require('./path/to/mod');| Members | Descriptions |
|---|---|
public static SandBoxnewSandBox() |
Create a SandBox object, see SandBox. |
Create a SandBox object, see SandBox.
websocket support module
To use it:
var websocket = require('websocket');| Members | Descriptions |
|---|---|
public static WebSocketMessagenewMessage() |
Create one websocket message object, refer WebSocketMessage. |
public static WebSocketHandlernewHandler() |
Create one websocket packet protocol conversion processor, refer WebSocketHandler. |
public static Stream connect(String url) |
Create one websocket connection, and return a completed connection Stream object. |
public static WebSocketMessagenewMessage()
Create one websocket message object, refer WebSocketMessage.
public static WebSocketHandlernewHandler()
Create one websocket packet protocol conversion processor, refer WebSocketHandler.
Create one websocket connection, and return a completed connection Stream object.
urlSpecifies the connection url,support ws:// and wss:// protocol
Return a completed connection Stream object, which can be Socket or SslSocket
xml module
| Members | Descriptions |
|---|---|
public static XmlDocumentnewDocument() |
xml document object, see XmlDocument object |
public static XmlDocument parse(String source,String type) |
Parse xml/html text and create XmlDocument object, does not support multiple languages. |
public static XmlDocument parse(Buffer source,String type) |
Parse xml/html and create XmlDocument object, convert by given language. |
public static String serialize(XmlNode node) |
Serialize XmlNode to string. |
public static XmlDocumentnewDocument()
xml document object, see XmlDocument object
public static XmlDocument parse(String source,String type)
Parse xml/html text and create XmlDocument object, does not support multiple languages.
-
sourcexml/html text to parse -
typeIndicates text type, default is text/xml, and can be text/html as well
Return created XmlDocument object
public static XmlDocument parse(Buffer source,String type)
Parse xml/html and create XmlDocument object, convert by given language.
-
sourcexml/html text to parse -
typeIndicates text type, default is text/xml, and can be text/html as well
Return created XmlDocument object
Serialize XmlNode to string.
nodeXmlNode to serialize
Return serialized string
Zip file processing module.
It can be used to compress and decompress file into or from zip file. The way to use:
var zip = require('zip');| Members | Descriptions |
|---|---|
public static Boolean isZipFile(String filename) |
Judge if the file is zip file. |
public static ZipFile open(String path,String mod,Integer compress_type) |
Open a zip file. |
public static ZipFile open(Buffer data,String mod,Integer compress_type) |
Open buffer of zip file data. |
public static ZipFile open(SeekableStream strm,String mod,Integer compress_type) |
Open stream of zip file data. |
public static Boolean isZipFile(String filename)
Judge if the file is zip file.
filenameto be judged.
Judge result, true means yes.
Open a zip file.
-
pathThe path of file to be opened. -
modFile open mode, "r" means read only, "w" means create and overwrite if the file exists, "a" means append after the zip file. -
compress_typeCompress type, ZIP_STORED means no compress and for storage only. The default parameter is ZIP_DEFLATED, it depends on library zlib in compressing.
The zip file object.
Open buffer of zip file data.
-
dataBuffer of zip file data. -
modFile open mode, "r" means read only, "w" means create and overwrite if the file exists, "a" means append after the zip file. -
compress_typeCompress type, ZIP_STORED means no compress and for storage only. The default parameter is ZIP_DEFLATED, it depends on library zlib in compressing.
The zip file object.
public static ZipFile open(SeekableStream strm,String mod,Integer compress_type)
Open stream of zip file data.
-
strmStream of zip file data. -
modFile open mode, "r" means read only, "w" means create and overwrite if the file exists, "a" means append after the zip file. -
compress_typeCompress type, ZIP_STORED means no compress and for storage only. The default parameter is ZIP_DEFLATED, it depends on library zlib in compressing.
The zip file object.
zlib compression and decompression module
To use it:
var zlib = require('zlib');| Members | Descriptions |
|---|---|
public static Buffer deflate(Buffer data,Integer level) |
Use deflate to compress data (zlib format) |
public static static deflateTo(Buffer data,Stream stm,Integer level) |
Use deflate to compress data to stream (zlib format) |
public static static deflateTo(Stream src,Stream stm,Integer level) |
Use deflate to compress a stream data to another (zlib format) |
public static Buffer inflate(Buffer data) |
Use deflate to decompress data (zlib format) |
public static static inflateTo(Buffer data,Stream stm) |
Use deflate to decompress data to stream (zlib format) |
public static static inflateTo(Stream src,Stream stm) |
Use deflate to decompress a stream data to another (zlib format) |
public static Buffer gzip(Buffer data) |
Use gzip to compress data. |
public static static gzipTo(Buffer data,Stream stm) |
Use gzip to compress data to stream. |
public static static gzipTo(Stream src,Stream stm) |
Use gzip to compress a stream data to another. |
public static Buffer gunzip(Buffer data) |
Use gzip to decompress data. |
public static static gunzipTo(Buffer data,Stream stm) |
Use gzip to decompress data to stream. |
public static static gunzipTo(Stream src,Stream stm) |
Use gzip to decompress a stream data to another. |
public static Buffer deflateRaw(Buffer data,Integer level) |
Use deflate to compress data (deflateRaw) |
public static static deflateRawTo(Buffer data,Stream stm,Integer level) |
Use deflate to compress data to stream (deflateRaw) |
public static static deflateRawTo(Stream src,Stream stm,Integer level) |
Use deflate to compress a stream data to another (deflateRaw) |
public static Buffer inflateRaw(Buffer data) |
Use deflate to decompress data (deflateRaw) |
public static static inflateRawTo(Buffer data,Stream stm) |
Use deflate to decompress data to stream (deflateRaw) |
public static static inflateRawTo(Stream src,Stream stm) |
Use deflate to decompress a stream data to another (deflateRaw) |
Use deflate to compress data (zlib format)
-
dataRaw data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
Return compressed binary
Use deflate to compress data to stream (zlib format)
-
dataRaw data -
stmStream to write compressed data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
Use deflate to compress a stream data to another (zlib format)
-
srcOriginal stream -
stmTarget stream to write compressed data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
Use deflate to decompress data (zlib format)
dataCompressed data
Return decompressed binary
Use deflate to decompress data to stream (zlib format)
-
dataCompressed data -
stmStream to write decompressed data
Use deflate to decompress a stream data to another (zlib format)
-
srcOriginal stream -
stmTarget stream to write decompressed data
Use gzip to compress data.
dataRaw data
Return compressed binary
Use gzip to compress data to stream.
-
dataRaw data -
stmStream to write compressed data
Use gzip to compress a stream data to another.
-
srcOriginal stream -
stmTarget stream to write compressed data
Use gzip to decompress data.
dataCompressed data
Return decompressed binary
Use gzip to decompress data to stream.
-
dataCompressed data -
stmStream to write decompressed data
Use gzip to decompress a stream data to another.
-
srcOriginal stream -
stmTarget stream to write decompressed data
public static Buffer deflateRaw(Buffer data,Integer level)
Use deflate to compress data (deflateRaw)
-
dataRaw data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
Return compressed binary
public static static deflateRawTo(Buffer data,Stream stm,Integer level)
Use deflate to compress data to stream (deflateRaw)
-
dataRaw data -
stmStream to write compressed data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
public static static deflateRawTo(Stream src,Stream stm,Integer level)
Use deflate to compress a stream data to another (deflateRaw)
-
srcOriginal stream -
stmTarget stream to write compressed data -
levelIndicate compression level, default is DEFAULT_COMPRESSION
public static Buffer inflateRaw(Buffer data)
Use deflate to decompress data (deflateRaw)
dataCompressed data
Return decompressed binary
public static static inflateRawTo(Buffer data,Stream stm)
Use deflate to decompress data to stream (deflateRaw)
-
dataCompressed data -
stmStream to write decompressed data
public static static inflateRawTo(Stream src,Stream stm)
Use deflate to decompress a stream data to another (deflateRaw)
-
srcOriginal stream -
stmTarget stream to write decompressed data
class AsyncWait
: public Handler
MessageHandler object for asynchronous waiting.
| Members | Descriptions |
|---|---|
public end() |
Finish waiting, moving on to handle the message. |
public Handler invoke(object v) |
handle a message or an object |
public dispose() |
Force dispose object immediately. |
public String toString() |
Return string representation of object, normally is "[Native Object]" and can be implemented by object itself. |
public Value toJSON(String key) |
Return JSON representation of object, normally is readable attributes collection. |
public Value valueOf() |
Return JSON representation of object. |
public end()
Finish waiting, moving on to handle the message.
handle a message or an object
vspecify the message or object to be handled
return the handler of the next step
public dispose()
Force dispose object immediately.
public String toString()
Return string representation of object, normally is "[Native Object]" and can be implemented by object itself.
Return string representation
public Value toJSON(String key)
Return JSON representation of object, normally is readable attributes collection.
keyNot used
Return JSON representation
public Value valueOf()
Return JSON representation of object.
Return JSON representation of object
class Buffer
: public object
Binary buffer used in dealing with I/O reading and writing.
Buffer object is a global basic class which can be created by "new Buffer(...)" at anytime:
var buf = new Buffer();| Members | Descriptions |
|---|---|
public Integer operator[] |
The binary data in the buffer can be accessed by using subscript. |
public readonly Integer length |
The buffer size. |
public Buffer(Array datas) |
Buffer constructor. |
public Buffer(Buffer buffer) |
Buffer constructor. |
public Buffer(String str,String codec) |
Buffer constructor. |
public Buffer(Integer size) |
Buffer constructor. |
public resize(Integer sz) |
Resize the buffer. |
public append(Array datas) |
Write an array into the buffer. |
public append(Buffer data) |
Write a set of binary data into the buffer. |
public append(String str,String codec) |
Write a string encoded in utf-8 into buffer. |
public Integer write(String str,Integer offset,Integer length,String codec) |
Writes string to the buffer at offset using the given encoding. |
public fill(Integer v,Integer offset,Integer end) |
Fill the buffer with the specified objects. |
public fill(Buffer v,Integer offset,Integer end) |
Fill the buffer with the specified objects. |
public fill(String v,Integer offset,Integer end) |
Fill the buffer with the specified objects. |
public Boolean equals(Buffer buf) |
Whether this and otherBuffer have the same bytes. |
public Integer compare(Buffer buf) |
Compare the contents of the buffer. |
public Integer copy(Buffer targetBuffer,Integer targetStart,Integer sourceStart,Integer sourceEnd) |
Copies data from a region of this buffer to a region in the target buffer even if the target memory region overlaps with the source. If undefined the targetStart and sourceStart parameters default to 0 while sourceEnd defaults to buffer.length. |
public Integer readUInt8(Integer offset,Boolean noAssert) |
Read an unsigned 8-bit integer from the buffer. |
public Integer readUInt16LE(Integer offset,Boolean noAssert) |
Read an unsigned 16-bit integer from the buffer and use the little-endian format for storage. |
public Integer readUInt16BE(Integer offset,Boolean noAssert) |
Read an unsigned 16-bit integer from the buffer and use the big-endian format for storage. |
public Long readUInt32LE(Integer offset,Boolean noAssert) |
Read an unsigned 32-bit integer from the buffer and use the little-endian format for storage. |
public Long readUInt32BE(Integer offset,Boolean noAssert) |
Read an unsigned 32-bit integer from the buffer and use the big-endian format for storage. |
public Integer readInt8(Integer offset,Boolean noAssert) |
Read an 8-bit integer from the buffer. |
public Integer readInt16LE(Integer offset,Boolean noAssert) |
Read an 16-bit integer from the buffer and use the little-endian format for storage. |
public Integer readInt16BE(Integer offset,Boolean noAssert) |
Read an 16-bit integer from the buffer and use the big-endian format for storage. |
public Integer readInt32LE(Integer offset,Boolean noAssert) |
Read an 32-bit integer from the buffer and use the little-endian format for storage. |
public Integer readInt32BE(Integer offset,Boolean noAssert) |
Read an 32-bit integer from the buffer and use the big-endian format for storage. |
public Int64 readInt64LE(Integer offset,Boolean noAssert) |
Read an 64-bit integer from the buffer and use the little-endian format for storage. |
public Int64 readInt64BE(Integer offset,Boolean noAssert) |
Read an 64-bit integer from the buffer and use the big-endian format for storage. |
public Number readFloatLE(Integer offset,Boolean noAssert) |
Read a float from the buffer and use the little-endian format for storage. |
public Number readFloatBE(Integer offset,Boolean noAssert) |
Read a float from the buffer and use the big-endian format for storage. |
public Number readDoubleLE(Integer offset,Boolean noAssert) |
Read a double from the buffer and use the little-endian format for storage. |
public Number readDoubleBE(Integer offset,Boolean noAssert) |
Read a double from the buffer and use the big-endian format for storage. |
public writeUInt8(Integer value,Integer offset,Boolean noAssert) |
Write an unsigned 8-bit integer into the buffer. |
public writeUInt16LE(Integer value,Integer offset,Boolean noAssert) |
Write an unsigned 16-bit integer into the buffer and use the little-endian format for storage. |
public writeUInt16BE(Integer value,Integer offset,Boolean noAssert) |
Write an unsigned 16-bit integer into the buffer and use the big-endian format for storage. |
public writeUInt32LE(Long value,Integer offset,Boolean noAssert) |
Write an unsigned 32-bit integer into the buffer and use the little-endian format for storage. |
public writeUInt32BE(Long value,Integer offset,Boolean noAssert) |
Write an unsigned 32-bit integer into the buffer and use the big-endian format for storage. |
public writeInt8(Integer value,Integer offset,Boolean noAssert) |
Write an 8-bit integer into the buffer. |
public writeInt16LE(Integer value,Integer offset,Boolean noAssert) |
Write a 16-bit integer into the buffer and use the little-endian format for storage. |
public writeInt16BE(Integer value,Integer offset,Boolean noAssert) |
Write a 16-bit integer into the buffer and use the big-endian format for storage. |
public writeInt32LE(Integer value,Integer offset,Boolean noAssert) |
Write a 32-bit integer into the buffer and use the little-endian format for storage. |
public writeInt32BE(Integer value,Integer offset,Boolean noAssert) |
Write a 32-bit integer into the buffer and use the big-endian format for storage. |
public writeInt64LE(Int64 value,Integer offset,Boolean noAssert) |
Write a 64-bit integer into the buffer and use the little-endian format for storage. |
public writeInt64BE(Int64 value,Integer offset,Boolean noAssert) |
Write a 64-bit integer into the buffer and use the big-endian format for storage. |
public writeFloatLE(Number value,Integer offset,Boolean noAssert) |
Write a float into the buffer and use the little-endian format for storage. |
public writeFloatBE(Number value,Integer offset,Boolean noAssert) |
Write a float into the buffer and use the big-endian format for storage. |
public writeDoubleLE(Number value,Integer offset,Boolean noAssert) |
Write a double into the buffer and use the little-endian format for storage. |
public writeDoubleBE(Number value,Integer offset,Boolean noAssert) |
Write a double into the buffer and use the big-endian format for storage. |
public Buffer slice(Integer start,Integer end) |
return a new buffer that contains data in the specified range. If the data is out of range of the buffer, return the available part of the data. |
public String hex() |
Store the data in the buffer with hexadecimal encoding? |
public String base64() |
Store the data in the buffer with base64 encoding? |
public String toString(String codec,Integer offset,Integer end) |
return the encoded string of the binary data |
public String toString() |
return the utf8-encoded string of the binary data |
public dispose() |
Force dispose object immediately. |
public Value toJSON(String key) |
Return JSON representation of object, normally is readable attributes collection. |
public Value valueOf() |
Return JSON representation of object. |
public Integer operator[]
The binary data in the buffer can be accessed by using subscript.
public readonly Integer length
The buffer size.
public Buffer(Array datas)
Buffer constructor.
datasInitial data array
Buffer constructor.
bufferotherBuffer
public Buffer(String str,String codec)
Buffer constructor.
-
strInitial string encoded in UTF-8, by default it will create an empty object. -
codecThe encode format, can be "hex", “base64”, "utf8" or any other character sets supported by the system.
public Buffer(Integer size)
Buffer constructor.
sizeInitial cache size
public resize(Integer sz)
Resize the buffer.
szNew size
public append(Array datas)
Write an array into the buffer.
datasInitial data array
Write a set of binary data into the buffer.
dataInitial binary data
public append(String str,String codec)
Write a string encoded in utf-8 into buffer.
-
strString to write -
codecCoded format, can be "hex", “base64”, "utf8" or any other character sets supported by the system.
public Integer write(String str,Integer offset,Integer length,String codec)
Writes string to the buffer at offset using the given encoding.
-
strString - data to be written to buffer -
offsetNumber, Optional, Default 0 -
lengthNumber, Optional, Default -1 -
codecCoded format, can be "hex", “base64”, "utf8" or any other character sets supported
Returns number of octets written.
public fill(Integer v,Integer offset,Integer end)
Fill the buffer with the specified objects.
-
vData intend to be filled, and will fill the entire buffer when the offset and end is not specified. -
offsetNumber, Optional, Default 0 -
endNumber, Optional, Default -1
Fill the buffer with the specified objects.
-
vData intend to be filled, and will fill the entire buffer when the offset and end is not specified. -
offsetNumber, Optional, Default 0 -
endNumber, Optional, Default -1
public fill(String v,Integer offset,Integer end)
Fill the buffer with the specified objects.
-
vData intend to be filled, and will fill the entire buffer when the offset and end is not specified. -
offsetNumber, Optional, Default 0 -
endNumber, Optional, Default -1
Whether this and otherBuffer have the same bytes.
bufotherBuffer
Returns a boolean of whether this and otherBuffer have the same bytes.
Compare the contents of the buffer.
bufotherBuffer
Returns a number indicating whether this comes before or after or is the same as the otherBuffer in sort order.
Copies data from a region of this buffer to a region in the target buffer even if the target memory region overlaps with the source. If undefined the targetStart and sourceStart parameters default to 0 while sourceEnd defaults to buffer.length.
-
targetStartNumber, Optional, Default: 0 -
sourceStartNumber, Optional, Default: 0 -
sourceEndNumber, Optional, Default: -1, represent buffer.length
Copied data byte length
public Integer readUInt8(Integer offset,Boolean noAssert)
Read an unsigned 8-bit integer from the buffer.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readUInt16LE(Integer offset,Boolean noAssert)
Read an unsigned 16-bit integer from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readUInt16BE(Integer offset,Boolean noAssert)
Read an unsigned 16-bit integer from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Long readUInt32LE(Integer offset,Boolean noAssert)
Read an unsigned 32-bit integer from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Long readUInt32BE(Integer offset,Boolean noAssert)
Read an unsigned 32-bit integer from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readInt8(Integer offset,Boolean noAssert)
Read an 8-bit integer from the buffer.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readInt16LE(Integer offset,Boolean noAssert)
Read an 16-bit integer from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readInt16BE(Integer offset,Boolean noAssert)
Read an 16-bit integer from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readInt32LE(Integer offset,Boolean noAssert)
Read an 32-bit integer from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Integer readInt32BE(Integer offset,Boolean noAssert)
Read an 32-bit integer from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Int64 readInt64LE(Integer offset,Boolean noAssert)
Read an 64-bit integer from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Int64 readInt64BE(Integer offset,Boolean noAssert)
Read an 64-bit integer from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted integer
public Number readFloatLE(Integer offset,Boolean noAssert)
Read a float from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted float
public Number readFloatBE(Integer offset,Boolean noAssert)
Read a float from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted float
public Number readDoubleLE(Integer offset,Boolean noAssert)
Read a double from the buffer and use the little-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted double
public Number readDoubleBE(Integer offset,Boolean noAssert)
Read a double from the buffer and use the big-endian format for storage.
-
offsetThe beginning of the address to read -
noAssertIf true, then do not throw an error when overread. By default it's false.
The targeted double
public writeUInt8(Integer value,Integer offset,Boolean noAssert)
Write an unsigned 8-bit integer into the buffer.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeUInt16LE(Integer value,Integer offset,Boolean noAssert)
Write an unsigned 16-bit integer into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeUInt16BE(Integer value,Integer offset,Boolean noAssert)
Write an unsigned 16-bit integer into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeUInt32LE(Long value,Integer offset,Boolean noAssert)
Write an unsigned 32-bit integer into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeUInt32BE(Long value,Integer offset,Boolean noAssert)
Write an unsigned 32-bit integer into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt8(Integer value,Integer offset,Boolean noAssert)
Write an 8-bit integer into the buffer.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt16LE(Integer value,Integer offset,Boolean noAssert)
Write a 16-bit integer into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt16BE(Integer value,Integer offset,Boolean noAssert)
Write a 16-bit integer into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt32LE(Integer value,Integer offset,Boolean noAssert)
Write a 32-bit integer into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt32BE(Integer value,Integer offset,Boolean noAssert)
Write a 32-bit integer into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt64LE(Int64 value,Integer offset,Boolean noAssert)
Write a 64-bit integer into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeInt64BE(Int64 value,Integer offset,Boolean noAssert)
Write a 64-bit integer into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeFloatLE(Number value,Integer offset,Boolean noAssert)
Write a float into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeFloatBE(Number value,Integer offset,Boolean noAssert)
Write a float into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeDoubleLE(Number value,Integer offset,Boolean noAssert)
Write a double into the buffer and use the little-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
public writeDoubleBE(Number value,Integer offset,Boolean noAssert)
Write a double into the buffer and use the big-endian format for storage.
-
valueThe value to write -
offsetThe beginning of the address to write -
noAssertIf true, then do not throw an error when overwrite. By default it's false.
return a new buffer that contains data in the specified range. If the data is out of range of the buffer, return the available part of the data.
-
startThe start of the specified range, by default it's the beginning of the buffer -
endThe end of the specified range, by default it's the end of the buffer
public String hex()
Store the data in the buffer with hexadecimal encoding?
The encoded string
public String base64()
Store the data in the buffer with base64 encoding?
The encoded string
public String toString(String codec,Integer offset,Integer end)
return the encoded string of the binary data
-
codecThe encode format, can be "hex", “base64”, "utf8" or any other character sets supported by the system. -
offsetThe start position of string, Default: 0 -
endThe end position of string, Default: -1
The string representing the value of the buffer.
public String toString()
return the utf8-encoded string of the binary data
The string representing the value of the buffer.
public dispose()
Force dispose object immediately.
public Value toJSON(String key)
Return JSON representation of object, normally is readable attributes collection.
keyNot used
Return JSON representation
public Value valueOf()
Return JSON representation of object.
Return JSON representation of object