open-index/open-npm huggingface dataset:
npm package: @tadasauciunas/aws-lambda-libreoffice
Description: 92 MB LibreOffice to fit inside AWS Lambda compressed with Brotli
Author: Vlad Holubiev
Latest version: 3.0.4

# aws-lambda-libreoffice ![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)

> 85 MB LibreOffice to fit inside AWS Lambda compressed with Brotli

Inspired by [chrome-aws-lambda](https://github.com/alixaxel/chrome-aws-lambda)

:information_source: Compiled LibreOffice version: 6.4.0.1

## Install

```
$ yarn add @shelf/aws-lambda-libreoffice
```

**NOTE:** Since version 2.0.0 npm package no longer ships the 85 MB LibreOffice but relies upon [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) instead.
Follow the instructions on how to add a lambda layer in [that repo](https://github.com/shelfio/libreoffice-lambda-layer).

## Usage

```js
const {convertTo, canBeConvertedToPDF} = require('@shelf/aws-lambda-libreoffice');

module.exports.handler = async () => {
  // assuming there is a document.docx file inside /tmp dir
  // original file will be deleted afterwards

  if (!canBeConvertedToPDF('document.docx')) {
    return false;
  }

  return convertTo('document.docx', 'pdf'); // returns /tmp/document.pdf
};
```

Or if you want more control:

```js
const {unpack, defaultArgs} = require('@shelf/aws-lambda-libreoffice');

await unpack(); // default path /tmp/instdir/program/soffice.bin

execSync(
  `/tmp/instdir/program/soffice.bin ${defaultArgs.join(
    ' '
  )} --convert-to pdf file.docx --outdir /tmp`
);
```

## See Also

- [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer)
- [serverless-libreoffice](https://github.com/vladgolubev/serverless-libreoffice)
- [aws-lambda-tesseract](https://github.com/shelfio/aws-lambda-tesseract)
- [aws-lambda-brotli-unpacker](https://github.com/shelfio/aws-lambda-brotli-unpacker)
- [chrome-aws-lambda](https://github.com/alixaxel/chrome-aws-lambda)

### Test

Smoke test that it works: `./test.sh`.
Make sure to clone [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) repo alongside

## License

MIT © [Shelf](https://shelf.io)
npm package: @tadashi/cache-redis
Description: Using redis as cache
Author: Thiago Lagden
Latest version: 7.0.1

# cache-redis

[![NPM version][npm-img]][npm]
[![Node.js CI][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]
[![Snyk badge][snyk-img]][snyk]

[npm-img]:         https://img.shields.io/npm/v/@tadashi/cache-redis.svg
[npm]:             https://www.npmjs.com/package/@tadashi/cache-redis
[ci-img]:          https://github.com/lagden/cache-redis/actions/workflows/nodejs.yml/badge.svg
[ci]:              https://github.com/lagden/cache-redis/actions/workflows/nodejs.yml
[coveralls-img]:   https://coveralls.io/repos/github/lagden/cache-redis/badge.svg?branch=main
[coveralls]:       https://coveralls.io/github/lagden/cache-redis?branch=main
[snyk-img]:        https://snyk.io/test/github/lagden/cache-redis/badge.svg
[snyk]:            https://snyk.io/test/github/lagden/cache-redis


Making cache with Redis


## Install

```
$ npm i @tadashi/cache-redis
```


## API

### new Cache( \[opts\])

| parameter | type        | required | default            | description       |
| --------- | ----------- | -------- | ------------------ | ----------------- |
| opts      | Object      | no       | [see below](#opts) | Options for configuring the cache. |


#### opts

| parameter      | type             | required | default        | description                             |
| -------------- | ---------------- | -------- | -------------- | --------------------------------------- |
| address        | String\|String[] | no       | 127.0.0.1:6379 | The address of the Redis server.        |
| namespace      | String           | no       | app            | A namespace for the cache keys.         |
| redisOptions   | Object           | no       | -              | [See configuration options](https://redis.github.io/ioredis/interfaces/CommonRedisOptions.html) |


### Cluster

To use `Cluster`, set addresses separated by commas or an array and set [clusterOptions](https://redis.github.io/ioredis/interfaces/ClusterOptions.html).

```js
import Cache from '@tadashi/cache-redis'

const cache = new Cache({
  address: '127.0.0.1:6379, 127.0.0.1:6380, 127.0.0.1:6381',
  // or
  address: ['127.0.0.1:6379', '127.0.0.1:6380', '127.0.0.1:6381'],
  // and
  redisOptions: {
    clusterOptions: {
      retryDelayOnClusterDown: 500,
      // ...
    }
  }
})
```


## Usage

```js
import Cache from '@tadashi/cache-redis'

const _cache = new Cache({
  redisOptions: {
    keyPrefix: 'api'
  },
  namespace: 'example'
})

async function find(key) {
  try {
    const cache = await _cache.get(key)
    if (cache) {
      return cache
    }
    const result = await getDataFromSomeWhere(key)
    await _cache.set(key, result, 'PX', 3600)
    return result
  } catch (err) {
    throw err
  }
}


await find('foo')
// => data from getDataFromSomeWhere

await find('foo')
// => data from cache
```

---

> [!IMPORTANT]  
> Buy me a coffee!  
> BTC: `bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4`


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/doc
Description: Validate CPF/CNPJ.
Author: Thiago Lagden
Latest version: 1.0.1

# doc

[![NPM version][npm-img]][npm]
[![Node.js CI][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]

[![XO code style][xo-img]][xo]

[npm-img]:         https://img.shields.io/npm/v/@tadashi/doc.svg
[npm]:             https://www.npmjs.com/package/@tadashi/doc
[ci-img]:          https://github.com/lagden/doc/workflows/Node.js%20CI/badge.svg
[ci]:              https://github.com/lagden/doc/actions?query=workflow%3A%22Node.js+CI%22
[coveralls-img]:   https://coveralls.io/repos/github/lagden/doc/badge.svg?branch=main
[coveralls]:       https://coveralls.io/github/lagden/doc?branch=main
[xo-img]:          https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]:              https://github.com/sindresorhus/xo


Validate CPF/CNPJ.


## Install

```
$ npm i @tadashi/doc
```


## API

```ts
onlyNumber(c: string): Array<number>
isCnpj(c: string): boolean
isCpf(c: string): boolean
```


## Usage

```js
import {isCnpj, isCpf, onlyNumber} from '@tadashi/doc'

isCpf('090.885.670-93')      // => true
isCnpj('29.249.091/0001-85') // => true
onlyNumber('1.2.3')          // => [1, 2, 3]
```


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/ee
Description: EventEmitter Singleton
Author: Thiago Lagden
Latest version: 1.1.0

# @tadashi/ee

[![NPM version][npm-img]][npm] [![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]

[npm-img]: https://img.shields.io/npm/v/@tadashi/ee.svg
[npm]: https://www.npmjs.com/package/@tadashi/ee
[ci-img]: https://github.com/lagden/ee/actions/workflows/nodejs.yml/badge.svg
[ci]: https://github.com/lagden/ee/actions/workflows/nodejs.yml
[coveralls-img]: https://coveralls.io/repos/github/lagden/ee/badge.svg?branch=main
[coveralls]: https://coveralls.io/github/lagden/ee?branch=main

---

EventEmitter Singleton

## Install

```
$ npm i @tadashi/ee
```

## Usage

```js
// log.js
import ee from '@tadashi/ee'

function _log(data) {
  console.log(data)
}

ee.on('logger', _log)

// ---

// app.js
import ee from '@tadashi/ee'

ee.emit('logger', {
  message: 'apenas um show',
})
```

## Donate ❤️

- BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4

## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/flatten-object
Description: Flattens object a single level deep
Author: Thiago Lagden
Latest version: 3.1.0

# Flatten

[![NPM version][npm-img]][npm]
[![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]
[![XO code style][xo-img]][xo]


[npm-img]:         https://img.shields.io/npm/v/@tadashi/flatten-object.svg
[npm]:             https://www.npmjs.com/package/@tadashi/flatten-object
[ci-img]:          https://travis-ci.org/lagden/flatten-object.svg
[ci]:              https://travis-ci.org/lagden/flatten-object
[coveralls-img]:   https://coveralls.io/repos/github/lagden/flatten-object/badge.svg?branch=master
[coveralls]:       https://coveralls.io/github/lagden/flatten-object?branch=master
[xo-img]:          https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]:              https://github.com/sindresorhus/xo

-----

Flattens object a single level deep

## Install

```
$ npm i -S @tadashi/flatten-object
```


## Usage

```js
import flatten from '@tadashi/flatten-object'

const flat = flatten({
  a: {
    b: {
      c: 'foo'
    },
    d: 'bar'
  }
}, '__')
// => {a__b__c: 'foo', a__d: 'bar'}
```


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/graylog
Description: Send logs to graylog
Author: Thiago Lagden
Latest version: 1.1.0

# @tadashi/graylog

[![NPM version][npm-img]][npm]
[![Node.js CI][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]

[npm-img]:         https://img.shields.io/npm/v/@tadashi/graylog.svg
[npm]:             https://www.npmjs.com/package/@tadashi/graylog
[ci-img]:          https://github.com/lagden/graylog/actions/workflows/nodejs.yml/badge.svg
[ci]:              https://github.com/lagden/graylog/actions/workflows/nodejs.yml
[coveralls-img]:   https://coveralls.io/repos/github/lagden/graylog/badge.svg?branch=main
[coveralls]:       https://coveralls.io/github/lagden/graylog?branch=main


Publishing application logs to Graylog.


## Install

```
$ npm i -S @tadashi/graylog
```

## API

### Environment variables available

- TADASHI_GRAYLOG = 1


### createLogger(name, \[options\]): Logger

> Type: Logger


#### name 

> Type: string

The log's name.


#### options 

> Type: object  
> Default: {}

See the options here:  
https://github.com/deepal/node-gelfy#gelfycreateoptions


## Usage

```js
import createLogger from '@tadashi/graylog'

const logger = createLogger('example', {
  host: '127.0.0.1'
})

logger.on('error', () => {
  process.stderr.write('error...')
})

logger.info({
  message: 'Show the info',
  custom_prop: '...'
})
```


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/hex
Description: Encode and decode
Author: Thiago Lagden
Latest version: 2.0.0

# Hex

[![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]
<!-- [![devDependency Status][devDep-img]][devDep] -->
[![XO code style][xo-img]][xo]

[ci-img]:        https://travis-ci.org/lagden/hex.svg
[ci]:            https://travis-ci.org/lagden/hex
[coveralls-img]: https://coveralls.io/repos/github/lagden/hex/badge.svg?branch=master
[coveralls]:     https://coveralls.io/github/lagden/hex?branch=master
[xo-img]:        https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]:            https://github.com/sindresorhus/xo


Encode and decode


## Install

```
$ npm i -S @tadashi/hex
```


## Usage

```js
const {encode, decode} = require('@lagden/hex')

encode('Tadashi') // \u0054\u0061\u0064\u0061\u0073\u0068\u0069
decode('\u0054\u0061\u0064\u0061\u0073\u0068\u0069') // Tadashi

/* or */

encode('😃', false) // d83dde03
decode('d83dde03', false) // 😃
```

## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/injection
Description: Inject data into file
Author: Thiago Lagden
Latest version: 2.0.1

# Injection

[![NPM version][npm-img]][npm]
[![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]
[![XO code style][xo-img]][xo]


[npm-img]:         https://img.shields.io/npm/v/@tadashi/injection.svg
[npm]:             https://www.npmjs.com/package/@tadashi/injection
[ci-img]:          https://travis-ci.org/lagden/injection.svg
[ci]:              https://travis-ci.org/lagden/injection
[coveralls-img]:   https://coveralls.io/repos/github/lagden/injection/badge.svg?branch=master
[coveralls]:       https://coveralls.io/github/lagden/injection?branch=master
[xo-img]:          https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]:              https://github.com/sindresorhus/xo


Inject data into file


## Install

```
$ npm i -S @tadashi/injection
```


## Sample

This is the file that will be inject: `script.js`  
```js
const a = 'Horray';
alert(a);
```

This is the source file with the markup showing where is the place will be injected: `input.html`  
```html
<body>
  <script>/* inject: ./script.js */</script>
</body>
```

Making injection specifying the output file  
```js
const injection = require('@tadashi/injection');

(async () => {
  await injection('./input.html', './output.html', '\/\\*\\sinject:\\s([\\w./]+)\\s\\*\\/')
})()
```

Result: `output.html`  
```html
<body><script>const a = 'Horray';alert(a);</script></body>
```


### API

#### injection(input[, output][, pattern])

Name        | Type                 | Required    | Default                             | Description
----------- | -------------------- | :---------: | :---------------------------------: | ------------
input       | string               | yes         | -                                   | Source file
output      | string               | no          | ./out                               | Result file
pattern     | string               | no          | `<!--\\sinject:\\s([\\w./]+)\\s-->` | RegExp pattern


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/json2mongo
Description: A MongoDB Extended JSON conversion utility which converts Strict Mode syntax to JavaScript Mode
Author: Thomas Watson Steen
Latest version: 4.0.0

# json2mongo

This is a [MongoDB Extended
JSON](http://docs.mongodb.org/manual/reference/mongodb-extended-json/)
convertion utility which converts Strict Mode syntax to JavaScript Mode.


## Installation

```
npm install @tadashi/json2mongo --save
```

## Example usage

```javascript
import json2mongo from '@tadashi/json2mongo'

const query = {
  created: { $date: '2013-01-01T00:00:00.000Z' },
  foo: { $undefined: true },
  bar: { $regex: '[0-9]' },
  baz: { $regex: '[a-z]', $options: 'i' }
}

json2mongo(query); // {
                   //   created: new Date('2013-01-01T00:00:00.000Z'),
                   //   foo: undefined,
                   //   bar: /[0-9]/,
                   //   baz: /[a-z]/i
                   // }
```

## License

MIT © [Thomas Watson Steen](https://github.com/watson)  
MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/jsonb
Description: Compress or decompress any data
Author: Thiago Lagden
Latest version: 5.0.1

# jsonb

[![NPM version][npm-img]][npm]
[![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]


[npm-img]:         https://img.shields.io/npm/v/@tadashi/jsonb.svg
[npm]:             https://www.npmjs.com/package/@tadashi/jsonb
[ci-img]:          https://github.com/lagden/jsonb/actions/workflows/nodejs.yml/badge.svg
[ci]:              https://github.com/lagden/jsonb/actions/workflows/nodejs.yml
[coveralls-img]:   https://coveralls.io/repos/github/lagden/jsonb/badge.svg?branch=master
[coveralls]:       https://coveralls.io/github/lagden/jsonb?branch=master


-----

Compress or decompress any data

## Install

```
$ npm i -S @tadashi/jsonb
```


## Usage

```js
import {compress, decompress} from '@tadashi/jsonb'

const c = await compress({a: 'foo', b: 'bar'})
// => Cw2AW3siYSI6MSwiYiI6Mn0sImZvbyIsImJhciJdAw==

const d = await decompress(c)
// => {a: 'foo', b: 'bar'}
```


## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/koa-base
Description: A web server with sugar
Author: Thiago Lagden
Latest version: 5.4.0

# Koa Base

[![NPM version][npm-img]][npm]
[![Build Status][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]

[npm-img]: https://img.shields.io/npm/v/@tadashi/koa-base.svg
[npm]: https://www.npmjs.com/package/@tadashi/koa-base
[ci-img]: https://github.com/lagden/koa-base/actions/workflows/nodejs.yml/badge.svg
[ci]: https://github.com/lagden/koa-base/actions/workflows/nodejs.yml
[coveralls-img]: https://coveralls.io/repos/github/lagden/koa-base/badge.svg?branch=master
[coveralls]: https://coveralls.io/github/lagden/koa-base?branch=master

Basic setup with [Koa](https://github.com/koajs/koa)

## Install

```
$ npm i @tadashi/koa-base
```

## Middleware

Middleware list pre installed

- [@tadashi/koa-error](https://github.com/lagden/koa-error)
- [@koa/cors](https://github.com/koajs/cors)
- [koa-compress](https://github.com/koajs/compress)
- [koa-conditional-get](https://github.com/koajs/conditional-get)
- [koa-etag](https://github.com/koajs/etag)

## Usage

```js
import app from '@tadashi/koa-base'

const options = {
  error: true,
}

const ignore = ['cors']

app(options, ignore)
  .use(ctx => {
    ctx.throw(401)
  })
  .on('error', err => {
    console.log(err.message) // Unauthorized
  })
```

## API

createApp( [opts] [, ignore ])

| Name   | Type   | Default    | Description        |
| ------ | ------ | ---------- | ------------------ |
| opts   | object | See bellow | Middleware options |
| ignore | array  | []         | Ignored middleware |

### opts

#### Default

```json
{
  "error": false,
  "compress": {},
  "cors": {}
}
```

---

See the options in the middleware itself

| Parameter | Middleware                                                |
| --------- | --------------------------------------------------------- |
| error     | [@tadashi/koa-error](https://github.com/lagden/koa-error) |
| compress  | [koa-compress](https://github.com/koajs/compress)         |
| cors      | [kcors](https://github.com/koajs/cors)                    |

## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/mysql-pool
Description: MySQL Pooling connections
Author: Thiago Lagden
Latest version: 3.0.0

# mysql-pool

[![NPM version][npm-img]][npm] [![Build Status][ci-img]][ci] [![Coverage Status][coveralls-img]][coveralls]

[npm-img]: https://img.shields.io/npm/v/@tadashi/mysql-pool.svg
[npm]: https://www.npmjs.com/package/@tadashi/mysql-pool
[ci-img]: https://github.com/lagden/mysql-pool/actions/workflows/nodejs.yml/badge.svg
[ci]: https://github.com/lagden/mysql-pool/actions/workflows/nodejs.yml
[coveralls-img]: https://coveralls.io/repos/github/lagden/mysql-pool/badge.svg?branch=master
[coveralls]: https://coveralls.io/github/lagden/mysql-pool?branch=master

Make pooling connections with [MySQL](https://sidorares.github.io/node-mysql2/docs/examples/connections/create-pool#pooloptions)

## Install

```
$ npm i @tadashi/mysql-pool
```

## Environment variable

| Variable             | Type    | Required | Default   | Description                         |
| -------------------- | ------- | -------- | --------- | ----------------------------------- |
| MYHOST               | string  | no       | localhost | Hostname or server address          |
| MYPORT               | number  | no       | 3306      | Port number for the connection      |
| MYUSER               | string  | no       | root      | User authentication                 |
| MYPASS               | string  | no       |           | Authentication password             |
| MYLIMIT              | number  | no       | 5         | Limit or threshold value            |
| MYCONNECTTIMEOUT     | number  | no       | 30000     | Connection timeout in milliseconds  |
| MYMULTIPLE           | boolean | no       | true      | Allowing multiple statements        |
| MYWAITFORCONNECTIONS | boolean | no       | true      | Waiting for available connections   |
| MYENCODE             | number  | no       | 0         | MYUSER and MYPASS encoded in base64 |

## Usage

```js
import MysqlPool from '@tadashi/mysql-pool'

const pool = new MysqlPool() // => https://sidorares.github.io/node-mysql2/docs/examples/connections/create-pool
const { results: [{ total }] } = await pool.query('SELECT 1 + ? as total', [1])
// => 2

// Closing all the connections in a pool
await pool.end()
```

## Team

[<img src="https://avatars.githubusercontent.com/u/130963?s=390" alt="Lagden" width="90">](https://github.com/lagden)

---

> [!IMPORTANT]\
> Buy me a coffee!\
> BTC: `bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4`

## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/request
Description: Request library for Node.js
Author: Thiago Lagden
Latest version: 1.1.0

# Request

[![NPM version][npm-img]][npm] [![Build Status][ci-img]][ci] [![Coverage Status][coveralls-img]][coveralls]

[npm-img]: https://img.shields.io/npm/v/@tadashi/request.svg
[npm]: https://www.npmjs.com/package/@tadashi/request
[ci-img]: https://github.com/lagden/request/actions/workflows/nodejs.yml/badge.svg
[ci]: https://github.com/lagden/request/actions/workflows/nodejs.yml
[coveralls-img]: https://coveralls.io/repos/github/lagden/request/badge.svg?branch=main
[coveralls]: https://coveralls.io/github/lagden/request?branch=main

---

Request library.

## Install

```
$ npm i @tadashi/request
```

## Usage

```js
import request from '@tadashi/request'

const obj = await request('https://registry.npmjs.org/@tadashi/request/latest')
// obj.name => '@tadashi/request'
```

## Team

[<img src="https://avatars.githubusercontent.com/u/130963?s=390" alt="Lagden" width="90">](https://github.com/lagden)

---

> [!IMPORTANT]\
> Buy me a coffee!\
> BTC: `bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4`

## License

MIT © [Thiago Lagden](https://github.com/lagden)
npm package: @tadashi/rollup-plugin-env
Description: Injects environment variables
Author: Thiago Lagden
Latest version: 0.1.2

# rollup-plugin-env

Injects environment variables


## Install

```
npm i -D @tadashi/rollup-plugin-env
```


## Usage

```js
import envs from '@tadashi/rollup-plugin-env'
import {rollup} from 'rollup'

const {
  ENDPOINT,
  VERSION
} = process.env

rollup({
  entry: 'src/index.js',
  plugins: [
    envs(APP_NAMESPACE, {
      ENDPOINT,
      VERSION
    })
  ]
}).then(/* ... */)
```


## License

MIT