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

feat: hasOwn support Node.js 14 #25

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
version: '16, 18, 20'
version: '16, 18, 20, 22'
22 changes: 22 additions & 0 deletions .github/workflows/nodejs-14.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js 14 CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '14'
- run: npm install
- run: node -v
- run: npm test
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# is-type-of

[![NPM version][npm-image]][npm-url]
[![CI](https://github.com/node-modules/is-type-of/actions/workflows/ci.yml/badge.svg)](https://github.com/node-modules/is-type-of/actions/workflows/ci.yml)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[![Node.js Version][node-version-image]][node-version-url]

[npm-image]: https://img.shields.io/npm/v/is-type-of.svg?style=flat-square
[npm-url]: https://npmjs.org/package/is-type-of
[codecov-image]: https://codecov.io/github/node-modules/is-type-of/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/node-modules/is-type-of?branch=master
[snyk-image]: https://snyk.io/test/npm/is-type-of/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/is-type-of
[download-image]: https://img.shields.io/npm/dm/is-type-of.svg?style=flat-square
[download-url]: https://npmjs.org/package/is-type-of
[node-version-image]: https://img.shields.io/node/v/is-type-of.svg?style=flat-square
[node-version-url]: https://nodejs.org/en/download/

Complete type checking for Node

## Features
Expand Down Expand Up @@ -288,3 +306,9 @@ See Also `is.longObject`
## License

[MIT](LICENSE)

## Contributors

[![Contributors](https://contrib.rocks/image?repo=node-modules/is-type-of)](https://github.com/node-modules/is-type-of/graphs/contributors)

Made with [contributors-img](https://contrib.rocks).
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
"eslint": "^8.54.0",
"eslint-config-egg": "^13.0.0",
"long": "^3.2.0",
"semver": "^5.4.1",
"semver": "^7.6.3",
"ts-expect": "^1.3.0",
"tshy": "^1.0.0",
"tshy": "^3.0.2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

tshy v3.0.2 is incompatible with Node.js 14

The tshy v3.0.2 package requires Node.js 20 or >=22, which conflicts with the PR's objective to support Node.js 14. This dependency update would prevent the package from working on Node.js 14.

  • Consider using an older version of tshy that supports Node.js 14
  • Or remove Node.js 14 support from the PR's objectives
🔗 Analysis chain

Consider if tshy v3.0.2 supports Node.js 14.

The tshy dependency was updated to ^3.0.2. Please verify its compatibility with Node.js 14.

Let's check tshy's version requirements:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check tshy package requirements
# Expected: Should support Node.js 14

# Check tshy package.json for engine requirements
curl -s https://registry.npmjs.org/tshy/3.0.2 | jq '.engines'

Length of output: 88

"tshy-after": "^1.0.0",
"typescript": "^5.2.2"
},
Expand Down
6 changes: 5 additions & 1 deletion src/types/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export function isInstanceOf<T extends Class>(val: unknown, Clazz: T): val is In
}

export function hasOwnProperty<T extends object>(obj: T, prop: PropertyKey): obj is T & Record<typeof prop, unknown> {
return Object.hasOwn(obj, prop);
if (Object.hasOwn) {
// Node.js >= 16
return Object.hasOwn(obj, prop);
}
return Object.prototype.hasOwnProperty.call(obj, prop);
}

export function hasOwnPropertyInChain<T extends object>(obj: T, prop: PropertyKey): obj is T & Record<typeof prop, unknown> {
Expand Down
Loading