Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coderich/util

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coderich/util - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

2

package.json
{
"name": "@coderich/util",
"main": "src/index.js",
"version": "0.1.6",
"version": "0.1.7",
"publishConfig": {

@@ -6,0 +6,0 @@ "access": "public"

@@ -19,3 +19,10 @@ const FS = require('fs');

exports.ucFirst = string => string.charAt(0).toUpperCase() + string.slice(1);
exports.isPlainArrayOrObject = obj => Array.isArray(obj) || exports.isPlainObject(obj);
exports.isPlainObject = (obj) => {
if (obj == null) return false;
const proto = Object.getPrototypeOf(obj);
return proto === Object.prototype || proto.toString?.call?.(obj) === '[object Object]';
};
exports.filterRe = (arr, fn) => {

@@ -39,8 +46,6 @@ const map = new Map();

const maxDepth = options.depth ?? Infinity;
const typeFn = options.safe ? exports.isPlainObject : exports.isPlainArrayOrObject;
return exports.map(mixed, el => (function flatten(data, obj = {}, path = [], depth = 0) {
const type = Object.prototype.toString.call(data);
const types = options.safe ? ['[object Object]'] : ['[object Object]', '[object Array]'];
if (depth <= maxDepth && types.includes(type) && Object.keys(data).length && !ObjectId.isValid(data)) {
if (depth <= maxDepth && Object.keys(data).length && typeFn(data)) {
return Object.entries(data).reduce((o, [key, value]) => {

@@ -62,6 +67,6 @@ const $key = options.strict && key.split('.').length > 1 ? `['${key}']` : key;

exports.unflatten = (data, options = {}) => {
const typeFn = options.safe ? exports.isPlainObject : exports.isPlainArrayOrObject;
return exports.map(data, (el) => {
const type = Object.prototype.toString.call(data);
const types = options.safe ? ['[object Object]'] : ['[object Object]', '[object Array]'];
return types.includes(type) ? Object.entries(el).reduce((prev, [key, value]) => {
return typeFn(data) ? Object.entries(el).reduce((prev, [key, value]) => {
return set(prev, key, value);

@@ -68,0 +73,0 @@ }, {}) : el;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc