JSPM

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

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q57590F
  • License MIT

Check if a value is property accessible

Package Exports

  • @sounisi5011/ts-utils-is-property-accessible
  • @sounisi5011/ts-utils-is-property-accessible/package.json

Readme

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

Go to the latest release page on npm Tested with Jest Commitizen friendly Minified Bundle Size Details Install Size Details Dependencies Status Build Status Maintainability Status

Check if a value is property accessible.

Installation

npm install @sounisi5011/ts-utils-is-property-accessible
yarn add @sounisi5011/ts-utils-is-property-accessible
pnpm add @sounisi5011/ts-utils-is-property-accessible

Usage

TypeScript

import { isPropertyAccessible } from '@sounisi5011/ts-utils-is-property-accessible';

if (isPropertyAccessible(value)) {
    // `value.anyProperty` is available!
    // Because the value is neither null nor undefined.
    // In addition, an index signature type will be added so that any property can be read.
} else {
    // If you try to read or write any property, a TypeError will probably be thrown.
    // Because the value is null or undefined.
}

JavaScript (ES Modules)

import { isPropertyAccessible } from '@sounisi5011/ts-utils-is-property-accessible';

if (isPropertyAccessible(value)) {
    // `value.anyProperty` is available!
    // Because the value is neither null nor undefined.
} else {
    // If you try to read or write any property, a TypeError will probably be thrown.
    // Because the value is null or undefined.
}

JavaScript (CommonJS)

const { isPropertyAccessible } = require('@sounisi5011/ts-utils-is-property-accessible');

if (isPropertyAccessible(value)) {
    // `value.anyProperty` is available!
    // Because the value is neither null nor undefined.
} else {
    // If you try to read or write any property, a TypeError will probably be thrown.
    // Because the value is null or undefined.
}