open-index/open-npm huggingface dataset:
npm package: @kali6o4/currency
Description: Currency tools for Request Network packages.
Latest version: 0.8.2

# @requestnetwork/currency

`@requestnetwork/currency` is a typescript library part of the [Request Network protocol](https://github.com/RequestNetwork/requestNetwork).
It is a collection of tools for the currencies shared between the @requestnetwork packages.

## Installation

```bash
npm install @requestnetwork/currency
```

## Usage

```javascript
import { RequestLogicTypes } from '@requestnetwork/types';
import { Currency, Token } from '@requestnetwork/currency';

const decimals = new Currency({
  type: RequestLogicTypes.CURRENCY.ETH,
  value: 'ETH',
}).getDecimals();

console.log(decimals); // 18

const ETHHash = new Currency({
  type: RequestLogicTypes.CURRENCY.ETH,
  value: 'ETH',
}).getHash();

console.log(ETHHash); // 0xF5AF88e117747e87fC5929F2ff87221B1447652E

// Get currencies from their symbol
const ETHCurrency: RequestLogicTypes.ICurrency = Currency.from('ETH');
const FAUCurrency: RequestLogicTypes.ICurrency = Currency.from('DAI');
// Get currencies from their address
const DAICurrency: RequestLogicTypes.ICurrency = Currency.from(
  '0x6B175474E89094C44Da98b954EedeAC495271d0F',
);

console.log(FAUCurrency.toString()); // FAU-rinkeby
console.log(DAICurrency.toString()); // DAI

// Get a token symbol from its address
const FAUToken = Token.from('0xFab46E002BbF0b4509813474841E0716E6730136');

console.log(FAUToken.symbol); // FAU
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
[Read the contributing guide](/CONTRIBUTING.md)

## License

[MIT](/LICENSE)
npm package: @kaliber/cache
Description: Simple memory cache
Latest version: 3.0.0

# Cache
Simple memory cache function.

## Motivation
Some times you want to cache a value but don't need a complex caching system. This package helps you cache values in side the memory of your application.

## Installation

```
yarn add @kaliber/cache
```

## Usage
```jsx
import fetch from 'node-fetch'
import { createCache } from '@kaliber/cache'

const cache = createCache({ allowReturnExpiredValue: false, expirationTime: 1000 })

function handleRequest(postId) {
  const data = cache({
    cacheKey: ['post', postId],
    async getValue() {
      const response = await fetch(`https://jsonplaceholder.typicode.com/posts/${postId}`)
      return await response.json()
    }
  })

  return data
}
```

## createCache

| Property                | Value  | Description|
| ----------------------- | ------ | ---------- |
| allowReturnExpiredValue | false | if `false` the `expirationTime` will be leading in getting results from the cache |
| allowReturnExpiredValue | true | if `true` the cache is in 'unsafe' safe mode this means that the cache will always return a value even if the cache time is expired. Of course the cache needs to have a value to get value from it. |
| expirationTime          | number | (in milliseconds) this is the time the cache is valid. |

## Disclaimer
This library is intended for internal use, we provide __no__ support, use at your own risk.
npm package: @kaliber/config
Description: Zero dependency, minimal configuration library operating on CONFIG_ENV
Latest version: 0.0.8

A small, simple and dependency-free library for configuration

# Recommendations

Do not use `default.js` for development values that are different in other environments. In other words: only use `default.js` for values that are the same for all environments.

Add `local.js` to your `.gitignore` file.

# Usage

Define a configuration file
```
// config/test.js
module.exports = {
  my_config_value: 'test'
}

```

Use the configuration
```
// index.js
const { my_config_value } = require('@kaliber/config')
console.log(my_config_value)
```

Run the command with the correct environment
```
CONFIG_ENV=test node index.js
```

# Usage from node

Define a configuration file
```
// config/test.js
module.exports = {
  my_config_value: 'test'
}

```

Load the configuration
```
// index.js
const load = require('@kaliber/config/load')
const { my_config_value } = load('test')
console.log(my_config_value)
```

# Usage from the command line

Define a configuration file
```
// config/test.js
module.exports = {
  my_config_value: 'test'
}

```

Run the command with the correct environment
```
./node_modules/.bin/kaliber-config test my_config_value
```

When running in an NPM environment (`scripts` in `package.json`):
```
kaliber-config test my_config_value
```

# Features

### `default.js` and `local.js`

Order:
1. `default.js`
2. `${CONFIG_ENV}.js`
3. `local.js`

So any value from `local.js` will override a value from one of the previous configuration files.

### objects

Any nested objects will be combined.

# Motivation

We used the [config npm package](https://www.npmjs.com/package/config) but ran into trouble with out staging/acceptance environment. In that environment we wanted to compile with `NODE_ENV=production` for performance benefits of certain libraries.

We also ran into trouble when we forgot to set an environment variable, the `config` library provided a default instead of throwing an error.

Another motivation was that we only needed a very simple library, the `config` library is 1750 line file full of usefull options that we did not need.
npm package: @kaliber/elasticsearch
Description: compiles .mapping.js to elasticsearch mappings and helps you query elasticsearch
Latest version: 2.1.2

# Elasticsearch

This package contains a custom render and a set of functions that can be used with @kaliber/build to build mappings. It also holds a set of util functions to query elasticsearch into a more readable format.

## Installation
```
yarn add @kaliber/elasticsearch
```

> **Note**
This library is precompiled using [kaliberjs/pack](https://github.com/kaliberjs/pack). Compiling it a second time will cause this library to stop working. This means for example that you should **not** add it to the `compileWithBabel` array of @kaliber/build.

## Motivation
We like to write clean code. So whe made a set of util functions that help us create more readable mappings and write simple queries to send to the elasticsearch api.

_The renderer is used for an internal plugin. So this is probably not that interesting for everybody. But
the rest of the project can be used without it._

## Usage of the utils
You can find more examples in the `/examples` folder.

_*.mapping.js_
```js
import { text, keyword, object } from '@kaliber/elasticsearch/mapping'

export default {
  mappings: {
    dynamic: 'strict',
    properties: {
      id: keyword(),
      title: text(),
      taxonomy: object({
        title: text(),
        slug: keyword(),
      }),
    }
  }
}
```

_example.js_
```js
import { filter, matchAll, term, search } from '@kaliber/elasticsearch/query'

const searchQuery = 'Waldo'
const taxonomy = 'books'

const query = and(
  searchQuery
    ? search(['title'], searchQuery),
    : matchAll(),
  filter(
    taxonomy && term('taxonomy.slug', taxonomy)
  )
)
```

### Usage of the Renderer
To configure @kaliber/build to use the custom renderer in this package, you have to update the config/default.js file:

```js
kaliber: {
  templateRenderers: {
    mapping: '@kaliber/elasticsearch/mapping-to-php-renderer'
  }
}
```

![](https://media.giphy.com/media/SUp0ZNb0pmL3G65I2k/giphy.gif)

## Releasing a new version
Because this library is used in both the node runtime and webpack environment, the library is precompiled using [kaliberjs/pack](https://github.com/kaliberjs/pack). When releasing a new version, do not forget to execute `yarn build` before running `yarn publish`. This should be done because the yarn publish command uses your local files to upload to the npm registry.

## Disclaimer
This library is intended for internal use, we provide __no__ support, use at your own risk.