sfcode An Online Competing and Development Environment

Plain Function

A Function instance that is not a Class

# <tt>plain-function/is</tt>

Confirms if given object is a plain function

const isPlainFunction = require("type/plain-function/is");
isPlainFunction(function () {}); // true
isPlainFunction(() => {}); // true
isPlainFunction(class {}); // false
isPlainFunction("foo"); // false

# <tt>plain-function/ensure</tt>

If given argument is a plain function object, it is returned back. Otherwise `TypeError` is thrown.

const ensurePlainFunction = require("type/function/ensure");
const fn = function () {};
ensurePlainFunction(fn); // fn
ensurePlainFunction(class {}); // Thrown TypeError: class is not a plain function