@pixi/utils
Advanced tools
Comparing version 5.0.0-rc.2 to 5.0.0-rc.3
/*! | ||
* @pixi/utils - v5.0.0-rc.2 | ||
* Compiled Mon, 18 Feb 2019 23:45:28 UTC | ||
* @pixi/utils - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* | ||
@@ -8,75 +8,11 @@ * @pixi/utils is licensed under the MIT License. | ||
*/ | ||
export { default as isMobile } from 'ismobilejs'; | ||
export { default as removeItems } from 'remove-array-items'; | ||
import { settings } from '@pixi/settings'; | ||
export { isMobile } from '@pixi/settings'; | ||
export { default as EventEmitter } from 'eventemitter3'; | ||
export { default as earcut } from 'earcut'; | ||
import { settings } from '@pixi/settings'; | ||
import _url from 'url'; | ||
export { default as url } from 'url'; | ||
import { BLEND_MODES } from '@pixi/constants'; | ||
import _url from 'url'; | ||
/** | ||
* Mixes all enumerable properties and methods from a source object to a target object. | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function mixin | ||
* @param {object} target The prototype or instance that properties and methods should be added to. | ||
* @param {object} source The source of properties and methods to mix in. | ||
*/ | ||
function mixin(target, source) | ||
{ | ||
if (!target || !source) { return; } | ||
// in ES8/ES2017, this would be really easy: | ||
// Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
// get all the enumerable property keys | ||
var keys = Object.keys(source); | ||
// loop through properties | ||
for (var i = 0; i < keys.length; ++i) | ||
{ | ||
var propertyName = keys[i]; | ||
// Set the property using the property descriptor - this works for accessors and normal value properties | ||
Object.defineProperty(target, propertyName, Object.getOwnPropertyDescriptor(source, propertyName)); | ||
} | ||
} | ||
var mixins = []; | ||
/** | ||
* Queues a mixin to be handled towards the end of the initialization of PIXI, so that deprecation | ||
* can take effect. | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function delayMixin | ||
* @param {object} target The prototype or instance that properties and methods should be added to. | ||
* @param {object} source The source of properties and methods to mix in. | ||
*/ | ||
function delayMixin(target, source) | ||
{ | ||
mixins.push(target, source); | ||
} | ||
/** | ||
* Handles all mixins queued via delayMixin(). | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function performMixins | ||
*/ | ||
function performMixins() | ||
{ | ||
for (var i = 0; i < mixins.length; i += 2) | ||
{ | ||
mixin(mixins[i], mixins[i + 1]); | ||
} | ||
mixins.length = 0; | ||
} | ||
var mixins$1 = ({ | ||
mixin: mixin, | ||
delayMixin: delayMixin, | ||
performMixins: performMixins | ||
}); | ||
/** | ||
* The prefix that denotes a URL is for a retina asset. | ||
@@ -94,3 +30,3 @@ * | ||
var saidHello = false; | ||
var VERSION = '5.0.0-rc.2'; | ||
var VERSION = '5.0.0-rc.3'; | ||
@@ -193,9 +129,11 @@ /** | ||
/** | ||
* Converts a hex color number to an [R, G, B] array | ||
* Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0). | ||
* | ||
* @example | ||
* PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1] | ||
* @memberof PIXI.utils | ||
* @function hex2rgb | ||
* @param {number} hex - The number to convert | ||
* @param {number} hex - The hexadecimal number to convert | ||
* @param {number[]} [out=[]] If supplied, this array will be used rather than returning a new one | ||
* @return {number[]} An array representing the [R, G, B] of the color. | ||
* @return {number[]} An array representing the [R, G, B] of the color where all values are floats. | ||
*/ | ||
@@ -214,8 +152,10 @@ function hex2rgb(hex, out) | ||
/** | ||
* Converts a hex color number to a string. | ||
* Converts a hexadecimal color number to a string. | ||
* | ||
* @example | ||
* PIXI.utils.hex2string(0xffffff); // returns "#ffffff" | ||
* @memberof PIXI.utils | ||
* @function hex2string | ||
* @param {number} hex - Number in hex | ||
* @return {string} The string color. | ||
* @param {number} hex - Number in hex (e.g., `0xffffff`) | ||
* @return {string} The string color (e.g., `"#ffffff"`). | ||
*/ | ||
@@ -231,8 +171,10 @@ function hex2string(hex) | ||
/** | ||
* Converts a hex string to a hex color number. | ||
* Converts a hexadecimal string to a hexadecimal color number. | ||
* | ||
* @example | ||
* PIXI.utils.string2hex("#ffffff"); // returns 0xffffff | ||
* @memberof PIXI.utils | ||
* @function string2hex | ||
* @param {string} The string color that starts with # | ||
* @return {number} hex - Number in hex | ||
* @param {string} The string color (e.g., `"#ffffff"`) | ||
* @return {number} Number in hexadecimal. | ||
*/ | ||
@@ -250,8 +192,10 @@ function string2hex(string) | ||
/** | ||
* Converts a color as an [R, G, B] array to a hex number | ||
* Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number. | ||
* | ||
* @example | ||
* PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff | ||
* @memberof PIXI.utils | ||
* @function rgb2hex | ||
* @param {number[]} rgb - rgb array | ||
* @return {number} The color number | ||
* @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0. | ||
* @return {number} Number in hexadecimal. | ||
*/ | ||
@@ -325,2 +269,3 @@ function rgb2hex(rgb) | ||
* @memberof PIXI.utils | ||
* @function premultiplyRgba | ||
* @param {Float32Array|number[]} rgb input rgb | ||
@@ -356,2 +301,3 @@ * @param {number} alpha alpha param | ||
* @memberof PIXI.utils | ||
* @function premultiplyTint | ||
* @param {number} tint integer RGB | ||
@@ -386,2 +332,3 @@ * @param {number} alpha floating point alpha (0.0-1.0) | ||
* @memberof PIXI.utils | ||
* @function premultiplyTintToRgba | ||
* @param {number} tint input tint | ||
@@ -441,2 +388,33 @@ * @param {number} alpha alpha param | ||
/** | ||
* Remove items from a javascript array without generating garbage | ||
* | ||
* @function removeItems | ||
* @memberof PIXI.utils | ||
* @param {Array} arr Array to remove elements from | ||
* @param {number} startIdx starting index | ||
* @param {number} removeCount how many to remove | ||
*/ | ||
function removeItems(arr, startIdx, removeCount) | ||
{ | ||
var length = arr.length; | ||
var i; | ||
if (startIdx >= length || removeCount === 0) | ||
{ | ||
return; | ||
} | ||
removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount); | ||
var len = length - removeCount; | ||
for (i = startIdx; i < len; ++i) | ||
{ | ||
arr[i] = arr[i + removeCount]; | ||
} | ||
arr.length = len; | ||
} | ||
var nextUid = 0; | ||
@@ -980,3 +958,3 @@ | ||
export { mixins$1 as mixins, skipHello, sayHello, isWebGLSupported, hex2rgb, hex2string, string2hex, rgb2hex, premultiplyBlendMode, correctBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba, createIndicesForQuads, uid, sign, nextPow2, isPow2, log2, CanvasRenderTarget, ProgramCache, TextureCache, BaseTextureCache, destroyTextureCache, clearTextureCache, trimCanvas, decomposeDataUri, determineCrossOrigin, getResolutionOfUrl, DATA_URI, deprecation }; | ||
export { BaseTextureCache, CanvasRenderTarget, DATA_URI, ProgramCache, TextureCache, clearTextureCache, correctBlendMode, createIndicesForQuads, decomposeDataUri, deprecation, destroyTextureCache, determineCrossOrigin, getResolutionOfUrl, hex2rgb, hex2string, isPow2, isWebGLSupported, log2, nextPow2, premultiplyBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba, removeItems, rgb2hex, sayHello, sign, skipHello, string2hex, trimCanvas, uid }; | ||
//# sourceMappingURL=utils.es.js.map |
192
lib/utils.js
/*! | ||
* @pixi/utils - v5.0.0-rc.2 | ||
* Compiled Mon, 18 Feb 2019 23:45:28 UTC | ||
* @pixi/utils - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* | ||
@@ -14,75 +14,9 @@ * @pixi/utils is licensed under the MIT License. | ||
var ismobilejs = _interopDefault(require('ismobilejs')); | ||
var removeArrayItems = _interopDefault(require('remove-array-items')); | ||
var settings = require('@pixi/settings'); | ||
var eventemitter3 = _interopDefault(require('eventemitter3')); | ||
var earcut = _interopDefault(require('earcut')); | ||
var settings = require('@pixi/settings'); | ||
var _url = _interopDefault(require('url')); | ||
var constants = require('@pixi/constants'); | ||
var _url = _interopDefault(require('url')); | ||
/** | ||
* Mixes all enumerable properties and methods from a source object to a target object. | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function mixin | ||
* @param {object} target The prototype or instance that properties and methods should be added to. | ||
* @param {object} source The source of properties and methods to mix in. | ||
*/ | ||
function mixin(target, source) | ||
{ | ||
if (!target || !source) { return; } | ||
// in ES8/ES2017, this would be really easy: | ||
// Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
// get all the enumerable property keys | ||
var keys = Object.keys(source); | ||
// loop through properties | ||
for (var i = 0; i < keys.length; ++i) | ||
{ | ||
var propertyName = keys[i]; | ||
// Set the property using the property descriptor - this works for accessors and normal value properties | ||
Object.defineProperty(target, propertyName, Object.getOwnPropertyDescriptor(source, propertyName)); | ||
} | ||
} | ||
var mixins = []; | ||
/** | ||
* Queues a mixin to be handled towards the end of the initialization of PIXI, so that deprecation | ||
* can take effect. | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function delayMixin | ||
* @param {object} target The prototype or instance that properties and methods should be added to. | ||
* @param {object} source The source of properties and methods to mix in. | ||
*/ | ||
function delayMixin(target, source) | ||
{ | ||
mixins.push(target, source); | ||
} | ||
/** | ||
* Handles all mixins queued via delayMixin(). | ||
* | ||
* @memberof PIXI.utils.mixins | ||
* @function performMixins | ||
*/ | ||
function performMixins() | ||
{ | ||
for (var i = 0; i < mixins.length; i += 2) | ||
{ | ||
mixin(mixins[i], mixins[i + 1]); | ||
} | ||
mixins.length = 0; | ||
} | ||
var mixins$1 = ({ | ||
mixin: mixin, | ||
delayMixin: delayMixin, | ||
performMixins: performMixins | ||
}); | ||
/** | ||
* The prefix that denotes a URL is for a retina asset. | ||
@@ -100,3 +34,3 @@ * | ||
var saidHello = false; | ||
var VERSION = '5.0.0-rc.2'; | ||
var VERSION = '5.0.0-rc.3'; | ||
@@ -199,9 +133,11 @@ /** | ||
/** | ||
* Converts a hex color number to an [R, G, B] array | ||
* Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0). | ||
* | ||
* @example | ||
* PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1] | ||
* @memberof PIXI.utils | ||
* @function hex2rgb | ||
* @param {number} hex - The number to convert | ||
* @param {number} hex - The hexadecimal number to convert | ||
* @param {number[]} [out=[]] If supplied, this array will be used rather than returning a new one | ||
* @return {number[]} An array representing the [R, G, B] of the color. | ||
* @return {number[]} An array representing the [R, G, B] of the color where all values are floats. | ||
*/ | ||
@@ -220,8 +156,10 @@ function hex2rgb(hex, out) | ||
/** | ||
* Converts a hex color number to a string. | ||
* Converts a hexadecimal color number to a string. | ||
* | ||
* @example | ||
* PIXI.utils.hex2string(0xffffff); // returns "#ffffff" | ||
* @memberof PIXI.utils | ||
* @function hex2string | ||
* @param {number} hex - Number in hex | ||
* @return {string} The string color. | ||
* @param {number} hex - Number in hex (e.g., `0xffffff`) | ||
* @return {string} The string color (e.g., `"#ffffff"`). | ||
*/ | ||
@@ -237,8 +175,10 @@ function hex2string(hex) | ||
/** | ||
* Converts a hex string to a hex color number. | ||
* Converts a hexadecimal string to a hexadecimal color number. | ||
* | ||
* @example | ||
* PIXI.utils.string2hex("#ffffff"); // returns 0xffffff | ||
* @memberof PIXI.utils | ||
* @function string2hex | ||
* @param {string} The string color that starts with # | ||
* @return {number} hex - Number in hex | ||
* @param {string} The string color (e.g., `"#ffffff"`) | ||
* @return {number} Number in hexadecimal. | ||
*/ | ||
@@ -256,8 +196,10 @@ function string2hex(string) | ||
/** | ||
* Converts a color as an [R, G, B] array to a hex number | ||
* Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number. | ||
* | ||
* @example | ||
* PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff | ||
* @memberof PIXI.utils | ||
* @function rgb2hex | ||
* @param {number[]} rgb - rgb array | ||
* @return {number} The color number | ||
* @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0. | ||
* @return {number} Number in hexadecimal. | ||
*/ | ||
@@ -331,2 +273,3 @@ function rgb2hex(rgb) | ||
* @memberof PIXI.utils | ||
* @function premultiplyRgba | ||
* @param {Float32Array|number[]} rgb input rgb | ||
@@ -362,2 +305,3 @@ * @param {number} alpha alpha param | ||
* @memberof PIXI.utils | ||
* @function premultiplyTint | ||
* @param {number} tint integer RGB | ||
@@ -392,2 +336,3 @@ * @param {number} alpha floating point alpha (0.0-1.0) | ||
* @memberof PIXI.utils | ||
* @function premultiplyTintToRgba | ||
* @param {number} tint input tint | ||
@@ -447,2 +392,33 @@ * @param {number} alpha alpha param | ||
/** | ||
* Remove items from a javascript array without generating garbage | ||
* | ||
* @function removeItems | ||
* @memberof PIXI.utils | ||
* @param {Array} arr Array to remove elements from | ||
* @param {number} startIdx starting index | ||
* @param {number} removeCount how many to remove | ||
*/ | ||
function removeItems(arr, startIdx, removeCount) | ||
{ | ||
var length = arr.length; | ||
var i; | ||
if (startIdx >= length || removeCount === 0) | ||
{ | ||
return; | ||
} | ||
removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount); | ||
var len = length - removeCount; | ||
for (i = startIdx; i < len; ++i) | ||
{ | ||
arr[i] = arr[i + removeCount]; | ||
} | ||
arr.length = len; | ||
} | ||
var nextUid = 0; | ||
@@ -986,37 +962,37 @@ | ||
exports.isMobile = ismobilejs; | ||
exports.removeItems = removeArrayItems; | ||
exports.isMobile = settings.isMobile; | ||
exports.EventEmitter = eventemitter3; | ||
exports.earcut = earcut; | ||
exports.mixins = mixins$1; | ||
exports.skipHello = skipHello; | ||
exports.sayHello = sayHello; | ||
exports.isWebGLSupported = isWebGLSupported; | ||
exports.url = _url; | ||
exports.BaseTextureCache = BaseTextureCache; | ||
exports.CanvasRenderTarget = CanvasRenderTarget; | ||
exports.DATA_URI = DATA_URI; | ||
exports.ProgramCache = ProgramCache; | ||
exports.TextureCache = TextureCache; | ||
exports.clearTextureCache = clearTextureCache; | ||
exports.correctBlendMode = correctBlendMode; | ||
exports.createIndicesForQuads = createIndicesForQuads; | ||
exports.decomposeDataUri = decomposeDataUri; | ||
exports.deprecation = deprecation; | ||
exports.destroyTextureCache = destroyTextureCache; | ||
exports.determineCrossOrigin = determineCrossOrigin; | ||
exports.getResolutionOfUrl = getResolutionOfUrl; | ||
exports.hex2rgb = hex2rgb; | ||
exports.hex2string = hex2string; | ||
exports.string2hex = string2hex; | ||
exports.rgb2hex = rgb2hex; | ||
exports.isPow2 = isPow2; | ||
exports.isWebGLSupported = isWebGLSupported; | ||
exports.log2 = log2; | ||
exports.nextPow2 = nextPow2; | ||
exports.premultiplyBlendMode = premultiplyBlendMode; | ||
exports.correctBlendMode = correctBlendMode; | ||
exports.premultiplyRgba = premultiplyRgba; | ||
exports.premultiplyTint = premultiplyTint; | ||
exports.premultiplyTintToRgba = premultiplyTintToRgba; | ||
exports.createIndicesForQuads = createIndicesForQuads; | ||
exports.uid = uid; | ||
exports.removeItems = removeItems; | ||
exports.rgb2hex = rgb2hex; | ||
exports.sayHello = sayHello; | ||
exports.sign = sign; | ||
exports.nextPow2 = nextPow2; | ||
exports.isPow2 = isPow2; | ||
exports.log2 = log2; | ||
exports.CanvasRenderTarget = CanvasRenderTarget; | ||
exports.ProgramCache = ProgramCache; | ||
exports.TextureCache = TextureCache; | ||
exports.BaseTextureCache = BaseTextureCache; | ||
exports.destroyTextureCache = destroyTextureCache; | ||
exports.clearTextureCache = clearTextureCache; | ||
exports.skipHello = skipHello; | ||
exports.string2hex = string2hex; | ||
exports.trimCanvas = trimCanvas; | ||
exports.decomposeDataUri = decomposeDataUri; | ||
exports.determineCrossOrigin = determineCrossOrigin; | ||
exports.getResolutionOfUrl = getResolutionOfUrl; | ||
exports.DATA_URI = DATA_URI; | ||
exports.deprecation = deprecation; | ||
exports.uid = uid; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@pixi/utils", | ||
"version": "5.0.0-rc.2", | ||
"version": "5.0.0-rc.3", | ||
"main": "lib/utils.js", | ||
"module": "lib/utils.es.js", | ||
"bundle": "dist/utils.js", | ||
"namespace": "PIXI.utils", | ||
"description": "Collection of utilities used by PixiJS", | ||
@@ -25,17 +27,16 @@ "author": "Mat Groves", | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"dist" | ||
], | ||
"dependencies": { | ||
"@pixi/constants": "^5.0.0-rc.2", | ||
"@pixi/settings": "^5.0.0-rc.2", | ||
"@pixi/constants": "^5.0.0-rc.3", | ||
"@pixi/settings": "^5.0.0-rc.3", | ||
"earcut": "^2.1.3", | ||
"eventemitter3": "^2.0.0", | ||
"ismobilejs": "^0.5.1", | ||
"remove-array-items": "^1.0.0", | ||
"eventemitter3": "^3.1.0", | ||
"url": "^0.11.0" | ||
}, | ||
"devDependencies": { | ||
"floss": "^2.1.5" | ||
"floss": "^2.2.0" | ||
}, | ||
"gitHead": "53b354f4e01d3baee7223756dd09a3163ad29d0f" | ||
"gitHead": "8bd27c8b903ae2c8f90d91d64e82d65b19ac1cdb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
579980
5
11
4767
1
+ Addedeventemitter3@3.1.2(transitive)
- Removedismobilejs@^0.5.1
- Removedremove-array-items@^1.0.0
- Removedeventemitter3@2.0.3(transitive)
- Removedismobilejs@0.5.2(transitive)
- Removedremove-array-items@1.1.1(transitive)
Updated@pixi/constants@^5.0.0-rc.3
Updated@pixi/settings@^5.0.0-rc.3
Updatedeventemitter3@^3.1.0