eyes.utils
Advanced tools
Comparing version 0.0.29 to 3.6.1
@@ -13,1 +13,4 @@ 'use strict'; | ||
exports.StreamUtils = require('./src/StreamUtils'); | ||
exports.UserAgent = require('./src/UserAgent').UserAgent; | ||
exports.OSNames = require('./src/OSNames').OSNames; | ||
exports.BrowserNames = require('./src/BrowserNames').BrowserNames; |
{ | ||
"name": "eyes.utils", | ||
"version": "0.0.29", | ||
"version": "3.6.1", | ||
"description": "General purpose Javascript utilities.", | ||
@@ -25,6 +25,6 @@ "keywords": [ | ||
"type": "git", | ||
"url": "git://github.com/applitools/eyes.utils.git" | ||
"url": "git://github.com/applitools/eyes.sdk.javascript.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/applitools/eyes.utils/issues" | ||
"url": "https://github.com/applitools/eyes.sdk.javascript/issues" | ||
}, | ||
@@ -48,19 +48,17 @@ "directories": { | ||
"@types/png-async": "*", | ||
"png-async": "^0.9.2", | ||
"dateformat": "^3.0.3" | ||
"dateformat": "^3.0.3", | ||
"png-async": "^0.9.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^5.1.1" | ||
"mocha": "^5.2.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha ./test/**/*.spec.js" | ||
"test": "mocha \"test/**/*.spec.js\"", | ||
"test:unit": "mocha \"test/unit/**/*.spec.js\"" | ||
}, | ||
"browser": { | ||
"fs": "browserify-fs", | ||
"zlib": "browserify-zlib" | ||
}, | ||
"license": "SEE LICENSE IN LICENSE", | ||
"engines": { | ||
"node": ">= 4.2.0" | ||
} | ||
"node": ">= 6.9.0" | ||
}, | ||
"gitHead": "509409aa04b8db9caf8590da5d0181b2c12dad2c" | ||
} |
@@ -256,3 +256,18 @@ (function () { | ||
//noinspection JSUnusedGlobalSymbols | ||
/** | ||
* Cartesian product of arrays | ||
* | ||
* @param {...(Array|Object)} arrays Variable number of arrays of n elements | ||
* @return {Array<Array>} Product of arrays as an array of X arrays of N elements, | ||
* where X is the product of the input arrays' lengths | ||
*/ | ||
GeneralUtils.cartesianProduct = function (...arrays) { | ||
const getArrayOf = a => (Array.isArray(a) ? a : [a]); | ||
const prod2 = (a, b) => getArrayOf(b).map(e1 => a.map(e2 => [e1, ...e2])).reduce((arr, e) => arr.concat(e), []); | ||
const prod = (a, ...rest) => (rest.length > 0 ? prod(prod2(a, rest.pop()), ...rest) : a); | ||
return prod([[]], ...arrays); | ||
}; | ||
exports.GeneralUtils = GeneralUtils; | ||
}()); |
@@ -459,16 +459,15 @@ (function () { | ||
* @param {Buffer} imageBuffer | ||
* @param {PromiseFactory} promiseFactory | ||
* @return {{width: number, height: number}} | ||
*/ | ||
ImageUtils.getImageSizeFromBuffer = function (imageBuffer, promiseFactory) { | ||
return promiseFactory.makePromise(function (resolve, reject) { | ||
if (imageBuffer[12] === 0x49 && imageBuffer[13] === 0x48 && imageBuffer[14] === 0x44 && imageBuffer[15] === 0x52) { | ||
var width = (imageBuffer[16] * 256 * 256 * 256) + (imageBuffer[17] * 256 * 256) + (imageBuffer[18] * 256) + imageBuffer[19]; | ||
var height = (imageBuffer[20] * 256 * 256 * 256) + (imageBuffer[21] * 256 * 256) + (imageBuffer[22] * 256) + imageBuffer[23]; | ||
resolve({width: width, height: height}); | ||
return; | ||
} | ||
ImageUtils.getImageSizeFromBuffer = function (imageBuffer) { | ||
// noinspection MagicNumberJS | ||
if (imageBuffer[12] === 0x49 && imageBuffer[13] === 0x48 && imageBuffer[14] === 0x44 && imageBuffer[15] === 0x52) { | ||
// noinspection MagicNumberJS | ||
const width = (imageBuffer[16] * 256 * 256 * 256) + (imageBuffer[17] * 256 * 256) + (imageBuffer[18] * 256) + imageBuffer[19]; | ||
// noinspection MagicNumberJS | ||
const height = (imageBuffer[20] * 256 * 256 * 256) + (imageBuffer[21] * 256 * 256) + (imageBuffer[22] * 256) + imageBuffer[23]; | ||
return { width, height }; | ||
} | ||
reject("Buffer contains unsupported image type."); | ||
}); | ||
throw new TypeError('Buffer contains unsupported image type.'); | ||
}; | ||
@@ -475,0 +474,0 @@ |
@@ -118,3 +118,3 @@ /* Type definitions for eyes.utils 0.0.1 */ | ||
*/ | ||
static mixin(to: void, from: void): void; | ||
static mixin(to: any, from: any): void; | ||
/** | ||
@@ -383,3 +383,3 @@ * Generate GUID | ||
**/ | ||
static getImageSizeFromBuffer(imageBuffer: Buffer, promiseFactory: PromiseFactory): RectangleSize; | ||
static getImageSizeFromBuffer(imageBuffer: Buffer): RectangleSize; | ||
static saveImage(imageBuffer: Buffer, filename: string, promiseFactory: PromiseFactory): Promise<void>; | ||
@@ -493,1 +493,39 @@ } | ||
} | ||
export enum BrowserNames { | ||
Edge = 'Edge', | ||
IE = 'IE', | ||
Firefox = 'Firefox', | ||
Chrome = 'Chrome', | ||
Safari = 'Safari', | ||
Chromium = 'Chromium' | ||
} | ||
export enum OSNames { | ||
Unknown = 'Unknown', | ||
Windows = 'Windows', | ||
IOS = 'IOS', | ||
Macintosh = 'Macintosh', | ||
ChromeOS = 'ChromeOS' | ||
} | ||
export class UserAgent { | ||
/** | ||
* @param userAgent User agent string to parse | ||
* @param unknowns Whether to treat unknown products as {@code UNKNOWN} or throw an exception. | ||
* @return A representation of the user agent string. | ||
*/ | ||
static parseUserAgentString(userAgent: string, unknowns: boolean) : UserAgent; | ||
getBrowser(): string; | ||
getBrowserMajorVersion(): string; | ||
getBrowserMinorVersion(): string; | ||
getOS(): string; | ||
getOSMajorVersion(): string; | ||
getOSMinorVersion(): string; | ||
} |
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
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 v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
121447
23
2545
0
Updatedpng-async@^0.9.3