renickbell / array-toolkit Goto Github PK
View Code? Open in Web Editor NEWsome tools for manipulating arrays
License: GNU General Public License v3.0
some tools for manipulating arrays
License: GNU General Public License v3.0
Both of these functions use the same subroutine. We want a more generic function which takes a function as an argument to use as the base for these two. These two should be specific cases of calling that function. Include all 3 functions in the library.
since ramda should be a dependency, remove zip and reimplement buildZip if necessary.
there is a findClosestSmaller. please add a similar function called findClosestLarger.
reimplement both in terms of a function called findClosestBy which takes a function as an argument and allows us to do custom findClosest functions.
let testNumArr = [1, 3, 6, 2, 7]
console.log(A.safeSplice(testNumArr, 2, 1, [5, 8, 8])) //[ 1, [ 5, 8, 8 ], 2, 7 ]
console.log(A.safeSplice(testNumArr, 2, 1, ...[5, 8, 8])) //[ 1, 5, 2, 7 ]
//none of those work
I should do this: [ 1, 5, 8, 8 , 2, 7 ]
when this is the input: console.log(A.safeSplice(testNumArr, 2, 1, ...[5, 8, 8]))
Write JSDoc for every function for better code completion/hint and other assistance in modern IDEs such as VSCode.
For instance:
/**
* Takes the length the array should be changed into as argument.
* If array longer, will shorten array. If array shorter will loop the array until desiredLength.
* (Generated with Chatgpt)
* @param {number} number the desired length
* @param {Array} array the array to modify
* @example console.log(adjustArrayLength(5, [0,1,2])) // [......]
*/
function adjustArrayLength(number, array) {
let arrayLength = array.length;
if (arrayLength === number) {
return array;
} else if (arrayLength < number) {
let numCopies = Math.ceil(number / arrayLength);
return array.concat(...Array(numCopies).fill(array)).slice(0, number);
} else {
return array.slice(0, number);
}
}
Now that there's an npm package, the readme needs npm installation instructions to make things friendlier.
The name of the function "resizeArray" isn't the most appropriate name for this function. We need to improve it. Can someone suggest a better name?
removeFirstInstance and removeAtIndex use splice rather than safeSplice or other non-mutating functions. these should be rewritten.
Would it be better to use ES6 import
and export
pattern in terms of code maintainability and clarity?
// arrayTransformations.js
export const adjustArrayLength = (number, array) => {
//...
}
export const anotherFunction = () => {}
// ...
// index.js
export {adjustArrayLength, anotherFunction} from "./arrayTransformations.js";
// usage
import {adjustArrayLength, anotherFunction} from "array-toolkit";
We have three potential types of removeItem:
Please implement and choose appropriate function names.
make a similar one that can remove an array of items. implement in terms of removeItem.
https://github.com/renickbell/arrayToolkit/blob/main/arrayTransformations.js
rename the numArray function to integerArray, in this file:
https://github.com/renickbell/arrayToolkit/blob/main/dataToArray.js
Dr.Bell told me to add it
The comment describing the original source for shuffle is still in Konduktiva combined.js and missing from arrayTransformations.js here.
let testNumArr = [1, 3, 6, 2, 7]
let testObj = {name: 'jill'}
let testMixArr = [1, 3, 'string', [1, 2], {name: 'bob'}, testObj, null, undefined]
console.log(A.removeAllInstance(testMixArr, {name: 'jill'}))
/*
[
1,
3,
'string',
[ 1, 2 ],
{ name: 'bob' },
{ name: 'jill' },
null,
undefined
]
*/
Should it remove { name: 'jill' }
?
These functions are unnecessary; just implement the functions where they are used with arrow functions.
Please fix the implementation of numArray so that it uses linearArray to produce its return value.
even though the installation is standard, we should put instructions on npm.org to let people know there's nothing special when installing it.
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.