open-index/open-npm huggingface dataset:
npm package: @juliancoleman/assoc-by-key
Description: Converts an object of objects into an array of objects with a given predicate.
Author: Julian Coleman
Latest version: 0.0.2

# assoc-by-key

[![Build Status](https://semaphoreci.com/api/v1/juliancoleman/assoc-by-key/branches/master/badge.svg)](https://semaphoreci.com/juliancoleman/assoc-by-key)
[![npm version](https://badge.fury.io/js/%40juliancoleman%2Fassoc-by-key.svg)](https://badge.fury.io/js/%40juliancoleman%2Fassoc-by-key)

A curried function using Ramda that transforms an object of
objects into an array of objects, where the key becomes a
property of that object. The function will return a new
array and will not mutate or destroy the original object.

This function performs the inverse of [index-by-key](https://github.com/juliancoleman/)

## Install

### `yarn`

```sh
yarn add @juliancoleman/assoc-by-key
```

### `npm`

```sh
npm i -S @juliancoleman/assoc-by-key
```

### Setup

This package provides the single function mentioned above.
You can specify the key on `require`, or you can specify a
key to `assoc` by later on.

```js
// initialize without specified key
const assocByKey = require("@juliancoleman/assoc-by-key");

// initialize with specified key at require
const assocById = require("@juliancoleman/assoc-by-key")("id");

// initialize with specified key later
const assocByFirstName = assocByKey("first_name");
```

Once required and a key is specified, you can then call the
function on your data to see the transformation. Again, the
function will return a new array and will not mutate or
destroy the original object.

Below is an example use on a `Promise` object returned by a
database call:

```js
const assocByKey = require("@juliancoleman/assoc-by-key");

const { getUsers } = appRequire("path/to/API");

(async () => {
  const assocById = assocByKey("id");
  const users = await getUsers();

  /*
  Example `users`

    { "1": { "first_name": "Julian",
              "last_name": "Coleman",
              "email_address": "julcol03@gmail.com"
            },
      "2": { "first_name": "Bob",
              "last_name": "Sagget",
              "email_address": "bob@sagget.com" } }
  */

  if (!users) {
    throw new Error("Unable to retrieve users");
  }

  return assocById(users);

})();

/*
results in the following output

[ { "id": 1,
    "first_name": "Julian",
    "last_name": "Coleman",
    "email_address": "julcol03@gmail.com" },
  { "id": 2,
    "first_name": "Bob",
    "last_name": "Sagget",
    "email_address": "bob@sagget.com" } ]
*/
```

Alternatively, this same thing can be achieved by doing the
following:

```js
API
  .getUser()
  .then(assocByKey("id"))
  .catch(UserNotFoundError, () => 404);
```
npm package: @juliancoleman/hapi-route-autoloader
Description: Loads Hapi routes according to js-hapi-api project structure.
Author: Edward Bramanti
Latest version: 1.0.3

Hapi Route Autoloader
===============================
[![Build Status](https://semaphoreci.com/api/v1/videoamp/hapi-route-autoloader/branches/master/badge.svg)](https://semaphoreci.com/videoamp/hapi-route-autoloader)
[![npm version](https://badge.fury.io/js/%40videoamp%2Fhapi-route-autoloader.svg)](https://badge.fury.io/js/%40videoamp%2Fhapi-route-autoloader)

A Hapi plugin that provides an auto-loader for Hapi routes from a specified directory.

## Install
## `yarn`
```sh
yarn add @videoamp/hapi-route-autoloader
```
## `npm`
```sh
npm install --save @videoamp/hapi-route-autoloader
```

## Setup
This package provides a Hapi plugin which loads routes according from the
directory provided to the function. This allows you to customize the directory
to load from on a per-project basis.

To use the Hapi plugin, you can require the package directly in `server.register`.
An example of server setup is below:

```js
var Hapi = require('hapi');
var server = new Hapi.Server({ port: 8000 });

server.register(require("@videoamp/hapi-route-autoloader")("controllers/"))
    .then(() => server.start());
```

## Folder Structure
Files inside of the specified directory can export either an array of routes or a single
route object. See [the fixtures folder](https://github.com/VideoAmp/hapi-route-autoloader/tree/master/test/fixtures) in `test/` for an example.
npm package: @juliancoleman/index-by-key
Description: Converts an array of objects into an object of objects with a given predicate.
Author: Julian Coleman
Latest version: 0.0.1

# Index By Key

[![Build Status](https://semaphoreci.com/api/v1/juliancoleman/index-by-key/branches/master/badge.svg)](https://semaphoreci.com/juliancoleman/index-by-key)
[![npm version](https://badge.fury.io/js/%40juliancoleman%2Findex-by-key.svg)](https://badge.fury.io/js/%40juliancoleman%2Findex-by-key)

A curried function using Ramda that transforms an array of
objects into an object of objects, where the key is the key
specified and the value is the rest of the object. The
function will return a new object and will not mutate or
destroy the original array.

## Install

### `yarn`

```sh
yarn add @juliancoleman/index-by-key
```

### `npm`

```sh
npm i -S @juliancoleman/index-by-key
```

### Setup

This package provides the single function mentioned above.
You can specify the key on `require`, or you can specify a
key to `indexBy` later on.

```js
// initialize without specified key
const indexByKey = require("@juliancoleman/index-by-key");

// initialize with specified key at require
const indexById = require("@juliancoleman/index-by-key")("id");

// initialize with specified key later
const indexByFirstName = indexByKey("first_name");
```

Once required and a key is specified, you can then call the
function on your data to see the transformation. Again, the
function will return a new object and will not mutate or
destroy the original array.

Below is an example use on a `Promise` object returned by
an asynchronous database call:

```js
const indexByKey = require("@juliancoleman/index-by-key");

const { getUsers } = appRequire("path/to/API");

(async () => {
  const indexById = indexByKey("id");
  const users = await getUsers();

  /*
  Example `users`

  [ { "id": 1,
      "first_name": "Julian",
      "last_name": "Coleman",
      "email_address": "julcol03@gmail.com" },
    { "id": 2,
      "first_name": "Bob",
      "last_name": "Sagget",
      "email_address": "bob@sagget.com" } ]
  */

  if (!users) {
    throw new Error("Unable to retrieve users");
  }

  return indexById(users);

})();

/*
results in the following output

  { "1": { "first_name": "Julian",
           "last_name": "Coleman",
           "email_address": "julcol03@gmail.com"
         },
    "2": { "first_name": "Bob",
           "last_name": "Sagget",
           "email_address": "bob@sagget.com" } }
*/
```

Alternatively, this same thing can be achieved by doing the
following:

```js
API.getUsers().then(indexByKey("id"));
```
npm package: @juliancoleman/named-error
Description: A tiny library for creating custom errors
Author: Julian Coleman
Latest version: 1.0.0

# Named Error

A tiny library for creating custom errors for use with
[Bluebird's filtered catch](http://bluebirdjs.com/docs/api/catch.html#filtered-catch)

## Example

```ts
import NamedError from "@juliancoleman/named-error";

// Instantiate with `new`
const NotFoundError = new NamedError(404, "Not found.");
```

This library is also particularly useful with APIs that use
an ORM, such as ObjectionJS.

```ts
import Base from "./base";

import NamedError from "@juliancoleman/named-error";

export class UserNotFoundError extends NamedError { }

export default class User extends Base {
  static tableName = "users";
  static NotFoundError = new UserNotFoundError(404, "User not found.");

  // ...
}
```

And when we need to catch

```ts
import Service from "../services/some-service";
import NotFoundError from "../errors/not-found-error";

Service.getThatOneThing() // Returns a Bluebird promise
  .then(doSomethingWithReturnedData)
  .catch(TypeError, NotFoundError, function(e) {
    // Generic catch-all for unexpected errors
  });
```