From c9fb8d49b4d093422e4ec6c4d3b2b3445bd0bac1 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Mon, 26 Oct 2026 20:49:04 +0530 Subject: [PATCH 1/2] feat: add docs to plot/vega/padding/ctor --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/plot/vega/padding/ctor/README.md | 266 ++++++++++++++++++ .../vega/padding/ctor/benchmark/benchmark.js | 76 +++++ .../plot/vega/padding/ctor/docs/repl.txt | 67 +++++ .../vega/padding/ctor/docs/types/index.d.ts | 233 +++++++++++++++ .../plot/vega/padding/ctor/docs/types/test.ts | 153 ++++++++++ 5 files changed, 795 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/padding/ctor/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/README.md b/lib/node_modules/@stdlib/plot/vega/padding/ctor/README.md new file mode 100644 index 000000000000..89f77bc2a798 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/README.md @@ -0,0 +1,266 @@ + + +# Padding + +> Padding constructor. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Padding = require( '@stdlib/plot/vega/padding/ctor' ); +``` + +#### Padding( \[options] ) + +Returns a padding instance. + +```javascript +var padding = new Padding(); +// returns +``` + +The constructor accepts the following `options`: + +- **bottom**: bottom padding (in pixels). Default: `0`. +- **left**: left padding (in pixels). Default: `0`. +- **right**: right padding (in pixels). Default: `0`. +- **top**: top padding (in pixels). Default: `0`. + +```javascript +var padding = new Padding({ + 'bottom': 10, + 'left': 20, + 'right': 30, + 'top': 40 +}); +// returns + +var v = padding.top; +// returns 40 +``` + +* * * + +### Writable Properties + + + +#### Padding.prototype.bottom + +Bottom padding (in pixels). Default: `0`. + +```javascript +var padding = new Padding(); + +// Set: +padding.bottom = 10; + +// Get: +var v = padding.bottom; +// returns 10 +``` + + + +#### Padding.prototype.left + +Left padding (in pixels). Default: `0`. + +```javascript +var padding = new Padding(); + +// Set: +padding.left = 10; + +// Get: +var v = padding.left; +// returns 10 +``` + + + +#### Padding.prototype.right + +Right padding (in pixels). Default: `0`. + +```javascript +var padding = new Padding(); + +// Set: +padding.right = 10; + +// Get: +var v = padding.right; +// returns 10 +``` + + + +#### Padding.prototype.top + +Top padding (in pixels). Default: `0`. + +```javascript +var padding = new Padding(); + +// Set: +padding.top = 10; + +// Get: +var v = padding.top; +// returns 10 +``` + +* * * + +### Read-only Properties + + + +#### Padding.prototype.properties + +List of enumerable properties. + +```javascript +var padding = new Padding(); + +var v = padding.properties; +// returns [ 'bottom', 'left', 'right', 'top' ] +``` + +* * * + +### Methods + + + +#### Padding.prototype.toJSON() + +Serializes a padding instance to a JSON object. + +```javascript +var padding = new Padding({ + 'top': 10 +}); + +var v = padding.toJSON(); +// returns { 'bottom': 0, 'left': 0, 'right': 0, 'top': 10 } +``` + +This method is implicitly invoked by `JSON.stringify`. + +```javascript +var padding = new Padding({ + 'top': 10 +}); + +var str = JSON.stringify( padding ); +// returns '{"bottom":0,"left":0,"right":0,"top":10}' +``` + +* * * + +### Events + +#### 'change' + +Emitted whenever a property value changes. + +```javascript +var padding = new Padding(); + +padding.on( 'change', onChange ); + +padding.top = 10; + +function onChange( event ) { + console.log( 'Updated property: %s', event.property ); +} +``` + +
+ + + + + +
+ +
+ + + + + +
+ +* * * + +## Examples + + + +```javascript +var Padding = require( '@stdlib/plot/vega/padding/ctor' ); + +var padding = new Padding(); +console.log( padding.toJSON() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js new file mode 100644 index 000000000000..294cb5e1fa4b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Padding = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::instantiation', pkg ), function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = new Padding(); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + } + b.toc(); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::instantiation,options', pkg ), function benchmark( b ) { + var opts; + var v; + var i; + + opts = { + 'bottom': 10, + 'left': 20, + 'right': 30, + 'top': 40 + }; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = new Padding( opts ); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + } + b.toc(); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/repl.txt new file mode 100644 index 000000000000..ac7dce9ad620 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/repl.txt @@ -0,0 +1,67 @@ + +{{alias}}( [options] ) + Returns a padding instance. + + Parameters + ---------- + options: Object (optional) + Options. + + options.bottom: number (optional) + Bottom padding (in pixels). Default: 0. + + options.left: number (optional) + Left padding (in pixels). Default: 0. + + options.right: number (optional) + Right padding (in pixels). Default: 0. + + options.top: number (optional) + Top padding (in pixels). Default: 0. + + Returns + ------- + padding: Padding + Padding instance. + + padding.bottom + Bottom padding (in pixels). + + padding.left + Left padding (in pixels). + + padding.properties + List of enumerable properties. + + padding.right + Right padding (in pixels). + + padding.top + Top padding (in pixels). + + padding.toJSON() + Serializes a padding instance to a JSON object. + + Examples + -------- + > var padding = new {{alias}}() + + + // Provide options at instantiation: + > padding = new {{alias}}( { 'top': 10, 'bottom': 20 } ) + + > padding.top + 10 + + // Set a property: + > padding.left = 30; + > padding.left + 30 + + // Serialize to JSON: + > padding.toJSON() + { 'bottom': 20, 'left': 30, 'right': 0, 'top': 10 } + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/index.d.ts new file mode 100644 index 000000000000..7ee27dc9df3e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/index.d.ts @@ -0,0 +1,233 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing constructor options. +*/ +interface Options { + /** + * Bottom padding (in pixels). Default: 0. + */ + bottom?: number; + + /** + * Left padding (in pixels). Default: 0. + */ + left?: number; + + /** + * Right padding (in pixels). Default: 0. + */ + right?: number; + + /** + * Top padding (in pixels). Default: 0. + */ + top?: number; +} + +/** +* Interface describing a JSON-serialized padding instance. +*/ +interface JSON { + /** + * Bottom padding (in pixels). + */ + bottom: number; + + /** + * Left padding (in pixels). + */ + left: number; + + /** + * Right padding (in pixels). + */ + right: number; + + /** + * Top padding (in pixels). + */ + top: number; +} + +/** +* Interface describing a padding instance. +*/ +interface Padding { + /** + * Bottom padding (in pixels). + * + * @example + * var padding = new Padding(); + * + * padding.bottom = 10; + * + * var v = padding.bottom; + * // returns 10 + */ + bottom: number; + + /** + * Left padding (in pixels). + * + * @example + * var padding = new Padding(); + * + * padding.left = 10; + * + * var v = padding.left; + * // returns 10 + */ + left: number; + + /** + * List of enumerable properties. + * + * @example + * var padding = new Padding(); + * + * var v = padding.properties; + * // returns [ 'bottom', 'left', 'right', 'top' ] + */ + readonly properties: Array; + + /** + * Right padding (in pixels). + * + * @example + * var padding = new Padding(); + * + * padding.right = 10; + * + * var v = padding.right; + * // returns 10 + */ + right: number; + + /** + * Top padding (in pixels). + * + * @example + * var padding = new Padding(); + * + * padding.top = 10; + * + * var v = padding.top; + * // returns 10 + */ + top: number; + + /** + * Serializes a padding instance to a JSON object. + * + * ## Notes + * + * - This method is implicitly invoked by `JSON.stringify`. + * + * @returns JSON object + * + * @example + * var padding = new Padding({ + * 'top': 10 + * }); + * + * var v = padding.toJSON(); + * // returns { 'bottom': 0, 'left': 0, 'right': 0, 'top': 10 } + */ + toJSON(): JSON; +} + +/** +* Interface defining a padding constructor which is both "newable" and "callable". +*/ +interface Constructor { + /** + * Padding constructor. + * + * @param options - constructor options + * @param options.bottom - bottom padding (in pixels) (default: 0) + * @param options.left - left padding (in pixels) (default: 0) + * @param options.right - right padding (in pixels) (default: 0) + * @param options.top - top padding (in pixels) (default: 0) + * @throws options argument must be an object + * @throws must provide valid options + * @returns padding instance + * + * @example + * var padding = new Padding({ + * 'top': 10 + * }); + * + * var v = padding.top; + * // returns 10 + */ + new ( options?: Options ): Padding; + + /** + * Padding constructor. + * + * @param options - constructor options + * @param options.bottom - bottom padding (in pixels) (default: 0) + * @param options.left - left padding (in pixels) (default: 0) + * @param options.right - right padding (in pixels) (default: 0) + * @param options.top - top padding (in pixels) (default: 0) + * @throws options argument must be an object + * @throws must provide valid options + * @returns padding instance + * + * @example + * var padding = Padding({ + * 'top': 10 + * }); + * + * var v = padding.top; + * // returns 10 + */ + ( options?: Options ): Padding; +} + +/** +* Padding constructor. +* +* @param options - constructor options +* @param options.bottom - bottom padding (in pixels) (default: 0) +* @param options.left - left padding (in pixels) (default: 0) +* @param options.right - right padding (in pixels) (default: 0) +* @param options.top - top padding (in pixels) (default: 0) +* @throws options argument must be an object +* @throws must provide valid options +* @returns padding instance +* +* @example +* var padding = new Padding(); +* // returns +* +* var v = padding.toJSON(); +* // returns { 'bottom': 0, 'left': 0, 'right': 0, 'top': 0 } +*/ +declare var ctor: Constructor; + + +// EXPORTS // + +export = ctor; + +// eslint-doctest-alias: Padding diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/test.ts new file mode 100644 index 000000000000..49ba4a6603bb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/docs/types/test.ts @@ -0,0 +1,153 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Padding = require( './index' ); + + +// TESTS // + +// The function returns a padding instance... +{ + new Padding(); // $ExpectType Padding + new Padding( {} ); // $ExpectType Padding + new Padding( { 'top': 10 } ); // $ExpectType Padding + new Padding( { 'bottom': 10, 'left': 20, 'right': 30, 'top': 40 } ); // $ExpectType Padding + + Padding(); // $ExpectType Padding + Padding( {} ); // $ExpectType Padding + Padding( { 'top': 10 } ); // $ExpectType Padding + Padding( { 'bottom': 10, 'left': 20, 'right': 30, 'top': 40 } ); // $ExpectType Padding +} + +// The compiler throws an error if the function is provided an options argument which is not an object... +{ + new Padding( '5' ); // $ExpectError + new Padding( 5 ); // $ExpectError + new Padding( true ); // $ExpectError + new Padding( false ); // $ExpectError + new Padding( null ); // $ExpectError + new Padding( [] ); // $ExpectError + new Padding( ( x: number ): number => x ); // $ExpectError + + Padding( '5' ); // $ExpectError + Padding( 5 ); // $ExpectError + Padding( true ); // $ExpectError + Padding( false ); // $ExpectError + Padding( null ); // $ExpectError + Padding( [] ); // $ExpectError + Padding( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `bottom` option which is not a number... +{ + new Padding( { 'bottom': '5' } ); // $ExpectError + new Padding( { 'bottom': true } ); // $ExpectError + new Padding( { 'bottom': false } ); // $ExpectError + new Padding( { 'bottom': null } ); // $ExpectError + new Padding( { 'bottom': [] } ); // $ExpectError + new Padding( { 'bottom': {} } ); // $ExpectError + new Padding( { 'bottom': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `left` option which is not a number... +{ + new Padding( { 'left': '5' } ); // $ExpectError + new Padding( { 'left': true } ); // $ExpectError + new Padding( { 'left': false } ); // $ExpectError + new Padding( { 'left': null } ); // $ExpectError + new Padding( { 'left': [] } ); // $ExpectError + new Padding( { 'left': {} } ); // $ExpectError + new Padding( { 'left': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `right` option which is not a number... +{ + new Padding( { 'right': '5' } ); // $ExpectError + new Padding( { 'right': true } ); // $ExpectError + new Padding( { 'right': false } ); // $ExpectError + new Padding( { 'right': null } ); // $ExpectError + new Padding( { 'right': [] } ); // $ExpectError + new Padding( { 'right': {} } ); // $ExpectError + new Padding( { 'right': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `top` option which is not a number... +{ + new Padding( { 'top': '5' } ); // $ExpectError + new Padding( { 'top': true } ); // $ExpectError + new Padding( { 'top': false } ); // $ExpectError + new Padding( { 'top': null } ); // $ExpectError + new Padding( { 'top': [] } ); // $ExpectError + new Padding( { 'top': {} } ); // $ExpectError + new Padding( { 'top': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided more than one argument... +{ + new Padding( {}, {} ); // $ExpectError + Padding( {}, {} ); // $ExpectError +} + +// A padding instance has numeric padding properties... +{ + const padding = new Padding(); + + const bottom = padding.bottom; // $ExpectType number + const left = padding.left; // $ExpectType number + const right = padding.right; // $ExpectType number + const top = padding.top; // $ExpectType number + + if ( bottom + left + right + top < 0 ) { + throw new Error( 'unexpected error' ); + } +} + +// The compiler throws an error if a padding property is assigned a value which is not a number... +{ + const padding = new Padding(); + + padding.bottom = '5'; // $ExpectError + padding.left = true; // $ExpectError + padding.right = null; // $ExpectError + padding.top = []; // $ExpectError +} + +// A padding instance has a read-only `properties` property... +{ + const padding = new Padding(); + + const props = padding.properties; // $ExpectType string[] + if ( props.length !== 4 ) { + throw new Error( 'unexpected error' ); + } + padding.properties = [ 'top' ]; // $ExpectError +} + +// A padding instance has a `toJSON` method which returns a JSON object... +{ + const padding = new Padding(); + + padding.toJSON(); // $ExpectType JSON +} + +// The compiler throws an error if the `toJSON` method is provided arguments... +{ + const padding = new Padding(); + + padding.toJSON( {} ); // $ExpectError +} From f21ee417852c344442d1b9ee2bd4f45c2ca8372a Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Mon, 26 Oct 2026 20:58:10 +0530 Subject: [PATCH 2/2] refactor: benchmark --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../vega/padding/ctor/benchmark/benchmark.js | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js index 294cb5e1fa4b..ee8aa0f14821 100644 --- a/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/plot/vega/padding/ctor/benchmark/benchmark.js @@ -22,6 +22,8 @@ var bench = require( '@stdlib/bench' ); var instanceOf = require( '@stdlib/assert/instance-of' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Padding = require( './../lib' ); @@ -48,6 +50,28 @@ bench( format( '%s::instantiation', pkg ), function benchmark( b ) { b.end(); }); +bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { + var ctor; + var v; + var i; + + ctor = Padding; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = ctor(); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + } + b.toc(); + if ( !instanceOf( v, Padding ) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( format( '%s::instantiation,options', pkg ), function benchmark( b ) { var opts; var v; @@ -74,3 +98,140 @@ bench( format( '%s::instantiation,options', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); + +bench( format( '%s::set,get:bottom', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + values = [ + 10, + 20, + 30 + ]; + v = new Padding(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v.bottom = values[ i % values.length ]; + if ( !isNumber( v.bottom ) ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isNumber( v.bottom ) ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::set,get:left', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + values = [ + 10, + 20, + 30 + ]; + v = new Padding(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v.left = values[ i % values.length ]; + if ( !isNumber( v.left ) ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isNumber( v.left ) ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::set,get:right', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + values = [ + 10, + 20, + 30 + ]; + v = new Padding(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v.right = values[ i % values.length ]; + if ( !isNumber( v.right ) ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isNumber( v.right ) ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::set,get:top', pkg ), function benchmark( b ) { + var values; + var v; + var i; + + values = [ + 10, + 20, + 30 + ]; + v = new Padding(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v.top = values[ i % values.length ]; + if ( !isNumber( v.top ) ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isNumber( v.top ) ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:toJSON', pkg ), function benchmark( b ) { + var values; + var v; + var o; + var i; + + values = [ + 10, + 20, + 30 + ]; + v = new Padding(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v.top = values[ i % values.length ]; + o = v.toJSON(); + if ( typeof o !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isPlainObject( o ) ) { + b.fail( 'should return an object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +});