|
|
@ -39,6 +39,24 @@ function arrayReplaceAt(src, pos, newElements) { |
|
|
|
return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1)); |
|
|
|
} |
|
|
|
|
|
|
|
// Sets a property whose initial is computed lazily on an target object
|
|
|
|
function defineLazyProperty(target, property, instantiator) { |
|
|
|
var initied = false; |
|
|
|
var value; |
|
|
|
Object.defineProperty(target, property, { |
|
|
|
get: function () { |
|
|
|
if (initied) return value; |
|
|
|
initied = true; |
|
|
|
value = instantiator(); |
|
|
|
return value; |
|
|
|
}, |
|
|
|
set: function (newValue) { |
|
|
|
initied = true; |
|
|
|
value = newValue; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
function isValidEntityCode(c) { |
|
|
@ -300,6 +318,7 @@ exports.lib.mdurl = require('mdurl'); |
|
|
|
exports.lib.ucmicro = require('uc.micro'); |
|
|
|
|
|
|
|
exports.assign = assign; |
|
|
|
exports.defineLazyProperty = defineLazyProperty; |
|
|
|
exports.isString = isString; |
|
|
|
exports.has = has; |
|
|
|
exports.unescapeMd = unescapeMd; |
|
|
|