Socket
Socket
Sign inDemoInstall

@supercharge/goodies

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supercharge/goodies - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

6

CHANGELOG.md
# Changelog
## [1.4.0](https://github.com/supercharge/goodies/compare/v1.3.0...v1.4.0) - 2020-05-23
### Added
- refined typings for async and sync functions
## [1.3.0](https://github.com/supercharge/goodies/compare/v1.2.0...v1.3.0) - 2020-05-22

@@ -5,0 +11,0 @@

8

dist/goodies.d.ts

@@ -11,3 +11,3 @@ export declare class Goodies {

*/
tap<T>(value: T, callback?: (value: T) => any | Promise<any>): T | Promise<T>;
tap<T>(value: T, callback?: (value: T) => any): any;
/**

@@ -44,3 +44,3 @@ * Calls the given `callback` function with the

*/
upon(value: any, callback: Function): Promise<any> | any;
upon<T>(value: any, callback?: (value: T) => any): any;
/**

@@ -55,3 +55,3 @@ * Calls the given `callback` function with the given `value` and returns

*/
uponSync(value: any, callback: Function): any;
uponSync(value: any, callback?: Function): any;
/**

@@ -67,3 +67,3 @@ * Calls the given `callback` function with the given `value` and returns

*/
uponAsync(value: any, callback: Function): Promise<any>;
uponAsync(value: any, callback?: Function): Promise<any>;
/**

@@ -70,0 +70,0 @@ * Determine whether the given `promise` is a Promise.

@@ -92,2 +92,5 @@ 'use strict';

uponSync(value, callback) {
if (!callback) {
return value;
}
return this.isFunction(callback)

@@ -108,2 +111,5 @@ ? callback(value)

async uponAsync(value, callback) {
if (!callback) {
return value;
}
if (this.isPromise(value)) {

@@ -110,0 +116,0 @@ value = await value;

@@ -17,3 +17,6 @@ /**

*/
export declare function tap<T>(value: T, callback?: (value: T) => any | Promise<any>): T | Promise<T>;
export declare function tap<T>(value: Promise<T>, callback?: (value: T) => Promise<any>): Promise<T>;
export declare function tap<T>(value: Promise<T>, callback?: (value: T) => any): Promise<T>;
export declare function tap<T>(value: T, callback?: (value: T) => Promise<any>): Promise<T>;
export declare function tap<T>(value: T, callback?: (value: T) => any): T;
/**

@@ -34,3 +37,6 @@ * Calls the given `callback` function with the given `value` and returns

*/
export declare function upon(value: any, callback: Function): any | Promise<any>;
export declare function upon<T>(value: Promise<T>, callback?: (value: T) => Promise<any>): Promise<any>;
export declare function upon<T>(value: Promise<T>, callback?: (value: T) => any): Promise<any>;
export declare function upon<T>(value: T, callback?: (value: T) => Promise<any>): Promise<any>;
export declare function upon<T>(value: T, callback?: (value: T) => any): any;
/**

@@ -37,0 +43,0 @@ * Determine whether the given `promise` is a Promise.

@@ -5,18 +5,2 @@ 'use strict';

const goodies_1 = require("./goodies");
/**
* Calls the given `callback` function with the given `value`
* and returns `value`. It resolves the `value` before
* passing it to the callback in case it is a Promise.
*
* @param {*} value
* @param {Function} callback
*
* @returns {*} value
*
* @example
* const user = await tap(new User({ name: 'Supercharge' }), async user => {
* await user.save()
* await user.subscribeToNewsletter()
* })
*/
function tap(value, callback) {

@@ -26,17 +10,2 @@ return new goodies_1.Goodies().tap(value, callback);

exports.tap = tap;
/**
* Calls the given `callback` function with the given `value` and returns
* the result of the callback. It resolves the `value` before passing
* it to the callback in case it is a Promise.
*
* @param {*} value
* @param {Function} callback
*
* @returns {*} value
*
* @example
* const email = await upon(User.findById(1), async user => {
* return user.email
* })
*/
function upon(value, callback) {

@@ -43,0 +12,0 @@ return new goodies_1.Goodies().upon(value, callback);

{
"name": "@supercharge/goodies",
"description": "Async utility functions for Node.js and JavaScript",
"version": "1.3.0",
"version": "1.4.0",
"author": "Marcus Pöhls <marcus@superchargejs.com>",

@@ -6,0 +6,0 @@ "bugs": {

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