8 lines
25 KiB
Plaintext
8 lines
25 KiB
Plaintext
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../../lib/utils.js"],
|
||
|
"sourcesContent": ["'use strict';\n\nconst DataTypes = require('./data-types');\nconst SqlString = require('./sql-string');\nconst _ = require('lodash');\nconst baseIsNative = require('lodash/_baseIsNative');\nconst uuidv1 = require('uuid').v1;\nconst uuidv4 = require('uuid').v4;\nconst operators = require('./operators');\nconst operatorsSet = new Set(Object.values(operators));\n\nlet inflection = require('inflection');\n\nexports.classToInvokable = require('./utils/class-to-invokable').classToInvokable;\nexports.joinSQLFragments = require('./utils/join-sql-fragments').joinSQLFragments;\n\nfunction useInflection(_inflection) {\n inflection = _inflection;\n}\nexports.useInflection = useInflection;\n\nfunction camelizeIf(str, condition) {\n let result = str;\n\n if (condition) {\n result = camelize(str);\n }\n\n return result;\n}\nexports.camelizeIf = camelizeIf;\n\nfunction underscoredIf(str, condition) {\n let result = str;\n\n if (condition) {\n result = underscore(str);\n }\n\n return result;\n}\nexports.underscoredIf = underscoredIf;\n\nfunction isPrimitive(val) {\n const type = typeof val;\n return ['string', 'number', 'boolean'].includes(type);\n}\nexports.isPrimitive = isPrimitive;\n\n// Same concept as _.merge, but don't overwrite properties that have already been assigned\nfunction mergeDefaults(a, b) {\n return _.mergeWith(a, b, (objectValue, sourceValue) => {\n // If it's an object, let _ handle it this time, we will be called again for each property\n if (!_.isPlainObject(objectValue) && objectValue !== undefined) {\n // _.isNative includes a check for core-js and throws an error if present.\n // Depending on _baseIsNative bypasses the core-js check.\n if (_.isFunction(objectValue) && baseIsNative(objectValue)) {\n return sourceValue || objectValue;\n }\n return objectValue;\n }\n });\n}\nexports.mergeDefaults = mergeDefaults;\n\n// An alternative to _.merge, which doesn't clone its arguments\n// Cloning is a bad idea because options arguments may contain references to sequelize\n// models - which again reference database libs which don't like to be cloned (in particular pg-native)\nfunction merge() {\n const result = {};\n\n for (const obj of arguments) {\n _.forOwn(obj, (value, key) => {\n if (value !== undefined) {\n if (!result[key]) {\n result[key] = value;\n } else if (_.isPlainObject(value) && _.isPlainObject(result[key])) {\n result[key] = merge(result[key], value);\n } else if (Array.isArray(value) && Array.isArray(result[key])) {\n result[key] = value.concat(result[key]);\n } else {\n result[key] = value;\n }\n }\n });\n }\n\n return result;\n}\nexports.merge = merge;\n\nfunction spliceStr(str, index, count, add) {\n return str.slice(0, index) + add + str.slice(index + count);\n}\nexports.spliceStr = spliceStr;\n\nfunction camelize(str) {\n return str.trim().replace(/[-_\\s]+(.)?/g, (match, c) => c.toUpperCase());\n}\nexports.camelize = camelize;\n\nfunction underscore(str) {\n return inflection.underscore(str);\n}\nexports.underscore = underscore;\n\nfunction singularize(str) {\n return inflection.singularize(str);\n}\nexports.singularize = singularize;\n\nfunction pluralize(str) {\n return inflection.pluralize(str);\n}\nexports.pluralize = pluralize;\n\nfunction format(arr, dialect) {\n const timeZone = null;\n // Make a clone of the array beacuse format modifies the passed args\n return SqlString.format(arr[0], arr.slice(1), timeZone, dialect);\n}\nexports.format = format;\n\nfunction formatNamedParameters(sql, parameters, dialect) {\n const timeZone = null;\n return SqlString.formatNamedParameters(sql, parameters, timeZone, dialect);\n}\nexports.formatNamedParameters = formatNamedParameters;\n\nfunction cloneDeep(obj, onlyPlain) {\n obj = obj || {};\n return _.cloneDeepWith(obj, elem => {\n // Do not try to customize cloning of arrays or POJOs\n if (Array.isArray(elem) || _.isPlainObject(elem)) {\n return undefined;\n }
|
||
|
"mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,YAAY,QAAQ;AAC1B,MAAM,YAAY,QAAQ;AAC1B,MAAM,IAAI,QAAQ;AAClB,MAAM,eAAe,QAAQ;AAC7B,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,YAAY,QAAQ;AAC1B,MAAM,eAAe,IAAI,IAAI,OAAO,OAAO;AAE3C,IAAI,aAAa,QAAQ;AAEzB,QAAQ,mBAAmB,QAAQ,8BAA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