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

hable

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hable - npm Package Compare versions

Comparing version 3.0.0-0 to 3.0.0

index.d.ts

15

CHANGELOG.md

@@ -1,5 +0,18 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [3.0.0](https://github.com/jsless/hable/compare/v2.3.0...v3.0.0) (2020-02-25)
### Bug Fixes
* revert back hooks ([07f52dc](https://github.com/jsless/hable/commit/07f52dc))
### Features
* advanced deprecation ([5b88628](https://github.com/jsless/hable/commit/5b88628))
* bundle package ([53a2a0e](https://github.com/jsless/hable/commit/53a2a0e))
# [2.3.0](https://github.com/jsless/hable/compare/v2.2.1...v2.3.0) (2019-09-01)

@@ -6,0 +19,0 @@

2

dist/hable.esm.js

@@ -1,2 +0,2 @@

export default class{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={}}hook(o,e){o&&"function"==typeof e&&(this._deprecatedHooks[o]&&("production"!==process.env.NODE_ENV&&this._logger.warn(`${o} hook has been deprecated, please use ${this._deprecatedHooks[o]}`),o=this._deprecatedHooks[o]),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(e))}deprecateHook(o,e){this._deprecatedHooks[o]=e}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const e=function o(e,s={},t){for(const r in e){const h=e[r],a=t?`${t}:${r}`:r;"object"==typeof h&&null!==h?o(h,s,a):s[a]=h}return s}(o);for(const o in e)this.hook(o,e[o])}async callHook(o,...e){var s,t;if(this._hooks[o])try{await(s=this._hooks[o],t=(o=>o(...e)),s.reduce((o,e)=>o.then(o=>t(e,o)),Promise.resolve(null)))}catch(e){"error"!==o&&await this.callHook("error",e),this._logger.fatal?this._logger.fatal(e):this._logger.error(e)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}
export default class{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this)}hook(o,t){if(!o||"function"!=typeof t)return;const s=o;let e;for(;this._deprecatedHooks[o];)"string"==typeof(e=this._deprecatedHooks[o])&&(e={to:e}),o=e.to;e&&(e.message?this._logger.warn(e.message):this._logger.warn(`${s} hook has been deprecated`+(e.to?`, please use ${e.to}`:""))),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(t)}deprecateHook(o,t){this._deprecatedHooks[o]=t}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const t=function o(t,s={},e){for(const h in t){const r=t[h],i=e?`${e}:${h}`:h;"object"==typeof r&&null!==r?o(r,s,i):s[i]=r}return s}(o);for(const o in t)this.hook(o,t[o])}async callHook(o,...t){var s,e;if(this._hooks[o])try{await(s=this._hooks[o],e=(o=>o(...t)),s.reduce((o,t)=>o.then(o=>e(t,o)),Promise.resolve(null)))}catch(t){"error"!==o&&await this.callHook("error",t),this._logger.fatal?this._logger.fatal(t):this._logger.error(t)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}
//# sourceMappingURL=hable.esm.js.map

@@ -1,2 +0,2 @@

"use strict";function flatHooks(o,e={},s){for(const t in o){const r=o[t],a=s?`${s}:${t}`:t;"object"==typeof r&&null!==r?flatHooks(r,e,a):e[a]=r}return e}function serial(o,e){return o.reduce((o,s)=>o.then(o=>e(s,o)),Promise.resolve(null))}class Hookable{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={}}hook(o,e){o&&"function"==typeof e&&(this._deprecatedHooks[o]&&("production"!==process.env.NODE_ENV&&this._logger.warn(`${o} hook has been deprecated, please use ${this._deprecatedHooks[o]}`),o=this._deprecatedHooks[o]),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(e))}deprecateHook(o,e){this._deprecatedHooks[o]=e}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const e=flatHooks(o);for(const o in e)this.hook(o,e[o])}async callHook(o,...e){if(this._hooks[o])try{await serial(this._hooks[o],o=>o(...e))}catch(e){"error"!==o&&await this.callHook("error",e),this._logger.fatal?this._logger.fatal(e):this._logger.error(e)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}module.exports=Hookable;
"use strict";function flatHooks(o,s={},t){for(const e in o){const r=o[e],h=t?`${t}:${e}`:e;"object"==typeof r&&null!==r?flatHooks(r,s,h):s[h]=r}return s}function serial(o,s){return o.reduce((o,t)=>o.then(o=>s(t,o)),Promise.resolve(null))}class Hookable{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this)}hook(o,s){if(!o||"function"!=typeof s)return;const t=o;let e;for(;this._deprecatedHooks[o];)"string"==typeof(e=this._deprecatedHooks[o])&&(e={to:e}),o=e.to;e&&(e.message?this._logger.warn(e.message):this._logger.warn(`${t} hook has been deprecated`+(e.to?`, please use ${e.to}`:""))),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(s)}deprecateHook(o,s){this._deprecatedHooks[o]=s}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const s=flatHooks(o);for(const o in s)this.hook(o,s[o])}async callHook(o,...s){if(this._hooks[o])try{await serial(this._hooks[o],o=>o(...s))}catch(s){"error"!==o&&await this.callHook("error",s),this._logger.fatal?this._logger.fatal(s):this._logger.error(s)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}module.exports=Hookable;
//# sourceMappingURL=hable.js.map

@@ -1,2 +0,2 @@

!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(o=o||self).hable=e()}(this,function(){"use strict";return class{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={}}hook(o,e){o&&"function"==typeof e&&(this._deprecatedHooks[o]&&("production"!==process.env.NODE_ENV&&this._logger.warn(`${o} hook has been deprecated, please use ${this._deprecatedHooks[o]}`),o=this._deprecatedHooks[o]),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(e))}deprecateHook(o,e){this._deprecatedHooks[o]=e}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const e=function o(e,t={},s){for(const r in e){const i=e[r],h=s?`${s}:${r}`:r;"object"==typeof i&&null!==i?o(i,t,h):t[h]=i}return t}(o);for(const o in e)this.hook(o,e[o])}async callHook(o,...e){var t,s;if(this._hooks[o])try{await(t=this._hooks[o],s=(o=>o(...e)),t.reduce((o,e)=>o.then(o=>s(e,o)),Promise.resolve(null)))}catch(e){"error"!==o&&await this.callHook("error",e),this._logger.fatal?this._logger.fatal(e):this._logger.error(e)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}});
!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(o=o||self).hable=e()}(this,function(){"use strict";return class{constructor(o=console){this._logger=o,this._hooks={},this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this)}hook(o,e){if(!o||"function"!=typeof e)return;const t=o;let s;for(;this._deprecatedHooks[o];)"string"==typeof(s=this._deprecatedHooks[o])&&(s={to:s}),o=s.to;s&&(s.message?this._logger.warn(s.message):this._logger.warn(`${t} hook has been deprecated`+(s.to?`, please use ${s.to}`:""))),this._hooks[o]=this._hooks[o]||[],this._hooks[o].push(e)}deprecateHook(o,e){this._deprecatedHooks[o]=e}deprecateHooks(o){Object.assign(this._deprecatedHooks,o)}addHooks(o){const e=function o(e,t={},s){for(const i in e){const r=e[i],h=s?`${s}:${i}`:i;"object"==typeof r&&null!==r?o(r,t,h):t[h]=r}return t}(o);for(const o in e)this.hook(o,e[o])}async callHook(o,...e){var t,s;if(this._hooks[o])try{await(t=this._hooks[o],s=(o=>o(...e)),t.reduce((o,e)=>o.then(o=>s(e,o)),Promise.resolve(null)))}catch(e){"error"!==o&&await this.callHook("error",e),this._logger.fatal?this._logger.fatal(e):this._logger.error(e)}}clearHook(o){o&&delete this._hooks[o]}clearHooks(){this._hooks={}}}});
//# sourceMappingURL=hable.umd.js.map
{
"name": "hable",
"version": "3.0.0-0",
"version": "3.0.0",
"description": "Awaitable hooks for Node.js",

@@ -19,28 +19,30 @@ "keywords": [

],
"main": "./dist/hable.js",
"browser": "./dist/hable.umd.js",
"types": "./index.d.ts",
"files": [
"index.d.ts",
"src",
"dist"
],
"main": "dist/hable.js",
"browser": "dist/hable.umd.js",
"scripts": {
"build": "bili --module-name hable --minify --format cjs,umd,es src/hable.js",
"lint": "eslint src",
"prepublish": "yarn build && yarn test",
"release": "standard-version && git push --follow-tags && npm publish",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && yarn jest"
},
"devDependencies": {
"babel-jest": "^24.9.0",
"bili": "^4.8.1",
"codecov": "^3.0.0",
"eslint": "^5.13.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.2.2",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"jest": "^24.1.0",
"standard-version": "^5.0.1"
"codecov": "^3.5.0",
"eslint": "^6.3.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^24.9.0",
"standard-version": "^7.0.0"
}
}

@@ -8,2 +8,6 @@ import { serial, flatHooks } from './utils'

this._deprecatedHooks = {}
// Allow destructuring hook and callHook functions out of instance object
this.hook = this.hook.bind(this)
this.callHook = this.callHook.bind(this)
}

@@ -16,8 +20,21 @@

if (this._deprecatedHooks[name]) {
if (process.env.NODE_ENV !== 'production') {
this._logger.warn(`${name} hook has been deprecated, please use ${this._deprecatedHooks[name]}`)
const originalName = name
let deprecatedHook
while (this._deprecatedHooks[name]) {
deprecatedHook = this._deprecatedHooks[name]
if (typeof deprecatedHook === 'string') {
deprecatedHook = { to: deprecatedHook }
}
name = this._deprecatedHooks[name]
name = deprecatedHook.to
}
if (deprecatedHook) {
if (!deprecatedHook.message) {
this._logger.warn(
`${originalName} hook has been deprecated` +
(deprecatedHook.to ? `, please use ${deprecatedHook.to}` : '')
)
} else {
this._logger.warn(deprecatedHook.message)
}
}

@@ -24,0 +41,0 @@ this._hooks[name] = this._hooks[name] || []

Sorry, the diff of this file is not supported yet

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