Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/index.js>wrap

A JavaScript extension package for building strong and modern applications.
Latest
function wrap
Re-export
import { wrap } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/index.js";

Wraps a function inside another function and returns a new function that copies the original function's name and other properties.

Examples

Example 1

import wrap from "@ayonli/jsext/wrap";

function log(text: string) {
    console.log(text);
}

const show = wrap(log, function (fn, text) {
    return fn.call(this, new Date().toISOString() + " " + text);
});

console.log(show.name); // log
console.log(show.length); // 1
console.assert(show.toString() === log.toString());

Parameters

fn
wrapper