New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bidon

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bidon - npm Package Compare versions

Comparing version 3.3.1 to 3.3.2

8

CHANGELOG.md

@@ -0,1 +1,9 @@

<a name="3.3.2"></a>
## [3.3.2](https://github.com/guillaumearm/bidon/compare/v3.3.1...v3.3.2) (2018-03-16)
### Bug Fixes
* revert readme ([86f2743](https://github.com/guillaumearm/bidon/commit/86f2743))
<a name="3.3.1"></a>

@@ -2,0 +10,0 @@ ## [3.3.1](https://github.com/guillaumearm/bidon/compare/v3.3.0...v3.3.1) (2018-03-16)

2

dist/cli.js
#!/usr/bin/env node
'use strict';
var version = "3.3.1";
var version = "3.3.2";

@@ -6,0 +6,0 @@ function main$1() {

@@ -7,3 +7,3 @@ (function (global, factory) {

var version = "3.3.1";
var version = "3.3.2";

@@ -10,0 +10,0 @@ function main$1() {

@@ -1,2 +0,2 @@

var version = "3.3.1";
var version = "3.3.2";

@@ -3,0 +3,0 @@ function main$1() {

'use strict';
var version = "3.3.1";
var version = "3.3.2";

@@ -5,0 +5,0 @@ function main$1() {

{
"name": "bidon",
"version": "3.3.1",
"version": "3.3.2",
"description": "Fake repository for testing ci tools",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -1,197 +0,14 @@

handle-io :sparkles: *[WIP]*
===============
[![CircleCI branch](https://img.shields.io/circleci/project/github/guillaumearm/handle-io/master.svg)](https://circleci.com/gh/guillaumearm/handle-io)
[![codecov](https://codecov.io/gh/guillaumearm/handle-io/branch/master/graph/badge.svg)](https://codecov.io/gh/guillaumearm/handle-io)
[![npm](https://img.shields.io/npm/v/handle-io.svg)](https://www.npmjs.com/package/handle-io)
[![Greenkeeper badge](https://badges.greenkeeper.io/guillaumearm/handle-io.svg)](https://greenkeeper.io/)
[![NSP Status](https://nodesecurity.io/orgs/trapcodien/projects/b050060a-8207-40cc-a229-89efb0e8cee0/badge)](https://nodesecurity.io/orgs/trapcodien/projects/b050060a-8207-40cc-a229-89efb0e8cee0)
[![dependencies Status](https://david-dm.org/guillaumearm/handle-io/status.svg)](https://david-dm.org/guillaumearm/handle-io)
[![devDependencies Status](https://david-dm.org/guillaumearm/handle-io/dev-status.svg)](https://david-dm.org/guillaumearm/handle-io?type=dev)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/guillaumearm/handle-io/blob/master/CONTRIBUTING.md)
bidon
======================
[![CircleCI](https://img.shields.io/circleci/project/github/guillaumearm/bidon.svg)](https://circleci.com/gh/guillaumearm/bidon)
[![npm](https://img.shields.io/npm/v/bidon.svg)](https://www.npmjs.com/package/bidon)
[![dependencies Status](https://david-dm.org/guillaumearm/bidon/status.svg)](https://david-dm.org/guillaumearm/bidon )
[![devDependencies Status](https://david-dm.org/guillaumearm/bidon/dev-status.svg)](https://david-dm.org/guillaumearm/bidon?type=dev)
[![NSP Status](https://nodesecurity.io/orgs/trapcodien/projects/e29ffd03-8631-4205-b225-39275e8a7bd3/badge)](https://nodesecurity.io/orgs/trapcodien/projects/e29ffd03-8631-4205-b225-39275e8a7bd3)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
Highly inspired by [funkia/io](https://github.com/funkia/io) and [redux-saga](https://github.com/redux-saga/redux-saga), this library intends to wrap small pieces of impure code, orchestrates and tests them.
## Purpose
Fake repository for testing ci tools.
:chocolate_bar: :chocolate_bar: :chocolate_bar:
### Test side effects orchestration without pain
```js
testHandler(logTwice('hello world'))
.matchIo(log('hello world'))
.matchIo(log('hello world'))
.run()
```
This piece of code is an assertion, an error will be throw if something go wrong :
- wrong io
- wrong io arguments
- too much runned io
- not enough runned io
# Getting started
## Install (not published on npm yet)
```js
npm install --save guillaumearm/handle-io.git
```
### IO
io is just a wrapper for functions and arguments.
In some way, it transforms impure functions into pure functions
Conceptually, an io just could be :
```js
const log = (...args) => [console.log, args];
```
but in `handle-io`, it's not.
##### Create IO
you can use `io` to create one :
```js
const { io } = require('handle-io');
const log = io(console.log);
```
##### Run IO
call .run() after apply io to arguments :
```js
log('Hello', 'World').run(); // print Hello World
```
**keep it mind** : piece of codes with `.run()` cannot be tested properly.
All the idea of this library is to apply **IO** in structures called **handlers**.
### Handlers
A **handler** is a wrapped pure [generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) which just apply some **IO** and/or **handlers**.
**e.g.**
```js
const { io, handler } = require('handle-io');
const log = io(console.log);
const logTwice = handler(function*(...args) {
yield log(...args);
yield log(...args);
});
```
#### Write tests for handlers
Write a test for this **handler** is very simple (please see first example above).
But what about test a **handler** which apply **IO** and return values ?
**There is a very simple way** :
- using second argument of .matchIo() method to mock returned values.
- using .shouldReturn() to assert final value
**e.g.**
```js
const { io, handler } = require('handle-io');
const getEnv = io((v) => process.env[v]);
const addValues = handler(function*() {
const value1 = yield getEnv('VALUE1');
const value2 = yield getEnv('VALUE2');
return value1 + value2;
});
testHandler(addValues())
.matchIo(getEnv('VALUE1'), 32),
.matchIo(getEnv('VALUE2'), 10),
.shouldReturn(42)
.run()
```
#### Run handlers
Same as for **IO**, there is a **.run()** method :
```js
addValues().run() // => 42
```
And same as for **IO**, don't use **.run()** everywhere in your codebase.
**handlers** are combinable together : **you can yield a handler**.
### Promise support
`handle-io` support promises and allow you to create asynchronous IO.
**e.g.**
```js
// async io
const sleep = io((ms) => new Promise(resolve => setTimeout(resolve, ms)));
// create an async combination
const sleepSecond = handler(function*(s) {
yield sleep(s * 1000);
return s;
});
// test this combination synchronously
testHander(sleepSecond(42))
.matchIo(sleep(42000))
.shouldReturn(42)
.run()
```
Please note `sleep(n)` and `sleepSecond(n)` will expose .run() method that return a promise.
**e.g.**
```js
sleepSecond(1).run().then((n) => {
console.log(`${n} second(s) waited`);
})
```
### Deal with errors
The very simple way to handle errors with `handle-io` is to use try/catch blocks.
As you can see in the example below, you can try/catch any errors inside a handler :
- Synchronous error (throw) from io
- Asynchronous error (unhandled promise rejection) from io
- Throw from another handler
**e.g.**
```js
const handler1 = handler(function*() {
throw new Error();
});
// Synchronous IO
const io1 = io(() => { throw new Error() });
// Asynchronous IO
const io2 = io(() => Promise.reject(new Error()));
// handler2 is safe, it can't throw because it handles errors
const handler2 = handler(function*() {
try {
yield io1();
yield io2();
yield handler1();
} catch (e) {
console.error(e);
}
});
```
## License
[MIT](https://github.com/guillaumearm/handle-io/blob/master/LICENSE)
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