Skip to content

Commit 7451540

Browse files
committed
Lint and cleanup types
1 parent 79bf2e9 commit 7451540

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ jobs:
2222
- name: Install deno
2323
uses: denolib/setup-deno@master
2424
with:
25-
deno-version: 1.1.2
25+
deno-version: 1.2.2
2626
- name: Check formatting
2727
if: matrix.config.kind == 'lint'
28-
run: deno fmt --check
28+
run: |
29+
deno fmt --check
30+
deno lint --unstable
2931
- name: Test
3032
if: matrix.config.kind == 'test'
3133
run: deno test

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Mixins
22

3-
[![version](https://img.shields.io/badge/release-v0.3.1-success)](https://github.com/udibo/mixins/tree/v0.3.1)
3+
[![version](https://img.shields.io/badge/release-v0.4.0-success)](https://github.com/udibo/mixins/tree/v0.4.0)
44
[![CI](https://github.com/udibo/mixins/workflows/CI/badge.svg)](https://github.com/udibo/mixins/actions?query=workflow%3ACI)
5-
[![deno version](https://img.shields.io/badge/deno-v1.1.2-success)](https://github.com/denoland/deno/tree/v1.1.2)
6-
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/raw.githubusercontent.com/udibo/mixins/v0.3.1/mod.ts)
5+
[![deno version](https://img.shields.io/badge/deno-v1.2.2-success)](https://github.com/denoland/deno/tree/v1.2.2)
6+
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/raw.githubusercontent.com/udibo/mixins/v0.4.0/mod.ts)
77
[![license](https://img.shields.io/github/license/udibo/mixins)](https://github.com/udibo/mixins/blob/master/LICENSE)
88

99
This module provides a few basic functions to help combine objects or build up classes from partial classes.
@@ -19,7 +19,7 @@ Applies properties of mixins to instance.
1919
Using `applyMixins` to add properties to an object:
2020

2121
```ts
22-
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.3.0/apply.ts";
22+
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.4.0/apply.ts";
2323
interface Point {
2424
x: number;
2525
y: number;
@@ -41,7 +41,7 @@ point3; // { time: 5, x: 2, y: 3, z: 7 }
4141
Using `applyMixins` to add properties to a function:
4242

4343
```ts
44-
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.3.0/apply.ts";
44+
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.4.0/apply.ts";
4545
interface Point {
4646
x: number;
4747
y: number;
@@ -78,7 +78,7 @@ point3.toString(); // "2, 3, 7, 5"
7878
Using `applyMixins` to add properties to a class:
7979

8080
```ts
81-
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.3.0/apply.ts";
81+
import { applyMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.4.0/apply.ts";
8282
interface Point {
8383
x: number;
8484
y: number;
@@ -130,7 +130,7 @@ point3.toString(); // "1, 2, 3, 4"
130130
Applies properties of base class prototypes to instance.
131131

132132
```ts
133-
import { applyMixins, applyInstanceMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.3.0/apply.ts";
133+
import { applyMixins, applyInstanceMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.4.0/apply.ts";
134134
class Point {
135135
constructor(public x: number, public y: number) {}
136136

@@ -177,7 +177,7 @@ point.toString(); // "2, 3, 7, 5"
177177
Applies properties of base class prototypes to class prototype.
178178

179179
```ts
180-
import { applyMixins, applyClassMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.3.0/apply.ts";
180+
import { applyMixins, applyClassMixins } from "https://raw.githubusercontent.com/udibo/mixins/v0.4.0/apply.ts";
181181
class Point {
182182
constructor(public x: number, public y: number) {}
183183

apply.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** This module is browser compatible. */
2+
13
/** Applies properties of mixins to instance. */
2-
export function applyMixins(instance: any, mixins: any[]) {
4+
// deno-lint-ignore no-explicit-any
5+
export function applyMixins<T>(instance: T, mixins: any[]) {
36
mixins.forEach((mixin) => {
47
Object.getOwnPropertyNames(mixin).forEach((name) => {
58
Object.defineProperty(
@@ -15,11 +18,16 @@ export function applyMixins(instance: any, mixins: any[]) {
1518
}
1619

1720
/** Applies properties of base class prototypes to instance. */
18-
export function applyInstanceMixins(instance: any, baseCtors: any[]) {
19-
applyMixins(instance, baseCtors.map((baseCtor) => baseCtor.prototype));
21+
// deno-lint-ignore no-explicit-any
22+
export function applyInstanceMixins<T>(instance: T, baseCtors: any[]) {
23+
applyMixins(
24+
instance,
25+
baseCtors.map((baseCtor) => baseCtor.prototype ?? baseCtor),
26+
);
2027
}
2128

2229
/** Applies properties of base class prototypes to class prototype. */
23-
export function applyClassMixins(ctor: any, baseCtors: any[]) {
30+
// deno-lint-ignore no-explicit-any
31+
export function applyClassMixins(ctor: Function, baseCtors: any[]) {
2432
applyInstanceMixins(ctor.prototype, baseCtors);
2533
}

apply_test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ Deno.test("applyMixins to class", () => {
8181
time: number;
8282
}
8383
interface Point4D extends Point, TimePoint {
84-
new (x: number, y: number, z: number, time: number): Point4D;
8584
z: number;
8685
toArray(): [number, number, number, number];
8786
toString(): string;

deps/std/testing/asserts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { assertEquals } from "https://deno.land/std@0.59.0/testing/asserts.ts";
1+
export { assertEquals } from "https://deno.land/std@0.63.0/testing/asserts.ts";

mod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** This module is browser compatible. */
2+
13
export {
24
applyMixins,
35
applyInstanceMixins,

0 commit comments

Comments
 (0)