Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Lambda functions and functional programming for javascript
$ npm install haskell
Make functions out of lambda strings
f = require('haskell');
add1 = f('+1');
add1(1); // => 2
f('x*x')(5); // => 25
f('a b -> a+b')(1, 2); // => 3
f('+2')(f('+1')(1)); // => 4
greater_than_0 = f('>0');
greater_than_0(1); // => true
greater_than_0(-1); // => false
array = [-1, 0, 1, 2];
array.map('+1'); // => [0, 1, 2, 3]
array.filter('>0'); // => [1, 2]
array.map('+1').filter('>0'); => [1, 2, 3]
array.every('>0'); // => false
array.some('>0'); // => true
f.fold([1, 2, 3, 4], 'a+b'); // => 10
// reverse array
[1, 2, 3, 4].foldr('a b -> a.push(b)', []); // => [4, 3, 2, 1]
[1, 2, 3].map('+1').fold('a+b'); // => 9
Curry a function with arguments. Returns a function with the arguments applied.
add3 = f('a + b + c')
add3(1, 2, 3);
// => 6
add3.curry(1); // f.curry(add3, 1);
add3(1, 2);
// => 4
f.curry(add3, 2);
add3(3);
// => 6
a = [-1, 0, 1, 2];
a.map(f('a+b').curry(2)); // f.map(a, f.curry('a+b', 2))
// => [1, 2, 3, 4]
Zip multiple arrays into an array of arrays
[0, 1, 2, 3].zip([0, -1, -2, -3])
// => [[0, 0], [1, -1], [2, -2], [3, -3]]
Array.zip([1, 3, 5, 7], [2, 4, 6, 8])
// => [[1, 2], [3, 4], [5, 6], [7, 8]]
zip("and", "fish", "be")
// => [['a', 'f', 'b'], ['n', 'i', 'e']]
Return an array of unique/distinct elements of an array
[1, 1, 2, 4, 5, 5, 5, 6, 7, 7].unique()
// => [1, 2, 4, 5, 6, 7]
Array.unique(["and", "fish", "be", "fish"])
// => ["and", "fish", "be"]
unique("array")
// => ['a', 'r', 'y']
Create a dictionary Object from an Array of objects
[
{ name: 'foo', value: 'bar' }
{ name: 'bar', value: 'baz' }
].dictionary('name')
// =>
// {
// 'foo': { name: 'foo', value: 'bar' }
// 'bar': { name: 'bar', value: 'baz' }
// }
Verify if an array is empty
[1, 1, 2, 4, 5, 5, 5, 6, 7, 7].empty(); // => false
Array.empty([]); // => true
empty(""); // => true
Verify if an array is a single tuple
[1, 1, 2, 4, 5, 5, 5, 6, 7, 7].single(); // => false
Array.single([]); // => false
f.single([1]); // => true
Return the top element of an array
[1, 1, 2, 4, 5, 5, 5, 6, 6, 7].top(); // => 6
Array.top([]); // => undefined
top("Haskell"); // => "l"
Remove items from an array by index or function test (affects original array)
[1, 1, 2, 4, 5, 5, 5, 6, 7, 7].remove(2)
// => [1, 1, 4, 5, 5, 5, 6, 7, 7]
Array.remove([1, 1, 2, 4, 5, 5, 5, 6, 7, 7], function(e) { return e == 5; })
// => [1, 1, 2, 4, 6, 7, 7]
remove([1], 0)
// => []
The MIT License (MIT)
Copyright (c) 2013 Arthur Xavier <arthur.xavierx@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Lambda functions and functional programming for javascript
We found that haskell 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.