From 8219cae7aeff5cf60f335dc670710325f6239731 Mon Sep 17 00:00:00 2001 From: Openbyte Date: Thu, 15 Feb 2018 20:05:57 +0100 Subject: [PATCH] removed linting errors --- types/object-merge/index.d.ts | 299 ++++++++++++----------- types/object-merge/object-merge-tests.ts | 36 ++- 2 files changed, 165 insertions(+), 170 deletions(-) diff --git a/types/object-merge/index.d.ts b/types/object-merge/index.d.ts index 33ef99276d..f200c1e268 100644 --- a/types/object-merge/index.d.ts +++ b/types/object-merge/index.d.ts @@ -1,163 +1,164 @@ -// Type definitions for object-merge 2.5.1 +// Type definitions for object-merge 2.5 // Project: https://github.com/matthewkastor/object-merge // Definitions by: OpenByteDev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -type ObjectMergeOptions = { depth: number|boolean, throwOnCircularRef: boolean }; +interface ObjectMergeOptions { + depth: number|boolean; + throwOnCircularRef: boolean; +} interface ObjectMerge { /** - * Merges JavaScript objects recursively without altering the objects merged. - * @namespace Merges JavaScript objects recursively without altering the objects merged. - * @author Matthew Kastor - * @param {ObjectMergeOptions} [opts] An options object created by - * objectMerge.createOptions. Options must be specified as the first argument - * and must be an object created with createOptions or else the object will - * not be recognized as an options object and will be merged instead. - * @param {Object} shadows [[shadows]...] One or more objects to merge. Each - * argument given will be treated as an object to merge. Each object - * overwrites the previous objects descendant properties if the property name - * matches. If objects properties are objects they will be merged recursively - * as well. - * @returns {Object} Returns a single merged object composed from clones of the - * input objects. - * @example - * var objectMerge = require('object-merge'); - * var x = { - * a : 'a', - * b : 'b', - * c : { - * d : 'd', - * e : 'e', - * f : { - * g : 'g' - * } - * } - * }; - * var y = { - * a : '`a', - * b : '`b', - * c : { - * d : '`d' - * } - * }; - * var z = { - * a : { - * b : '``b' - * }, - * fun : function foo () { - * return 'foo'; - * }, - * aps : Array.prototype.slice - * }; - * var out = objectMerge(x, y, z); - * // out.a will be { - * // b : '``b' - * // } - * // out.b will be '`b' - * // out.c will be { - * // d : '`d', - * // e : 'e', - * // f : { - * // g : 'g' - * // } - * // } - * // out.fun will be a clone of z.fun - * // out.aps will be equal to z.aps - */ - (opts: ObjectMergeOptions, ...shadows: object[]): object + * Merges JavaScript objects recursively without altering the objects merged. + * @author Matthew Kastor + * @param [opts] An options object created by + * objectMerge.createOptions. Options must be specified as the first argument + * and must be an object created with createOptions or else the object will + * not be recognized as an options object and will be merged instead. + * @param shadows [[shadows]...] One or more objects to merge. Each + * argument given will be treated as an object to merge. Each object + * overwrites the previous objects descendant properties if the property name + * matches. If objects properties are objects they will be merged recursively + * as well. + * @returns Returns a single merged object composed from clones of the + * input objects. + * @example + * var objectMerge = require('object-merge'); + * var x = { + * a : 'a', + * b : 'b', + * c : { + * d : 'd', + * e : 'e', + * f : { + * g : 'g' + * } + * } + * }; + * var y = { + * a : '`a', + * b : '`b', + * c : { + * d : '`d' + * } + * }; + * var z = { + * a : { + * b : '``b' + * }, + * fun : function foo () { + * return 'foo'; + * }, + * aps : Array.prototype.slice + * }; + * var out = objectMerge(x, y, z); + * // out.a will be { + * // b : '``b' + * // } + * // out.b will be '`b' + * // out.c will be { + * // d : '`d', + * // e : 'e', + * // f : { + * // g : 'g' + * // } + * // } + * // out.fun will be a clone of z.fun + * // out.aps will be equal to z.aps + */ + (opts: ObjectMergeOptions, ...shadows: object[]): object; /** - * Merges JavaScript objects recursively without altering the objects merged. - * @namespace Merges JavaScript objects recursively without altering the objects merged. - * @author Matthew Kastor - * @param {Object} shadows [[shadows]...] One or more objects to merge. Each - * argument given will be treated as an object to merge. Each object - * overwrites the previous objects descendant properties if the property name - * matches. If objects properties are objects they will be merged recursively - * as well. - * @returns {Object} Returns a single merged object composed from clones of the - * input objects. - * @example - * var objectMerge = require('object-merge'); - * var x = { - * a : 'a', - * b : 'b', - * c : { - * d : 'd', - * e : 'e', - * f : { - * g : 'g' - * } - * } - * }; - * var y = { - * a : '`a', - * b : '`b', - * c : { - * d : '`d' - * } - * }; - * var z = { - * a : { - * b : '``b' - * }, - * fun : function foo () { - * return 'foo'; - * }, - * aps : Array.prototype.slice - * }; - * var out = objectMerge(x, y, z); - * // out.a will be { - * // b : '``b' - * // } - * // out.b will be '`b' - * // out.c will be { - * // d : '`d', - * // e : 'e', - * // f : { - * // g : 'g' - * // } - * // } - * // out.fun will be a clone of z.fun - * // out.aps will be equal to z.aps - */ - (...shadows: object[]): object + * Merges JavaScript objects recursively without altering the objects merged. + * @author Matthew Kastor + * @param shadows [[shadows]...] One or more objects to merge. Each + * argument given will be treated as an object to merge. Each object + * overwrites the previous objects descendant properties if the property name + * matches. If objects properties are objects they will be merged recursively + * as well. + * @returns Returns a single merged object composed from clones of the + * input objects. + * @example + * var objectMerge = require('object-merge'); + * var x = { + * a : 'a', + * b : 'b', + * c : { + * d : 'd', + * e : 'e', + * f : { + * g : 'g' + * } + * } + * }; + * var y = { + * a : '`a', + * b : '`b', + * c : { + * d : '`d' + * } + * }; + * var z = { + * a : { + * b : '``b' + * }, + * fun : function foo () { + * return 'foo'; + * }, + * aps : Array.prototype.slice + * }; + * var out = objectMerge(x, y, z); + * // out.a will be { + * // b : '``b' + * // } + * // out.b will be '`b' + * // out.c will be { + * // d : '`d', + * // e : 'e', + * // f : { + * // g : 'g' + * // } + * // } + * // out.fun will be a clone of z.fun + * // out.aps will be equal to z.aps + */ + (...shadows: object[]): object; /** - * Creates a new options object suitable for use with objectMerge. - * @memberOf objectMerge - * @param {Object} [opts] An object specifying the options. - * @param {Object} [opts.depth = false] Specifies the depth to traverse objects - * during merging. If this is set to false then there will be no depth limit. - * @param {Object} [opts.throwOnCircularRef = true] Set to false to suppress - * errors on circular references. - * @returns {ObjectMergeOptions} Returns an instance of ObjectMergeOptions - * to be used with objectMerge. - * @example - * var opts = objectMerge.createOptions({ - * depth : 2, - * throwOnCircularRef : false - * }); - * var obj1 = { - * a1 : { - * a2 : { - * a3 : {} - * } - * } - * }; - * var obj2 = { - * a1 : { - * a2 : { - * a3 : 'will not be in output' - * }, - * a22 : {} - * } - * }; - * objectMerge(opts, obj1, obj2); - */ - createOptions: (options:object) => ObjectMergeOptions + * Creates a new options object suitable for use with objectMerge. + * @param [opts] An object specifying the options. + * @param [opts.depth = false] Specifies the depth to traverse objects + * during merging. If this is set to false then there will be no depth limit. + * @param [opts.throwOnCircularRef = true] Set to false to suppress + * errors on circular references. + * @returns Returns an instance of ObjectMergeOptions + * to be used with objectMerge. + * @example + * var opts = objectMerge.createOptions({ + * depth : 2, + * throwOnCircularRef : false + * }); + * var obj1 = { + * a1 : { + * a2 : { + * a3 : {} + * } + * } + * }; + * var obj2 = { + * a1 : { + * a2 : { + * a3 : 'will not be in output' + * }, + * a22 : {} + * } + * }; + * objectMerge(opts, obj1, obj2); + */ + createOptions: (options: object) => ObjectMergeOptions; } declare const objectMerge: ObjectMerge; -export default objectMerge; \ No newline at end of file +export default objectMerge; diff --git a/types/object-merge/object-merge-tests.ts b/types/object-merge/object-merge-tests.ts index 9c2adba824..e0b2d69ad0 100644 --- a/types/object-merge/object-merge-tests.ts +++ b/types/object-merge/object-merge-tests.ts @@ -1,6 +1,6 @@ import objectMerge from 'object-merge'; -let x = { +const x = { a : 'a', b : 'b', c : { @@ -8,46 +8,40 @@ let x = { e : 'e', f : { g : 'g' - } } }; -let y = { +const y = { a : '`a', b : '`b', c : { d : '`d' } }; -let z = { +const z = { a : { b : '``b' }, - fun : function foo () { + fun : function foo() { return 'foo'; }, aps : Array.prototype.slice }; +const out = objectMerge(x, y, z); -let out = objectMerge(x, y, z); - - - -let a = { - 'a1' : { - 'a2' : { - 'a3' : {} +const a = { + a1 : { + a2 : { + a3 : {} } } }; -let b = { - 'b1' : { - 'b2' : { - 'b3' : {} +const b = { + b1 : { + b2 : { + b3 : {} } } }; -let opts = objectMerge.createOptions({depth : 2}); -let res = objectMerge(opts, a, b); - -objectMerge(a, b); \ No newline at end of file +const opts = objectMerge.createOptions({depth : 2}); +const res = objectMerge(opts, a, b);