# something-something

> a little asynchronous functional programming library.

Latest version **0.0.1** (published 2014-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install something-something
pnpm add something-something
yarn add something-something
bun add something-something
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-07-14 |
| First published | 2014-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrew Couch |
| Maintainers | couchand |
| Keywords | async, asynchronous, functional, collection, map, reduce, filter |

## Links

- npm: https://www.npmjs.com/package/something-something
- Repository: https://github.com/couchand/something-something
- Issues: https://github.com/couchand/something-something/issues
- npm.io page: https://npm.io/package/something-something

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2014-07-14

## README

something something
===================

*go crazy?  don't mind if i do...*

a little asynchronous functional programming library.

  * [why?](#why)
  * [how?](#how)
  * [what?](#what)

why?
----

There are plenty of collections libraries out there (think
[underscore][0], [lodash][1], etc) and plenty of asynchronous ones
([async][2] comes to mind), but none of them seem to support
asynchronous mapping over plain old JavaScript objects.  So I wrote
this for that use-case, and while I was at it generalized it to
handle both objects and arrays.

how?
----

Use NPM to install.  Other package managers welcome, please submit a
pull request to support your favorite.

```sh
# npm
npm install --save something-something
```

Require it in your project and start asynchronizing.

```coffeescript
__ = require 'something-something'

double = (value, cb) -> cb null, value * 2
ba_s = (key, value, cb) -> cb null, /ba./.test key

original =
  foo: 1
  bar: 2
  baz: 3

__.map original, double, (error, doubled) ->
  __.filter doubled, ba_s, (error, result) ->
    assert Object.keys(result).length is 2
    assert result.bar is 4
    assert result.baz is 6
```

Simple, right?

what?
-----

The standard functional collections methods are here.

  * [map](#map)
  * [filter](#filter)
  * [any](#any)
  * [all](#all)
  * [what, no reduce?](#what-no-reduce)

All methods work equally well for arrays and objects.

### map ###

```
__.map(collection, iterator, [complete])

collection = Array
           | Object
iterator   = (value, cb) -> result
           | (key, value, cb) -> result
           | (key, value, collection, cb) -> result
complete   = (error, results) ->
```

Standard `map` function, known in some circles as `collect`.  The
iterator function is called for each element in the collection.  Its
behavior is guessed from the airity of the function, so don't try any
fancy business with `arguments` here.

The complete callback is called with the `results` collection once
every iteration is complete.  If any iteration callsback with an error
the map immediately fails, calling back with that error.

### filter ###

```
__.filter(collection, predicate, [complete])

collection = Array
           | Object
predicate  = (value, cb) -> Boolean
           | (key, value, cb) -> Boolean
           | (key, value, collection, cb) -> Boolean
complete   = (error, results) ->
```

Standard `filter` function, also known as `select`.  The predicate
is called for each element in the collection.  Again its behavior is
assumed based on the airity.  The result is coerced to a Boolean.

The complete callback is called with the filtered `results` once
every predicate is complete.  If any predicate callsback with an error
the filter immediately fails, calling back with that error.

### any ###

```
__.any(collection, predicate, [complete])

collection = Array
           | Object
predicate  = (value, cb) -> Boolean
           | (key, value, cb) -> Boolean
           | (key, value, collection, cb) -> Boolean
complete   = (error, result) ->
```

Short-circuiting boolean or (aka `some`).  Callsback `true` as soon as
any of the predicates callsback `true`.  Callsback `false` if every
predicate callsback `false`.

Callsback with an error if any predicate callsback in error before one
callsback `true`.  This means it swallows some errors and not others,
which may not be desirable.

### all ###

```
collection = Array
           | Object
predicate  = (value, cb) -> Boolean
           | (key, value, cb) -> Boolean
           | (key, value, collection, cb) -> Boolean
complete   = (error, result) ->
```

Short-circuiting boolean and (aka `every`).  Callsback `false` as soon
as a single predicate callsback `false`.  Callsback `true` if every
predicate callsback `true`.

Callsback with an error if any predicate callsback in error before one
callsback `false`.  This means it swallows some errors and not others,
which may not be desirable.

### what, no reduce? ###

This library is about eagerly evaluating a sequence of asynchronous
callbacks massively parallel.  Reduce is by nature a series algorithm.
If you think there's a good way to write reduce in the same style as
the other methods please do submit a pull request.

##### ╭╮☲☲☲╭╮ #####

[0]: http://underscorejs.org
[1]: http://lodash.com
[2]: https://github.com/caolan/async

---
_Source: https://npm.io/package/something-something · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
