
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
rubydoobydoo
Advanced tools
Helping JS be more Ruby.
Unashamedly monkey patching JS numbers, strings, arrays and objects with Ruby methods.
Ruby has loads of really nice methods, now you can use them in JS as well!
Write code like:
[1,2,3].last // 3
[1,2,3].count // 3
(21).ordinalize // "21st"
"Rubydoobydoo".reverse //m "oodyboodybuR"
[1,2,3].sum.squared // 9
["A","A","C","A","B","A","B"].tally // {"A": 4, "C": 1, "B": 2}
npm install rubydoobydoo
Then just add either require "rubydoobydoo" or import "rubydoobydoo" to the top of any JS file and suddenly coding in JS becomes a lot more ejoyable!
firstReturns the first element of the array.
[1, 2, 3].first; // 1
[].first; // undefined
second, third, fourth, fifthReturns the second, third, fourth, or fifth element of the array.
[10, 20, 30].second; // 20
[10].third; // undefined
forty_twoReturns the 42nd element (index 41) of the array.
Array(50).fill(0).map((_, i) => i + 1).forty_two; // 42
### third_to_last, second_to_last, last
Returns the third-to-last, second-to-last, or last element of the array.
[1, 2, 3, 4].second_to_last; // 3
[].last; // undefined
emptyReturns true if the array is empty, false otherwise.
[].empty; // true
[1].empty; // false
clear()Clears all elements from the array.
let arr = [1, 2, 3];
arr.clear();
console.log(arr); // []
sizeReturns the length of the array.
[1, 2, 3].size; // 3
min, maxReturns the smallest or largest number in the array.
[5, 3, 9].min; // 3
[5, 3, 9].max; // 9
[].min; // undefined
uniqReturns a new array with duplicate elements removed.
[1, 2, 2, 3].uniq; // [1, 2, 3]
to_sentenceConverts the array into a human-readable sentence.
["a", "b", "c"].to_sentence; // "a, b and c"
compactReturns a new array with null and undefined values removed.
[1, null, 2, undefined, 3].compact; // [1, 2, 3]
to_paramConverts the array into a string joined by /.
["users", 42, "edit"].to_param; // "users/42/edit"
any(func?)Returns true if at least one element satisfies func, or if the array is not empty.
[1, 2, 3].any(x => x > 2); // true
[].any(); // false
one(func?)Returns true if exactly one element satisfies func.
[1, 2, 3].one(x => x > 2); // true
[1, 2, 3, 4].one(x => x > 2); // false
sum(func?)Returns the sum of all elements, or applies func before summing.
[1, 2, 3].sum(); // 6
[1, 2, 3].sum(x => x * 2); // 12
reject(func)Returns a new array without elements matching func.
[1, 2, 3, 4].reject(x => x % 2 === 0); // [1, 3]
partition(func)Splits the array into two: one matching func, one not.
[1, 2, 3, 4].partition(x => x % 2 === 0); // [[2, 4], [1, 3]]
count(func?)Returns the number of elements satisfying func, or the total length.
[1, 2, 3, 4].count(x => x % 2 === 0); // 2
[1, 2, 3].count(); // 3
pluck(prop)Extracts values of the given property from an array of objects.
[{id: 1}, {id: 2}].pluck("id"); // [1, 2]
from(n)Returns a new array starting from index n.
[10, 20, 30, 40].from(2); // [30, 40]
combination(n)Returns all possible combinations of n elements.
[1, 2, 3].combination(2); // [[1,2], [1,3], [2,3]]
tally()Counts occurrences of each unique element.
["a", "b", "a"].tally(); // { a: 2, b: 1 }
each_cons(n)Returns overlapping subarrays of size n.
[1, 2, 3, 4].each_cons(2); // [[1,2], [2,3], [3,4]]
rotate(n = 1)Returns a rotated array by n places.
[1, 2, 3].rotate(); // [2, 3, 1]
sample(n = 1)Returns n random elements.
[1, 2, 3, 4].sample(2); // Random subset
zip(arr)Zips two arrays together.
[1, 2, 3].zip(["a", "b", "c"]); // [[1, "a"], [2, "b"], [3, "c"]]
union(...arrs)Returns a merged array without duplicates.
[1, 2].union([2, 3], [3, 4]); // [1, 2, 3, 4]
collect → map
all → every
select → filter
each → forEach
detect → find
inject → reduce
delete_if → reject
FAQs
Monkey patching JavaScript to make it Ruby Dooby Doo!
The npm package rubydoobydoo receives a total of 0 weekly downloads. As such, rubydoobydoo popularity was classified as not popular.
We found that rubydoobydoo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.