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

promise-thunk

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-thunk - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

2

package.json
{
"name": "promise-thunk",
"version": "0.1.10",
"version": "0.1.11",
"description": "Promise and thunk",

@@ -5,0 +5,0 @@ "main": "promise-thunk.js",

@@ -325,17 +325,14 @@ // promise-thunk.js

function promisify(fn, options) {
// promisify(object target, string method, [string postfix]) : undefined
if (arguments[0] && arguments[1] &&
typeof arguments[0] === 'object' &&
typeof arguments[1] === 'string') {
var object = arguments[0], method = arguments[1];
var postfix = arguments[2] && typeof arguments[2] === 'string' ? arguments[2] :
arguments[2] && typeof arguments[2].postfix === 'string' ? arguments[2].postfix :
arguments[2] && typeof arguments[2].suffix === 'string' ? arguments[2].suffix : 'Async';
var methodAcached = method + postfix + 'Cached';
Object.defineProperty(object, method + postfix, {
// promisify(object target, string method, [object options]) : undefined
if (fn && typeof fn === 'object' && options && typeof options === 'string') {
var object = fn, method = options, options = arguments[2];
var suffix = options && typeof options === 'string' ? options :
options && typeof options.suffix === 'string' ? options.suffix :
options && typeof options.postfix === 'string' ? options.postfix : 'Async';
var methodAsyncCached = method + suffix + 'Cached';
Object.defineProperty(object, method + suffix, {
get: function () {
return this.hasOwnProperty(methodAcached) &&
typeof this[methodAcached] === 'function' ?
this[methodAcached] :
setValue(this, methodAcached, promisify(this, this[method]));
return this.hasOwnProperty(methodAsyncCached) &&
typeof this[methodAsyncCached] === 'function' ? this[methodAsyncCached] :
setValue(this, methodAsyncCached, promisify(this, this[method]));
},

@@ -381,17 +378,14 @@ configurable: true

function thunkify(fn, options) {
// thunkify(object target, string method, [string postfix]) : undefined
if (arguments[0] && arguments[1] &&
typeof arguments[0] === 'object' &&
typeof arguments[1] === 'string') {
var object = arguments[0], method = arguments[1];
var postfix = arguments[2] && typeof arguments[2] === 'string' ? arguments[2] :
arguments[2] && typeof arguments[2].postfix === 'string' ? arguments[2].postfix :
arguments[2] && typeof arguments[2].suffix === 'string' ? arguments[2].suffix : 'Async';
var methodAcached = method + postfix + 'Cached';
Object.defineProperty(object, method + postfix, {
// thunkify(object target, string method, [object options]) : undefined
if (fn && typeof fn === 'object' && options && typeof options === 'string') {
var object = fn, method = options, options = arguments[2];
var suffix = options && typeof options === 'string' ? options :
options && typeof options.suffix === 'string' ? options.suffix :
options && typeof options.postfix === 'string' ? options.postfix : 'Async';
var methodAsyncCached = method + suffix + 'Cached';
Object.defineProperty(object, method + suffix, {
get: function () {
return this.hasOwnProperty(methodAcached) &&
typeof this[methodAcached] === 'function' ?
this[methodAcached] :
setValue(this, methodAcached, thunkify(this, this[method]));
return this.hasOwnProperty(methodAsyncCached) &&
typeof this[methodAsyncCached] === 'function' ? this[methodAsyncCached] :
setValue(this, methodAsyncCached, thunkify(this, this[method]));
},

@@ -398,0 +392,0 @@ configurable: true

@@ -216,5 +216,5 @@ [promise-thunk](https://www.npmjs.org/package/promise-thunk) - npm

+ `method`: method name string.
+ `options`: method name postfix or suffix. default: 'Async'. or options object.
+ `postfix`: method name postfix or suffix. default: 'Async'.
+ `suffix`: method name postfix or suffix. default: 'Async'.
+ `options`: method name suffix or postfix. default: 'Async'. or options object.
+ `suffix`: method name suffix or postfix. default: 'Async'.
+ `postfix`: method name suffix or postfix. default: 'Async'.

@@ -225,3 +225,3 @@ #### postgres `pg` example:

var pg = require('pg');
PromiseThunk.promisify(pg, 'connect', {postfix: 'A'}); // -> yield pg.connectA()
PromiseThunk.promisify(pg, 'connect', {suffix: 'A'}); // -> yield pg.connectA()
PromiseThunk.promisify(pg.Client.prototype, 'connect'); // -> yield client.connectAsync()

@@ -236,5 +236,5 @@ PromiseThunk.promisify(pg.Client.prototype, 'query'); // -> yield client.queryAsync()

+ `object`: target object.
+ `options`: method name postfix or suffix. default: 'Async'. or options object.
+ `postfix`: method name postfix or suffix. default: 'Async'.
+ `suffix`: method name postfix or suffix. default: 'Async'.
+ `options`: method name suffix or postfix. default: 'Async'. or options object.
+ `suffix`: method name suffix or postfix. default: 'Async'.
+ `postfix`: method name suffix or postfix. default: 'Async'.

@@ -245,3 +245,3 @@ #### file system `fs` example:

var fs = require('fs');
PromiseThunk.promisifyAll(fs, {postfix: 'A'}); // -> yield fs.readFileA()
PromiseThunk.promisifyAll(fs, {suffix: 'A'}); // -> yield fs.readFileA()
```

@@ -253,3 +253,3 @@

var pg = require('pg');
PromiseThunk.promisifyAll(pg.constructor.prototype, {postfix: 'A'}); // -> yield pg.connectA()
PromiseThunk.promisifyAll(pg.constructor.prototype, {suffix: 'A'}); // -> yield pg.connectA()
PromiseThunk.promisifyAll(pg.Client.prototype); // -> yield client.connectAsync()

@@ -285,5 +285,5 @@ // -> yield client.queryAsync()

+ `method`: method name string.
+ `options`: method name postfix or suffix. default: 'Async'. or options object.
+ `postfix`: method name postfix or suffix. default: 'Async'.
+ `suffix`: method name postfix or suffix. default: 'Async'.
+ `options`: method name suffix or postfix. default: 'Async'. or options object.
+ `suffix`: method name suffix or postfix. default: 'Async'.
+ `postfix`: method name suffix or postfix. default: 'Async'.

@@ -294,3 +294,3 @@ #### postgres `pg` example:

var pg = require('pg');
PromiseThunk.thunkify(pg, 'connect', {postfix: 'A'}); // -> yield pg.connectA()
PromiseThunk.thunkify(pg, 'connect', {suffix: 'A'}); // -> yield pg.connectA()
PromiseThunk.thunkify(pg.Client.prototype, 'connect'); // -> yield client.connectAsync()

@@ -305,5 +305,5 @@ PromiseThunk.thunkify(pg.Client.prototype, 'query'); // -> yield client.queryAsync()

+ `object`: target object.
+ `options`: method name postfix or suffix. default: 'Async'. or options object.
+ `postfix`: method name postfix or suffix. default: 'Async'.
+ `suffix`: method name postfix or suffix. default: 'Async'.
+ `options`: method name suffix or postfix. default: 'Async'. or options object.
+ `suffix`: method name suffix or postfix. default: 'Async'.
+ `postfix`: method name suffix or postfix. default: 'Async'.

@@ -314,3 +314,3 @@ #### file system `fs` example:

var fs = require('fs');
PromiseThunk.thunkifyAll(fs, {postfix: 'A'}); // -> yield fs.readFileA()
PromiseThunk.thunkifyAll(fs, {suffix: 'A'}); // -> yield fs.readFileA()
```

@@ -322,3 +322,3 @@

var pg = require('pg');
PromiseThunk.thunkifyAll(pg.constructor.prototype, {postfix: 'A'}); // -> yield pg.connectA()
PromiseThunk.thunkifyAll(pg.constructor.prototype, {suffix: 'A'}); // -> yield pg.connectA()
PromiseThunk.thunkifyAll(pg.Client.prototype); // -> yield client.connectAsync()

@@ -325,0 +325,0 @@ // -> yield client.queryAsync()

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