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

@wordpress/deprecated

Package Overview
Dependencies
Maintainers
6
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/deprecated - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

30

build-module/index.js

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

import "core-js/modules/es6.string.link";
import _Object$create from "@babel/runtime/core-js/object/create";
/**
* Object map tracking messages which have been logged, for use in ensuring a
* message is only logged once.
*
* @type {Object}
*/
export var logged = _Object$create(null);
/**
* Logs a message to notify developers about a deprecated feature.

@@ -12,2 +22,3 @@ *

*/
export default function deprecated(feature) {

@@ -21,11 +32,16 @@ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

var pluginMessage = plugin ? ' from ' + plugin : '';
var versionMessage = version ? pluginMessage + ' in ' + version : '';
var useInsteadMessage = alternative ? ' Please use ' + alternative + ' instead.' : '';
var linkMessage = link ? ' See: ' + link : '';
var hintMessage = hint ? ' Note: ' + hint : '';
var message = feature + ' is deprecated and will be removed' + versionMessage + '.' + useInsteadMessage + linkMessage + hintMessage;
var pluginMessage = plugin ? " from ".concat(plugin) : '';
var versionMessage = version ? "".concat(pluginMessage, " in ").concat(version) : '';
var useInsteadMessage = alternative ? " Please use ".concat(alternative, " instead.") : '';
var linkMessage = link ? " See: ".concat(link) : '';
var hintMessage = hint ? " Note: ".concat(hint) : '';
var message = "".concat(feature, " is deprecated and will be removed").concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged.
// eslint-disable-next-line no-console
if (message in logged) {
return;
} // eslint-disable-next-line no-console
console.warn(message);
logged[message] = true;
}

@@ -1,3 +0,5 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -7,3 +9,16 @@ value: true

exports.default = deprecated;
exports.logged = void 0;
require("core-js/modules/es6.string.link");
var _create = _interopRequireDefault(require("@babel/runtime/core-js/object/create"));
/**
* Object map tracking messages which have been logged, for use in ensuring a
* message is only logged once.
*
* @type {Object}
*/
var logged = (0, _create.default)(null);
/**
* Logs a message to notify developers about a deprecated feature.

@@ -19,2 +34,5 @@ *

*/
exports.logged = logged;
function deprecated(feature) {

@@ -28,11 +46,16 @@ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

var pluginMessage = plugin ? ' from ' + plugin : '';
var versionMessage = version ? pluginMessage + ' in ' + version : '';
var useInsteadMessage = alternative ? ' Please use ' + alternative + ' instead.' : '';
var linkMessage = link ? ' See: ' + link : '';
var hintMessage = hint ? ' Note: ' + hint : '';
var message = feature + ' is deprecated and will be removed' + versionMessage + '.' + useInsteadMessage + linkMessage + hintMessage;
var pluginMessage = plugin ? " from ".concat(plugin) : '';
var versionMessage = version ? "".concat(pluginMessage, " in ").concat(version) : '';
var useInsteadMessage = alternative ? " Please use ".concat(alternative, " instead.") : '';
var linkMessage = link ? " See: ".concat(link) : '';
var hintMessage = hint ? " Note: ".concat(hint) : '';
var message = "".concat(feature, " is deprecated and will be removed").concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged.
// eslint-disable-next-line no-console
if (message in logged) {
return;
} // eslint-disable-next-line no-console
console.warn(message);
logged[message] = true;
}
{
"name": "@wordpress/deprecated",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Deprecation utility for WordPress",

@@ -21,5 +21,7 @@ "author": "The WordPress Contributors",

"module": "build-module/index.js",
"react-native": "src/index",
"publishConfig": {
"access": "public"
}
},
"gitHead": "8827c049ec802471f51a5cb906d9096ffc1b4e48"
}
/**
* Object map tracking messages which have been logged, for use in ensuring a
* message is only logged once.
*
* @type {Object}
*/
export const logged = Object.create( null );
/**
* Logs a message to notify developers about a deprecated feature.

@@ -20,4 +28,11 @@ *

// Skip if already logged.
if ( message in logged ) {
return;
}
// eslint-disable-next-line no-console
console.warn( message );
logged[ message ] = true;
}
/**
* Internal dependencies
*/
import deprecated from '../';
import deprecated, { logged } from '../';
describe( 'deprecated', () => {
afterEach( () => {
for ( const key in logged ) {
delete logged[ key ];
}
} );
it( 'should show a deprecation warning', () => {

@@ -68,2 +74,11 @@ deprecated( 'Eating meat' );

} );
it( 'should show a message once', () => {
deprecated( 'Eating meat' );
deprecated( 'Eating meat' );
expect( console ).toHaveWarned();
// eslint-disable-next-line no-console
expect( console.warn ).toHaveBeenCalledTimes( 1 );
} );
} );
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