Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
pagyew committed Apr 1, 2024
0 parents commit fc14166
Show file tree
Hide file tree
Showing 16 changed files with 7,106 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install
run: nci

- name: Lint
run: nr lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install
run: nci

- name: Typecheck
run: nr typecheck

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [16.x, 18.x]
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install
run: nci

- name: Build
run: nr build

- name: Test
run: nr test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
71 changes: 71 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{
"rule": "style/*",
"severity": "off"
},
{
"rule": "format/*",
"severity": "off"
},
{
"rule": "*-indent",
"severity": "off"
},
{
"rule": "*-spacing",
"severity": "off"
},
{
"rule": "*-spaces",
"severity": "off"
},
{
"rule": "*-order",
"severity": "off"
},
{
"rule": "*-dangle",
"severity": "off"
},
{
"rule": "*-newline",
"severity": "off"
},
{
"rule": "*quotes",
"severity": "off"
},
{
"rule": "*semi",
"severity": "off"
}
],
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"gql",
"graphql"
]
}
21 changes: 21 additions & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

function safolor(color) {
if (typeof color !== "string")
throw new TypeError("Expected a string");
const hex = color.match(
/^#(?:([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?|([\da-f]{1})([\da-f]{1})([\da-f]{1})([\da-f]{1})?)$/i
);
if (hex === null)
throw new SyntaxError("Expected a HEX format");
const [_, rr, gg, bb, __, r, g, b, ___] = hex;
const R = rr || r.padEnd(2, r);
const G = gg || g.padEnd(2, g);
const B = bb || b.padEnd(2, b);
const nR = (Math.round(Number.parseInt(R, 16) / 51) * 51).toString(16);
const nG = (Math.round(Number.parseInt(G, 16) / 51) * 51).toString(16);
const nB = (Math.round(Number.parseInt(B, 16) / 51) * 51).toString(16);
return `#${nR.padEnd(2, nR)}${nG.padEnd(2, nG)}${nB.padEnd(2, nB)}`;
}

exports.safolor = safolor;
4 changes: 4 additions & 0 deletions dist/index.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type HEX = `#${string}`;
declare function safolor(color: HEX): HEX;

export { type HEX, safolor };
4 changes: 4 additions & 0 deletions dist/index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type HEX = `#${string}`;
declare function safolor(color: HEX): HEX;

export { type HEX, safolor };
4 changes: 4 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type HEX = `#${string}`;
declare function safolor(color: HEX): HEX;

export { type HEX, safolor };
19 changes: 19 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function safolor(color) {
if (typeof color !== "string")
throw new TypeError("Expected a string");
const hex = color.match(
/^#(?:([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?|([\da-f]{1})([\da-f]{1})([\da-f]{1})([\da-f]{1})?)$/i
);
if (hex === null)
throw new SyntaxError("Expected a HEX format");
const [_, rr, gg, bb, __, r, g, b, ___] = hex;
const R = rr || r.padEnd(2, r);
const G = gg || g.padEnd(2, g);
const B = bb || b.padEnd(2, b);
const nR = (Math.round(Number.parseInt(R, 16) / 51) * 51).toString(16);
const nG = (Math.round(Number.parseInt(G, 16) / 51) * 51).toString(16);
const nB = (Math.round(Number.parseInt(B, 16) / 51) * 51).toString(16);
return `#${nR.padEnd(2, nR)}${nG.padEnd(2, nG)}${nB.padEnd(2, nB)}`;
}

export { safolor };
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@antfu/eslint-config'

export default config()
Loading

0 comments on commit fc14166

Please sign in to comment.