Skip to content

Commit

Permalink
0.73.0
Browse files Browse the repository at this point in the history
- css, flex: flow and stack now use modifiers again (e.g., flow-small)
- js, chunk: higher default chunk size
- minor changes & fixes
  • Loading branch information
oscarpalmer committed Sep 24, 2024
1 parent 8dd8dc0 commit c5c6b4c
Show file tree
Hide file tree
Showing 15 changed files with 460 additions and 483 deletions.
Binary file modified bun.lockb
Binary file not shown.
16 changes: 5 additions & 11 deletions dist/css/flex.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
flex: 1;
}

:where(.flow, .flow-large, .flow-small, .flow-text,
.stack,
.stack-large,
.stack-small,
.stack-text) {
:where(.flow, .stack) {
display: flex;
}

:where(.flow, .flow-large, .flow-small, .flow-text) {
:where(.flow) {
flex-flow: row wrap;
align-items: center;
}
:where(.flow) {
gap: var(--flow-gap, 1rem);
}

:where(.flow-large) {
gap: var(--flow-gap-large, calc(2 * var(--flow-gap, 1rem)));
}
Expand All @@ -30,12 +25,11 @@
gap: var(--flow-gap-text, 1em);
}

:where(.stack, .stack-large, .stack-small, .stack-text) {
flex-flow: column nowrap;
}
:where(.stack) {
flex-flow: column nowrap;
gap: var(--stack-gap, 1rem);
}

:where(.stack-large) {
gap: var(--stack-gap-large, calc(2 * var(--stack-gap, 1rem)));
}
Expand Down
88 changes: 44 additions & 44 deletions dist/js/array/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// src/js/array/chunk.ts
function chunk(array, size) {
const { length } = array;
const chunkSize = typeof size === "number" && size > 0 ? size : 32000;
const chunkSize = typeof size === "number" && size > 0 ? size : 64000;
if (length <= chunkSize) {
return [array];
}
Expand Down Expand Up @@ -33,11 +33,11 @@ function insertValues(type, array, values, start, deleteCount) {
}

// src/js/array/index.ts
function flatten(array2) {
return array2.flat(Number.POSITIVE_INFINITY);
function flatten(array) {
return array.flat(Number.POSITIVE_INFINITY);
}
function push(array2, values) {
return insertValues("push", array2, values, array2.length, 0);
function push(array, values) {
return insertValues("push", array, values, array.length, 0);
}

// src/js/array/compact.ts
Expand Down Expand Up @@ -166,32 +166,32 @@ function getRandomInteger(min, max) {
}

// src/js/array/shuffle.ts
function shuffle2(array) {
function shuffle(array) {
const shuffled = array.slice();
const { length } = shuffled;
for (let index = 0;index < length; index += 1) {
const random2 = getRandomInteger(0, length);
[shuffled[index], shuffled[random2]] = [shuffled[random2], shuffled[index]];
const random = getRandomInteger(0, length);
[shuffled[index], shuffled[random]] = [shuffled[random], shuffled[index]];
}
return shuffled;
}
// src/js/string/index.ts
function getString(value2) {
if (typeof value2 === "string") {
return value2;
function getString(value) {
if (typeof value === "string") {
return value;
}
if (typeof value2 !== "object" || value2 == null) {
return String(value2);
if (typeof value !== "object" || value == null) {
return String(value);
}
const valueOff = value2.valueOf?.() ?? value2;
const valueOff = value.valueOf?.() ?? value;
const asString = valueOff?.toString?.() ?? String(valueOff);
return asString.startsWith("[object ") ? JSON.stringify(value2) : asString;
return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
}
function join(value2, delimiter) {
return compact(value2).map(getString).filter((value3) => value3.trim().length > 0).join(typeof delimiter === "string" ? delimiter : "");
function join(value, delimiter) {
return compact(value).map(getString).filter((value2) => value2.trim().length > 0).join(typeof delimiter === "string" ? delimiter : "");
}
function words(value2) {
return value2.match(/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g) ?? [];
function words(value) {
return value.match(/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g) ?? [];
}
// src/js/math.ts
function max(values) {
Expand Down Expand Up @@ -283,17 +283,17 @@ function getParts(value) {
return typeof value === "object" ? [value] : words(getString(value));
}
// src/js/is.ts
function isKey(value2) {
return typeof value2 === "number" || typeof value2 === "string";
function isKey(value) {
return typeof value === "number" || typeof value === "string";
}

// src/js/array/sort.ts
function sort(array2, first, second) {
if (array2.length < 2) {
return array2;
function sort(array, first, second) {
if (array.length < 2) {
return array;
}
if (first == null || typeof first === "boolean") {
return first === true ? array2.sort((first2, second2) => second2 - first2) : array2.sort();
return first === true ? array.sort((first2, second2) => second2 - first2) : array.sort();
}
const direction = second === true ? "desc" : "asc";
const keys = (Array.isArray(first) ? first : [first]).map((key) => {
Expand All @@ -302,23 +302,23 @@ function sort(array2, first, second) {
callback: undefined
};
if (isKey(key)) {
returned.callback = (value2) => value2[key];
returned.callback = (value) => value[key];
} else if (typeof key === "function") {
returned.callback = key;
} else if (typeof key?.value === "function" || isKey(key?.value)) {
returned.direction = key?.direction ?? direction;
returned.callback = typeof key.value === "function" ? key.value : (value2) => value2[key.value];
returned.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
}
return returned;
}).filter((key) => typeof key.callback === "function");
const { length } = keys;
if (length === 0) {
return direction === "asc" ? array2.sort() : array2.sort((first2, second2) => second2 - first2);
return direction === "asc" ? array.sort() : array.sort((first2, second2) => second2 - first2);
}
if (length === 1) {
return array2.sort((first2, second2) => compare(keys[0].callback(first2), keys[0].callback(second2)) * (keys[0].direction === "asc" ? 1 : -1));
return array.sort((first2, second2) => compare(keys[0].callback(first2), keys[0].callback(second2)) * (keys[0].direction === "asc" ? 1 : -1));
}
const sorted = array2.sort((first2, second2) => {
const sorted = array.sort((first2, second2) => {
for (let index = 0;index < length; index += 1) {
const { callback, direction: direction2 } = keys[index];
const descending = direction2 === "desc";
Expand All @@ -332,48 +332,48 @@ function sort(array2, first, second) {
return sorted;
}
// src/js/array/splice.ts
function splice(array2, start, amountOrValues, values) {
function splice(array, start, amountOrValues, values) {
const amoutOrValuesIsArray = Array.isArray(amountOrValues);
return insertValues("splice", array2, amoutOrValuesIsArray ? amountOrValues : values ?? [], start, amoutOrValuesIsArray ? array2.length : typeof amountOrValues === "number" && amountOrValues > 0 ? amountOrValues : 0);
return insertValues("splice", array, amoutOrValuesIsArray ? amountOrValues : values ?? [], start, amoutOrValuesIsArray ? array.length : typeof amountOrValues === "number" && amountOrValues > 0 ? amountOrValues : 0);
}
// src/js/array/to-map.ts
function toMap(array2, first, second) {
function toMap(array, first, second) {
const asArrays = first === true || second === true;
const callbacks = getCallbacks(undefined, first);
const hasCallback = typeof callbacks?.key === "function";
const map = new Map;
const { length } = array2;
const { length } = array;
for (let index = 0;index < length; index += 1) {
const value2 = array2[index];
const key = hasCallback ? callbacks?.key?.(value2, index, array2) ?? index : index;
const value = array[index];
const key = hasCallback ? callbacks?.key?.(value, index, array) ?? index : index;
if (asArrays) {
const existing = map.get(key);
if (Array.isArray(existing)) {
existing.push(value2);
existing.push(value);
} else {
map.set(key, [value2]);
map.set(key, [value]);
}
} else {
map.set(key, value2);
map.set(key, value);
}
}
return map;
}
// src/js/array/to-record.ts
function toRecord(array2, first, second) {
return groupValues(array2, first, first === true || second === true, true);
function toRecord(array, first, second) {
return groupValues(array, first, first === true || second === true, true);
}
// src/js/array/unique.ts
function unique(array2, key) {
return findValues("unique", array2, undefined, key);
function unique(array, key) {
return findValues("unique", array, undefined, key);
}
export {
unique,
toRecord,
toMap,
splice,
sort,
shuffle2 as shuffle,
shuffle,
push,
insert,
indexOf,
Expand Down
26 changes: 13 additions & 13 deletions dist/js/colour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ function getNormalisedHex(value) {
return normalised.length === 3 ? normalised.split("").map((character) => character.repeat(2)).join("") : normalised;
}
function hexToRgb(value) {
const hex2 = anyPattern.test(value) ? getNormalisedHex(value) : "";
const pairs = groupedPattern.exec(hex2) ?? [];
const rgb2 = [];
const hex = anyPattern.test(value) ? getNormalisedHex(value) : "";
const pairs = groupedPattern.exec(hex) ?? [];
const rgb = [];
const { length } = pairs;
for (let index = 1;index < length; index += 1) {
rgb2.push(Number.parseInt(pairs[index], 16));
rgb.push(Number.parseInt(pairs[index], 16));
}
return new RGBColour({
blue: rgb2[2] ?? 0,
green: rgb2[1] ?? 0,
red: rgb2[0] ?? 0
blue: rgb[2] ?? 0,
green: rgb[1] ?? 0,
red: rgb[0] ?? 0
});
}
function hslToRgb(value) {
Expand All @@ -193,14 +193,14 @@ function hslToRgb(value) {
}
function rgbToHex(value) {
return new HexColour(`${[value.red, value.green, value.blue].map((colour) => {
const hex2 = colour.toString(16);
return hex2.length === 1 ? `0${hex2}` : hex2;
const hex = colour.toString(16);
return hex.length === 1 ? `0${hex}` : hex;
}).join("")}`);
}
function rgbToHsl(rgb2) {
const blue = rgb2.blue / 255;
const green = rgb2.green / 255;
const red = rgb2.red / 255;
function rgbToHsl(rgb) {
const blue = rgb.blue / 255;
const green = rgb.green / 255;
const red = rgb.red / 255;
const max = Math.max(blue, green, red);
const min = Math.min(blue, green, red);
const delta = max - min;
Expand Down
Loading

0 comments on commit c5c6b4c

Please sign in to comment.