@daren/utils
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -1,153 +0,2 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// index.ts | ||
var utils_exports = {}; | ||
__export(utils_exports, { | ||
__DEV__: () => __DEV__, | ||
cx: () => import_clsx.default, | ||
deepmerge: () => deepmerge, | ||
isArray: () => isArray, | ||
isBrowser: () => isBrowser, | ||
isObject: () => isObject, | ||
omit: () => omit, | ||
pick: () => pick, | ||
roundToNearest15: () => roundToNearest15, | ||
useControllableState: () => useControllableState, | ||
useSafeEffect: () => useSafeEffect, | ||
walkObject: () => walkObject | ||
}); | ||
module.exports = __toCommonJS(utils_exports); | ||
// lib/index.ts | ||
var import_clsx = __toESM(require("clsx")); | ||
// lib/assertion.ts | ||
function isArray(value) { | ||
return Array.isArray(value); | ||
} | ||
function isObject(value) { | ||
const type = typeof value; | ||
return value != null && (type === "object" || type === "function") && !isArray(value); | ||
} | ||
var __DEV__ = process.env.NODE_ENV !== "production"; | ||
// lib/date.ts | ||
function roundToNearest15(date = new Date()) { | ||
const minutes = 15; | ||
const ms = 1e3 * 60 * minutes; | ||
return new Date(Math.round(date.getTime() / ms) * ms); | ||
} | ||
// lib/hooks.ts | ||
var import_react = require("react"); | ||
function useControllableState(propValue, initialValue, changeHandler) { | ||
const [stateValue, setState] = (0, import_react.useState)(initialValue); | ||
const value = propValue !== void 0 ? propValue : stateValue; | ||
return [ | ||
value, | ||
(newValue) => { | ||
setState(newValue); | ||
if (changeHandler) { | ||
changeHandler(newValue); | ||
} | ||
} | ||
]; | ||
} | ||
// lib/misc.ts | ||
var React = __toESM(require("react")); | ||
var isBrowser = typeof document !== "undefined"; | ||
var useSafeEffect = isBrowser ? React.useLayoutEffect : React.useEffect; | ||
// lib/object.ts | ||
function omit(object, keys) { | ||
const result = {}; | ||
Object.keys(object).forEach((key) => { | ||
if (keys.includes(key)) | ||
return; | ||
result[key] = object[key]; | ||
}); | ||
return result; | ||
} | ||
function pick(object, keys) { | ||
const result = {}; | ||
keys.forEach((key) => { | ||
if (key in object) { | ||
result[key] = object[key]; | ||
} | ||
}); | ||
return result; | ||
} | ||
function deepmerge(target, source, options = { clone: false }) { | ||
const output = options.clone ? { ...target } : target; | ||
if (isObject(target) && isObject(source)) { | ||
Object.keys(source).forEach((key) => { | ||
if (key === "__proto__") { | ||
return; | ||
} | ||
if (isObject(source[key]) && key in target) { | ||
output[key] = deepmerge(target[key], source[key], options); | ||
} else { | ||
output[key] = source[key]; | ||
} | ||
}); | ||
} | ||
return output; | ||
} | ||
// lib/walk-object.ts | ||
function walkObject(target, predicate) { | ||
function inner(value, path = []) { | ||
if (isArray(value)) { | ||
return value.map((item, index) => inner(item, [...path, String(index)])); | ||
} | ||
if (isObject(value)) { | ||
return Object.fromEntries( | ||
Object.entries(value).map(([key, child]) => [ | ||
key, | ||
inner(child, [...path, key]) | ||
]) | ||
); | ||
} | ||
return predicate(value, path); | ||
} | ||
return inner(target); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
__DEV__, | ||
cx, | ||
deepmerge, | ||
isArray, | ||
isBrowser, | ||
isObject, | ||
omit, | ||
pick, | ||
roundToNearest15, | ||
useControllableState, | ||
useSafeEffect, | ||
walkObject | ||
}); | ||
"use strict";var j=Object.create;var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var r in t)f(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!L.call(e,o)&&o!==r&&f(e,o,{get:()=>t[o],enumerable:!(n=x(t,o))||n.enumerable});return e};var T=(e,t,r)=>(r=e!=null?j(l(e)):{},u(t||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e)),D=e=>u(f({},"__esModule",{value:!0}),e);var M={};P(M,{__DEV__:()=>E,cx:()=>O.default,deepmerge:()=>b,isArray:()=>s,isBrowser:()=>d,isObject:()=>i,omit:()=>v,pick:()=>w,roundToNearest15:()=>S,useControllableState:()=>_,useSafeEffect:()=>A,walkObject:()=>K});module.exports=D(M);var O=T(require("clsx"));function s(e){return Array.isArray(e)}function i(e){let t=typeof e;return e!=null&&(t==="object"||t==="function")&&!s(e)}var E=!1;function S(e=new Date){return new Date(Math.round(e.getTime()/9e5)*9e5)}var m=require("react");function _(e,t,r){let[n,o]=(0,m.useState)(t);return[e!==void 0?e:n,a=>{o(a),r&&r(a)}]}var p=T(require("react")),d=typeof document<"u",A=d?p.useLayoutEffect:p.useEffect;function v(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function w(e,t){let r={};return t.forEach(n=>{n in e&&(r[n]=e[n])}),r}function b(e,t,r={clone:!1}){let n=r.clone?{...e}:e;return i(e)&&i(t)&&Object.keys(t).forEach(o=>{o!=="__proto__"&&(i(t[o])&&o in e?n[o]=b(e[o],t[o],r):n[o]=t[o])}),n}function K(e,t){function r(n,o=[]){return s(n)?n.map((c,a)=>r(c,[...o,String(a)])):i(n)?Object.fromEntries(Object.entries(n).map(([c,a])=>[c,r(a,[...o,c])])):t(n,o)}return r(e)}0&&(module.exports={__DEV__,cx,deepmerge,isArray,isBrowser,isObject,omit,pick,roundToNearest15,useControllableState,useSafeEffect,walkObject}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@daren/utils", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"repository": { | ||
@@ -10,19 +10,23 @@ "type": "git", | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.mjs", | ||
"unpkg": "dist/index.global.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"lib" | ||
], | ||
"tsup": { | ||
"entry": [ | ||
"lib/index.ts" | ||
], | ||
"format": [ | ||
"esm", | ||
"cjs", | ||
"iife" | ||
] | ||
}, | ||
"scripts": { | ||
"build": "run-s build:*", | ||
"build:source": "tsup ./index.ts --format esm,cjs --legacy-output --dts ./index.ts", | ||
"build:source": "tsup --env.NODE_ENV production --minify --sourcemap --clean --dts", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", | ||
@@ -49,3 +53,3 @@ "lint": "run-p lint:*", | ||
}, | ||
"gitHead": "0cb696ce495fec15dafa4b2b174a840eabbcaa2c" | ||
"gitHead": "d8961f4af4428e03a5bc78e5b7bd0b20be30825b" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
55687
17
0
231
2