All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2601_2700.s2666_allow_one_function_call.solution.ts Maven / Gradle / Ivy

There is a newer version: 1.35
Show newest version
// #Easy #2023_09_09_Time_50_ms_(88.35%)_Space_43.1_MB_(19.45%)

type Fn = (...args: any[]) => any

function once(fn: Fn): Fn {
    let wasCalled = false
    return function (...args) {
        if (!wasCalled) {
            wasCalled = true
            return fn(...args)
        }
    }
}

export { once }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy