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.7.1 to 0.8.0

1

declaration/utils.d.ts
import { IArrayFormat, IObject } from "./types";
export declare function dot(a1: number, a2: number, b1: number, b2: number): number;
export declare function isUndefined(value: any): value is undefined;

@@ -3,0 +4,0 @@ export declare function isObject(value: any): value is IObject<any>;

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

repository: https://github.com/daybrush/utils
@version 0.7.1
@version 0.8.0
*/

@@ -254,2 +254,20 @@ /**

/**
* Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).
* @memberof Utils
* @param - The first number
* @param - The second number
* @param - The first number to base on the inner product
* @param - The second number to base on the inner product
* @return - Returns the inner product
import { dot } from "@daybrush/utils";
console.log(dot(0, 15, 2, 3)); // 6
console.log(dot(5, 15, 2, 3)); // 9
console.log(dot(5, 15, 1, 1)); // 10
*/
function dot(a1, a2, b1, b2) {
return (a1 * b2 + a2 * b1) / (b1 + b2);
}
/**
* Check the type that the value is undefined.

@@ -861,3 +879,3 @@ * @memberof Utils

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

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

repository: https://github.com/daybrush/utils
@version 0.7.1
@version 0.8.0
*/

@@ -260,2 +260,20 @@ (function (global, factory) {

/**
* Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).
* @memberof Utils
* @param - The first number
* @param - The second number
* @param - The first number to base on the inner product
* @param - The second number to base on the inner product
* @return - Returns the inner product
import { dot } from "@daybrush/utils";
console.log(dot(0, 15, 2, 3)); // 6
console.log(dot(5, 15, 2, 3)); // 9
console.log(dot(5, 15, 1, 1)); // 10
*/
function dot(a1, a2, b1, b2) {
return (a1 * b2 + a2 * b1) / (b1 + b2);
}
/**
* Check the type that the value is undefined.

@@ -894,2 +912,3 @@ * @memberof Utils

stringToRGBA: stringToRGBA,
dot: dot,
isUndefined: isUndefined,

@@ -896,0 +915,0 @@ isObject: isObject,

4

dist/utils.min.js

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

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

@@ -34,3 +34,4 @@ "main": "dist/utils.js",

"isString",
"isNumber"
"isNumber",
"dot"
],

@@ -37,0 +38,0 @@ "scripts": {

@@ -66,2 +66,2 @@ # @daybrush/utils [![npm version](https://badge.fury.io/js/%40daybrush%2Futils.svg)](https://badge.fury.io/js/%40daybrush%2Futils)

* toArray
* dot

@@ -9,2 +9,19 @@ import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW } from "./consts";

/**
* Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).
* @memberof Utils
* @param - The first number
* @param - The second number
* @param - The first number to base on the inner product
* @param - The second number to base on the inner product
* @return - Returns the inner product
import { dot } from "@daybrush/utils";
console.log(dot(0, 15, 2, 3)); // 6
console.log(dot(5, 15, 2, 3)); // 9
console.log(dot(5, 15, 1, 1)); // 10
*/
export function dot(a1: number, a2: number, b1: number, b2: number) {
return (a1 * b2 + a2 * b1) / (b1 + b2);
}
/**
* Check the type that the value is undefined.

@@ -11,0 +28,0 @@ * @memberof Utils

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