diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58f05ed..1b3ace9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml new file mode 100644 index 0000000..40d6c58 --- /dev/null +++ b/.github/workflows/nodejs-14.yml @@ -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 diff --git a/README.md b/README.md index b10b44b..6090da8 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). diff --git a/package.json b/package.json index 0d36604..66ef162 100644 --- a/package.json +++ b/package.json @@ -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", "tshy-after": "^1.0.0", "typescript": "^5.2.2" }, diff --git a/src/types/util.ts b/src/types/util.ts index 645e2ad..ad5b7d0 100644 --- a/src/types/util.ts +++ b/src/types/util.ts @@ -6,7 +6,11 @@ export function isInstanceOf(val: unknown, Clazz: T): val is In } export function hasOwnProperty(obj: T, prop: PropertyKey): obj is T & Record { - 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(obj: T, prop: PropertyKey): obj is T & Record {