menaiala / arrow Goto Github PK
View Code? Open in Web Editor NEWA modern JavaScript utility library for complex data structures.
License: MIT License
A modern JavaScript utility library for complex data structures.
License: MIT License
@boussadjra , I need your opinion about exporting each function like in the example provided in README.
Or export an Object that lets the developers call the functions inside it.
In React we have the two options :
import React from "react"
React.createElement()
and
import {useEffect} from "react"
const effect = useEffect();
JS has a functional and OOP ( recently ) paradigm so I could get exactly the decision behind each architecture.
In Java, I was doing this by defining the static functions, factory functions, and instantiated functions... The concept was clean but JS behavior confuses me.
What's your opinion?
Source | Category | Suggestion | Description |
Duplicated snippets | Refactoring | passString() & passNumber() are duplicated in many unit tests |
In null.spec.js & and number.spec.js there are duplicated methods in many positions :
it("should throw error if the parameter is not an array", () => {
function passNumber() {
ArrayNull.hasPairNull(0);
}
function passString() {
ArrayNull.hasPairNull("item");
}
expect(passNumber).toThrowError("The parameter should be an array");
expect(passString).toThrowError("The parameter should be an array");
});
function
or code snippet by many unit tests
scripts ?The goal of this function is to find the asymmetric difference between two or more arrays. However, I found a silent bug when I was adding more unit tests.
export const difference = (...arrays) => {
if (arrays.length === 1) return arrays[0]
const args = Array.from([...arrays])
let initArray = args[0];
let differentElements = new Set();
args.forEach(array => args.indexOf(array) !== 0 && isArray(array) &&
array.forEach(value => !initArray.includes(value) && differentElements.add(value)))
return Array.from(differentElements)
}
export const diff = (arr1, arr2) => {
return [
...arr1.filter((item) => !arr2.includes(item)),
...arr2.filter((item) => !arr1.includes(item)),
];
};
it('should return an array with the uncommon elements between arrays ', () => {
expect(diff([1, 2], [1, 2, 5])).toStrictEqual([5]); // passed
expect(diff([1, 2], [1, 2, 3], [1, 2, 3, 4])).toStrictEqual([4]); // failed
expect(diff(['a', 'b'], ['b', 'a'], ['a', 'b', 'c'])).toStrictEqual(['c']); // failed
expect(diff([null], [undefined, null], [undefined, null, 'Ala'])).toStrictEqual(['Ala']); //failed
expect(diff(['diorite', 'andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'],['diorite', 'andesite', 'grass', 'dirt', 'dead shrub'])
).toStrictEqual(['pink wool']); // failed
});
it('should return an empty array ', () => {
expect(diff([1, 2], [1, 2], [1, 2])).toStrictEqual([]); //failed
});
it('should return the original array ', () => {
expect(diff([1, 2])).toStrictEqual([1, 2]); //failed
});
Source | Category | Suggestion | Description |
Duplicated snippets | Refactoring | if(expression){ duplicated code } are duplicated in __throwError() function |
In null.spec.js there are duplicated if
with the same functions : passString()
, passNumber()
,passEmptyArray()
,passUndefinedOrNull()
:
function __throwError(func) {
if (func.length === 1) {
function passNumber() {
func(0);
}
function passString() {
func("item");
}
function passEmptyArray() {
func([]);
}
function passUndefinedOrNull() {
func(undefined || null);
}
expect(passNumber).toThrowError("The parameter should be an array");
expect(passString).toThrowError("The parameter should be an array");
expect(passEmptyArray).toThrowError("The array is empty");
expect(passUndefinedOrNull).toThrowError("The parameter is null or undefined");
}
if (func.length === 2) {
function passNumber() {
func(0, 1);
}
function passString() {
func("item", 1);
}
function passEmptyArray() {
func([], 1);
}
function passUndefinedOrNull() {
func(undefined || null, 1);
}
expect(passNumber).toThrowError("The parameter should be an array");
expect(passString).toThrowError("The parameter should be an array");
expect(passEmptyArray).toThrowError("The array is empty");
expect(passUndefinedOrNull).toThrowError("The parameter is null or undefined");
}
}
@boussadjra , I'm struggling to export the modules to one global file index.js
then create a build setup from it.
please check create-build-setup-branch and see how I created index.js for each folder ( has, math..) then create one index.js that import module from these indexes then run npm run build
to build the setup.
The problem is I could not import the functions when I want to use the module for production.
Looking for someone who's familiar with @Jenkins or CirlceCI.
While I'm continuing the development stage of modules, I'm looking for someone who will configure the @webpack for the build setup. Who would I assign this task to him?
average.js is a module that contains a functions for calculating the average value of an array.
More details are comments on the average.js
file.
Need to implement a function that looks like the sql group by
statement in which we indicate the field to group by it and an aggregate function such as sum
, avg
, count
, min
and max
, lets suppose that we have the following array :
let scores=[
{
"date": "2020-08-04",
"time": "8:32",
"score": 2
},
{
"date": "2020-08-04",
"time": "8:45",
"score": 1
},
{
"date": "2020-08-04",
"time": "11:15",
"score": 4
},
{
"date": "2020-08-06",
"time": "9:52",
"score": 7
},
{
"date": "2020-08-06",
"time": "15:42",
"score": 3
},
{
"date": "2020-08-09",
"time": "8:57",
"score": 1
},
{
"date": "2020-08-09",
"time": "18:26",
"score": 5
}
]
expected result after applying the function groupBy('date','sum','score')
:
[
{
date:'2020-08-04',
score :7
},
{
date:'2020-08-06',
score:10
},
{
date:'2020-08-09',
score:6
}]
or the other result by applying groupBy('date','count','score')
or groupBy('date','count','*')
:
[
{
date:'2020-08-04',
count:3
},
{
date:'2020-08-06',
count:2
},
{
date:'2020-08-09',
count:2
}]
Source | Category | Suggestion | Description |
Implemenation | / | Implement `orderRange()` and `order()` |
I'm looking for someone who would implement two functions that passes these tests order.spec.js.
Functions descriptions are available on : order.js
Source | Category | Description |
Architecture | I need to create a project structure that follows the Javascript Projects Standards |
assets/
For images
doc/
For documentation files
dist/
For compiled scripts
coverage
For testing coverage ( Auto-generated )
examples
For code examples
specs
For unit testing
src
For manipulated code
.babelrc
For Babel Configuration
.eslintignore
For Eslint Configuration
.eslintrc.json
For Eslint Configuration
gitignore
For git Configuration
npmignore
For npm Configuration
.jestconfig
For Jest Configuration
.webpack.dev.config
For Webpack Configuration
.webpack.prod.config
For Webpack Configuration
Did I miss a directory or a configuration ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.