Skip to content

Commit 6eb8c8b

Browse files
Update copyright dates, restore old Function checking behaviour
1 parent 3501eae commit 6eb8c8b

File tree

7 files changed

+46
-26
lines changed

7 files changed

+46
-26
lines changed

.github/workflows/node.js.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@
44
name: Node.js CI
55

66
on:
7-
push:
8-
branches: [ master ]
9-
pull_request:
10-
branches: [ master ]
7+
push:
8+
branches: [master]
9+
pull_request:
10+
branches: [master]
1111

1212
jobs:
13-
build:
13+
build:
14+
runs-on: ubuntu-latest
1415

15-
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [10.x, 12.x, 14.x, 15.x]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1620

17-
strategy:
18-
matrix:
19-
node-version: [10.x, 12.x, 14.x, 15.x]
20-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21-
22-
steps:
23-
- uses: actions/checkout@v2
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v1
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
- run: npm ci
29-
- run: npm run-script build
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run-script build

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,11 @@ export function isArray(val: unknown): val is unknown[] {
3030
return Object.prototype.toString.call(val) === "[object Array]";
3131
}
3232

33+
// eslint-disable-next-line @typescript-eslint/ban-types
34+
export function isFunction(val: unknown): val is Function {
35+
return Object.prototype.toString.call(val) === "[object Function]";
36+
}
37+
3338
export function isSet(val: unknown): val is Set<unknown> {
3439
return Object.prototype.toString.call(val) === "[object Set]";
3540
}
@@ -51,7 +56,7 @@ export function isMap(val: unknown): val is Map<unknown, unknown> {
5156
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
5257
export function stringify(value: any): string {
5358
if (!isUndefined(value) && !isNull(value)) {
54-
if (value?.toString) {
59+
if (isFunction(value?.toString)) {
5560
value = value.toString();
5661
}
5762
}

test/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

test/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

test/src/utils.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016-2019 Michael Kourlas
2+
* Copyright (C) 2016-2020 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import {
2020
isMap,
2121
isNull,
2222
isObject,
23+
isFunction,
2324
isSet,
2425
isUndefined,
2526
stringify,
@@ -83,6 +84,21 @@ describe("utils", () => {
8384
});
8485
});
8586

87+
describe("#isFunction", () => {
88+
it("should return true for functions", () => {
89+
assert.isTrue(isFunction(() => 0));
90+
assert.isTrue(isFunction(() => "test"));
91+
});
92+
93+
it("should return false for values that are not functions", () => {
94+
assert.isFalse(isFunction("test"));
95+
assert.isFalse(isFunction(3));
96+
assert.isFalse(isFunction(undefined));
97+
assert.isFalse(isFunction(true));
98+
assert.isFalse(isFunction(null));
99+
});
100+
});
101+
86102
describe("#isSet", () => {
87103
it("should return true for sets", () => {
88104
assert.isTrue(isSet(new Set()));

0 commit comments

Comments
 (0)