Giter Club home page Giter Club logo

js-vault's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

js-vault's Issues

Event Dispatcher Implementation

Implement a class / function / utility which exhibits an event dispatcher mechanism and the following methods are available

/**
 * Implement an Event dispatcher
 * which has a way to add listener, remove listeners
 * and dispatch events
 *
 *
 * EventDispatcher.addEventListener()
 * EventDispatcher.removeEventListener()
 * EventDispatcher.dispatch(Event)
 *
 */

Array.map - why is there a element exists check?

In array.map impl, why is there a element exists in the array check? What is that supposed to do?
Its literally taking that value out of the array in the previous line and checking if that exists in that line.

From what i know, the in-built impl doesn't protect against array modification. Is it trying to do that?
Atleast why not just check for undefined (say if length got modified).

I have got nothing against useless checks, but that check alone is bringing down the performance from o(n) to o(n**2).

Implement the pipe function

function pipe() {
  // Implement code here
}

const double = (x) => x * 2;
const square = (x) => x * x;
const cube = (x) => x ** 3;

// const value = pipe(double, cube, square)(2); // output 4096
// console.log(value);

Keep the pipe function as generic as possible..

Promisify a function

Given a function as mentioned below. Write a utility, promisify, where the usage is as explained below

function asyncFunction(a, b, callback) {
  const isError = Math.random() > 0.7;
  setTimeout(() => {
    if (isError) {
      callback(null, new Error("Something went wrong"));
      return;
    }

    callback(a + b, null);
  }, 3000);
}

function promisify(fn) {
  // Implement Code here
}

// Old ussage
asyncFunction(1,2, function(result, err) {
  console.log(result,err)
})


// New Usage
const promisifiedFn = promisify(asyncFunction);
 promisifiedFn(1, 2)
   .then(res => {
     console.log("result", res);
   })
   .catch(console.log);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.