Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

musejs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

musejs

![](/assets/logo.png)

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Muse

MIT License Current Version

Getting started


import {
  map,
  filter,
  ...
} from 'musejs';

Utils

map

Higher order map


map([1, 2, 3, 4], i => i + 1)
// => [2, 3, 4, 5]

filter

Higher order filter


filter([1, 'hey', '3', 4], !isNaN);
// => [1, 3, 4]

reduce

Higher order reduce


reduce([1, 2, 3, 4], (i, j) => i + j);
// => 10

foreach

Higher order forEach


forEach([1, 2, 3, 4], i => console.log (i))
// => 1
// => 2
// => 3
// => 4

reverse

Higher order reverse


reverse([1, 2, 3])
// => [3, 2, 1]

id

Return true if the value is not 0, undefined or null


filter([1, null, 4, undefined, 'Hello'], id)
// => [1, 4, 'Hello']

complement

Negates a function


let isNumber = complement(isNaN);
isNumber(1)
// => true

range

Yields a range from min to max by step


[...range(0, 10)]
// => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

times

Performs an action n times


times(3, () => console.log ('Hello'))
// => Hello
// => Hello
// => Hello

flatten

Flatten an array


flatten([1, 2, 3, [4, [5, [6, [7, [8, 9]]]]]])
// => [1, 2, 3, 4, 5, 6, 7, 8, 9]

partial

Take a function fn and an array of args with empty spaces and returns a partial function g that take a single arg


let rgb = (r, g, b) => [r, g, b];
let varyGreen = partial(rgb, 4, null, 5);

varyGreen(4)
// => rgb(4, 4, 5);

thread

Pass a value to a list of function, one function at a time

thread(
  1,
  i => i + 1,
  i => i - 2
)
// => -1

compose

Return a function that takes a value to be threaded in a list of functions


add3AndMultiply3 = compose(add3, multiply3);
add3AndMultiply3(3);
// => 18

promisify

Transform a callback style function into a Promise style function

let readfile = promisify(fs.readFile)

let text = readfile('./test.txt')
text.then(console.log.bind(console))

isNumber, isArray, isString, isObject

Primitives type checking functions


isNumber('3')
// => true

isString('Hello')
// => true

isArray({name: guillaume})
// => false

Math

dotProduct

Dot product between 2 vectors


dotProduct([1, 2, 3], [4, 5, 6]);
// => 32

addMatrix

Matrix/vector addition


addMatrix(
  [[1, 1, 1, 1],
   [1, 1, 1, 1]],

  [[1, 1, 1, 1],
   [1, 1, 1, 1]]
)
// => [[2, 2, 2, 2], [2, 2, 2, 2]]

getRow

Returns a matrix row as a vector


getRow(
  [[1, 1, 1, 1, 1],
   [2, 2, 2, 2, 2],
   [1, 1, 1, 1, 1],
   [1, 1, 1, 1, 1]],
  1
)
// => [2, 2, 2, 2, 2]

getColumn

Returns a matrix column as a vector


getColumn(
  [[2, 1, 1, 1, 1],
   [2, 1, 1, 1, 1],
   [2, 1, 1, 1, 1],
   [2, 1, 1, 1, 1]],
   0
)
// => [2, 2, 2, 2, 2]

multMatrix

Performs a matricex multiplication

const m1 = [
  [1, 2, 3],
  [4, 5, 6]
];
const m2 = [
  [7, 8],
  [9 , 10],
  [11, 12]
]
multMatrix(m1, m2)
// => [ [58, 64],
//      [139, 154]]

matrixDimensions

Returns a matrix dimensions [rows, columns]


const [rows, columns] = matrixDimensions(myMatrix);

transpose

Transpose a matrix


console.log (transpose([
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]))
// => [   [ 1, 4, 7 ],
//        [ 2, 5, 8 ],
//        [ 3, 6, 9 ]   ]

FAQs

Package last updated on 01 Dec 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc