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

@wordpress/private-apis

Package Overview
Dependencies
Maintainers
0
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/private-apis - npm Package Compare versions

Comparing version 1.13.0 to 1.13.1-next.a9f418477.0

12

build-module/implementation.js

@@ -95,6 +95,7 @@ /**

}
if (!(__private in object)) {
object[__private] = {};
const _object = object;
if (!(__private in _object)) {
_object[__private] = {};
}
lockedData.set(object[__private], privateData);
lockedData.set(_object[__private], privateData);
}

@@ -129,6 +130,7 @@

}
if (!(__private in object)) {
const _object = object;
if (!(__private in _object)) {
throw new Error('Cannot unlock an object that was not locked before. ');
}
return lockedData.get(object[__private]);
return lockedData.get(_object[__private]);
}

@@ -135,0 +137,0 @@ const lockedData = new WeakMap();

@@ -44,3 +44,3 @@ /**

*/
declare function lock(object: Record<symbol, WeakKey>, privateData: unknown): void;
declare function lock(object: unknown, privateData: unknown): void;
/**

@@ -69,3 +69,3 @@ * Unlocks the private data bound to an object.

*/
declare function unlock(object: Record<symbol, WeakKey>): any;
declare function unlock<T = any>(object: unknown): T;
/**

@@ -72,0 +72,0 @@ * Private function to allow the unit tests to allow

@@ -105,6 +105,7 @@ "use strict";

}
if (!(__private in object)) {
object[__private] = {};
const _object = object;
if (!(__private in _object)) {
_object[__private] = {};
}
lockedData.set(object[__private], privateData);
lockedData.set(_object[__private], privateData);
}

@@ -139,6 +140,7 @@

}
if (!(__private in object)) {
const _object = object;
if (!(__private in _object)) {
throw new Error('Cannot unlock an object that was not locked before. ');
}
return lockedData.get(object[__private]);
return lockedData.get(_object[__private]);
}

@@ -145,0 +147,0 @@ const lockedData = new WeakMap();

{
"name": "@wordpress/private-apis",
"version": "1.13.0",
"version": "1.13.1-next.a9f418477.0",
"description": "Internal experimental APIs for WordPress core.",

@@ -38,3 +38,3 @@ "author": "The WordPress Contributors",

},
"gitHead": "cce81c13739c2a8b53d91df90c4f037cb68c2665"
"gitHead": "c1a8f3e9cada3b7d8342d1d2595c2dac0433111d"
}

@@ -140,10 +140,12 @@ /**

*/
function lock( object: Record< symbol, WeakKey >, privateData: unknown ) {
function lock( object: unknown, privateData: unknown ) {
if ( ! object ) {
throw new Error( 'Cannot lock an undefined object.' );
}
if ( ! ( __private in object ) ) {
object[ __private ] = {};
const _object = object as Record< symbol, WeakKey >;
if ( ! ( __private in _object ) ) {
_object[ __private ] = {};
}
lockedData.set( object[ __private ], privateData );
lockedData.set( _object[ __private ], privateData );
}

@@ -174,7 +176,9 @@

*/
function unlock( object: Record< symbol, WeakKey > ) {
function unlock< T = any >( object: unknown ): T {
if ( ! object ) {
throw new Error( 'Cannot unlock an undefined object.' );
}
if ( ! ( __private in object ) ) {
const _object = object as Record< symbol, WeakKey >;
if ( ! ( __private in _object ) ) {
throw new Error(

@@ -185,3 +189,3 @@ 'Cannot unlock an object that was not locked before. '

return lockedData.get( object[ __private ] );
return lockedData.get( _object[ __private ] );
}

@@ -188,0 +192,0 @@

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

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