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

@ribajs/utils

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ribajs/utils - npm Package Compare versions

Comparing version 1.9.0-alpha.2 to 1.9.0-alpha.10

10

package.json
{
"name": "@ribajs/utils",
"description": "Utils module of Riba.js",
"version": "1.9.0-alpha.2",
"version": "1.9.0-alpha.10",
"author": "Pascal Garber <pascal@artandcode.studio>",

@@ -42,7 +42,7 @@ "contributors": [

"devDependencies": {
"@babel/runtime": "^7.10.5",
"@babel/runtime-corejs3": "^7.10.5",
"@ribajs/tsconfig": "1.9.0-alpha.2",
"babel-jest": "^26.1.0"
"@babel/runtime": "^7.11.2",
"@babel/runtime-corejs3": "^7.11.2",
"@ribajs/tsconfig": "1.9.0-alpha.10",
"babel-jest": "^26.3.0"
}
}

@@ -27,3 +27,6 @@ import { Deferred } from "./types";

* The debounce function receives our function as a parameter
* It is recommended to use this method for scroll events, but the event should still be passive
* This method uses uses internaly the requestAnimationFrame method
* @see https://css-tricks.com/styling-based-on-scroll-position/
* @see https://www.telerik.com/blogs/debouncing-and-throttling-in-javascript
*/

@@ -48,1 +51,20 @@ export const debounce = (fn: (...params: any) => any) => {

};
/**
* The throttle function receives our function as a parameter
* It is recommended to use this method for resize events
* Throttling is a technique in which, no matter how many times the user fires the event, the attached function will be executed only once in a given time interval.
* @see https://www.telerik.com/blogs/debouncing-and-throttling-in-javascript
* @see https://gist.github.com/peduarte/969217eac456538789e8fac8f45143b4
*/
export const throttle = (fn: (...params: any) => any, wait = 100) => {
let timerId: number | null = null;
return (...params: any[]) => {
if (timerId === null) {
timerId = window.setTimeout(() => {
fn(...params);
timerId = null;
}, wait);
}
};
};

@@ -119,2 +119,4 @@ export const MAX_UID = 1000;

((event as MouseEvent).relatedTarget as HTMLAnchorElement) ||
// JQuery event
((event as any).delegateTarget as HTMLUnknownElement) ||
((event as any).fromElement as HTMLAnchorElement);

@@ -246,2 +248,3 @@ return el;

(script as any).onreadystatechange = null;
script?.setAttribute("loaded", "true");
resolve(script as HTMLScriptElement);

@@ -253,6 +256,7 @@ }

// Other browsers
script.onload = function () {
script.addEventListener("load", () => {
script?.setAttribute("loaded", "true");
resolve(script as HTMLScriptElement);
};
script.onerror = function (...args) {
});
script.addEventListener("error", (...args) => {
const error = new Error("Error on load script " + script?.src);

@@ -262,6 +266,5 @@ console.error(error);

reject(error);
};
});
});
script.setAttribute("loaded", "true");
return script;

@@ -268,0 +271,0 @@ };

@@ -192,2 +192,4 @@ export const couldBeJson = (str?: string | null) => {

* @see http://www.damirscorner.com/blog/posts/20180216-VariableNumberOfArgumentsInTypescript.html
* Copied from here:
* @see https://gomakethings.com/merging-objects-with-vanilla-javascript/
*/

@@ -202,3 +204,4 @@ export const extend = (

for (const prop in obj) {
if (obj[prop]) {
// eslint-disable-next-line no-prototype-builtins
if (obj.hasOwnProperty(prop)) {
if (

@@ -231,5 +234,7 @@ deep &&

* @param object2 The second object containing properties to concat.
*
* Note: This is actually just the same as extend with only two objects. Redundant.
*/
export const concat = (deep: boolean, object1?: any, object2?: any): any => {
object1 = extend(deep, object1 || {}, object1 || {}, object2 || {});
object1 = extend(deep, object1 || {}, object2 || {});
return object1;

@@ -243,5 +248,9 @@ };

*/
export const clone = (deep: boolean, val: any) => {
export const clone = (deep: boolean, val: any): any => {
if (isArray(val)) {
return val.slice();
if (deep) {
return (val as any[]).map((x) => clone(true, x));
} else {
return val.slice();
}
}

@@ -248,0 +257,0 @@ if (isObject(val)) {

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