@azera/reflect
Reflection util
Last updated 3 days ago by mdzzohrabi .
MIT · Original npm · Tarball · package.json
$ cnpm install @azera/reflect 
SYNC missed versions from official npm registry.

Azera Reflect

isCallable( value ): boolean

import {isCallable} from "@azera/reflect";

isCallable(function () {}); // true
isCallable(class {}); // false

isClass( value ): boolean

import {isClass} from "@azera/reflect";

isClass(function () {}); // false
isClass(class {}); // true

isMethod( value ): boolean

import {isMethod} from "@azera/reflect";

class Console {
  static print() {}
}

isMethod(Console.print); // true
isMethod(function () {}); // false
isMethod( name => null ); // false
iisMethod( class {} ); // false

getParameters( value ): string[]

import {getParameters} from "@azera/reflect";

getParameters( name => `Hello ${name}` ); // [ 'name' ]
getParameters( (first, last) => `Hello ${first} ${last}` ); // [ 'first', 'last' ]
getParameters( function ( options ) {} ); // [ 'options' ]
getParameters(class App {
  constructor( version ) {}
}); // [ 'version' ]

getParameters(function ({ name, age }) {}); // [ 'p0' ]

reflect(value: Function)

import {reflect} from "@azera/reflect";

console.log( reflect(class Console {
    constructor(version) {}
}) );

Output :

{
  name: 'Console',
  isClass: true,
  isFunction: false,
  isAnonymous: false,
  isArrow: false,
  parameters: [ 'version' ],
  toString: 'class Console {\r\n            constructor(version) { }\r\n        }'
 }

Current Tags

  • 1.0.9                                ...           latest (3 days ago)

10 Versions

  • 1.0.9                                ...           3 days ago
  • 1.0.8                                ...           3 days ago
  • 1.0.7                                ...           5 months ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 5
This Week 25
This Month 30
Last Day 2
Last Week 1
Last Month 2
Dependencies (2)
Dev Dependencies (6)

Copyright 2014 - 2016 © taobao.org |