]> git.kaiwu.me - njs.git/commit
Added the pretty string representation for values.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 27 Jul 2018 14:01:52 +0000 (17:01 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 27 Jul 2018 14:01:52 +0000 (17:01 +0300)
commitbd2e5d89b395f948b2bccec8a0df6beaa88c8b99
treec508a71c0ed423dc7dbec6650c47d090dd5783a8
parent888a4a1f5e9d6a70bfa749d215e0ea541e5cd71a
Added the pretty string representation for values.

Interactive shell: dumping the pretty string representation of
the last expression.

>> [1, new Number(2), {a: new String('αβZγ')}, true, console.log,
    /^undef$/m, new Date(0)]
[
 1,
 [Number: 2],
 {
  a: [String: 'αβZγ']
 },
 true,
 [Function: native],
 /^undef$/m,
 1970-01-01T00:00:00.000Z
]

njs.dump(value[, indent]):
    Returns the pretty string representation of a value.
    value - a value of any type.
    indent - a number.
        A number of space characters per indentation level.

    njs.dump({a:[]}) -> '{a:[]}'
    njs.dump({a:[]}, 1) -> '{\n a: [\n  \n ]\n}'

console.log([value1[, values]])
    Prints to stdout the flat pretty string representation
    of values (no new lines).

console.dump([value1[, values]])
    Prints to stdout the pretty string representation of values.

This fixes #11 issue on GitHub.
14 files changed:
njs/njs.h
njs/njs_builtin.c
njs/njs_date.c
njs/njs_date.h
njs/njs_error.c
njs/njs_error.h
njs/njs_extern.c
njs/njs_extern.h
njs/njs_json.c
njs/njs_regexp.c
njs/njs_regexp.h
njs/njs_shell.c
njs/test/njs_expect_test.exp
njs/test/njs_unit_test.c