Socket
Socket
Sign inDemoInstall

@daybrush/utils

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daybrush/utils - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

1

declaration/utils.d.ts

@@ -34,1 +34,2 @@ import { IArrayFormat, IObject } from "./types";

export declare function getKeys(obj: IObject<any>): string[];
export declare function sortOrders(keys: string[], orders?: string[]): void;

56

dist/utils.esm.js

@@ -7,3 +7,3 @@ /*

repository: https://github.com/daybrush/utils
@version 0.11.0
@version 0.12.0
*/

@@ -175,5 +175,3 @@ /**

var getCrossBrowserProperty =
/*#__PURE__*/
function (property) {
var getCrossBrowserProperty = /*#__PURE__*/function (property) {
if (!doc) {

@@ -209,5 +207,3 @@ return "";

var TRANSFORM =
/*#__PURE__*/
getCrossBrowserProperty("transform");
var TRANSFORM = /*#__PURE__*/getCrossBrowserProperty("transform");
/**

@@ -222,5 +218,3 @@ * get string "filter" with the vendor prefix.

var FILTER =
/*#__PURE__*/
getCrossBrowserProperty("filter");
var FILTER = /*#__PURE__*/getCrossBrowserProperty("filter");
/**

@@ -235,5 +229,3 @@ * get string "animation" with the vendor prefix.

var ANIMATION =
/*#__PURE__*/
getCrossBrowserProperty("animation");
var ANIMATION = /*#__PURE__*/getCrossBrowserProperty("animation");
/**

@@ -248,5 +240,3 @@ * get string "keyframes" with the vendor prefix.

var KEYFRAMES =
/*#__PURE__*/
ANIMATION.replace("animation", "keyframes");
var KEYFRAMES = /*#__PURE__*/ANIMATION.replace("animation", "keyframes");
var OPEN_CLOSED_CHARACTER = ["\"", "'", "\\\"", "\\'"];

@@ -658,5 +648,3 @@

var requestAnimationFrame =
/*#__PURE__*/
function () {
var requestAnimationFrame = /*#__PURE__*/function () {
var firstTime = now();

@@ -688,5 +676,3 @@ var raf = IS_WINDOW && (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame);

var cancelAnimationFrame =
/*#__PURE__*/
function () {
var cancelAnimationFrame = /*#__PURE__*/function () {
var caf = IS_WINDOW && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame);

@@ -710,3 +696,27 @@ return caf ? caf.bind(window) : function (handle) {

}
function sortOrders(keys, orders) {
if (orders === void 0) {
orders = [];
}
keys.sort(function (a, b) {
var index1 = orders.indexOf(a);
var index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;
});
}
/**

@@ -1036,3 +1046,3 @@ * @namespace

export { RGB, RGBA, HSL, HSLA, COLOR_MODELS, FUNCTION, PROPERTY, ARRAY, OBJECT, STRING, NUMBER, UNDEFINED, IS_WINDOW, doc as document, getCrossBrowserProperty, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, OPEN_CLOSED_CHARACTER, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, find, requestAnimationFrame, cancelAnimationFrame, getKeys, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent };
export { RGB, RGBA, HSL, HSLA, COLOR_MODELS, FUNCTION, PROPERTY, ARRAY, OBJECT, STRING, NUMBER, UNDEFINED, IS_WINDOW, doc as document, getCrossBrowserProperty, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, OPEN_CLOSED_CHARACTER, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, find, requestAnimationFrame, cancelAnimationFrame, getKeys, sortOrders, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent };
//# sourceMappingURL=utils.esm.js.map

@@ -7,3 +7,3 @@ /*

repository: https://github.com/daybrush/utils
@version 0.11.0
@version 0.12.0
*/

@@ -181,5 +181,3 @@ (function (global, factory) {

var getCrossBrowserProperty =
/*#__PURE__*/
function (property) {
var getCrossBrowserProperty = /*#__PURE__*/function (property) {
if (!doc) {

@@ -215,5 +213,3 @@ return "";

var TRANSFORM =
/*#__PURE__*/
getCrossBrowserProperty("transform");
var TRANSFORM = /*#__PURE__*/getCrossBrowserProperty("transform");
/**

@@ -228,5 +224,3 @@ * get string "filter" with the vendor prefix.

var FILTER =
/*#__PURE__*/
getCrossBrowserProperty("filter");
var FILTER = /*#__PURE__*/getCrossBrowserProperty("filter");
/**

@@ -241,5 +235,3 @@ * get string "animation" with the vendor prefix.

var ANIMATION =
/*#__PURE__*/
getCrossBrowserProperty("animation");
var ANIMATION = /*#__PURE__*/getCrossBrowserProperty("animation");
/**

@@ -254,5 +246,3 @@ * get string "keyframes" with the vendor prefix.

var KEYFRAMES =
/*#__PURE__*/
ANIMATION.replace("animation", "keyframes");
var KEYFRAMES = /*#__PURE__*/ANIMATION.replace("animation", "keyframes");
var OPEN_CLOSED_CHARACTER = ["\"", "'", "\\\"", "\\'"];

@@ -664,5 +654,3 @@

var requestAnimationFrame =
/*#__PURE__*/
function () {
var requestAnimationFrame = /*#__PURE__*/function () {
var firstTime = now();

@@ -694,5 +682,3 @@ var raf = IS_WINDOW && (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame);

var cancelAnimationFrame =
/*#__PURE__*/
function () {
var cancelAnimationFrame = /*#__PURE__*/function () {
var caf = IS_WINDOW && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame);

@@ -716,3 +702,27 @@ return caf ? caf.bind(window) : function (handle) {

}
function sortOrders(keys, orders) {
if (orders === void 0) {
orders = [];
}
keys.sort(function (a, b) {
var index1 = orders.indexOf(a);
var index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;
});
}
/**

@@ -1090,2 +1100,3 @@ * @namespace

getKeys: getKeys,
sortOrders: sortOrders,
$: $,

@@ -1092,0 +1103,0 @@ hasClass: hasClass,

@@ -7,5 +7,5 @@ /*

repository: https://github.com/daybrush/utils
@version 0.11.0
@version 0.12.0
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.utils=n()}(this,function(){"use strict";var s="rgb",f="rgba",c="hsl",l="hsla",e=[s,f,c,l],n="function",t="object",r="string",a="undefined",i=typeof window!==a,o=typeof document!==a&&document,u=["webkit","ms","moz","o"],m=function(e){if(!o)return"";var n=(o.body||o.documentElement).style,t=u.length;if(typeof n[e]!==a)return e;for(var r=0;r<t;++r){var i="-"+u[r]+"-"+e;if(typeof n[i]!==a)return i}return""},d=m("transform"),p=m("filter"),v=m("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(e,n,t,r){for(var i=t;i<r;++i){var a=n[i].trim();if(a===e)return i;var o=i;if("("===a?o=A(")",n,i+1,r):-1<h.indexOf(a)&&(o=A(a,n,i+1,r)),-1===o)break;i=o}return-1}function g(e,n){for(var t=new RegExp("(\\s*"+(n||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=e.split(t).filter(Boolean),i=r.length,a=[],o=[],u=0;u<i;++u){var s=r[u].trim(),f=u;if("("===s)f=A(")",r,u+1,i);else{if(")"===s)throw new Error("invalid format");if(-1<h.indexOf(s))f=A(s,r,u+1,i);else if(s===n){o.length&&(a.push(o.join("")),o=[]);continue}}-1===f&&(f=i-1),o.push(r.slice(u,f+1).join("")),u=f}return o.length&&a.push(o.join("")),a}function y(e){return g(e,",")}function R(e){var n=/([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(e);return!n||n.length<4?{}:{prefix:n[1],value:n[2],suffix:n[3]}}function b(){return Date.now?Date.now():(new Date).getTime()}function E(e,n,t){void 0===t&&(t=-1);for(var r=e.length,i=0;i<r;++i)if(n(e[i],i,e))return i;return t}var x=function(){var t=b(),e=i&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return e?e.bind(window):function(e){var n=b();return window.setTimeout(function(){e(n-t)},1e3/60)}}();function F(e){return e.replace("#","")}function N(e){var n=F(e),t=parseInt(n.substring(0,2),16),r=parseInt(n.substring(2,4),16),i=parseInt(n.substring(4,6),16),a=parseInt(n.substring(6,8),16)/255;return isNaN(a)&&(a=1),[t,r,i,a]}function C(e){var n=e.charAt(1),t=e.charAt(2),r=e.charAt(3),i=e.charAt(4);return["#",n,n,t,t,r,r,i,i].join("")}function O(e){var n,t=e[0],r=e[1],i=e[2];t<0&&(t+=360*Math.floor((Math.abs(t)+360)/360)),t%=360;var a,o=(1-Math.abs(2*i-1))*r,u=o*(1-Math.abs(t/60%2-1)),s=i-o/2;return a=t<60?[o,u,0]:t<120?[u,o,0]:t<180?[0,o,u]:t<240?[0,u,o]:t<300?[u,0,o]:t<360?[o,0,u]:[0,0,0],[Math.round(255*(a[0]+s)),Math.round(255*(a[1]+s)),Math.round(255*(a[2]+s)),null!==(n=e[3])&&void 0!==n?n:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:e,FUNCTION:n,PROPERTY:"property",ARRAY:"array",OBJECT:t,STRING:r,NUMBER:"number",UNDEFINED:a,IS_WINDOW:i,document:o,getCrossBrowserProperty:m,TRANSFORM:d,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:F,hexToRGBA:N,toFullHex:C,hslToRGBA:O,stringToRGBA:function(e){if("#"===e.charAt(0))return 4===e.length||5===e.length?N(C(e)):N(e);if(-1!==e.indexOf("(")){var n=R(e),t=n.prefix,r=n.value;if(!t||!r)return;var i=y(r),a=[0,0,0,1],o=i.length;switch(t){case s:case f:for(var u=0;u<o;++u)a[u]=parseFloat(i[u]);return a;case c:case l:for(u=0;u<o;++u)-1!==i[u].indexOf("%")?a[u]=parseFloat(i[u])/100:a[u]=parseFloat(i[u]);return O(a)}}},dot:function(e,n,t,r){return(e*r+n*t)/(t+r)},isUndefined:function(e){return typeof e===a},isObject:function(e){return e&&typeof e===t},isArray:function(e){return Array.isArray(e)},isString:function(e){return typeof e===r},isFunction:function(e){return typeof e===n},splitText:g,splitSpace:function(e){return g(e,"")},splitComma:y,splitBracket:R,splitUnit:function(e){var n=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(e);if(!n)return{prefix:"",unit:"",value:NaN};var t=n[1],r=n[2];return{prefix:t,unit:n[3],value:parseFloat(r)}},camelize:function(e){return e.replace(/[\s-_]([a-z])/g,function(e,n){return n.toUpperCase()})},decamelize:function(e,r){return void 0===r&&(r="-"),e.replace(/([a-z])([A-Z])/g,function(e,n,t){return""+n+r+t.toLowerCase()})},toArray:function(e){return[].slice.call(e)},now:b,findIndex:E,find:function(e,n,t){var r=E(e,n);return-1<r?e[r]:t},requestAnimationFrame:x,cancelAnimationFrame:function(){var e=i&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return e?e.bind(window):function(e){clearTimeout(e)}}(),getKeys:function(e){if(Object.keys)return Object.keys(e);var n=[];for(var t in n)n.push(t);return n},$:function(e,n){return n?o.querySelectorAll(e):o.querySelector(e)},hasClass:function(e,n){return e.classList?e.classList.contains(n):!!e.className.match(new RegExp("(\\s|^)"+n+"(\\s|$)"))},addClass:function(e,n){e.classList?e.classList.add(n):e.className+=" "+n},removeClass:function(e,n){if(e.classList)e.classList.remove(n);else{var t=new RegExp("(\\s|^)"+n+"(\\s|$)");e.className=e.className.replace(t," ")}},fromCSS:function(e,n){if(!e||!n||!n.length)return{};var t;if(e instanceof Element)t=e;else{if(!e.length)return{};t=e[0]}for(var r={},i=window.getComputedStyle(t),a=n.length,o=0;o<a;++o)r[n[o]]=i[n[o]];return r},addEvent:function(e,n,t,r){e.addEventListener(n,t,r)},removeEvent:function(e,n,t){e.removeEventListener(n,t)}}});
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.utils=e()}(this,function(){"use strict";function n(n){if(!u)return"";var e=(u.body||u.documentElement).style,t=d.length;if(typeof e[n]!=o)return n;for(var r=0;r<t;++r){var i="-"+d[r]+"-"+n;if(typeof e[i]!=o)return i}return""}var s="rgb",f="rgba",c="hsl",l="hsla",e=[s,f,c,l],t="function",r="object",i="string",o="undefined",a=typeof window!=o,u=typeof document!=o&&document,d=["webkit","ms","moz","o"],m=n("transform"),p=n("filter"),v=n("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(n,e,t,r){for(var i=t;i<r;++i){var o=e[i].trim();if(o===n)return i;var a=i;if("("===o?a=A(")",e,i+1,r):-1<h.indexOf(o)&&(a=A(o,e,i+1,r)),-1===a)break;i=a}return-1}function g(n,e){for(var t=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=n.split(t).filter(Boolean),i=r.length,o=[],a=[],u=0;u<i;++u){var s=r[u].trim(),f=u;if("("===s)f=A(")",r,u+1,i);else{if(")"===s)throw new Error("invalid format");if(-1<h.indexOf(s))f=A(s,r,u+1,i);else if(s===e){a.length&&(o.push(a.join("")),a=[]);continue}}-1===f&&(f=i-1),a.push(r.slice(u,f+1).join("")),u=f}return a.length&&o.push(a.join("")),o}function y(n){return g(n,",")}function R(n){var e=/([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(n);return!e||e.length<4?{}:{prefix:e[1],value:e[2],suffix:e[3]}}function x(){return Date.now?Date.now():(new Date).getTime()}function b(n,e,t){void 0===t&&(t=-1);for(var r=n.length,i=0;i<r;++i)if(e(n[i],i,n))return i;return t}var E=function(){var t=x(),n=a&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=x();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function F(n){return n.replace("#","")}function O(n){var e=F(n),t=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),o=parseInt(e.substring(6,8),16)/255;return isNaN(o)&&(o=1),[t,r,i,o]}function N(n){var e=n.charAt(1),t=n.charAt(2),r=n.charAt(3),i=n.charAt(4);return["#",e,e,t,t,r,r,i,i].join("")}function C(n){var e,t=n[0],r=n[1],i=n[2];t<0&&(t+=360*Math.floor((Math.abs(t)+360)/360)),t%=360;var o=(1-Math.abs(2*i-1))*r,a=o*(1-Math.abs(t/60%2-1)),u=i-o/2,s=t<60?[o,a,0]:t<120?[a,o,0]:t<180?[0,o,a]:t<240?[0,a,o]:t<300?[a,0,o]:t<360?[o,0,a]:[0,0,0];return[Math.round(255*(s[0]+u)),Math.round(255*(s[1]+u)),Math.round(255*(s[2]+u)),null!==(e=n[3])&&void 0!==e?e:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:e,FUNCTION:t,PROPERTY:"property",ARRAY:"array",OBJECT:r,STRING:i,NUMBER:"number",UNDEFINED:o,IS_WINDOW:a,document:u,getCrossBrowserProperty:n,TRANSFORM:m,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:F,hexToRGBA:O,toFullHex:N,hslToRGBA:C,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?O(N(n)):O(n);if(-1!==n.indexOf("(")){var e=R(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=y(r),o=[0,0,0,1],a=i.length;switch(t){case s:case f:for(var u=0;u<a;++u)o[u]=parseFloat(i[u]);return o;case c:case l:for(u=0;u<a;++u)-1!==i[u].indexOf("%")?o[u]=parseFloat(i[u])/100:o[u]=parseFloat(i[u]);return C(o)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n==o},isObject:function(n){return n&&typeof n==r},isArray:function(n){return Array.isArray(n)},isString:function(n){return typeof n==i},isFunction:function(n){return typeof n==t},splitText:g,splitSpace:function(n){return g(n,"")},splitComma:y,splitBracket:R,splitUnit:function(n){var e=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(n);if(!e)return{prefix:"",unit:"",value:NaN};var t=e[1],r=e[2];return{prefix:t,unit:e[3],value:parseFloat(r)}},camelize:function(n){return n.replace(/[\s-_]([a-z])/g,function(n,e){return e.toUpperCase()})},decamelize:function(n,r){return void 0===r&&(r="-"),n.replace(/([a-z])([A-Z])/g,function(n,e,t){return""+e+r+t.toLowerCase()})},toArray:function(n){return[].slice.call(n)},now:x,findIndex:b,find:function(n,e,t){var r=b(n,e);return-1<r?n[r]:t},requestAnimationFrame:E,cancelAnimationFrame:function(){var n=a&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:function(n){if(Object.keys)return Object.keys(n);var e=[];for(var t in e)e.push(t);return e},sortOrders:function(n,i){void 0===i&&(i=[]),n.sort(function(n,e){var t=i.indexOf(n),r=i.indexOf(e);return-1===r&&-1===t?0:-1===t?1:-1===r?-1:t-r})},$:function(n,e){return e?u.querySelectorAll(n):u.querySelector(n)},hasClass:function(n,e){return n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},addClass:function(n,e){n.classList?n.classList.add(e):n.className+=" "+e},removeClass:function(n,e){var t;n.classList?n.classList.remove(e):(t=new RegExp("(\\s|^)"+e+"(\\s|$)"),n.className=n.className.replace(t," "))},fromCSS:function(n,e){if(!n||!e||!e.length)return{};var t;if(n instanceof Element)t=n;else{if(!n.length)return{};t=n[0]}for(var r={},i=window.getComputedStyle(t),o=e.length,a=0;a<o;++a)r[e[a]]=i[e[a]];return r},addEvent:function(n,e,t,r){n.addEventListener(e,t,r)},removeEvent:function(n,e,t){n.removeEventListener(e,t)}}});
//# sourceMappingURL=utils.min.js.map
{
"name": "@daybrush/utils",
"version": "0.11.0",
"version": "0.12.0",
"description": "utils for daybrush",

@@ -5,0 +5,0 @@ "main": "dist/utils.js",

@@ -422,1 +422,19 @@ import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW, OPEN_CLOSED_CHARACTER } from "./consts";

}
export function sortOrders(keys: string[], orders: string[] = []) {
keys.sort((a, b) => {
const index1 = orders.indexOf(a);
const index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;
});
}

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