Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: es6 classes syntax #4

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f2efa4a
fix(types): add missing Primitive type
nberlette Dec 6, 2022
48082d0
chore: update repo config
nberlette Dec 8, 2022
a6475cc
chore: update hooks
nberlette Dec 8, 2022
40418be
feat: update + move tools to _util
nberlette Dec 8, 2022
0be44a0
chore: update dependencies
nberlette Dec 8, 2022
de7df5c
refactor!: full rewrite to class-syntax
nberlette Dec 8, 2022
72559ed
refactor: assert.ts
nberlette Dec 8, 2022
7ac3139
chore(types): update deno.jsonc
nberlette Dec 8, 2022
17f30d3
types: add missing imports
nberlette Dec 8, 2022
2e9365b
refactor: project style
nberlette Dec 8, 2022
dfdc038
feat: add is.not (negated checks)
nberlette Dec 13, 2022
7c8b305
refactor: move decorators to _util/decorators
nberlette Dec 13, 2022
19f9650
refactor(util): types and tools in _util
nberlette Dec 13, 2022
a958a4a
chore(config): update egg.json and deno.jsonc
nberlette Dec 13, 2022
fb14005
chore: update assert.ts
nberlette Dec 13, 2022
539c10b
feat(util): add constants.ts
nberlette Dec 13, 2022
f97dc01
chore: add triple-slash libs
nberlette Dec 22, 2022
d72b864
feat(types): add shape types
nberlette Dec 22, 2022
47b2840
feat(types): add IsNaN and IsInfinity
nberlette Dec 22, 2022
bafe215
test: add initial unit tests
nberlette Dec 22, 2022
40c8e6e
feat: is.not negated interface
nberlette Dec 22, 2022
403ac20
feat: is.{empty,nonEmpty,set,map} subcategories
nberlette Dec 22, 2022
6d609ea
feat(config): add .github folder
nberlette Dec 22, 2022
eb51b66
chore(config): update config files
nberlette Dec 22, 2022
114f4b9
chore: rename egg.json -> egg.yaml
nberlette Dec 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .github/CONTRIBUTING.md
Empty file.
12 changes: 9 additions & 3 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,29 @@ function __pre_commit_hook() {

# run fmt
eval "$__fmt" || return $?

# run lint
eval "$__lint" || return $?

# run test
eval "$__test" || return $?
local tests=$(eval "$__test" 2>&1)

if [[ $tests =~ ^.*("No test modules"|"no test specified").*$ ]]; then
: # noop
else
echo "$tests"
return $?
fi
# still here? commit!
return 0
}

if [[ $1 =~ ^(-{0,2}(help|info|usage))|-(h|?)$ ]]; then
usage
[[ $DEBUG =~ ^(1|true)$ ]] && debug
return 1
fi

precommit "$@"
[[ $DEBUG =~ ^(1|true)$ ]] && debug
return $?
}

Expand Down
91 changes: 91 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
repository:
security_and_analysis:
advanced_security:
status: enabled
secret_scanning:
status: enabled
has_issues: true
has_projects: false
has_wiki: false
default_branch: main
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: false
allow_auto_merge: false
delete_branch_on_merge: true
enable_automated_security_fixes: true
enable_vulnerability_alerts: true
labels:
- name: "Complexity: High"
color: F9D0C4
- name: "Complexity: Medium"
color: FEF2C0
- name: "Complexity: Low"
color: D4C5F9
- name: "Priority: Critical"
color: "000000"
- name: "Priority: High"
color: F9D0C4
- name: "Priority: Medium"
color: FEF2C0
- name: "Priority: Low"
color: D4C5F9
- name: "State: Help Wanted"
color: 0E8A16
- name: "State: Work in Progress"
color: "5319E7"
- name: "State: Conversation"
color: 27828C
- name: "State: Blocked"
color: "000000"
- name: "State: Postponed"
color: C5DEF5
- name: "State: Unassigned"
color: BFDADC
- name: "Type: Enhancement"
color: 1D76DB
- name: "Type: Bug"
color: B60205
- name: "Type: Infrastructure"
color: FBCA04
- name: "Type: Dependencies"
color: D4C5F9
- name: "Meta: Question"
color: BFDADC
- name: "Meta: Duplicate"
color: BFDADC
- name: "Meta: Abandoned"
color: "808080"
teams:
- name: core
permission: admin
- name: pm
permission: maintain
- name: dev
permission: push
- name: qa
permission: pull
- name: triage
permission: triage
branches:
- name: main
protection:
required_pull_request_reviews:
dismiss_stale_reviews: true
require_code_owner_reviews: true
required_approving_review_count: 1
dismissal_restrictions:
users: []
teams: []
required_status_checks:
strict: true
contexts: []
enforce_admins: false
required_linear_history: true
allow_force_pushes: false
allow_deletions: false
required_conversation_resolution: true
restrictions:
apps: []
users: []
teams: []
23 changes: 23 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
daysUntilStale: 14
daysUntilClose: 3
exemptLabels:
- "Priority: Critical"
- "Priority: High"
- "Priority: Medium"
- "Priority: Low"
- "State: Help Wanted"
- "State: Postponed"
- "State: Work in Progress"
staleLabel: "Meta: Abandoned"
markComment: >
This submission has been flagged as abandoned due to lack of activity. Is there something specific that is causing this to be delayed?

Please leave a comment if this issue has not yet been resolved, otherwise it will be automatically closed in the near future.
closeComment: >
Following with the previous comment, this submission has been automatically closed.

This was due to the following:
- No activity has been made for the past 14 days.
- There are no labels that indicate this is a protected issue.

If this issue is still relevant and needs to be opened again in the future, please leave a comment elaborating upon the reason to continue with this issue.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "🦕 Deno CI"
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

defaults:
run:
shell: bash
working-directory: ./

permissions:
contents: read

jobs:
deno:
runs-on: ${{matrix.os}}
# Continue in case the canary run does not succeed
continue-on-error: ${{matrix.canary}}
# env:
# DENO_DIR: .deno-cache
# CACHE_VERSION: ${{secrets.CACHE_VERSION}}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
deno: [v1.x]
canary: [false]
include:
- deno: canary
os: ubuntu-20.04
canary: true
steps:
- name: "(env) gitconfig"
run: |
sudo git config --system core.autocrlf false
sudo git config --system core.eol lf

- name: "(cache) setup"
uses: actions/cache@v2
with:
path: ${{env.DENO_DIR}}
key: deno911-${{hashFiles('./{deps.ts,import_map.json}')}}

- name: "(env) checkout"
uses: actions/checkout@v3

- name: "(setup) 🦕 ${{matrix.deno}}"
uses: denoland/setup-deno@main
with:
deno-version: ${{matrix.deno}}

- name: "(cache) reload"
run: deno cache --reload --lock-write deps.ts

- name: "(run) fmt"
run: deno fmt --unstable

- name: "(run) lint"
run: deno lint --unstable --no-bad-types --

- name: "(run) test"
run: deno test -A --unstable --no-check
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "🦕 Release"
on:
push:
tags:
- "*"
jobs:
release:
runs-on: ubuntu-latest
# Continue in case the canary run does not succeed
continue-on-error: false
steps:
- name: "(env) gitconfig"
run: |
sudo git config --system core.autocrlf false
sudo git config --system core.eol lf

- name: "(env) checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "(setup) 🦕 deno"
uses: denoland/setup-deno@main
with:
deno-version: 1.x

- run: deno run --unstable -A npm:conventional-github-releaser -p angular
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Thumbs.db
node
deno.lock
_mod.ts
_descriptors.json
__*
!__test__
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"https://x.nest.land": true
},
"deno.suggest.names": true,
"deno.suggest.completeFunctionCalls": true
}
"deno.suggest.completeFunctionCalls": true,
"github-actions.workflows.pinned.refresh.enabled": true
}
1 change: 1 addition & 0 deletions _test/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "https://deno.land/x/[email protected]/mod.ts";
56 changes: 56 additions & 0 deletions _test/is.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { is } from "../mod.ts";
import "./deps.ts";

const { assign, freeze } = Object;

describe("is(value: unknown) => TypeName", () => {
it("should accurately return primitive type names", () =>
([
["string", "string"],
[0o644, "number"],
[true, "boolean"],
[0o644n, "bigint"],
[Symbol(), "symbol"],
] as const).forEach(
([input, output]) => assertStrictEquals(is(input as any), output),
));

it("should differentiate 'null' and 'undefined'", () => {
assertEquals(is(null), "null");
assertEquals(is(undefined), "undefined");
});

it(
"should differentiate 'number' and NaN",
() => assertEquals(is(NaN), "NaN"),
);

it(
"should differentiate 'number' and Infinity",
() => assertEquals(is(Infinity), "Infinity"),
);

it("can identify TemplateStringsArray (new)", () => {
const tsa: TemplateStringsArray = assign(
["hello ", "world"],
freeze({ raw: ["hello ", "world"] }),
);
assert(is.templateStringsArray(tsa));
assertEquals(is(tsa), "TemplateStringsArray");
});

it(
"can identify ArrayLike objects",
() => assertEquals(is(freeze({ "length": 1, "0": "hello!" })), "ArrayLike"),
);

it(
"should identify functions as 'Function'",
() => assertEquals(is(() => {}), "Function"),
);

it(
"should identify async functions as 'AsyncFunction'",
() => assertEquals(is(async () => {}), "AsyncFunction"),
);
});
Loading