Skip to content

Commit

Permalink
indent + 6 missing exports
Browse files Browse the repository at this point in the history
  • Loading branch information
nclslbrn committed Jun 28, 2024
1 parent b3f4f72 commit 37cc2bd
Showing 1 changed file with 166 additions and 160 deletions.
326 changes: 166 additions & 160 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
import { type Scheme, Args, DefaultArgs, EntryScheme } from './type';
import { type Scheme, Args, DefaultArgs, EntryScheme } from "./type";

import { albers, alys, andre, anuszkiewicz } from './artists/a';
import { bacon, bruegel } from './artists/b';
import { corbusier } from './artists/c';
import { dali, delaunay, doesburg, drei, durer } from './artists/d';
import { ernst } from './artists/e';
import { freud } from './artists/f';
import { gentileschi, giacometti, goldin, greco } from './artists/g';
import { hockney, hopper } from './artists/h';
import { judd, johns } from './artists/j';
import { kandinsky, kelly, khalil, kiefer, klee, klint } from './artists/k';
import { lewitt } from './artists/l';
import { magritte, malevich, martin, molnar, moss, mura } from './artists/m';
import { newman } from './artists/n';
import { okeefe, orozco } from './artists/o';
import { picasso, pollard, pollock } from './artists/p';
import { rauschenberg, riley, rothko, rozanova } from './artists/r';
import { saville, sherman } from './artists/s';
import { taeuberArp, turner } from './artists/t';
import { vasarely, vermeer } from './artists/v';
import { yoshitoshi } from './artists/y';
import { warb } from './artists/w.ts'
import { albers, alys, andre, anuszkiewicz } from "./artists/a";
import { bacon, bruegel } from "./artists/b";
import { corbusier } from "./artists/c";
import { dali, delaunay, doesburg, drei, durer } from "./artists/d";
import { ernst } from "./artists/e";
import { freud } from "./artists/f";
import { gentileschi, giacometti, goldin, greco } from "./artists/g";
import { hockney, hopper } from "./artists/h";
import { judd, johns } from "./artists/j";
import { kandinsky, kelly, khalil, kiefer, klee, klint } from "./artists/k";
import { lewitt } from "./artists/l";
import { magritte, malevich, martin, molnar, moss, mura } from "./artists/m";
import { newman } from "./artists/n";
import { okeefe, orozco } from "./artists/o";
import { picasso, pollard, pollock } from "./artists/p";
import { rauschenberg, riley, rothko, rozanova } from "./artists/r";
import { saville, sherman } from "./artists/s";
import { taeuberArp, turner } from "./artists/t";
import { vasarely, vermeer } from "./artists/v";
import { yoshitoshi } from "./artists/y";
import { warb } from "./artists/w.ts";

const entries: EntryScheme = {
albers,
alys,
andre,
anuszkiewicz,
bacon,
bruegel,
corbusier,
dali,
delaunay,
doesburg,
drei,
durer,
ernst,
freud,
gentileschi,
giacometti,
goldin,
greco,
hockney,
hopper,
albers,
alys,
andre,
anuszkiewicz,
bacon,
bruegel,
corbusier,
dali,
delaunay,
doesburg,
drei,
durer,
ernst,
freud,
gentileschi,
giacometti,
goldin,
greco,
hockney,
hopper,
johns,
judd,
kandinsky,
kelly,
khalil,
kiefer,
klee,
klint,
lewitt,
magritte,
malevich,
martin,
judd,
kandinsky,
kelly,
khalil,
kiefer,
klee,
klint,
lewitt,
magritte,
malevich,
martin,
molnar,
moss,
mura,
newman,
okeefe,
mura,
newman,
okeefe,
orozco,
picasso,
pollard,
pollock,
rauschenberg,
riley,
rothko,
picasso,
pollard,
pollock,
rauschenberg,
riley,
rothko,
rozanova,
saville,
sherman,
taeuberArp,
turner,
vasarely,
vermeer,
yoshitoshi,
warb
saville,
sherman,
taeuberArp,
turner,
vasarely,
vermeer,
yoshitoshi,
warb,
};

const palettesKey = Object.keys(entries);
Expand All @@ -92,101 +92,107 @@ const palettes: Scheme[] = palettesKey.map((id) => entries[id]);
* @returns false|Scheme false if no palette match current option else Scheme
*/
const getPalette = (args: Args): false | Scheme => {
const defaultArgs: DefaultArgs = {
rand: Math.random(),
temp: 'any',
theme: 'any',
artist: 'any',
};
// Overwrite default query with user value
const query: DefaultArgs = { ...defaultArgs, ...args };
const defaultArgs: DefaultArgs = {
rand: Math.random(),
temp: "any",
theme: "any",
artist: "any",
};
// Overwrite default query with user value
const query: DefaultArgs = { ...defaultArgs, ...args };

// Test query param value
if (!['any', 'warm', 'cold'].includes(query.temp)) {
console.warn(
'temp option not recognized, the script will use default value (any)'
);
query.temp = 'any';
}
if (!['any', 'bright', 'dark'].includes(query.theme)) {
console.warn(
'theme option not recognized, the script will use default value (any)'
);
query.theme = 'any';
}
if (query.rand < 0 || query.rand > 1) {
console.warn(
'rand is not in the required range (0-1), the script will cast it.'
);
query.rand = Math.max(0, Math.min(query.rand, 1));
}
// Test query param value
if (!["any", "warm", "cold"].includes(query.temp)) {
console.warn(
"temp option not recognized, the script will use default value (any)",
);
query.temp = "any";
}
if (!["any", "bright", "dark"].includes(query.theme)) {
console.warn(
"theme option not recognized, the script will use default value (any)",
);
query.theme = "any";
}
if (query.rand < 0 || query.rand > 1) {
console.warn(
"rand is not in the required range (0-1), the script will cast it.",
);
query.rand = Math.max(0, Math.min(query.rand, 1));
}

// Filter palette according to query param
let matchQuery = palettes;
// Filter palette according to query param
let matchQuery = palettes;

if (query.temp !== 'any') {
matchQuery = matchQuery.filter((p) => p.temp === query.temp);
}
if (query.theme !== 'any') {
matchQuery = matchQuery.filter((p) => p.theme === query.theme);
}
if (query.artist !== 'any') {
matchQuery = matchQuery.filter((p) => p.meta.artist === query.artist);
}
if (query.temp !== "any") {
matchQuery = matchQuery.filter((p) => p.temp === query.temp);
}
if (query.theme !== "any") {
matchQuery = matchQuery.filter((p) => p.theme === query.theme);
}
if (query.artist !== "any") {
matchQuery = matchQuery.filter((p) => p.meta.artist === query.artist);
}

if (matchQuery.length === 0) {
return false;
} else if (matchQuery.length === 1) {
return matchQuery[0];
} else {
return matchQuery[Math.floor(query.rand * matchQuery.length)];
}
if (matchQuery.length === 0) {
return false;
} else if (matchQuery.length === 1) {
return matchQuery[0];
} else {
return matchQuery[Math.floor(query.rand * matchQuery.length)];
}
};

export {
albers,
alys,
anuszkiewicz,
bacon,
bruegel,
corbusier,
dali,
delaunay,
doesburg,
drei,
durer,
freud,
gentileschi,
giacometti,
goldin,
greco,
hockney,
hopper,
judd,
kandinsky,
kelly,
khalil,
kiefer,
klee,
klint,
lewitt,
magritte,
malevich,
martin,
mura,
newman,
okeefe,
picasso,
pollard,
pollock,
riley,
rothko,
saville,
sherman,
turner,
vasarely,
vermeer,
yoshitoshi,
palettes,
getPalette,
albers,
alys,
anuszkiewicz,
bacon,
bruegel,
corbusier,
dali,
delaunay,
doesburg,
drei,
durer,
freud,
gentileschi,
giacometti,
goldin,
greco,
hockney,
hopper,
johns,
judd,
kandinsky,
kelly,
khalil,
kiefer,
klee,
klint,
lewitt,
magritte,
malevich,
martin,
molnar,
moss,
mura,
newman,
okeefe,
orozco,
picasso,
pollard,
pollock,
riley,
rothko,
rozanova,
saville,
sherman,
turner,
vasarely,
vermeer,
yoshitoshi,
warb,
palettes,
getPalette,
};

0 comments on commit 37cc2bd

Please sign in to comment.