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

@pluginjs/utils

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/utils - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

207

dist/utils.esm.js

@@ -1,52 +0,1 @@

import $ from 'jquery';
/* eslint no-undef: "off" */
/* Credit to http://featurejs.com MIT */
/**
* Test if it's an old device that we want to filter out
*/
/**
* Function that takes a standard CSS property name as a parameter and
* returns it's prefixed version valid for current browser it runs in
*/
const pfx = function () {
const prefixes = ['Webkit', 'Moz', 'O', 'ms'];
const memory = {};
const style = document.createElement('dummy').style;
return function (prop) {
if (typeof memory[prop] === 'undefined') {
const ucProp = prop.charAt(0).toUpperCase() + prop.substr(1);
const props = `${prop} ${prefixes.join(`${ucProp} `)}${ucProp}`.split(' ');
memory[prop] = null;
for (const i in props) {
if (style[props[i]] !== undefined) {
memory[prop] = props[i];
break;
}
}
}
return memory[prop];
};
}();
const transitionEndEvent = () => {
const eventNames = {
transition: 'transitionend',
OTransition: 'oTransitionEnd',
MozTransition: 'transitionend',
WebkitTransition: 'webkitTransitionEnd'
};
const style = document.createElement('dummy').style;
for (const i in eventNames) {
if (eventNames.hasOwnProperty(i)) {
if (style[i] !== undefined) {
return eventNames[i];
}
}
}
return false;
};
var asyncGenerator = function () {

@@ -315,4 +264,3 @@ function AwaitValue(value) {

function filterOffset(obj) {
const {
offset } = obj,
const { offset } = obj,
result = objectWithoutProperties(obj, ['offset']);

@@ -347,4 +295,3 @@ return result;

const newKeyFrames = keyframes.map((keyframe, keyframeIndex) => {
const {
transform } = keyframe,
const { transform } = keyframe,
newKeyFrame = objectWithoutProperties(keyframe, ['transform']);

@@ -396,47 +343,66 @@ if (transform) {

};
function nub(arr) {
return Array.from(new Set(arr));
}
function isPaintObject(data) {
if (typeof data !== 'object') {
return false;
}
const deepMerge = (...args) => {
const input = args.filter(obj => Object(obj) === obj);
const firstChild = input[0];
const newDataFromType = Array.isArray(firstChild) ? [] : {};
if (!input.length) {
return {};
if (data === null) {
return false;
}
if (input.length === 1) {
if (typeof input[0] !== 'function') {
return JSON.parse(JSON.stringify(input[0]));
}
return input[0];
if (data instanceof Set || data instanceof Map) {
return false;
}
return input.reduce((result, item) => {
if (Array.isArray(result) && Array.isArray(item)) {
return item.reduce((resu, el, index) => {
const newData = deepClone(resu);
if (typeof el !== 'object' || !resu[index]) {
newData[index] = el;
return newData;
}
newData[index] = deepMerge(resu[index], el);
return newData;
}, result);
}
if (Array.isArray(data)) {
return false;
}
return Object.keys(item).reduce((resu, key) => {
if (typeof item[key] !== 'object' || !resu[key]) {
return _extends({}, resu, {
[key]: item[key]
});
}
return _extends({}, resu, {
[key]: deepMerge(resu[key], item[key])
});
}, result);
}, newDataFromType);
};
return true;
}
function deepMergeTwo(x, y) {
if (isPaintObject(y) && isPaintObject(x) || isPaintObject(x) && Array.isArray(y)) {
return fromPairs(nub(Object.keys(x).concat(Object.keys(y))).map(key => [key, deepMergeTwo(x[key], y[key])]));
}
if (isPaintObject(y) && typeof x === 'function') {
return Object.assign(function (...args) {
return x.apply(this, args);
}, y);
}
if (isPaintObject(y) && Array.isArray(x)) {
return Object.assign([], x, y);
}
if (isPaintObject(x) && typeof y === 'function') {
return Object.assign(function (...args) {
return y.apply(this, args);
}, x);
}
if (Array.isArray(y) && Array.isArray(x)) {
// return x.concat(y)
return nub(Object.keys(y).concat(Object.keys(x))).map(index => deepMergeTwo(x[index], y[index]));
}
if (typeof y === 'undefined') {
return x;
}
return y;
}
function isObject(obj) {
return Object(obj) === obj;
}
function deepMerge(...args) {
return args.filter(isObject).reduce(deepMergeTwo);
}
const curry = (fn, args = []) => (...subArgs) => {
const currylen = fn.currylen || fn.length;
const collect = args.concat(subArgs);
if (collect.length >= fn.length) {
if (collect.length >= currylen) {
return fn(...collect);

@@ -447,8 +413,12 @@ }

const compose = (...fn) => (...args) => fn.reduceRight((r, i) => {
if (Array.isArray(r)) {
return i(...r);
}
return i(r);
}, args);
const compose = (...fn) => {
const callback = (...args) => fn.reduceRight((r, i, index) => {
if (Array.isArray(r) && index === fn.length - 1) {
return i(...r);
}
return i(r);
}, args);
callback.currylen = fn[fn.curylen || fn.length - 1].length;
return callback;
};

@@ -629,7 +599,2 @@ const MAX_UID = 1000000;

const asTransitionEnd = 'asTransitionEnd';
function triggerTransitionEnd(element) {
$(element).trigger(transitionEndEvent());
}
function fromPairs(arr) {

@@ -646,38 +611,2 @@ return arr.reduce((r, [k, v]) => _extends({}, r, {

function setTransitionEndSupport() {
$.fn.asTransitionEnd = function (duration) {
let called = false;
$(this).one(asTransitionEnd, () => {
called = true;
});
setTimeout(() => {
if (!called) {
triggerTransitionEnd(this);
}
}, duration);
return this;
};
const isTransitionEndEvent = transitionEndEvent();
if (isTransitionEndEvent) {
// suport transition end
$.event.special[asTransitionEnd] = {
bindType: isTransitionEndEvent,
delegateType: isTransitionEndEvent,
handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
}
return undefined;
}
};
}
}
setTransitionEndSupport();
export { deepClone, deepMerge, curry, compose, getUID, range, reflow, arraysEqual, arrayDiff, arrayIntersect, convertPercentageToFloat, convertFloatToPercentage, convertMatrixToArray, getTime, camelize, getValueByPath, throttle, debounce, asTransitionEnd, triggerTransitionEnd, fromPairs, mergeWith, mapKeyFramesToAnime as keyframes2Anime };
export { deepClone, nub, deepMerge, curry, compose, getUID, range, reflow, arraysEqual, arrayDiff, arrayIntersect, convertPercentageToFloat, convertFloatToPercentage, convertMatrixToArray, getTime, camelize, getValueByPath, throttle, debounce, fromPairs, mergeWith, mapKeyFramesToAnime as keyframes2Anime };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) :
(factory((global['@pluginjs/utils'] = {}),global.jQuery));
}(this, (function (exports,$) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global['@pluginjs/utils'] = {})));
}(this, (function (exports) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
/* eslint no-undef: "off" */
/* Credit to http://featurejs.com MIT */
/**
* Test if it's an old device that we want to filter out
*/
/**
* Function that takes a standard CSS property name as a parameter and
* returns it's prefixed version valid for current browser it runs in
*/
var pfx = function () {
var prefixes = ['Webkit', 'Moz', 'O', 'ms'];
var memory = {};
var style = document.createElement('dummy').style;
return function (prop) {
if (typeof memory[prop] === 'undefined') {
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1);
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' ');
memory[prop] = null;
for (var i in props) {
if (style[props[i]] !== undefined) {
memory[prop] = props[i];
break;
}
}
}
return memory[prop];
};
}();
var transitionEndEvent = function transitionEndEvent() {
var eventNames = {
transition: 'transitionend',
OTransition: 'oTransitionEnd',
MozTransition: 'transitionend',
WebkitTransition: 'webkitTransitionEnd'
};
var style = document.createElement('dummy').style;
for (var i in eventNames) {
if (eventNames.hasOwnProperty(i)) {
if (style[i] !== undefined) {
return eventNames[i];
}
}
}
return false;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -542,55 +491,88 @@ return typeof obj;

};
function nub(arr) {
return Array.from(new Set(arr));
}
function isPaintObject(data) {
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
return false;
}
var deepMerge = function deepMerge() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
if (data === null) {
return false;
}
var input = args.filter(function (obj) {
return Object(obj) === obj;
});
var firstChild = input[0];
var newDataFromType = Array.isArray(firstChild) ? [] : {};
if (!input.length) {
return {};
if (data instanceof Set || data instanceof Map) {
return false;
}
if (input.length === 1) {
if (typeof input[0] !== 'function') {
return JSON.parse(JSON.stringify(input[0]));
}
return input[0];
if (Array.isArray(data)) {
return false;
}
return input.reduce(function (result, item) {
if (Array.isArray(result) && Array.isArray(item)) {
return item.reduce(function (resu, el, index) {
var newData = deepClone(resu);
if ((typeof el === 'undefined' ? 'undefined' : _typeof(el)) !== 'object' || !resu[index]) {
newData[index] = el;
return newData;
}
newData[index] = deepMerge(resu[index], el);
return newData;
}, result);
}
return true;
}
function deepMergeTwo(x, y) {
if (isPaintObject(y) && isPaintObject(x) || isPaintObject(x) && Array.isArray(y)) {
return fromPairs(nub(Object.keys(x).concat(Object.keys(y))).map(function (key) {
return [key, deepMergeTwo(x[key], y[key])];
}));
}
return Object.keys(item).reduce(function (resu, key) {
if (_typeof(item[key]) !== 'object' || !resu[key]) {
return _extends({}, resu, defineProperty({}, key, item[key]));
if (isPaintObject(y) && typeof x === 'function') {
return Object.assign(function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _extends({}, resu, defineProperty({}, key, deepMerge(resu[key], item[key])));
}, result);
}, newDataFromType);
};
return x.apply(this, args);
}, y);
}
if (isPaintObject(y) && Array.isArray(x)) {
return Object.assign([], x, y);
}
if (isPaintObject(x) && typeof y === 'function') {
return Object.assign(function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return y.apply(this, args);
}, x);
}
if (Array.isArray(y) && Array.isArray(x)) {
// return x.concat(y)
return nub(Object.keys(y).concat(Object.keys(x))).map(function (index) {
return deepMergeTwo(x[index], y[index]);
});
}
if (typeof y === 'undefined') {
return x;
}
return y;
}
function isObject(obj) {
return Object(obj) === obj;
}
function deepMerge() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return args.filter(isObject).reduce(deepMergeTwo);
}
var curry = function curry(fn) {
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return function () {
for (var _len2 = arguments.length, subArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
subArgs[_key2] = arguments[_key2];
for (var _len4 = arguments.length, subArgs = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
subArgs[_key4] = arguments[_key4];
}
var currylen = fn.currylen || fn.length;
var collect = args.concat(subArgs);
if (collect.length >= fn.length) {
if (collect.length >= currylen) {
return fn.apply(undefined, toConsumableArray(collect));

@@ -603,13 +585,13 @@ }

var compose = function compose() {
for (var _len3 = arguments.length, fn = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
fn[_key3] = arguments[_key3];
for (var _len5 = arguments.length, fn = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
fn[_key5] = arguments[_key5];
}
return function () {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
var callback = function callback() {
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
return fn.reduceRight(function (r, i) {
if (Array.isArray(r)) {
return fn.reduceRight(function (r, i, index) {
if (Array.isArray(r) && index === fn.length - 1) {
return i.apply(undefined, toConsumableArray(r));

@@ -620,2 +602,4 @@ }

};
callback.currylen = fn[fn.curylen || fn.length - 1].length;
return callback;
};

@@ -766,4 +750,4 @@

return function () {
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}

@@ -783,4 +767,4 @@

return function () {
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
for (var _len8 = arguments.length, args = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
args[_key8] = arguments[_key8];
}

@@ -812,4 +796,4 @@

return function () {
for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
for (var _len9 = arguments.length, args = Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}

@@ -828,7 +812,2 @@

var asTransitionEnd = 'asTransitionEnd';
function triggerTransitionEnd(element) {
$(element).trigger(transitionEndEvent());
}
function fromPairs(arr) {

@@ -853,41 +832,4 @@ return arr.reduce(function (r, _ref) {

function setTransitionEndSupport() {
$.fn.asTransitionEnd = function (duration) {
var _this3 = this;
var called = false;
$(this).one(asTransitionEnd, function () {
called = true;
});
setTimeout(function () {
if (!called) {
triggerTransitionEnd(_this3);
}
}, duration);
return this;
};
var isTransitionEndEvent = transitionEndEvent();
if (isTransitionEndEvent) {
// suport transition end
$.event.special[asTransitionEnd] = {
bindType: isTransitionEndEvent,
delegateType: isTransitionEndEvent,
handle: function handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
}
return undefined;
}
};
}
}
setTransitionEndSupport();
exports.deepClone = deepClone;
exports.nub = nub;
exports.deepMerge = deepMerge;

@@ -910,4 +852,2 @@ exports.curry = curry;

exports.debounce = debounce;
exports.asTransitionEnd = asTransitionEnd;
exports.triggerTransitionEnd = triggerTransitionEnd;
exports.fromPairs = fromPairs;

@@ -914,0 +854,0 @@ exports.mergeWith = mergeWith;

@@ -1,1 +0,1 @@

!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jquery")):"function"==typeof define&&define.amd?define(["exports","jquery"],n):n(r["@pluginjs/utils"]={},r.jQuery)}(this,function(r,n){"use strict";function t(r){return r.reduce(function(r,n){var t=h(n,2),e=t[0],o=t[1];return p({},r,v({},e,o))},{})}function e(r){return["translate","rotate","scale"].filter(function(n){var t=new RegExp(n,"g");return!!r.match(t)}).reduce(function(n,t){var e=r.match(/\(([^()]+)\)/)[1].split(",");return function(r){switch(r){case"translate":return i;case"rotate":return u;case"scale":return o;default:return function(){return"no match!"}}}(t)(e)},{})}function o(r){return r.map(function(r,n){var t=parseFloat(r,10);return v({},"scale"+m[n],t||0)}).reduce(a)}function i(r){return r.map(function(r,n){var t=parseFloat(r.slice(0,-2),10);return v({},"translate"+m[n],t||0)}).reduce(a)}function u(r){var n=r[r.length-1].slice(0,-3),t=r.slice(0,-1).map(function(r,n){return parseInt(r,10)?"rotate"+m[n]:r}).filter(f);return v({},t[0],parseFloat(n))}function a(r,n){return p({},r,n)}function c(r,n){return Array.isArray(r)?r.concat(n):[r,n]}function f(r){return!!r}function l(r){n(r).trigger(s())}n=n&&n.hasOwnProperty("default")?n.default:n;!function(){var r=["Webkit","Moz","O","ms"],n={},t=document.createElement("dummy").style}();var s=function(){var r={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},n=document.createElement("dummy").style;for(var t in r)if(r.hasOwnProperty(t)&&void 0!==n[t])return r[t];return!1},y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},v=(function(){function r(r){this.value=r}function n(n){function t(o,i){try{var u=n[o](i),a=u.value;a instanceof r?Promise.resolve(a.value).then(function(r){t("next",r)},function(r){t("throw",r)}):e(u.done?"return":"normal",u.value)}catch(r){e("throw",r)}}function e(r,n){switch(r){case"return":o.resolve({value:n,done:!0});break;case"throw":o.reject(n);break;default:o.resolve({value:n,done:!1})}(o=o.next)?t(o.key,o.arg):i=null}var o,i;this._invoke=function(r,n){return new Promise(function(e,u){var a={key:r,arg:n,resolve:e,reject:u,next:null};i?i=i.next=a:(o=i=a,t(r,n))})},"function"!=typeof n.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(r){return this._invoke("next",r)},n.prototype.throw=function(r){return this._invoke("throw",r)},n.prototype.return=function(r){return this._invoke("return",r)}}(),function(r,n,t){return n in r?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,r}),p=Object.assign||function(r){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},d=function(r,n){var t={};for(var e in r)n.indexOf(e)>=0||Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t},h=function(){return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,n){var t=[],e=!0,o=!1,i=void 0;try{for(var u,a=r[Symbol.iterator]();!(e=(u=a.next()).done)&&(t.push(u.value),!n||t.length!==n);e=!0);}catch(r){o=!0,i=r}finally{try{!e&&a.return&&a.return()}finally{if(o)throw i}}return t}(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),g=function(r){if(Array.isArray(r)){for(var n=0,t=Array(r.length);n<r.length;n++)t[n]=r[n];return t}return Array.from(r)},m={0:"X",1:"Y",2:"Z"},b=function(r){return"function"==typeof r?r:JSON.parse(JSON.stringify(r))},w=1e6,O="asTransitionEnd";!function(){n.fn.asTransitionEnd=function(r){var t=this,e=!1;return n(this).one(O,function(){e=!0}),setTimeout(function(){e||l(t)},r),this};var r=s();r&&(n.event.special[O]={bindType:r,delegateType:r,handle:function(r){if(n(r.target).is(this))return r.handleObj.handler.apply(this,arguments)}})}(),r.deepClone=b,r.deepMerge=function r(){for(var n=arguments.length,t=Array(n),e=0;e<n;e++)t[e]=arguments[e];var o=t.filter(function(r){return Object(r)===r}),i=o[0],u=Array.isArray(i)?[]:{};return o.length?1===o.length?"function"!=typeof o[0]?JSON.parse(JSON.stringify(o[0])):o[0]:o.reduce(function(n,t){return Array.isArray(n)&&Array.isArray(t)?t.reduce(function(n,t,e){var o=b(n);return"object"===(void 0===t?"undefined":y(t))&&n[e]?(o[e]=r(n[e],t),o):(o[e]=t,o)},n):Object.keys(t).reduce(function(n,e){return"object"===y(t[e])&&n[e]?p({},n,v({},e,r(n[e],t[e]))):p({},n,v({},e,t[e]))},n)},u):{}},r.curry=function r(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return function(){for(var e=arguments.length,o=Array(e),i=0;i<e;i++)o[i]=arguments[i];var u=t.concat(o);return u.length>=n.length?n.apply(void 0,g(u)):r(n,u)}},r.compose=function(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];return function(){for(var r=arguments.length,t=Array(r),e=0;e<r;e++)t[e]=arguments[e];return n.reduceRight(function(r,n){return Array.isArray(r)?n.apply(void 0,g(r)):n(r)},t)}},r.getUID=function(r){do{r+=~~(Math.random()*w)}while(document.getElementById(r));return r},r.range=function(r){return Array.from({length:r},function(r,n){return n})},r.reflow=function(r){return r.offsetHeight},r.arraysEqual=function(r,n){if(r===n)return!0;if(void 0===r||void 0===n)return!1;if(r.length!==n.length)return!1;for(var t=0;t<r.length;++t)if(r[t]!==n[t])return!1;return!0},r.arrayDiff=function(r,n){return r.filter(function(r){return n.indexOf(r)<0})},r.arrayIntersect=function(r,n){var t=void 0;return n.length>r.length&&(t=n,n=r,r=t),r.filter(function(r){return-1!==n.indexOf(r)})},r.convertPercentageToFloat=function(r){return parseFloat(r.slice(0,-1)/100,10)},r.convertFloatToPercentage=function(r){return r<0?r=0:r>1&&(r=1),100*parseFloat(r).toFixed(4)+"%"},r.convertMatrixToArray=function(r){return!(!r||"matrix"!==r.substr(0,6))&&r.replace(/^.*\((.*)\)$/g,"$1").replace(/px/g,"").split(/, +/)},r.getTime=function(){return void 0!==window.performance&&window.performance.now?window.performance.now():Date.now()},r.camelize=function(r){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r=r.replace(/[_.-\s](\w|$)/g,function(r,n){return n.toUpperCase()}),n&&(r=r.substring(0,1).toUpperCase()+r.substring(1)),r},r.getValueByPath=function(r,n){if(Object(r)!==r||void 0===n)return r;if(n in r)return r[n];var t=n.split("."),e=t.length;if(e){for(var o=-1;r&&++o<e;){for(var i=t[o];"\\"===i[i.length-1];)i=i.slice(0,-1)+"."+t[++o];r=r[i]}return r}},r.throttle=function(r,n){function t(){o=!1}var e=this,o=!1;return void 0!==n||null!==n?function(){for(var i=arguments.length,u=Array(i),a=0;a<i;a++)u[a]=arguments[a];var c=e;o||(o=!0,r.apply(c,u),window.setTimeout(t,n))}:function(){for(var n=arguments.length,i=Array(n),u=0;u<n;u++)i[u]=arguments[u];var a=e;o||(o=!0,window.requestAnimationFrame(function(){r.apply(a,i),t()}))}},r.debounce=function(r){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,e=void 0;return function(){for(var o=arguments.length,i=Array(o),u=0;u<o;u++)i[u]=arguments[u];var a=n;e&&(clearTimeout(e),e=null),e=setTimeout(function(){r.apply(a,i)},t)}},r.asTransitionEnd=O,r.triggerTransitionEnd=l,r.fromPairs=function(r){return r.reduce(function(r,n){var t=h(n,2),e=t[0],o=t[1];return p({},r,v({},e,o))},{})},r.mergeWith=function(r,n,t){return Object.entries(r).reduce(function(r,e){var o=h(e,2),i=o[0],u=o[1];return p({},r,v({},i,t(u,n[i])))},{})},r.keyframes2Anime=function(r){var n=[],o=new Set,i=r.map(function(r,t){var i=r.transform,u=d(r,["transform"]);if(i){var a=i.split(") ").map(function(r,n,t){return n!==t.length-1?r+")":r}).map(function(r){if(/3d/g.test(r)){var n=e(r);return Object.keys(n).map(function(r){return o.add(r)}),n}return r}).filter(function(r){return"string"!=typeof r});return a.length?Object.assign.apply(Object,[{},u].concat(g(a))):(n.push(t),u)}return u}),u=t(Array.from(o).map(function(r){return/scale/g.test(r)?[r,1]:[r,0]}));if(n.length){var a=!0,f=!1,l=void 0;try{for(var s,y=n[Symbol.iterator]();!(a=(s=y.next()).done);a=!0){var m=s.value;Object.assign(i[m],u)}}catch(r){f=!0,l=r}finally{try{!a&&y.return&&y.return()}finally{if(f)throw l}}}return function(r){return r.offset,d(r,["offset"])}(function(r){return t(Object.entries(r).filter(function(r){return!!h(r,2)[1].filter(function(r){return Boolean(r)}).length}).map(function(r){var n=h(r,2),t=n[0],e=n[1].map(function(r){return void 0===r?/scale/g.test(t)?1:0:r});return[t,e]}))}(function(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];var e=n.slice(0,-1),o=n[n.length-1];return Object.entries(n[0]).reduce(function(r,n){var t=h(n,1)[0];return p({},r,v({},t,e.map(function(r){return r[t]}).filter(function(r){return Boolean(r)||0===r}).reduce(function(r,n){return o(r,n)})))},{})}.apply(void 0,g(i).concat([c]))))},Object.defineProperty(r,"__esModule",{value:!0})});
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(r["@pluginjs/utils"]={})}(this,function(r){"use strict";function n(r){return r.reduce(function(r,n){var t=m(n,2),e=t[0],o=t[1];return d({},r,h({},e,o))},{})}function t(r){return["translate","rotate","scale"].filter(function(n){var t=new RegExp(n,"g");return!!r.match(t)}).reduce(function(n,t){var i=r.match(/\(([^()]+)\)/)[1].split(",");return function(r){switch(r){case"translate":return o;case"rotate":return u;case"scale":return e;default:return function(){return"no match!"}}}(t)(i)},{})}function e(r){return r.map(function(r,n){var t=parseFloat(r,10);return h({},"scale"+A[n],t||0)}).reduce(i)}function o(r){return r.map(function(r,n){var t=parseFloat(r.slice(0,-2),10);return h({},"translate"+A[n],t||0)}).reduce(i)}function u(r){var n=r[r.length-1].slice(0,-3),t=r.slice(0,-1).map(function(r,n){return parseInt(r,10)?"rotate"+A[n]:r}).filter(c);return h({},t[0],parseFloat(n))}function i(r,n){return d({},r,n)}function a(r,n){return Array.isArray(r)?r.concat(n):[r,n]}function c(r){return!!r}function f(r){return Array.from(new Set(r))}function l(r){return"object"===(void 0===r?"undefined":v(r))&&(null!==r&&(!(r instanceof Set||r instanceof Map)&&!Array.isArray(r)))}function s(r,n){return l(n)&&l(r)||l(r)&&Array.isArray(n)?p(f(Object.keys(r).concat(Object.keys(n))).map(function(t){return[t,s(r[t],n[t])]})):l(n)&&"function"==typeof r?Object.assign(function(){for(var n=arguments.length,t=Array(n),e=0;e<n;e++)t[e]=arguments[e];return r.apply(this,t)},n):l(n)&&Array.isArray(r)?Object.assign([],r,n):l(r)&&"function"==typeof n?Object.assign(function(){for(var r=arguments.length,t=Array(r),e=0;e<r;e++)t[e]=arguments[e];return n.apply(this,t)},r):Array.isArray(n)&&Array.isArray(r)?f(Object.keys(n).concat(Object.keys(r))).map(function(t){return s(r[t],n[t])}):void 0===n?r:n}function y(r){return Object(r)===r}function p(r){return r.reduce(function(r,n){var t=m(n,2),e=t[0],o=t[1];return d({},r,h({},e,o))},{})}var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},h=(function(){function r(r){this.value=r}function n(n){function t(o,u){try{var i=n[o](u),a=i.value;a instanceof r?Promise.resolve(a.value).then(function(r){t("next",r)},function(r){t("throw",r)}):e(i.done?"return":"normal",i.value)}catch(r){e("throw",r)}}function e(r,n){switch(r){case"return":o.resolve({value:n,done:!0});break;case"throw":o.reject(n);break;default:o.resolve({value:n,done:!1})}(o=o.next)?t(o.key,o.arg):u=null}var o,u;this._invoke=function(r,n){return new Promise(function(e,i){var a={key:r,arg:n,resolve:e,reject:i,next:null};u?u=u.next=a:(o=u=a,t(r,n))})},"function"!=typeof n.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(r){return this._invoke("next",r)},n.prototype.throw=function(r){return this._invoke("throw",r)},n.prototype.return=function(r){return this._invoke("return",r)}}(),function(r,n,t){return n in r?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,r}),d=Object.assign||function(r){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},g=function(r,n){var t={};for(var e in r)n.indexOf(e)>=0||Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t},m=function(){return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,n){var t=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(t.push(i.value),!n||t.length!==n);e=!0);}catch(r){o=!0,u=r}finally{try{!e&&a.return&&a.return()}finally{if(o)throw u}}return t}(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=function(r){if(Array.isArray(r)){for(var n=0,t=Array(r.length);n<r.length;n++)t[n]=r[n];return t}return Array.from(r)},A={0:"X",1:"Y",2:"Z"},w=1e6;r.deepClone=function(r){return"function"==typeof r?r:JSON.parse(JSON.stringify(r))},r.nub=f,r.deepMerge=function(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.filter(y).reduce(s)},r.curry=function r(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return function(){for(var e=arguments.length,o=Array(e),u=0;u<e;u++)o[u]=arguments[u];var i=n.currylen||n.length,a=t.concat(o);return a.length>=i?n.apply(void 0,b(a)):r(n,a)}},r.compose=function(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];var e=function(){for(var r=arguments.length,t=Array(r),e=0;e<r;e++)t[e]=arguments[e];return n.reduceRight(function(r,t,e){return Array.isArray(r)&&e===n.length-1?t.apply(void 0,b(r)):t(r)},t)};return e.currylen=n[n.curylen||n.length-1].length,e},r.getUID=function(r){do{r+=~~(Math.random()*w)}while(document.getElementById(r));return r},r.range=function(r){return Array.from({length:r},function(r,n){return n})},r.reflow=function(r){return r.offsetHeight},r.arraysEqual=function(r,n){if(r===n)return!0;if(void 0===r||void 0===n)return!1;if(r.length!==n.length)return!1;for(var t=0;t<r.length;++t)if(r[t]!==n[t])return!1;return!0},r.arrayDiff=function(r,n){return r.filter(function(r){return n.indexOf(r)<0})},r.arrayIntersect=function(r,n){var t=void 0;return n.length>r.length&&(t=n,n=r,r=t),r.filter(function(r){return-1!==n.indexOf(r)})},r.convertPercentageToFloat=function(r){return parseFloat(r.slice(0,-1)/100,10)},r.convertFloatToPercentage=function(r){return r<0?r=0:r>1&&(r=1),100*parseFloat(r).toFixed(4)+"%"},r.convertMatrixToArray=function(r){return!(!r||"matrix"!==r.substr(0,6))&&r.replace(/^.*\((.*)\)$/g,"$1").replace(/px/g,"").split(/, +/)},r.getTime=function(){return void 0!==window.performance&&window.performance.now?window.performance.now():Date.now()},r.camelize=function(r){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r=r.replace(/[_.-\s](\w|$)/g,function(r,n){return n.toUpperCase()}),n&&(r=r.substring(0,1).toUpperCase()+r.substring(1)),r},r.getValueByPath=function(r,n){if(Object(r)!==r||void 0===n)return r;if(n in r)return r[n];var t=n.split("."),e=t.length;if(e){for(var o=-1;r&&++o<e;){for(var u=t[o];"\\"===u[u.length-1];)u=u.slice(0,-1)+"."+t[++o];r=r[u]}return r}},r.throttle=function(r,n){function t(){o=!1}var e=this,o=!1;return void 0!==n||null!==n?function(){for(var u=arguments.length,i=Array(u),a=0;a<u;a++)i[a]=arguments[a];var c=e;o||(o=!0,r.apply(c,i),window.setTimeout(t,n))}:function(){for(var n=arguments.length,u=Array(n),i=0;i<n;i++)u[i]=arguments[i];var a=e;o||(o=!0,window.requestAnimationFrame(function(){r.apply(a,u),t()}))}},r.debounce=function(r){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,e=void 0;return function(){for(var o=arguments.length,u=Array(o),i=0;i<o;i++)u[i]=arguments[i];var a=n;e&&(clearTimeout(e),e=null),e=setTimeout(function(){r.apply(a,u)},t)}},r.fromPairs=p,r.mergeWith=function(r,n,t){return Object.entries(r).reduce(function(r,e){var o=m(e,2),u=o[0],i=o[1];return d({},r,h({},u,t(i,n[u])))},{})},r.keyframes2Anime=function(r){var e=[],o=new Set,u=r.map(function(r,n){var u=r.transform,i=g(r,["transform"]);if(u){var a=u.split(") ").map(function(r,n,t){return n!==t.length-1?r+")":r}).map(function(r){if(/3d/g.test(r)){var n=t(r);return Object.keys(n).map(function(r){return o.add(r)}),n}return r}).filter(function(r){return"string"!=typeof r});return a.length?Object.assign.apply(Object,[{},i].concat(b(a))):(e.push(n),i)}return i}),i=n(Array.from(o).map(function(r){return/scale/g.test(r)?[r,1]:[r,0]}));if(e.length){var c=!0,f=!1,l=void 0;try{for(var s,y=e[Symbol.iterator]();!(c=(s=y.next()).done);c=!0){var p=s.value;Object.assign(u[p],i)}}catch(r){f=!0,l=r}finally{try{!c&&y.return&&y.return()}finally{if(f)throw l}}}return function(r){return r.offset,g(r,["offset"])}(function(r){return n(Object.entries(r).filter(function(r){return!!m(r,2)[1].filter(function(r){return Boolean(r)}).length}).map(function(r){var n=m(r,2),t=n[0],e=n[1].map(function(r){return void 0===r?/scale/g.test(t)?1:0:r});return[t,e]}))}(function(){for(var r=arguments.length,n=Array(r),t=0;t<r;t++)n[t]=arguments[t];var e=n.slice(0,-1),o=n[n.length-1];return Object.entries(n[0]).reduce(function(r,n){var t=m(n,1)[0];return d({},r,h({},t,e.map(function(r){return r[t]}).filter(function(r){return Boolean(r)||0===r}).reduce(function(r,n){return o(r,n)})))},{})}.apply(void 0,b(u).concat([a]))))},Object.defineProperty(r,"__esModule",{value:!0})});
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) :
(factory((global['@pluginjs/utils'] = {}),global.jQuery));
}(this, (function (exports,$) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global['@pluginjs/utils'] = {})));
}(this, (function (exports) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
/* eslint no-undef: "off" */
/* Credit to http://featurejs.com MIT */
/**
* Test if it's an old device that we want to filter out
*/
/**
* Function that takes a standard CSS property name as a parameter and
* returns it's prefixed version valid for current browser it runs in
*/
var pfx = function () {
var prefixes = ['Webkit', 'Moz', 'O', 'ms'];
var memory = {};
var style = document.createElement('dummy').style;
return function (prop) {
if (typeof memory[prop] === 'undefined') {
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1);
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' ');
memory[prop] = null;
for (var i in props) {
if (style[props[i]] !== undefined) {
memory[prop] = props[i];
break;
}
}
}
return memory[prop];
};
}();
var transitionEndEvent = function transitionEndEvent() {
var eventNames = {
transition: 'transitionend',
OTransition: 'oTransitionEnd',
MozTransition: 'transitionend',
WebkitTransition: 'webkitTransitionEnd'
};
var style = document.createElement('dummy').style;
for (var i in eventNames) {
if (eventNames.hasOwnProperty(i)) {
if (style[i] !== undefined) {
return eventNames[i];
}
}
}
return false;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -542,55 +491,88 @@ return typeof obj;

};
function nub(arr) {
return Array.from(new Set(arr));
}
function isPaintObject(data) {
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
return false;
}
var deepMerge = function deepMerge() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
if (data === null) {
return false;
}
var input = args.filter(function (obj) {
return Object(obj) === obj;
});
var firstChild = input[0];
var newDataFromType = Array.isArray(firstChild) ? [] : {};
if (!input.length) {
return {};
if (data instanceof Set || data instanceof Map) {
return false;
}
if (input.length === 1) {
if (typeof input[0] !== 'function') {
return JSON.parse(JSON.stringify(input[0]));
}
return input[0];
if (Array.isArray(data)) {
return false;
}
return input.reduce(function (result, item) {
if (Array.isArray(result) && Array.isArray(item)) {
return item.reduce(function (resu, el, index) {
var newData = deepClone(resu);
if ((typeof el === 'undefined' ? 'undefined' : _typeof(el)) !== 'object' || !resu[index]) {
newData[index] = el;
return newData;
}
newData[index] = deepMerge(resu[index], el);
return newData;
}, result);
}
return true;
}
function deepMergeTwo(x, y) {
if (isPaintObject(y) && isPaintObject(x) || isPaintObject(x) && Array.isArray(y)) {
return fromPairs(nub(Object.keys(x).concat(Object.keys(y))).map(function (key) {
return [key, deepMergeTwo(x[key], y[key])];
}));
}
return Object.keys(item).reduce(function (resu, key) {
if (_typeof(item[key]) !== 'object' || !resu[key]) {
return _extends({}, resu, defineProperty({}, key, item[key]));
if (isPaintObject(y) && typeof x === 'function') {
return Object.assign(function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _extends({}, resu, defineProperty({}, key, deepMerge(resu[key], item[key])));
}, result);
}, newDataFromType);
};
return x.apply(this, args);
}, y);
}
if (isPaintObject(y) && Array.isArray(x)) {
return Object.assign([], x, y);
}
if (isPaintObject(x) && typeof y === 'function') {
return Object.assign(function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return y.apply(this, args);
}, x);
}
if (Array.isArray(y) && Array.isArray(x)) {
// return x.concat(y)
return nub(Object.keys(y).concat(Object.keys(x))).map(function (index) {
return deepMergeTwo(x[index], y[index]);
});
}
if (typeof y === 'undefined') {
return x;
}
return y;
}
function isObject(obj) {
return Object(obj) === obj;
}
function deepMerge() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return args.filter(isObject).reduce(deepMergeTwo);
}
var curry = function curry(fn) {
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return function () {
for (var _len2 = arguments.length, subArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
subArgs[_key2] = arguments[_key2];
for (var _len4 = arguments.length, subArgs = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
subArgs[_key4] = arguments[_key4];
}
var currylen = fn.currylen || fn.length;
var collect = args.concat(subArgs);
if (collect.length >= fn.length) {
if (collect.length >= currylen) {
return fn.apply(undefined, toConsumableArray(collect));

@@ -603,13 +585,13 @@ }

var compose = function compose() {
for (var _len3 = arguments.length, fn = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
fn[_key3] = arguments[_key3];
for (var _len5 = arguments.length, fn = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
fn[_key5] = arguments[_key5];
}
return function () {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
var callback = function callback() {
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
return fn.reduceRight(function (r, i) {
if (Array.isArray(r)) {
return fn.reduceRight(function (r, i, index) {
if (Array.isArray(r) && index === fn.length - 1) {
return i.apply(undefined, toConsumableArray(r));

@@ -620,2 +602,4 @@ }

};
callback.currylen = fn[fn.curylen || fn.length - 1].length;
return callback;
};

@@ -766,4 +750,4 @@

return function () {
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}

@@ -783,4 +767,4 @@

return function () {
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
for (var _len8 = arguments.length, args = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
args[_key8] = arguments[_key8];
}

@@ -812,4 +796,4 @@

return function () {
for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
for (var _len9 = arguments.length, args = Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}

@@ -828,7 +812,2 @@

var asTransitionEnd = 'asTransitionEnd';
function triggerTransitionEnd(element) {
$(element).trigger(transitionEndEvent());
}
function fromPairs(arr) {

@@ -853,41 +832,4 @@ return arr.reduce(function (r, _ref) {

function setTransitionEndSupport() {
$.fn.asTransitionEnd = function (duration) {
var _this3 = this;
var called = false;
$(this).one(asTransitionEnd, function () {
called = true;
});
setTimeout(function () {
if (!called) {
triggerTransitionEnd(_this3);
}
}, duration);
return this;
};
var isTransitionEndEvent = transitionEndEvent();
if (isTransitionEndEvent) {
// suport transition end
$.event.special[asTransitionEnd] = {
bindType: isTransitionEndEvent,
delegateType: isTransitionEndEvent,
handle: function handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
}
return undefined;
}
};
}
}
setTransitionEndSupport();
exports.deepClone = deepClone;
exports.nub = nub;
exports.deepMerge = deepMerge;

@@ -910,4 +852,2 @@ exports.curry = curry;

exports.debounce = debounce;
exports.asTransitionEnd = asTransitionEnd;
exports.triggerTransitionEnd = triggerTransitionEnd;
exports.fromPairs = fromPairs;

@@ -914,0 +854,0 @@ exports.mergeWith = mergeWith;

{
"name": "@pluginjs/utils",
"title": "Plugin",
"version": "0.2.6",
"version": "0.2.7",
"description": "A workflow for modern frontend development.",

@@ -34,4 +34,3 @@ "author": "Creation Studio Limited",

"dependencies": {
"@pluginjs/feature": "^0.2.6",
"jquery": "*"
"@pluginjs/feature": "^0.2.6"
},

@@ -41,3 +40,4 @@ "category": "core",

"standalone": "dist/utils.standalone.js",
"module": "dist/utils.esm.js"
"module": "dist/utils.esm.js",
"dev-main": "src/main.js"
}

@@ -118,5 +118,3 @@ function fromPairs (arr) {

function filterOffset (obj) {
const {
offset, ...result
} = obj
const { offset, ...result } = obj
return result

@@ -154,5 +152,3 @@ }

const newKeyFrames = keyframes.map((keyframe, keyframeIndex) => {
const {
transform, ...newKeyFrame
} = keyframe
const { transform, ...newKeyFrame } = keyframe
if (transform) {

@@ -159,0 +155,0 @@ const arr = transform

@@ -1,3 +0,1 @@

import $ from 'jquery'
import { transitionEndEvent } from '@pluginjs/feature'
import keyframes2Anime from './anime-polyfill'

@@ -11,49 +9,76 @@

}
export function nub (arr) {
return Array.from(new Set(arr))
}
function isPaintObject (data) {
if (typeof data !== 'object') {
return false
}
export const deepMerge = (...args) => {
const input = args.filter(obj => Object(obj) === obj)
const firstChild = input[0]
const newDataFromType = Array.isArray(firstChild) ? [] : {}
if (!input.length) {
return {}
if (data === null) {
return false
}
if (input.length === 1) {
if (typeof input[0] !== 'function') {
return JSON.parse(JSON.stringify(input[0]))
}
return input[0]
if (data instanceof Set || data instanceof Map) {
return false
}
return input.reduce((result, item) => {
if (Array.isArray(result) && Array.isArray(item)) {
return item.reduce((resu, el, index) => {
const newData = deepClone(resu)
if (typeof el !== 'object' || !resu[index]) {
newData[index] = el
return newData
}
newData[index] = deepMerge(resu[index], el)
return newData
}, result)
}
if (Array.isArray(data)) {
return false
}
return Object.keys(item).reduce((resu, key) => {
if (typeof item[key] !== 'object' || !resu[key]) {
return {
...resu,
[key]: item[key]
}
}
return {
...resu,
[key]: deepMerge(resu[key], item[key])
}
}, result)
}, newDataFromType)
return true
}
function deepMergeTwo (x, y) {
if (
isPaintObject(y) && isPaintObject(x) ||
isPaintObject(x) && Array.isArray(y)
) {
return fromPairs(
nub(Object.keys(x).concat(Object.keys(y))).map(key => [
key,
deepMergeTwo(x[key], y[key])
])
)
}
if (isPaintObject(y) && typeof x === 'function') {
return Object.assign(function (...args) {
return x.apply(this, args)
}, y)
}
if (isPaintObject(y) && Array.isArray(x)) {
return Object.assign([], x, y)
}
if (isPaintObject(x) && typeof y === 'function') {
return Object.assign(function (...args) {
return y.apply(this, args)
}, x)
}
if (Array.isArray(y) && Array.isArray(x)) {
// return x.concat(y)
return nub(Object.keys(y).concat(Object.keys(x))).map(index =>
deepMergeTwo(x[index], y[index])
)
}
if (typeof y === 'undefined') {
return x
}
return y
}
function isObject (obj) {
return Object(obj) === obj
}
export function deepMerge (...args) {
return args.filter(isObject).reduce(deepMergeTwo)
}
export const curry = (fn, args = []) => (...subArgs) => {
const currylen = fn.currylen || fn.length
const collect = args.concat(subArgs)
if (collect.length >= fn.length) {
if (collect.length >= currylen) {
return fn(...collect)

@@ -64,9 +89,13 @@ }

export const compose = (...fn) => (...args) =>
fn.reduceRight((r, i) => {
if (Array.isArray(r)) {
return i(...r)
}
return i(r)
}, args)
export const compose = (...fn) => {
const callback = (...args) =>
fn.reduceRight((r, i, index) => {
if (Array.isArray(r) && index === fn.length - 1) {
return i(...r)
}
return i(r)
}, args)
callback.currylen = fn[fn.curylen || fn.length - 1].length
return callback
}

@@ -250,7 +279,2 @@ const MAX_UID = 1000000

export const asTransitionEnd = 'asTransitionEnd'
export function triggerTransitionEnd (element) {
$(element).trigger(transitionEndEvent())
}
export function fromPairs (arr) {

@@ -275,38 +299,2 @@ return arr.reduce(

function setTransitionEndSupport () {
$.fn.asTransitionEnd = function (duration) {
let called = false
$(this).one(asTransitionEnd, () => {
called = true
})
setTimeout(() => {
if (!called) {
triggerTransitionEnd(this)
}
}, duration)
return this
}
const isTransitionEndEvent = transitionEndEvent()
if (isTransitionEndEvent) {
// suport transition end
$.event.special[asTransitionEnd] = {
bindType: isTransitionEndEvent,
delegateType: isTransitionEndEvent,
handle (event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
}
return undefined
}
}
}
}
setTransitionEndSupport()
export { keyframes2Anime }
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