npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dyvas/array-object-helper

v1.0.0

Published

This package help handle arrays and objects

Downloads

1

Readme

Task #2. JS

Pre-requirements

  • Participating lecture;
  • Basic JS knowledge;
  • ES6 Features Knowledge.

Explanation

In this task you will need to create JS utile library to work with arrays and objects.

All code should be written in a single lib.js file. Your library need to be created as a standalone module, so that it can be imported into other projects. In order to make your library usable on any environment, use UMD module pattern.

DISCLAIMER

You're not allowed to use built-in JS-array methods, so each function need to be implementated manually. Any signs of a copy-pasted code from similar utile libs will be considered as a deliberate deception, fully compromising your solution.

The library should provide the following functionality.

Array methods:
map(array, callback)
reduce(array, callback, initialValue)
filter(array, callback)
foreach(array, callback)
take(array, n)
skip(array, n)
some(array, callback)
every(array, callback)
max(array)
min(array)

Object methods:
keys(obj)
values(obj)
pairs(obj)
fromPairs(array)

Here is an example of calling.

libName.take([1, 2, 3, 4], 2) // will return`[1, 2]

The rest of the functions work the same way.

libName.map([1, 2, 3], a => a * 2 ) // will return [2, 4, 6]

After finishing the implementation of these methods, you should implement new chain and value functions, which will allow using the library in the following way.

libName.chain([1, 2, 3]).take(2).skip(1).value(); // will return [2]

Tests

Separate test.js should be filled in with a bunch of examples of usages of your library. Add at least 3 example of calls for each of your methods. No need to use any actual testing frameworks.

Example:

// This function already exists. Feel free to use.
const isEqual = (a = [], b = []) => a.length === b.length && a.every((v, i) => v === b[i]);

...

const testMap = (input, callback, expected) => {
  const actual = libName.map(input, callback);
  console.log(`
    Inputs: ${input}
    Actual: ${actual}
    Expected: ${expected}
    Assess: ${isEqual(actual, expected)}
  `);
};

console.log('[map]: Testing started');
testMap([1,2,3,4], v => v * 2, [2,4,6,8]);
testMap([1,2,3,4], v => v + 2, [3,4,5,6]);
testMap([1,2,3,4], v => v, [1,2,3,4]);
console.log('[map]: Testing done');

Rating criterias

  • 5 – Task is completed, solution is clean, readable and reliable. Module can be imported in NodeJS project, React project and used in plain JS-script. All tests are passing;
  • 4 – Task is completed, minor edge-cases missed, code is readable and reliable in most cases. Module can be imported in at least one environment. All tests are passing;
  • 3 – Task is completed, edge cases missing, code is readable, but has huge gaps in reliability;
  • 2 – Partial completion of the tasks, functionality doesn’t fully work or fail on some usual cases;
  • 1 – Partial completion of the tasks, unable to run, test;
  • 0 – No completion or no submission.