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

knifecycle

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knifecycle - npm Package Compare versions

Comparing version 5.0.2 to 5.0.3

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [5.0.3](https://github.com/nfroidure/knifecycle/compare/v5.0.2...v5.0.3) (2019-01-12)
### Bug Fixes
* **autoInject:** Ensure auto injection works with trailing commas ([521ab18](https://github.com/nfroidure/knifecycle/commit/521ab18))
## [5.0.2](https://github.com/nfroidure/knifecycle/compare/v5.0.1...v5.0.2) (2018-11-29)

@@ -2,0 +11,0 @@

11

dist/util.js

@@ -10,2 +10,3 @@ "use strict";

exports.autoInject = autoInject;
exports.parseInjections = parseInjections;
exports.alsoInject = alsoInject;

@@ -187,2 +188,7 @@ exports.extra = extra;

const source = initializer.toString();
const dependencies = parseInjections(source);
return inject(dependencies, initializer);
}
function parseInjections(source) {
const matches = source.match(/^\s*(?:async\s+function(?:\s+\w+)?|async)\s*\(\{\s*([^{}}]+)\s*\}/);

@@ -198,4 +204,3 @@

const dependencies = matches[1].trim().split(/\s*,\s*/).map(injection => (injection.includes('=') ? '?' : '') + injection.split(/\s*=\s*/).shift().split(/\s*:\s*/).shift()).filter(injection => !/[)(\][]/.test(injection));
return inject(dependencies, initializer);
return matches[1].trim().replace(/,$/, '').split(/\s*,\s*/).map(injection => (injection.includes('=') ? '?' : '') + injection.split(/\s*=\s*/).shift().split(/\s*:\s*/).shift()).filter(injection => !/[)(\][]/.test(injection));
}

@@ -333,3 +338,3 @@ /**

* new Knifecycle()
* .register(name(async function myService() {}));
* .register(autoName(async function myService() {}));
*/

@@ -336,0 +341,0 @@

@@ -302,2 +302,22 @@ "use strict";

});
describe('parseInjections', () => {
it('should work with TypeScript dependencies', () => {
_assert.default.deepEqual((0, _util.parseInjections)(`async function initNexmo({
ENV,
NEXMO,
log = noop,
}: {
ENV: any;
NEXMO: any;
log: Function;
}): Promise<SMSService> {}`), ['ENV', 'NEXMO', '?log']);
});
it('should allow to decorate an initializer with dependencies', () => {
const newInitializer = (0, _util.alsoInject)(['ENV'], aProvider);
_assert.default.notEqual(newInitializer, aProvider);
_assert.default.deepEqual(newInitializer[_util.SPECIAL_PROPS.INJECT], ['ENV']);
});
});
describe('options', () => {

@@ -304,0 +324,0 @@ it('should allow to decorate an initializer with options', () => {

{
"name": "knifecycle",
"version": "5.0.2",
"version": "5.0.3",
"description": "Manage your NodeJS processes's lifecycle.",

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

@@ -342,6 +342,6 @@ [//]: # ( )

That said, if your need to build your code with `webpack`/`babel` you may
That said, if you need to build your code with `webpack`/`babel` you may
have to convert auto-detections to raw declarations with the
[babel-plugin-knifecycle](https://github.com/nfroidure/babel-plugin-knifecycle)
plugin.
plugin. You can also do this only for the performance improvements it brings.

@@ -391,2 +391,11 @@ Also, keep in mind that the auto-detection is based on a simple regular

a simple in memory key-value store.
- [whook](https://github.com/nfroidure/whook):
a framework to build REST web services.
- [postgresql-service](https://github.com/nfroidure/postgresql-service):
a simple wrapper around the `pg` module.
- [jwt-service](https://github.com/nfroidure/jwt-service):
a simple wrapper around the `jwt` module to simplify its use.
Notice that those modules remains usable without using Knifecycle at
all which is maybe the best feature of this library ;).

@@ -872,3 +881,3 @@ [//]: # (::contents:end)

new Knifecycle()
.register(name(async function myService() {}));
.register(autoName(async function myService() {}));
```

@@ -875,0 +884,0 @@ <a name="type"></a>

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