util.js 907 字节
Newer Older
6
cloud  
6360c489aee4323e88771a44 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/**
 * Continues with the callback on the next tick.
 * @function
 * @param {function(...[*])} callback Callback to execute
 * @inner
 */
var nextTick = typeof process !== 'undefined' && process && typeof process.nextTick === 'function'
    ? (typeof setImmediate === 'function' ? setImmediate : process.nextTick)
    : setTimeout;

/**
 * Converts a JavaScript string to UTF8 bytes.
 * @param {string} str String
 * @returns {!Array.<number>} UTF8 bytes
 * @inner
 */
function stringToBytes(str) {
    var out = [],
        i = 0;
    utfx.encodeUTF16toUTF8(function() {
        if (i >= str.length) return null;
        return str.charCodeAt(i++);
    }, function(b) {
        out.push(b);
    });
    return out;
}

//? include("util/base64.js");

//? include("../../node_modules/utfx/dist/utfx-embeddable.js");

Date.now = Date.now || function() { return +new Date; };