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

@zag-js/utils

Package Overview
Dependencies
Maintainers
1
Versions
781
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/utils - npm Package Compare versions

Comparing version 0.0.0-dev-20220413091534 to 0.0.0-dev-20220413174154

dist/array.d.ts.map

1

dist/array.d.ts

@@ -20,1 +20,2 @@ export declare function toArray<T>(v: T | T[] | undefined | null): T[];

export declare const chunk: <T>(v: T[], size: number) => T[][];
//# sourceMappingURL=array.d.ts.map

@@ -8,1 +8,2 @@ export declare const runIfFn: <T>(v: T, ...a: T extends (...a: any[]) => void ? Parameters<T> : never) => T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T>;

export declare function merge<T, U>(origin: T, patch: U): T & U;
//# sourceMappingURL=functions.d.ts.map

@@ -26,1 +26,2 @@ export declare const isDev: () => boolean;

export declare const isCtrlKey: (v: KeyboardEvent) => boolean;
//# sourceMappingURL=guard.d.ts.map

@@ -5,1 +5,2 @@ export * from "./array";

export * from "./warning";
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,214 @@

var a=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var O=(t,n)=>{for(var e in n)a(t,e,{get:n[e],enumerable:!0})},K=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of w(n))!N.call(t,r)&&r!==e&&a(t,r,{get:()=>n[r],enumerable:!(o=A(n,r))||o.enumerable});return t};var I=t=>K(a({},"__esModule",{value:!0}),t);var Tt={};O(Tt,{add:()=>F,callAll:()=>q,cast:()=>L,chunk:()=>V,clear:()=>C,first:()=>k,fromLength:()=>M,has:()=>D,invariant:()=>xt,isApple:()=>X,isArray:()=>v,isBoolean:()=>Y,isCtrlKey:()=>ut,isDev:()=>G,isDom:()=>c,isEmpty:()=>j,isFirefox:()=>J,isFunction:()=>tt,isIPad:()=>g,isIPhone:()=>E,isIos:()=>h,isLeftClick:()=>it,isMac:()=>u,isModifiedEvent:()=>pt,isMouseEvent:()=>rt,isNumber:()=>Z,isObject:()=>l,isRightClick:()=>ct,isSafari:()=>H,isString:()=>$,isTouchEvent:()=>st,isWebkit:()=>Q,last:()=>d,merge:()=>b,next:()=>S,nextIndex:()=>x,noop:()=>W,pipe:()=>B,prev:()=>U,prevIndex:()=>m,remove:()=>R,removeAt:()=>y,runIfFn:()=>_,supportsMouseEvent:()=>ot,supportsPointerEvent:()=>nt,supportsTouchEvent:()=>et,toArray:()=>P,uuid:()=>z,warn:()=>at});module.exports=I(Tt);function P(t){return t?Array.isArray(t)?t:[t]:[]}var M=t=>Array.from(Array(t).keys()),k=t=>t[0],d=t=>t[t.length-1],j=t=>t.length===0,D=(t,n)=>t.indexOf(n)!==-1,F=(t,...n)=>t.concat(n),R=(t,n)=>y(t,t.indexOf(n)),y=(t,n)=>(n>-1&&t.splice(n,1),t);function C(t){for(;t.length>0;)t.pop();return t}function x(t,n,e={}){let{step:o=1,loop:r=!0}=e,s=n+o,i=t.length,f=i-1;return n===-1?o>0?0:f:s<0?r?f:0:s>=i?r?0:n>i?i:n:s}function S(t,n,e={}){return t[x(t,n,e)]}function m(t,n,e={}){let{step:o=1,loop:r=!0}=e;return x(t,n,{step:-o,loop:r})}function U(t,n,e={}){return t[m(t,n,e)]}var V=(t,n)=>{let e=[];return t.reduce((o,r,s)=>{var i;return s%n===0?o.push([r]):(i=d(o))==null||i.push(r),o},e)};var _=(t,...n)=>{let e=typeof t=="function"?t(...n):t;return e!=null?e:void 0},L=t=>t,W=()=>{},B=(...t)=>n=>t.reduce((e,o)=>o(e),n),q=(...t)=>(...n)=>{t.forEach(function(e){e==null||e(...n)})},z=(()=>{let t=0;return()=>(t++,t.toString(36))})();function b(t,n){if(typeof n!="object")return n;let e=typeof t!="object"?{}:Object.assign({},t);for(let o of Object.keys(n)){let r=n[o],s=e[o];r===null?delete e[o]:Array.isArray(r)||Array.isArray(s)?e[o]=(s||[]).concat(r||[]):e[o]=b(s,r)}return e}var T=t=>c()&&t.test(navigator.platform),p=t=>c()&&t.test(navigator.userAgent),G=()=>!1,c=()=>typeof window!="undefined",u=()=>T(/^Mac/),E=()=>T(/^iPhone/),g=()=>T(/^iPad/)||u()&&navigator.maxTouchPoints>1,h=()=>E()||g(),H=()=>p(/^((?!chrome|android).)*safari/i),J=()=>p(/^Firefox/),Q=()=>p(/^WebKit/)&&!p(/Chrome/),X=()=>u()||h(),v=t=>Array.isArray(t),Y=t=>t===!0||t===!1,l=t=>!(t==null||typeof t!="object"||v(t)),Z=t=>typeof t=="number"&&!Number.isNaN(t),$=t=>typeof t=="string",tt=t=>typeof t=="function",nt=()=>c()&&window.onpointerdown===null,et=()=>c()&&window.ontouchstart===null,ot=()=>c()&&window.onmousedown===null,rt=t=>l(t)&&"button"in t,st=t=>l(t)&&"touches"in t,it=t=>t.button===0,ct=t=>t.button===2,pt=t=>t.ctrlKey||t.altKey||t.metaKey||t.shiftKey,ut=t=>u()?t.metaKey&&!t.ctrlKey:t.ctrlKey&&!t.metaKey;function at(...t){let n=t.length===1?t[0]:t[1],e=t.length===2?t[0]:!0}function xt(...t){let n=t.length===1?t[0]:t[1],e=t.length===2?t[0]:!0}
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
add: () => add,
callAll: () => callAll,
cast: () => cast,
chunk: () => chunk,
clear: () => clear,
first: () => first,
fromLength: () => fromLength,
has: () => has,
invariant: () => invariant,
isApple: () => isApple,
isArray: () => isArray,
isBoolean: () => isBoolean,
isCtrlKey: () => isCtrlKey,
isDev: () => isDev,
isDom: () => isDom,
isEmpty: () => isEmpty,
isFirefox: () => isFirefox,
isFunction: () => isFunction,
isIPad: () => isIPad,
isIPhone: () => isIPhone,
isIos: () => isIos,
isLeftClick: () => isLeftClick,
isMac: () => isMac,
isModifiedEvent: () => isModifiedEvent,
isMouseEvent: () => isMouseEvent,
isNumber: () => isNumber,
isObject: () => isObject,
isRightClick: () => isRightClick,
isSafari: () => isSafari,
isString: () => isString,
isTouchEvent: () => isTouchEvent,
isWebkit: () => isWebkit,
last: () => last,
merge: () => merge,
next: () => next,
nextIndex: () => nextIndex,
noop: () => noop,
pipe: () => pipe,
prev: () => prev,
prevIndex: () => prevIndex,
remove: () => remove,
removeAt: () => removeAt,
runIfFn: () => runIfFn,
supportsMouseEvent: () => supportsMouseEvent,
supportsPointerEvent: () => supportsPointerEvent,
supportsTouchEvent: () => supportsTouchEvent,
toArray: () => toArray,
uuid: () => uuid,
warn: () => warn
});
module.exports = __toCommonJS(src_exports);
// src/array.ts
function toArray(v) {
if (!v)
return [];
return Array.isArray(v) ? v : [v];
}
var fromLength = (length) => Array.from(Array(length).keys());
var first = (v) => v[0];
var last = (v) => v[v.length - 1];
var isEmpty = (v) => v.length === 0;
var has = (v, t) => v.indexOf(t) !== -1;
var add = (v, ...items) => v.concat(items);
var remove = (v, item) => removeAt(v, v.indexOf(item));
var removeAt = (v, i) => {
if (i > -1)
v.splice(i, 1);
return v;
};
function clear(v) {
while (v.length > 0)
v.pop();
return v;
}
function nextIndex(v, idx, opts = {}) {
const { step = 1, loop = true } = opts;
const next2 = idx + step;
const len = v.length;
const last2 = len - 1;
if (idx === -1)
return step > 0 ? 0 : last2;
if (next2 < 0)
return loop ? last2 : 0;
if (next2 >= len)
return loop ? 0 : idx > len ? len : idx;
return next2;
}
function next(v, idx, opts = {}) {
return v[nextIndex(v, idx, opts)];
}
function prevIndex(v, idx, opts = {}) {
const { step = 1, loop = true } = opts;
return nextIndex(v, idx, { step: -step, loop });
}
function prev(v, index, opts = {}) {
return v[prevIndex(v, index, opts)];
}
var chunk = (v, size) => {
const res = [];
return v.reduce((rows, value, index) => {
var _a;
if (index % size === 0)
rows.push([value]);
else
(_a = last(rows)) == null ? void 0 : _a.push(value);
return rows;
}, res);
};
// src/functions.ts
var runIfFn = (v, ...a) => {
const res = typeof v === "function" ? v(...a) : v;
return res != null ? res : void 0;
};
var cast = (v) => v;
var noop = () => {
};
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
var callAll = (...fns) => (...a) => {
fns.forEach(function(fn) {
fn == null ? void 0 : fn(...a);
});
};
var uuid = /* @__PURE__ */ (() => {
let id = 0;
return () => {
id++;
return id.toString(36);
};
})();
function merge(origin, patch) {
if (!(typeof patch === "object"))
return patch;
const result = !(typeof origin === "object") ? {} : Object.assign({}, origin);
for (const key of Object.keys(patch)) {
const value = patch[key];
const src = result[key];
if (value === null)
delete result[key];
else if (Array.isArray(value) || Array.isArray(src))
result[key] = (src || []).concat(value || []);
else
result[key] = merge(src, value);
}
return result;
}
// src/guard.ts
var platform = (v) => isDom() && v.test(navigator.platform);
var ua = (v) => isDom() && v.test(navigator.userAgent);
var isDev = () => void 0 !== "production";
var isDom = () => !!(typeof window !== "undefined");
var isMac = () => platform(/^Mac/);
var isIPhone = () => platform(/^iPhone/);
var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
var isIos = () => isIPhone() || isIPad();
var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
var isFirefox = () => ua(/^Firefox/);
var isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/);
var isApple = () => isMac() || isIos();
var isArray = (v) => Array.isArray(v);
var isBoolean = (v) => v === true || v === false;
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
var isString = (v) => typeof v === "string";
var isFunction = (v) => typeof v === "function";
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
var isMouseEvent = (v) => isObject(v) && "button" in v;
var isTouchEvent = (v) => isObject(v) && "touches" in v;
var isLeftClick = (v) => v.button === 0;
var isRightClick = (v) => v.button === 2;
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey || v.shiftKey;
var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
// src/warning.ts
function warn(...a) {
const m = a.length === 1 ? a[0] : a[1];
const c = a.length === 2 ? a[0] : true;
if (c && void 0 !== "production") {
console.warn(m);
}
}
function invariant(...a) {
const m = a.length === 1 ? a[0] : a[1];
const c = a.length === 2 ? a[0] : true;
if (c && void 0 !== "production") {
throw new Error(m);
}
}
//# sourceMappingURL=index.js.map

@@ -5,1 +5,2 @@ export declare function warn(m: string): void;

export declare function invariant(c: boolean, m: string): void;
//# sourceMappingURL=warning.d.ts.map

15

package.json
{
"name": "@zag-js/utils",
"version": "0.0.0-dev-20220413091534",
"version": "0.0.0-dev-20220413174154",
"description": "",

@@ -19,3 +19,3 @@ "keywords": [

"files": [
"dist"
"dist/**/*"
],

@@ -27,3 +27,12 @@ "publishConfig": {

"url": "https://github.com/chakra-ui/zag/issues"
},
"scripts": {
"build:fast": "zag build",
"start": "zag build --watch",
"build": "zag build --prod",
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
"lint": "eslint src --ext .ts,.tsx",
"test:ci": "yarn test --ci --runInBand",
"test:watch": "yarn test --watch --updateSnapshot"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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