@ktpi2000/sort-colors
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

sort-colors

Sort an array containing hex color codes in order of saturation. This is useful for sorting colors by saturation.

install

npm install @ktpi2000/sort-colors

or

yarn add @ktpi2000/sort-colors

usage

import { sortHex } from "@ktpi2000/sort-colors";

const hexList = [
  "#cc5050",
  "#bd5757",
  "#e32222",
  "#c28686",
  "#e34444",
  "#b56e6e",
  "#fff",
];
console.log(sortHex(hexList));

/*
Map(7) {
  0 => { list_index: 6, hex: '#fff' },
  1 => { list_index: 3, hex: '#c28686' },
  2 => { list_index: 5, hex: '#b56e6e' },
  3 => { list_index: 1, hex: '#bd5757' },
  4 => { list_index: 0, hex: '#cc5050' },
  5 => { list_index: 4, hex: '#e34444' },
  6 => { list_index: 2, hex: '#e32222' }
}
 */

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.44latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.44
0.1.30
0.1.20
0.1.10

Package Sidebar

Install

npm i @ktpi2000/sort-colors

Weekly Downloads

4

Version

0.1.4

License

MIT

Unpacked Size

8.29 kB

Total Files

15

Last publish

Collaborators

  • ktpi2000