UNPKG

@sounisi5011/ts-utils-is-property-accessible

Version:
93 lines 5.59 kB
{ "name": "@sounisi5011/ts-utils-is-property-accessible", "version": "1.0.3", "description": "Check if a value is property accessible", "keywords": [ "assert", "assertion", "check", "check-type", "checking", "define-type", "guard", "guards", "is", "nullable", "property", "test", "ts", "type", "type-check", "type-checker", "type-checking", "typechecker", "typed", "typeguard", "typeguards", "typeof", "types", "typescript", "util", "utility", "validate", "validation", "verify" ], "homepage": "https://github.com/sounisi5011/npm-packages/tree/main/packages/ts-utils/is-property-accessible#readme", "bugs": { "url": "https://github.com/sounisi5011/npm-packages/issues" }, "repository": { "type": "git", "url": "git+https://github.com/sounisi5011/npm-packages.git", "directory": "packages/ts-utils/is-property-accessible" }, "license": "MIT", "author": "sounisi5011", "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" }, "./package.json": "./package.json" }, "main": "./dist/index.cjs", "types": "./dist/index.d.ts", "files": [ "dist/", "/CHANGELOG.md", "!**/*.tsbuildinfo" ], "devDependencies": { "@betit/rollup-plugin-rename-extensions": "0.1.0", "@rollup/plugin-typescript": "8.3.2", "@types/jest": "27.5.1", "glob-exec": "0.1.1", "jest": "28.1.0", "rollup": "2.75.0", "ts-jest": "28.0.3", "tsd": "0.20.0", "tslib": "2.4.0", "typescript": "4.7.2", "ultra-runner": "3.10.5" }, "scripts": { "build": "run-p build:*", "build-with-cache": "ultra build", "build:cjs": "rollup --config", "build:mjs": "tsc -p ./src/", "lint:tsc": "run-p lint:tsc:*", "lint:tsc:src": "tsc -p ./src/ --noEmit", "lint:tsc:test": "tsc -p ./tests/ --noEmit", "lint:tsc:test-d": "tsc -p ./test-d/ --noEmit", "test": "npm-run-all build-with-cache --parallel 'test:!(examples|tsd)' test:examples:run test:tsd:exec", "test:examples": "run-s build-with-cache test:examples:*", "test:examples:run": "glob-exec --foreach 'examples/*.{js,cjs,mjs}' -- 'echo \"$\" node {{file}}; node {{file}}; echo'", "test:jest": "jest", "test:tsd": "run-s build:mjs test:tsd:*", "test:tsd:exec": "tsd" }, "readme": "# @sounisi5011/ts-utils-is-property-accessible\n\n[![Go to the latest release page on npm](https://img.shields.io/npm/v/@sounisi5011/ts-utils-is-property-accessible.svg)](https://www.npmjs.com/package/@sounisi5011/ts-utils-is-property-accessible)\n[![Tested with Jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Minified Bundle Size Details](https://img.shields.io/bundlephobia/min/@sounisi5011/ts-utils-is-property-accessible/1.0.3)](https://bundlephobia.com/result?p=%40sounisi5011%2Fts-utils-is-property-accessible%401.0.3)\n[![Install Size Details](https://packagephobia.com/badge?p=%40sounisi5011%2Fts-utils-is-property-accessible%401.0.3)](https://packagephobia.com/result?p=%40sounisi5011%2Fts-utils-is-property-accessible%401.0.3)\n[![Dependencies Status](https://status.david-dm.org/gh/sounisi5011/npm-packages.svg?path=packages%2Fts-utils%2Fis-property-accessible)](https://david-dm.org/sounisi5011/npm-packages?path=packages%2Fts-utils%2Fis-property-accessible)\n[![Build Status](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml/badge.svg)](https://github.com/sounisi5011/npm-packages/actions/workflows/ci.yaml)\n[![Maintainability Status](https://api.codeclimate.com/v1/badges/26495b68302f7ff963c3/maintainability)](https://codeclimate.com/github/sounisi5011/npm-packages/maintainability)\n\nCheck if a value is property accessible.\n\n## Installation\n\n```sh\nnpm install @sounisi5011/ts-utils-is-property-accessible\n```\n\n```sh\nyarn add @sounisi5011/ts-utils-is-property-accessible\n```\n\n```sh\npnpm add @sounisi5011/ts-utils-is-property-accessible\n```\n\n## Usage\n\n### TypeScript\n\n```ts\nimport { isPropertyAccessible } from '@sounisi5011/ts-utils-is-property-accessible';\n\nif (isPropertyAccessible(value)) {\n // `value.anyProperty` is available!\n // Because the value is neither null nor undefined.\n // In addition, an index signature type will be added so that any property can be read.\n} else {\n // If you try to read or write any property, a TypeError will probably be thrown.\n // Because the value is null or undefined.\n}\n```\n\n### JavaScript (ES Modules)\n\n```js\nimport { isPropertyAccessible } from '@sounisi5011/ts-utils-is-property-accessible';\n\nif (isPropertyAccessible(value)) {\n // `value.anyProperty` is available!\n // Because the value is neither null nor undefined.\n} else {\n // If you try to read or write any property, a TypeError will probably be thrown.\n // Because the value is null or undefined.\n}\n```\n\n### JavaScript (CommonJS)\n\n```js\nconst { isPropertyAccessible } = require('@sounisi5011/ts-utils-is-property-accessible');\n\nif (isPropertyAccessible(value)) {\n // `value.anyProperty` is available!\n // Because the value is neither null nor undefined.\n} else {\n // If you try to read or write any property, a TypeError will probably be thrown.\n // Because the value is null or undefined.\n}\n```\n" }