Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.4 KB

README.md

File metadata and controls

54 lines (44 loc) · 1.4 KB

is-arrow-fn

Determine if a function is an ES6 arrow function or not.

version license size download

installation

npm install @jswork/is-arrow-fn

usage

import isArrowFn from '@jswork/is-arrow-fn';

const obj = {
  fn1() {
    console.log("normal fn1", this);
  },
  fn2: () => {
    console.log("arrow fn2", this);
  },
  fn3: function () {
    console.log("normal fn3", this);
  },
  fn4: function () {
    return () => {
      console.log("123");
    };
  },
};

isArrowFn(obj.fn1); // false
isArrowFn(obj.fn2); // true
isArrowFn(obj.fn3); // false
isArrowFn(obj.fn4); // false

license

Code released under the MIT license.