Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-object-typeof-interface

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-object-typeof-interface

A simple package which returns true when object is type of some specific interface or type.

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

is-object-typeof-interface

A simple package which returns true when object is type of some specific interface or type.

This is my first package, hope it will be helpful. :heart:

Install

Install with npm:

$ npm install is-object-typeof-interface

Usage

import isObjectTypeOfInterface from 'is-object-typeof-interface';

interface IObj1 {
  foo: string;
  bar: number;
}

interface IObj2 {
  baz: boolean;
  biz: string;
}

const obj1: any = { foo: 'str', bar: 5 };
const obj2: any = { baz: true, biz: 'str' };

const result1 = isObjectTypeOfInterface<IObj1>(obj1, 'foo');
const result2 = isObjectTypeOfInterface<IObj2>(obj2, 'baz');

console.log('Result 1: ', result1); // true
console.log('Result 2: ', result2); // true

About

Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/ALbert2504/is-object-typeof-interface/issues/new).
Motivation Receving an object from Redux store had two different types as the same component was rendering different datas, and I needed check what interface my object has to get correct property. After googling I found [this](https://stackoverflow.com/questions/14425568/interface-type-check-with-typescript) question and published this package, which will be extended in future.

Author

Albert Arakelyan

Keywords

FAQs

Package last updated on 16 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc