0.2.2 • Published 11 months ago

is-object-typeof-interface v0.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

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

Author

Albert Arakelyan