Skip to content

Commit

Permalink
chore: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Aug 5, 2024
0 parents commit b385b88
Show file tree
Hide file tree
Showing 26 changed files with 4,823 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
public/
pnpm-lock.yaml
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @type {import("eslint").Linter.Config */
const config = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
rules: {
"@typescript-eslint/consistent-type-imports": ["warn"],
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
};

// eslint-disable-next-line no-undef
module.exports = config;
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Install pnpm 🤏🏻
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Cache 📦
uses: actions/setup-node@v4
with:
cache: pnpm

- name: Install 🚀
run: |
pnpm install
- name: Lint 🧹
run: |
pnpm run lint
- name: Test 🧪
run: |
pnpm run test:coverage
- name: Build 🔧
run: |
pnpm run build
- name: Coverage 📊
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docs 📖
run: |
pnpm run docs
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs
37 changes: 37 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on: ["pull_request"]

name: Build and Test PR

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Install pnpm 🤏🏻
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Cache 📦
uses: actions/setup-node@v4
with:
cache: pnpm

- name: Install 🚀
run: |
pnpm install
- name: Lint 🧹
run: |
pnpm run lint
- name: Test 🧪
run: |
pnpm run test:coverage
- name: Build 🔧
run: |
pnpm run build
108 changes: 108 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

docs

.DS_Store
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/*
coverage/*
docs/*
CHANGELOG.md
pnpm-lock.yaml
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"endOfLine": "auto",
"arrowParens": "avoid"
}
62 changes: 62 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.addMissingImports": "explicit",
"source.organizeImports": "explicit"
},
"cSpell.enabled": true,
"eslint.enable": true,
"prettier.enable": true,
"eslint.probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
],
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
],
"typescript.tsdk": "node_modules/typescript/lib",
"[html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 CRIMX

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# weak-cache

<p align="center">
<img width="200" src="https://raw.githubusercontent.com/crimx/weak-cache/main/assets/logo.svg">
</p>

[![Docs](https://img.shields.io/badge/Docs-read-%23fdf9f5)](https://crimx.github.io/weak-cache)
[![Build Status](https://github.com/crimx/weak-cache/actions/workflows/build.yml/badge.svg)](https://github.com/crimx/weak-cache/actions/workflows/build.yml)
[![Coverage Status](https://img.shields.io/codeclimate/coverage/crimx/weak-cache)](https://codeclimate.com/github/crimx/weak-cache)

[![npm-version](https://img.shields.io/npm/v/weak-cache.svg)](https://www.npmjs.com/package/weak-cache)
[![minified-size](https://img.shields.io/bundlephobia/minzip/weak-cache)](https://bundlephobia.com/package/weak-cache)
[![no-dependencies](https://img.shields.io/badge/dependencies-none-success)](https://bundlejs.com/?q=weak-cache)
[![tree-shakable](https://img.shields.io/badge/tree-shakable-success)](https://bundlejs.com/?q=weak-cache)
[![side-effect-free](https://img.shields.io/badge/side--effect-free-success)](https://bundlejs.com/?q=weak-cache)

WeakCache is like WeakMap but extends support to primitive keys, and with both object keys and object values being weakly referenced.

## Install

```bash
npm add weak-cache
```

## Usage

```ts
import { WeakCache } from "weak-cache";

const cache = new WeakCache();

cache.set("key", { value: "value" });

const objectKey = { key: "key" };

cache.set(key, { value: "value" });

console.log(cache.size); // 2

console.log(cache.get("key")); // { value: "value" }
console.log(cache.get(objectKey)); // { value: "value" }

// ...
// gc()

console.log(cache.size); // 0
```
9 changes: 9 additions & 0 deletions assets/docs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.tsd-hierarchy {
display: none;
}

@media (min-width: 1025px) {
.tsd-index-group {
display: none;
}
}
Loading

0 comments on commit b385b88

Please sign in to comment.