antiflasher / apcach Goto Github PK
View Code? Open in Web Editor NEWJS color calculator for composing colors with consistent APCA contrast ratio.
License: MIT License
JS color calculator for composing colors with consistent APCA contrast ratio.
License: MIT License
These fields are mandatory for npm release
"name": "apcach",
"version": "0.0.0"
I am using 0.0.0
before release.
console.log(apcach(crToBg('white',7), maxChroma(.1),30).lightness); still gives 1, while it should be 0.9something.
The best way to write a benchmark is to use library.
pnpm add --save-dev benchmark
Then you can copy benchmark code from https://github.com/ai/nanoevents/blob/main/test/benchmark.js to benchmark.js
To run it you need to call node ./benchmark.js
Donβt forget to add benchmark.js
to .npmignore
.
You are using import
. But by default Node.js is using old require()
. To switch the mode to ESM you need to add "type": "module"
to package.json
.
Also, we can explicitly mark what library exports by adding:
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
It tells to Node.js that if user write import * from 'apcach'
, this 'apcach'
should be replaced to ./node_modules/apcach/index.js
.
It is opinionated, but I prefer to clean dev configs from package.json
before releasing to npm.
This is why I release with clean-publish
.
pnpm add --save-dev clean-publish
And for release I write:
pnpm clean-publish
Like here: https://github.com/ai/nanoevents/blob/main/package.json#L4-L15
Also, set the same short description to Github repo description.
In npm, there is a conversion of calling the main file as index.js
. For instance, culori use it.
You can key apcach.js
name as well, but in this case you need to set main
field to package.json
to explain to npm where is your main file.
"main": "./apcach.js",
Since we are planning to release it to npm we need to move the dependencies (culori
) to npm as well.
pnpm add culori https://cdn.skypack.dev/apca-w3
import { calcAPCA } from "https://cdn.skypack.dev/apca-w3"
to import { calcAPCA } from "apca-w3"
We need README.md
with just basis information:
Your tool can be used for dynamic theme on client-side. It will be nice to keep track the size of the tool inside JS bundle.
There is a tool for that called Size Limit.
There are two ways of using it:
pnpm test
and call it on every commit on CI (so you will be able to track size by reading CI log)Anyway, the first steps are equal:
pnpm add --save-dev size-limit @size-limit/preset-small-lib
"test:size": "size-limit"
to package.json
βscripts
(pnpm test
automatically runs all scripts with test:
prefix)If you want to set limit:
Run pnpm size-limit
locally to get the current size
Add to package.json
:
"size-limit": [
{
"limit": "100 B"
}
],
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.