@alice-health/ky-hooks-change-case
Advanced tools
Comparing version 0.0.2 to 0.0.3
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'lodash'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ky-hooks-change-case'] = {}, global.lodash)); | ||
}(this, (function (exports, lodash) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/snakeCase'), require('lodash/camelCase'), require('lodash/kebabCase'), require('lodash/isPlainObject'), require('lodash/isObject'), require('lodash/isArray')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'lodash/snakeCase', 'lodash/camelCase', 'lodash/kebabCase', 'lodash/isPlainObject', 'lodash/isObject', 'lodash/isArray'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ky-hooks-change-case'] = {}, global.snakeCase, global.camelCase, global.kebabCase, global.isPlainObject, global.isObject, global.isArray)); | ||
}(this, (function (exports, snakeCase, camelCase, kebabCase, isPlainObject, isObject, isArray) { 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var snakeCase__default = /*#__PURE__*/_interopDefaultLegacy(snakeCase); | ||
var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase); | ||
var kebabCase__default = /*#__PURE__*/_interopDefaultLegacy(kebabCase); | ||
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject); | ||
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject); | ||
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray); | ||
const uuidValidate = function (value) { | ||
@@ -13,3 +22,3 @@ const regex = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; | ||
const mapKeysDeep = function (obj, fn) { | ||
if (lodash.isArray(obj)) { | ||
if (isArray__default['default'](obj)) { | ||
return obj.map((item) => { | ||
@@ -20,7 +29,7 @@ return mapKeysDeep(item, fn); | ||
if (lodash.isPlainObject(obj)) { | ||
if (isPlainObject__default['default'](obj)) { | ||
return Object.keys(obj).reduce((accumulator, key) => { | ||
const value = obj[key]; | ||
const newKey = uuidValidate(key) ? key : fn(key); | ||
accumulator[newKey] = lodash.isObject(value) ? mapKeysDeep(value, fn) : value; | ||
accumulator[newKey] = isObject__default['default'](value) ? mapKeysDeep(value, fn) : value; | ||
return accumulator; | ||
@@ -55,9 +64,9 @@ }, {}); | ||
const requestToSnakeCase = createRequestModify(lodash.snakeCase); | ||
const requestToCamelCase = createRequestModify(lodash.camelCase); | ||
const requestToKebabCase = createRequestModify(lodash.kebabCase); | ||
const requestToSnakeCase = createRequestModify(snakeCase__default['default']); | ||
const requestToCamelCase = createRequestModify(camelCase__default['default']); | ||
const requestToKebabCase = createRequestModify(kebabCase__default['default']); | ||
const responseToSnakeCase = createResponseModify(lodash.snakeCase); | ||
const responseToCamelCase = createResponseModify(lodash.camelCase); | ||
const responseToKebabCase = createResponseModify(lodash.kebabCase); | ||
const responseToSnakeCase = createResponseModify(snakeCase__default['default']); | ||
const responseToCamelCase = createResponseModify(camelCase__default['default']); | ||
const responseToKebabCase = createResponseModify(kebabCase__default['default']); | ||
@@ -64,0 +73,0 @@ exports.requestToCamelCase = requestToCamelCase; |
14
index.js
@@ -1,9 +0,7 @@ | ||
import { | ||
snakeCase, | ||
camelCase, | ||
kebabCase, | ||
isPlainObject, | ||
isObject, | ||
isArray, | ||
} from "lodash"; | ||
import snakeCase from 'lodash/snakeCase' | ||
import camelCase from 'lodash/camelCase' | ||
import kebabCase from 'lodash/kebabCase' | ||
import isPlainObject from 'lodash/isPlainObject' | ||
import isObject from 'lodash/isObject' | ||
import isArray from 'lodash/isArray' | ||
@@ -10,0 +8,0 @@ const uuidValidate = function (value) { |
{ | ||
"name": "@alice-health/ky-hooks-change-case", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Allow modifications cases on requests and responses of the objects during the ky request", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13028
195
1