@8base/utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,6 +12,11 @@ "use strict"; | ||
const omitDeep = (omitedProps, objectForOmitting) => { | ||
if (!objectForOmitting || !R.is(Object, objectForOmitting)) { | ||
if (!objectForOmitting || | ||
!R.is(Object, objectForOmitting) || | ||
typeof objectForOmitting === 'number' || | ||
typeof objectForOmitting === 'string') { | ||
return objectForOmitting; | ||
} | ||
const currentLevelOmitedObject = R.omit(omitedProps, objectForOmitting); | ||
const currentLevelOmitedObject = Array.isArray(objectForOmitting) | ||
? R.map(value => omitDeep(omitedProps, value), objectForOmitting) | ||
: R.omit(omitedProps, objectForOmitting); | ||
const omitValue = (value) => { | ||
@@ -26,3 +31,5 @@ if (R.is(Array, value)) { | ||
}; | ||
const fullOmitedObject = R.mapObjIndexed(omitValue, currentLevelOmitedObject); | ||
const fullOmitedObject = Array.isArray(currentLevelOmitedObject) | ||
? R.map(omitValue, currentLevelOmitedObject) | ||
: R.mapObjIndexed(omitValue, currentLevelOmitedObject); | ||
return fullOmitedObject; | ||
@@ -29,0 +36,0 @@ }; |
{ | ||
"name": "@8base/utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"repository": "https://github.com/8base/sdk", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme", |
import * as R from 'ramda'; | ||
const omitDeep = (omitedProps: string[], objectForOmitting?: any) => { | ||
if (!objectForOmitting || !R.is(Object, objectForOmitting)) { | ||
if ( | ||
!objectForOmitting || | ||
!R.is(Object, objectForOmitting) || | ||
typeof objectForOmitting === 'number' || | ||
typeof objectForOmitting === 'string' | ||
) { | ||
return objectForOmitting; | ||
} | ||
const currentLevelOmitedObject = R.omit(omitedProps, objectForOmitting); | ||
const currentLevelOmitedObject: any = Array.isArray(objectForOmitting) | ||
? R.map(value => omitDeep(omitedProps, value), objectForOmitting) | ||
: R.omit(omitedProps, objectForOmitting); | ||
@@ -19,3 +26,5 @@ const omitValue = (value: any): any => { | ||
const fullOmitedObject = R.mapObjIndexed(omitValue, currentLevelOmitedObject); | ||
const fullOmitedObject = Array.isArray(currentLevelOmitedObject) | ||
? R.map(omitValue, currentLevelOmitedObject) | ||
: R.mapObjIndexed(omitValue, currentLevelOmitedObject); | ||
@@ -22,0 +31,0 @@ return fullOmitedObject; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
276355
4491