Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-protocol-helpers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-protocol-helpers - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

17

lib/index.js

@@ -81,2 +81,16 @@ 'use strict';

var clean = function clean(s) {
if (hasPayload(s)) {
return {
success: s.success,
payload: s.payload
};
} else if (hasError(s)) {
return {
success: s.success,
error: s.error
};
}
};
module.exports = {

@@ -94,4 +108,5 @@ getSuccesses: getSuccesses,

isProtocol: isProtocol,
errorToObject: errorToObject
errorToObject: errorToObject,
clean: clean
};
//# sourceMappingURL=index.js.map

@@ -17,3 +17,4 @@ 'use strict';

failure = _require2.failure,
isProtocol = _require2.isProtocol;
isProtocol = _require2.isProtocol,
clean = _require2.clean;

@@ -236,3 +237,27 @@ describe('index.js', function () {

});
describe('clean()', function () {
it('should clean a success', function () {
var s = success(1);
s.meta = { foo: 'bar' };
var actual = clean(s);
var expected = {
success: true,
payload: 1
};
deepEqual(actual, expected);
});
it('should clean a failure', function () {
var s = failure(1);
s.meta = { foo: 'bar' };
var actual = clean(s);
var expected = {
success: false,
error: 1
};
deepEqual(actual, expected);
});
});
});
//# sourceMappingURL=index.spec.js.map

2

package.json
{
"name": "simple-protocol-helpers",
"version": "0.1.0",
"version": "0.2.0",
"description": "A small library for using simple protocol",

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

@@ -51,2 +51,16 @@ const isSuccess = p => p.success === true

const clean = (s) => {
if (hasPayload(s)) {
return {
success: s.success,
payload: s.payload
}
} else if (hasError(s)) {
return {
success: s.success,
error: s.error
}
}
}
module.exports = {

@@ -64,3 +78,4 @@ getSuccesses,

isProtocol,
errorToObject
errorToObject,
clean
}

@@ -13,3 +13,4 @@ const { deepEqual } = require('assert')

failure,
isProtocol
isProtocol,
clean
} = require('./index')

@@ -233,2 +234,26 @@

})
describe('clean()', () => {
it('should clean a success', () => {
const s = success(1)
s.meta = { foo: 'bar' }
const actual = clean(s)
const expected = {
success: true,
payload: 1
}
deepEqual(actual, expected)
})
it('should clean a failure', () => {
const s = failure(1)
s.meta = { foo: 'bar' }
const actual = clean(s)
const expected = {
success: false,
error: 1
}
deepEqual(actual, expected)
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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