@supercharge/goodies
Advanced tools
Comparing version 1.8.0 to 1.9.0
# Changelog | ||
## [1.9.0](https://github.com/supercharge/goodies/compare/v1.8.0...v1.9.0) - 2021-04-11 | ||
### Updated | ||
- bump dependencies | ||
- refactored the `Goodies` class to individual methods | ||
- this package now exports individual methods making the package tree-shakable and usable in bundled environments | ||
- move test runner from `jest` to `AVA` (avoiding globals and using explicit methods instead) | ||
## [1.8.0](https://github.com/supercharge/goodies/compare/v1.7.0...v1.8.0) - 2021-01-05 | ||
@@ -5,0 +14,0 @@ |
@@ -1,107 +0,9 @@ | ||
/** | ||
* 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() | ||
* }) | ||
*/ | ||
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; | ||
/** | ||
* 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 | ||
* }) | ||
*/ | ||
export declare function upon<T, R>(value: Promise<T>, callback?: (value: T) => Promise<any>): Promise<R>; | ||
export declare function upon<T, R>(value: Promise<T>, callback?: (value: T) => R): Promise<R>; | ||
export declare function upon<T, R>(value: T, callback?: (value: T) => Promise<R>): Promise<R>; | ||
export declare function upon<T, R>(value: T, callback?: (value: T) => R): R; | ||
/** | ||
* Determine whether the given `input` is a function. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {Boolean} | ||
* | ||
* @example | ||
* isFunction('no') // false | ||
* isFunction(() => {}) // true | ||
* isFunction(function () {}) // true | ||
*/ | ||
export declare function isFunction(input?: any): boolean; | ||
/** | ||
* Determine whether the given `promise` is a Promise. | ||
* | ||
* @param {*} promise | ||
* | ||
* @returns {Boolean} | ||
* | ||
* @example | ||
* isPromise('no') // false | ||
* isPromise(new Promise(() => {})) // true | ||
*/ | ||
export declare function isPromise(promise?: any): boolean; | ||
/** | ||
* Determine whether the given `input` is an async function. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
export declare function isAsyncFunction(input: any): boolean; | ||
/** | ||
* Runs the given `callback` if the `predicate` is `null` or `undefined`. | ||
* | ||
* @param {Boolean} predicate | ||
* @param {Function} callback | ||
* | ||
* @returns {*} | ||
*/ | ||
export declare function ifNullish<R>(input: boolean, callback: () => Promise<R>): undefined | Promise<R>; | ||
/** | ||
* Runs the given `callback` if the `predicate` is `null` or `undefined`. | ||
* | ||
* @param {Boolean} predicate | ||
* @param {Function} callback | ||
* | ||
* @returns {*} | ||
*/ | ||
export declare function isNullish(input: any): boolean; | ||
/** | ||
* Returns the resolved ESM default exports and CommonJS (module) exports. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {*} | ||
*/ | ||
export declare function esmResolve(input: any): any; | ||
/** | ||
* `require`s with the given `path` and returns the resolved | ||
* ESM default exports and CommonJS (module) exports. | ||
* | ||
* @param {String} path | ||
* | ||
* @returns {*} | ||
*/ | ||
export declare function esmRequire<T = any>(path: string): T; | ||
export * from './esmRequire'; | ||
export * from './esmResolve'; | ||
export * from './ifNullish'; | ||
export * from './isAsyncFunction'; | ||
export * from './isFunction'; | ||
export * from './isNullish'; | ||
export * from './isPromise'; | ||
export * from './tap'; | ||
export * from './upon'; |
'use strict'; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.esmRequire = exports.esmResolve = exports.isNullish = exports.ifNullish = exports.isAsyncFunction = exports.isPromise = exports.isFunction = exports.upon = exports.tap = void 0; | ||
const goodies_1 = require("./goodies"); | ||
function tap(value, callback) { | ||
return new goodies_1.Goodies().tap(value, callback); | ||
} | ||
exports.tap = tap; | ||
function upon(value, callback) { | ||
return new goodies_1.Goodies().upon(value, callback); | ||
} | ||
exports.upon = upon; | ||
/** | ||
* Determine whether the given `input` is a function. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {Boolean} | ||
* | ||
* @example | ||
* isFunction('no') // false | ||
* isFunction(() => {}) // true | ||
* isFunction(function () {}) // true | ||
*/ | ||
function isFunction(input) { | ||
return new goodies_1.Goodies().isFunction(input); | ||
} | ||
exports.isFunction = isFunction; | ||
/** | ||
* Determine whether the given `promise` is a Promise. | ||
* | ||
* @param {*} promise | ||
* | ||
* @returns {Boolean} | ||
* | ||
* @example | ||
* isPromise('no') // false | ||
* isPromise(new Promise(() => {})) // true | ||
*/ | ||
function isPromise(promise) { | ||
return new goodies_1.Goodies().isPromise(promise); | ||
} | ||
exports.isPromise = isPromise; | ||
/** | ||
* Determine whether the given `input` is an async function. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
function isAsyncFunction(input) { | ||
return new goodies_1.Goodies().isAsyncFunction(input); | ||
} | ||
exports.isAsyncFunction = isAsyncFunction; | ||
function ifNullish(input, callback) { | ||
return new goodies_1.Goodies().ifNullish(input, callback); | ||
} | ||
exports.ifNullish = ifNullish; | ||
/** | ||
* Runs the given `callback` if the `predicate` is `null` or `undefined`. | ||
* | ||
* @param {Boolean} predicate | ||
* @param {Function} callback | ||
* | ||
* @returns {*} | ||
*/ | ||
function isNullish(input) { | ||
return new goodies_1.Goodies().isNullish(input); | ||
} | ||
exports.isNullish = isNullish; | ||
/** | ||
* Returns the resolved ESM default exports and CommonJS (module) exports. | ||
* | ||
* @param {*} input | ||
* | ||
* @returns {*} | ||
*/ | ||
function esmResolve(input) { | ||
return new goodies_1.Goodies().esmResolve(input); | ||
} | ||
exports.esmResolve = esmResolve; | ||
/** | ||
* `require`s with the given `path` and returns the resolved | ||
* ESM default exports and CommonJS (module) exports. | ||
* | ||
* @param {String} path | ||
* | ||
* @returns {*} | ||
*/ | ||
function esmRequire(path) { | ||
return new goodies_1.Goodies().esmRequire(path); | ||
} | ||
exports.esmRequire = esmRequire; | ||
__exportStar(require("./esmRequire"), exports); | ||
__exportStar(require("./esmResolve"), exports); | ||
__exportStar(require("./ifNullish"), exports); | ||
__exportStar(require("./isAsyncFunction"), exports); | ||
__exportStar(require("./isFunction"), exports); | ||
__exportStar(require("./isNullish"), exports); | ||
__exportStar(require("./isPromise"), exports); | ||
__exportStar(require("./tap"), exports); | ||
__exportStar(require("./upon"), exports); |
{ | ||
"name": "@supercharge/goodies", | ||
"description": "Async utility functions for Node.js and JavaScript", | ||
"version": "1.8.0", | ||
"description": "Utility functions for Node.js and JavaScript", | ||
"version": "1.9.0", | ||
"author": "Marcus Pöhls <marcus@superchargejs.com>", | ||
@@ -12,16 +12,16 @@ "bugs": { | ||
"@supercharge/tsconfig": "~1.0.0", | ||
"@types/jest": "~26.0.19", | ||
"@typescript-eslint/eslint-plugin": "~4.12.0", | ||
"eslint": "~7.17.0", | ||
"eslint-config-standard-with-typescript": "~19.0.1", | ||
"@types/node": "~14.14.37", | ||
"@typescript-eslint/eslint-plugin": "~4.21.0", | ||
"ava": "~4.0.0-alpha.2", | ||
"eslint": "~7.24.0", | ||
"eslint-config-standard-with-typescript": "~20.0.0", | ||
"eslint-plugin-import": "~2.22.1", | ||
"eslint-plugin-node": "~11.1.0", | ||
"eslint-plugin-promise": "~4.2.1", | ||
"eslint-plugin-promise": "~4.3.1", | ||
"eslint-plugin-standard": "~4.1.0", | ||
"jest": "~26.6.3", | ||
"typescript": "~4.1.3" | ||
"nyc": "~15.1.0", | ||
"typescript": "~4.2.4" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"main": "dist", | ||
"types": "dist", | ||
"files": [ | ||
@@ -41,3 +41,2 @@ "dist" | ||
"license": "MIT", | ||
"main": "dist", | ||
"publishConfig": { | ||
@@ -56,5 +55,4 @@ "access": "public" | ||
"test": "npm run build && npm run lint && npm run test:run", | ||
"test:run": "jest" | ||
}, | ||
"types": "dist" | ||
"test:run": "nyc --reporter=html --reporter=text ava" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24
18708
12
348
1