Skip to content

Commit

Permalink
remove core-js and coveralls.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Bezkrovnyi committed Sep 12, 2021
1 parent 15583cb commit b436cbe
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 257 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

dist
docs
coverage
reports

/examples/node.js/demo.js
/examples/node.js/demo.js.map
Expand Down
6 changes: 2 additions & 4 deletions packages/image-q/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
Complete Image Quantization Library in **TypeScript** _(MIT License)_

[![Build Status](https://travis-ci.org/ibezkrovnyi/image-quantization.svg?branch=master)](https://travis-ci.org/ibezkrovnyi/image-quantization)
[![Coverage Status](https://coveralls.io/repos/github/ibezkrovnyi/image-quantization/badge.svg)](https://coveralls.io/github/ibezkrovnyi/image-quantization)
[![Demo](https://img.shields.io/badge/demo-online-brightgreen.svg)](https://ibezkrovnyi.github.io/image-quantization-demo/)
[![Demo (outdated, use /packages/demo for up-to-date demo)](https://img.shields.io/badge/demo-online-brightgreen.svg)](https://ibezkrovnyi.github.io/image-quantization-demo/)
[![GitHub](https://img.shields.io/badge/github-.com-brightgreen.svg)](https://github.com/ibezkrovnyi/image-quantization)
[![NPM](https://badge.fury.io/js/image-q.svg)](https://www.npmjs.com/package/image-q)
[![Greenkeeper badge](https://badges.greenkeeper.io/ibezkrovnyi/image-quantization.svg)](https://greenkeeper.io/)
[![API](https://img.shields.io/badge/API-Available-blue.svg)](http://ibezkrovnyi.github.io/image-quantization/)
[![API)](https://img.shields.io/badge/API-Available-blue.svg)](http://ibezkrovnyi.github.io/image-quantization/)
[![NPM License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

![quantization](quantization.png)
Expand Down
1 change: 1 addition & 0 deletions packages/image-q/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'tsx',
],
collectCoverage: true,
coverageDirectory: '<rootDir>/reports/jest',
coverageReporters: [
'lcov',
'text-summary',
Expand Down
7 changes: 2 additions & 5 deletions packages/image-q/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "image-q",
"version": "3.0.3",
"version": "3.0.4",
"description": "Image Quantization Library in **TypeScript** *(MIT Licensed)*",
"license": "MIT",
"contributors": [],
Expand All @@ -17,8 +17,7 @@
"clean": "shx rm -rf ./node_modules/.cache",
"build": "tsc -p tsconfig.build-esm.json && webpack",
"test": "jest",
"gh-pages-DISABLED": "shx rm -rf ./docs && typedoc.cmd src && gh-pages -d docs",
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls"
"gh-pages-DISABLED": "shx rm -rf ./docs && typedoc.cmd src && gh-pages -d docs"
},
"files": [
"dist",
Expand Down Expand Up @@ -49,8 +48,6 @@
},
"devDependencies": {
"@types/pngjs": "3.3.0",
"core-js": "^3.17.3",
"coveralls": "3.0.1",
"gh-pages": "3.2.3",
"pngjs": "3.3.3",
"typedoc": "0.22.2"
Expand Down
20 changes: 11 additions & 9 deletions packages/image-q/src/basicAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
*
* helper.ts - part of Image Quantization Library
*/
import setImmediate from 'core-js/features/set-immediate';
import * as distance from './distance';
import * as image from './image';
import * as palette from './palette';
import { AbstractDistanceCalculator } from './distance/distanceCalculator';
import { PointContainer } from './utils/pointContainer';
import { Palette } from './utils/palette';

const setImmediateImpl =
typeof setImmediate === 'function'
? setImmediate
: typeof process !== 'undefined' && typeof process?.nextTick === 'function'
? (callback: () => void) => process.nextTick(callback)
: (callback: () => void) => setTimeout(callback, 0);

export type ColorDistanceFormula =
| 'cie94-textiles'
| 'cie94-graphic-arts'
Expand Down Expand Up @@ -99,7 +105,6 @@ export async function buildPalette(
images.forEach((image) => paletteQuantizer.sample(image));

let palette: Palette;
let timerId: number;
const iterator = paletteQuantizer.quantize();
const next = () => {
try {
Expand All @@ -109,14 +114,13 @@ export async function buildPalette(
} else {
if (result.value.palette) palette = result.value.palette;
if (onProgress) onProgress(result.value.progress);
timerId = setImmediate(next);
setImmediateImpl(next);
}
} catch (error) {
clearTimeout(timerId);
reject(error);
}
};
timerId = setImmediate(next);
setImmediateImpl(next);
});
}

Expand Down Expand Up @@ -152,7 +156,6 @@ export async function applyPalette(
);

let outPointContainer: PointContainer;
let timerId: number;
const iterator = imageQuantizer.quantize(image, palette);
const next = () => {
try {
Expand All @@ -164,14 +167,13 @@ export async function applyPalette(
outPointContainer = result.value.pointContainer;
}
if (onProgress) onProgress(result.value.progress);
timerId = setImmediate(next);
setImmediateImpl(next);
}
} catch (error) {
clearTimeout(timerId);
reject(error);
}
};
timerId = setImmediate(next);
setImmediateImpl(next);
});
}

Expand Down
Loading

0 comments on commit b436cbe

Please sign in to comment.