1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- lunr.utils = {}
- lunr.utils.warn = (function (global) {
-
- return function (message) {
- if (global.console && console.warn) {
- console.warn(message)
- }
- }
-
- })(this)
- lunr.utils.asString = function (obj) {
- if (obj === void 0 || obj === null) {
- return ""
- } else {
- return obj.toString()
- }
- }
- lunr.utils.clone = function (obj) {
- if (obj === null || obj === undefined) {
- return obj
- }
- var clone = Object.create(null),
- keys = Object.keys(obj)
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i],
- val = obj[key]
- if (Array.isArray(val)) {
- clone[key] = val.slice()
- continue
- }
- if (typeof val === 'string' ||
- typeof val === 'number' ||
- typeof val === 'boolean') {
- clone[key] = val
- continue
- }
- throw new TypeError("clone is not deep and does not support nested objects")
- }
- return clone
- }
|