@nothing-but/utils
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,3 @@ | ||
export { binaryInsert, binaryInsertUnique, binaryInsertWith, binarySearch, binarySearchWith, deduped, equals, includesSameMembers, mutateFilter, pickRandom, pickRandomExclidingOne, randomIterate, remove, wrap } from '../chunk/HSNCKYHC.js'; | ||
export { binaryInsert, binaryInsertUnique, binaryInsertWith, binarySearch, binarySearchWith, deduped, equals, includesSameMembers, mutateFilter, pickRandom, pickRandomExclidingOne, randomIterate, remove, wrap } from '../chunk/PRANYL6F.js'; | ||
import '../chunk/FEYGEDAE.js'; | ||
import '../chunk/OZRPOR2F.js'; | ||
@@ -3,0 +4,0 @@ import '../chunk/77EWK6YV.js'; |
@@ -1,34 +0,1 @@ | ||
declare class RGB { | ||
r: number; | ||
g: number; | ||
b: number; | ||
constructor(r: number, g: number, b: number); | ||
toString: () => string; | ||
} | ||
declare class RGBA extends RGB { | ||
a: number; | ||
constructor(r: number, g: number, b: number, a: number); | ||
toString: () => string; | ||
} | ||
declare function RGBToString(rgb: RGB): string; | ||
declare function RGBAToString(rgba: RGBA): string; | ||
/** | ||
* Converts a hex color to an rgb color | ||
* | ||
* @example | ||
* hexToRGBA('#ff0000') // { r: 255, g: 0, b: 0 } | ||
* hexToRGBA('#f00') // { r: 255, g: 0, b: 0 } | ||
*/ | ||
declare function hexToRGB(hex: string): RGB; | ||
/** | ||
* Converts a hex color to an rgba color | ||
* | ||
* @example | ||
* hexToRGBA('#ff0000') // { r: 255, g: 0, b: 0, a: 1 } | ||
* hexToRGBA('#ff000000') // { r: 255, g: 0, b: 0, a: 0 } | ||
* hexToRGBA('#f00') // { r: 255, g: 0, b: 0, a: 1 } | ||
* hexToRGBA('#f000') // { r: 255, g: 0, b: 0, a: 0 } | ||
*/ | ||
declare function hexToRGBA(hex: string): RGBA; | ||
export { RGB, RGBA, RGBAToString, RGBToString, hexToRGB, hexToRGBA }; | ||
export { R as RGB, a as RGBA, d as RGBAToString, b as RGBToString, h as hexToRGB, e as hexToRGBA } from '../color-4e19072b.js'; |
@@ -0,56 +1,2 @@ | ||
export { RGB, RGBA, RGBAToString, RGBToString, hexToRGB, hexToRGBA } from '../chunk/FEYGEDAE.js'; | ||
import '../chunk/5ZKAE4VZ.js'; | ||
// src/color.ts | ||
var RGB = class { | ||
constructor(r, g, b) { | ||
this.r = r; | ||
this.g = g; | ||
this.b = b; | ||
} | ||
toString = RGBToString.bind(null, this); | ||
}; | ||
var RGBA = class extends RGB { | ||
constructor(r, g, b, a) { | ||
super(r, g, b); | ||
this.a = a; | ||
} | ||
toString = RGBAToString.bind(null, this); | ||
}; | ||
function RGBToString(rgb) { | ||
return `rgb(${rgb.r} ${rgb.g} ${rgb.b})`; | ||
} | ||
function RGBAToString(rgba) { | ||
return `rgb(${rgba.r} ${rgba.g} ${rgba.b} / ${rgba.a})`; | ||
} | ||
function hexToRGB(hex) { | ||
if (hex[0] === "#") | ||
hex = hex.slice(1); | ||
if (hex.length < 6) { | ||
const r2 = parseInt(hex[0], 16); | ||
const g2 = parseInt(hex[1], 16); | ||
const b2 = parseInt(hex[2], 16); | ||
return new RGB(r2, g2, b2); | ||
} | ||
const r = parseInt(hex.slice(0, 2), 16); | ||
const g = parseInt(hex.slice(2, 4), 16); | ||
const b = parseInt(hex.slice(4, 6), 16); | ||
return new RGB(r, g, b); | ||
} | ||
function hexToRGBA(hex) { | ||
if (hex[0] === "#") | ||
hex = hex.slice(1); | ||
if (hex.length < 6) { | ||
const r2 = parseInt(hex[0], 16); | ||
const g2 = parseInt(hex[1], 16); | ||
const b2 = parseInt(hex[2], 16); | ||
const a2 = hex[3] ? parseInt(hex[3], 16) / 255 : 1; | ||
return new RGBA(r2, g2, b2, a2); | ||
} | ||
const r = parseInt(hex.slice(1, 3), 16); | ||
const g = parseInt(hex.slice(3, 5), 16); | ||
const b = parseInt(hex.slice(5, 7), 16); | ||
const a = hex.length > 7 ? parseInt(hex.slice(7, 9), 16) / 255 : 1; | ||
return new RGBA(r, g, b, a); | ||
} | ||
export { RGB, RGBA, RGBAToString, RGBToString, hexToRGB, hexToRGBA }; |
export { a as array } from '../array-2ae64097.js'; | ||
export { c as color } from '../color-4e19072b.js'; | ||
export { e as ease } from '../ease-8473b216.js'; | ||
@@ -3,0 +4,0 @@ export { m as math } from '../math-b7f74671.js'; |
@@ -1,2 +0,3 @@ | ||
export { array_exports as array } from '../chunk/HSNCKYHC.js'; | ||
export { array_exports as array } from '../chunk/PRANYL6F.js'; | ||
export { color_exports as color } from '../chunk/FEYGEDAE.js'; | ||
export { ease_exports as ease } from '../chunk/OZRPOR2F.js'; | ||
@@ -3,0 +4,0 @@ export { math_exports as math } from '../chunk/77EWK6YV.js'; |
{ | ||
"name": "@nothing-but/utils", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", |
export * as array from './array' | ||
export * as color from './color' | ||
export * as ease from './ease' | ||
@@ -3,0 +4,0 @@ export * as math from './math' |
92848
49
2519