@@ -144,23 +144,6 @@ export function checkObjectHasKeys(obj: object, keys: string[]) {
144144 }
145145}
146146
147- /**
148- * Checks that the given object has no extra keys other than the specified ones.
149- * @param {Object } obj The object to check.
150- * @param {string[] } allowedKeys The list of allowed key names.
151- * @throws If there are extra keys.
152- */
153- export function checkObjectHasNoAdditionalKeys ( obj : object , allowedKeys : string [ ] ) : void {
154- for ( const key in obj ) {
155- if ( ! obj . hasOwnProperty ( key ) ) {
156- continue ;
157- }
158- if ( allowedKeys . indexOf ( key ) === - 1 ) {
159- throw new Error ( "Unknown key: " + key ) ;
160- }
161- }
162- }
163-
164147/**
165148 * Deep copy the given object. The object MUST NOT have circular references and
166149 * MUST NOT have functions.
@@ -283,69 +266,6 @@ export function deepSortedObjectEntries(obj: any): [string, any][] {
283266 return pairs ;
284267}
285268
286- /**
287- * Inherit the prototype methods from one constructor into another. This is a
288- * port of the Node.js implementation with an Object.create polyfill.
289- *
290- * @param {function } ctor Constructor function which needs to inherit the
291- * prototype.
292- * @param {function } superCtor Constructor function to inherit prototype from.
293- */
294- export function inherits ( ctor : Function , superCtor : Function ) {
295- // Add util.inherits from Node.js
296- // Source:
297- // https://github.com/joyent/node/blob/master/lib/util.js
298- // Copyright Joyent, Inc. and other Node contributors.
299- //
300- // Permission is hereby granted, free of charge, to any person obtaining a
301- // copy of this software and associated documentation files (the
302- // "Software"), to deal in the Software without restriction, including
303- // without limitation the rights to use, copy, modify, merge, publish,
304- // distribute, sublicense, and/or sell copies of the Software, and to permit
305- // persons to whom the Software is furnished to do so, subject to the
306- // following conditions:
307- //
308- // The above copyright notice and this permission notice shall be included
309- // in all copies or substantial portions of the Software.
310- //
311- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
312- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
313- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
314- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
315- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
316- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
317- // USE OR OTHER DEALINGS IN THE SOFTWARE.
318- ( ctor as any ) . super_ = superCtor ;
319- ctor . prototype = Object . create ( superCtor . prototype , {
320- constructor : {
321- value : ctor ,
322- enumerable : false ,
323- writable : true ,
324- configurable : true ,
325- } ,
326- } ) ;
327- }
328-
329- /**
330- * Polyfills inheritance for prototypes by allowing different kinds of
331- * super types. Typically prototypes would use `SuperType.call(this, params)`
332- * though this doesn't always work in some environments - this function
333- * falls back to using `Object.assign()` to clone a constructed copy
334- * of the super type onto `thisArg`.
335- * @param {any } thisArg The child instance. Modified in place.
336- * @param {any } SuperType The type to act as a super instance
337- * @param {any } params Arguments to supply to the super type's constructor
338- */
339- export function polyfillSuper ( thisArg : any , SuperType : any , ...params : any [ ] ) {
340- try {
341- SuperType . call ( thisArg , ...params ) ;
342- } catch ( e ) {
343- // fall back to Object.assign to just clone the thing
344- const fakeSuper = new SuperType ( ...params ) ;
345- Object . assign ( thisArg , fakeSuper ) ;
346- }
347- }
348-
349269/**
350270 * Returns whether the given value is a finite number without type-coercion
351271 *
0 commit comments