@pluginjs/utils
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -52,4 +52,169 @@ import $ from 'jquery'; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
} | ||
return target; | ||
}; | ||
function fromPairs$1(arr) { | ||
return arr.reduce((r, [k, v]) => babelHelpers.extends({}, r, { | ||
return arr.reduce((r, [k, v]) => _extends({}, r, { | ||
[k]: v | ||
@@ -62,3 +227,3 @@ }), {}); | ||
const customizer = args[args.length - 1]; | ||
return Object.entries(args[0]).reduce((r, [k]) => babelHelpers.extends({}, r, { | ||
return Object.entries(args[0]).reduce((r, [k]) => _extends({}, r, { | ||
[k]: objs.map(obj => obj[k]).filter(v => Boolean(v) || v === 0).reduce((r, i) => customizer(r, i)) | ||
@@ -134,3 +299,3 @@ }), {}); | ||
function mergeObject(r, i) { | ||
return babelHelpers.extends({}, r, i); | ||
return _extends({}, r, i); | ||
} | ||
@@ -155,3 +320,3 @@ | ||
offset } = obj, | ||
result = babelHelpers.objectWithoutProperties(obj, ['offset']); | ||
result = objectWithoutProperties(obj, ['offset']); | ||
return result; | ||
@@ -187,3 +352,3 @@ } | ||
transform } = keyframe, | ||
newKeyFrame = babelHelpers.objectWithoutProperties(keyframe, ['transform']); | ||
newKeyFrame = objectWithoutProperties(keyframe, ['transform']); | ||
if (transform) { | ||
@@ -265,7 +430,7 @@ const arr = transform.split(') ').map((item, index, arr) => { | ||
if (typeof item[key] !== 'object' || !resu[key]) { | ||
return babelHelpers.extends({}, resu, { | ||
return _extends({}, resu, { | ||
[key]: item[key] | ||
}); | ||
} | ||
return babelHelpers.extends({}, resu, { | ||
return _extends({}, resu, { | ||
[key]: deepMerge(resu[key], item[key]) | ||
@@ -472,3 +637,3 @@ }); | ||
function fromPairs(arr) { | ||
return arr.reduce((r, [k, v]) => babelHelpers.extends({}, r, { | ||
return arr.reduce((r, [k, v]) => _extends({}, r, { | ||
[k]: v | ||
@@ -478,3 +643,3 @@ }), {}); | ||
function mergeWith(obj1, obj2, customizer) { | ||
return Object.entries(obj1).reduce((r, [k, v]) => babelHelpers.extends({}, r, { | ||
return Object.entries(obj1).reduce((r, [k, v]) => _extends({}, r, { | ||
[k]: customizer(v, obj2[k]) | ||
@@ -481,0 +646,0 @@ }), {}); |
{ | ||
"name": "@pluginjs/utils", | ||
"title": "Plugin", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A workflow for modern frontend development.", | ||
"author": "Creation Studio Limited", | ||
"homepage": "https://github.com/amazingSurge/plugins", | ||
"homepage": "https://github.com/amazingSurge/plugin.js", | ||
"license": "GPL-v3", | ||
"main": "src/index.js", | ||
"main": "dist/utils.js", | ||
"files": [ | ||
@@ -23,7 +23,7 @@ "dist", | ||
"repository": { | ||
"url": "git@github.com:amazingSurge/plugins.git", | ||
"url": "git@github.com:amazingSurge/plugin.js.git", | ||
"type": "git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/amazingSurge/plugins/issues" | ||
"url": "https://github.com/amazingSurge/plugin.js/issues" | ||
}, | ||
@@ -40,6 +40,6 @@ "engines": { | ||
}, | ||
"category": "Unkown", | ||
"category": "core", | ||
"min": "dist/utils.min.js", | ||
"standalone": "dist/utils.js", | ||
"standalone": "dist/utils.standalone.js", | ||
"module": "dist/utils.esm.js" | ||
} |
@@ -18,4 +18,4 @@ function fromPairs (arr) { | ||
[k]: objs | ||
.map((obj) => obj[k]) | ||
.filter((v) => Boolean(v) || v === 0) | ||
.map(obj => obj[k]) | ||
.filter(v => Boolean(v) || v === 0) | ||
.reduce((r, i) => customizer(r, i)) | ||
@@ -36,3 +36,3 @@ }), | ||
return css3dList | ||
.filter((key) => { | ||
.filter(key => { | ||
const regx = new RegExp(key, 'g') | ||
@@ -130,3 +130,3 @@ if (str.match(regx)) { | ||
.filter(([, v]) => { | ||
const arr = v.filter((i) => Boolean(i)) | ||
const arr = v.filter(i => Boolean(i)) | ||
if (arr.length) { | ||
@@ -138,3 +138,3 @@ return true | ||
.map(([k, v]) => { | ||
const value = v.map((i) => { | ||
const value = v.map(i => { | ||
if (i === undefined) { | ||
@@ -169,6 +169,6 @@ if (/scale/g.test(k)) { | ||
}) | ||
.map((value) => { | ||
.map(value => { | ||
if (/3d/g.test(value)) { | ||
const transformObject = mapTransformToAnime(value) | ||
Object.keys(transformObject).map((key) => transformKeys.add(key)) | ||
Object.keys(transformObject).map(key => transformKeys.add(key)) | ||
return transformObject | ||
@@ -178,3 +178,3 @@ } | ||
}) | ||
.filter((value) => typeof value !== 'string') | ||
.filter(value => typeof value !== 'string') | ||
// console.log(arr) | ||
@@ -190,3 +190,3 @@ if (!arr.length) { | ||
const emptyTransform = fromPairs( | ||
Array.from(transformKeys).map((key) => { | ||
Array.from(transformKeys).map(key => { | ||
if (/scale/g.test(key)) { | ||
@@ -193,0 +193,0 @@ return [key, 1] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
78166
2543