spa-component-list
Advanced tools
Comparing version 1.0.1 to 1.0.2
150
index.js
/** | ||
* @license The MIT License (MIT) | ||
* @copyright Stanislav Kalashnik <darkpark.main@gmail.com> | ||
* @author Stanislav Kalashnik <darkpark.main@gmail.com> | ||
*/ | ||
@@ -61,6 +61,12 @@ | ||
if ( DEVELOP ) { | ||
if ( typeof config !== 'object' ) { throw new Error(__filename + ': wrong config type'); } | ||
if ( typeof config !== 'object' ) { | ||
throw new Error(__filename + ': wrong config type'); | ||
} | ||
// init parameters checks | ||
if ( config.className && typeof config.className !== 'string' ) { throw new Error(__filename + ': wrong or empty config.className'); } | ||
if ( config.type && Number(config.type) !== config.type ) { throw new Error(__filename + ': config.type must be a number'); } | ||
if ( 'className' in config && (!config.className || typeof config.className !== 'string') ) { | ||
throw new Error(__filename + ': wrong or empty config.className'); | ||
} | ||
if ( config.type && Number(config.type) !== config.type ) { | ||
throw new Error(__filename + ': config.type must be a number'); | ||
} | ||
} | ||
@@ -241,4 +247,8 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( !Array.isArray(data) ) { throw new Error(__filename + ': wrong data type'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
if ( !Array.isArray(data) ) { | ||
throw new Error(__filename + ': wrong data type'); | ||
} | ||
} | ||
@@ -259,4 +269,8 @@ | ||
if ( DEVELOP ) { | ||
//if ( !('value' in item) ) { throw new Error(__filename + ': field "value" is missing'); } | ||
if ( ('mark' in item) && Boolean(item.mark) !== item.mark ) { throw new Error(__filename + ': item.mark must be boolean'); } | ||
// if ( !('value' in item) ) { | ||
// throw new Error(__filename + ': field "value" is missing'); | ||
// } | ||
if ( ('mark' in item) && Boolean(item.mark) !== item.mark ) { | ||
throw new Error(__filename + ': item.mark must be boolean'); | ||
} | ||
} | ||
@@ -300,4 +314,8 @@ } | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( typeof config !== 'object' ) { throw new Error(__filename + ': wrong config type'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
if ( typeof config !== 'object' ) { | ||
throw new Error(__filename + ': wrong config type'); | ||
} | ||
} | ||
@@ -318,4 +336,7 @@ | ||
if ( DEVELOP ) { | ||
if ( typeof config.render !== 'function' ) { throw new Error(__filename + ': wrong config.render type'); } | ||
if ( typeof config.render !== 'function' ) { | ||
throw new Error(__filename + ': wrong config.render type'); | ||
} | ||
} | ||
// apply | ||
@@ -328,5 +349,10 @@ this.renderItem = config.render; | ||
if ( DEVELOP ) { | ||
if ( Number(config.size) !== config.size ) { throw new Error(__filename + ': config.size must be a number'); } | ||
if ( config.size <= 0 ) { throw new Error(__filename + ': config.size should be positive'); } | ||
if ( Number(config.size) !== config.size ) { | ||
throw new Error(__filename + ': config.size must be a number'); | ||
} | ||
if ( config.size <= 0 ) { | ||
throw new Error(__filename + ': config.size should be positive'); | ||
} | ||
} | ||
// apply | ||
@@ -406,4 +432,7 @@ this.size = config.size; | ||
if ( DEVELOP ) { | ||
if ( !Array.isArray(config.data) ) { throw new Error(__filename + ': wrong config.data type'); } | ||
if ( !Array.isArray(config.data) ) { | ||
throw new Error(__filename + ': wrong config.data type'); | ||
} | ||
} | ||
// prepare user data | ||
@@ -416,6 +445,11 @@ this.data = normalize(config.data); | ||
if ( config.viewIndex !== undefined ) { | ||
if ( Number(config.viewIndex) !== config.viewIndex ) { throw new Error(__filename + ': config.viewIndex must be a number'); } | ||
if ( config.viewIndex < 0 ) { throw new Error(__filename + ': config.viewIndex should be positive'); } | ||
if ( Number(config.viewIndex) !== config.viewIndex ) { | ||
throw new Error(__filename + ': config.viewIndex must be a number'); | ||
} | ||
if ( config.viewIndex < 0 ) { | ||
throw new Error(__filename + ': config.viewIndex should be positive'); | ||
} | ||
} | ||
} | ||
// reset current view window position | ||
@@ -449,5 +483,11 @@ this.viewIndex = null; | ||
if ( DEVELOP ) { | ||
if ( Number(config.focusIndex) !== config.focusIndex ) { throw new Error(__filename + ': config.focusIndex must be a number'); } | ||
if ( config.focusIndex < 0 ) { throw new Error(__filename + ': config.focusIndex should be positive'); } | ||
// if ( config.focusIndex > this.data.length - 1 ) { throw new Error(__filename + ': config.focusIndex should be less than data size'); } | ||
if ( Number(config.focusIndex) !== config.focusIndex ) { | ||
throw new Error(__filename + ': config.focusIndex must be a number'); | ||
} | ||
if ( config.focusIndex < 0 ) { | ||
throw new Error(__filename + ': config.focusIndex should be positive'); | ||
} | ||
// if ( config.focusIndex > this.data.length - 1 ) { | ||
// throw new Error(__filename + ': config.focusIndex should be less than data size'); | ||
// } | ||
} | ||
@@ -488,6 +528,14 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( Number(index) !== index ) { throw new Error(__filename + ': index must be a number'); } | ||
if ( index < 0 ) { throw new Error(__filename + ': index should be more than zero'); } | ||
// if ( index >= this.data.length ) { throw new Error(__filename + ': index should be less than data size'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
if ( Number(index) !== index ) { | ||
throw new Error(__filename + ': index must be a number'); | ||
} | ||
if ( index < 0 ) { | ||
throw new Error(__filename + ': index should be more than zero'); | ||
} | ||
// if ( index >= this.data.length ) { | ||
// throw new Error(__filename + ': index should be less than data size'); | ||
// } | ||
} | ||
@@ -589,4 +637,8 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( Number(direction) !== direction ) { throw new Error(__filename + ': direction must be a number'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
if ( Number(direction) !== direction ) { | ||
throw new Error(__filename + ': direction must be a number'); | ||
} | ||
} | ||
@@ -833,3 +885,5 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
} | ||
@@ -840,4 +894,8 @@ | ||
if ( DEVELOP ) { | ||
if ( !($item instanceof Element) ) { throw new Error(__filename + ': wrong $item type'); } | ||
if ( $item.parentNode !== this.$body ) { throw new Error(__filename + ': wrong $item parent element'); } | ||
if ( !($item instanceof Element) ) { | ||
throw new Error(__filename + ': wrong $item type'); | ||
} | ||
if ( $item.parentNode !== this.$body ) { | ||
throw new Error(__filename + ': wrong $item parent element'); | ||
} | ||
} | ||
@@ -848,3 +906,5 @@ | ||
if ( DEVELOP ) { | ||
if ( !($prev instanceof Element) ) { throw new Error(__filename + ': wrong $prev type'); } | ||
if ( !($prev instanceof Element) ) { | ||
throw new Error(__filename + ': wrong $prev type'); | ||
} | ||
} | ||
@@ -923,3 +983,5 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 1 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( arguments.length !== 1 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
} | ||
@@ -963,5 +1025,11 @@ | ||
if ( DEVELOP ) { | ||
if ( Number(index) !== index ) { throw new Error(__filename + ': index must be a number'); } | ||
if ( index < 0 ) { throw new Error(__filename + ': index should be positive'); } | ||
// if ( index > this.data.length - 1 ) { throw new Error(__filename + ': index should be less than data size'); } | ||
if ( Number(index) !== index ) { | ||
throw new Error(__filename + ': index must be a number'); | ||
} | ||
if ( index < 0 ) { | ||
throw new Error(__filename + ': index should be positive'); | ||
} | ||
// if ( index > this.data.length - 1 ) { | ||
// throw new Error(__filename + ': index should be less than data size'); | ||
// } | ||
} | ||
@@ -1001,6 +1069,14 @@ | ||
if ( DEVELOP ) { | ||
if ( arguments.length !== 2 ) { throw new Error(__filename + ': wrong arguments number'); } | ||
if ( !($item instanceof Element) ) { throw new Error(__filename + ': wrong $item type'); } | ||
if ( $item.parentNode !== this.$body ) { throw new Error(__filename + ': wrong $item parent element'); } | ||
if ( Boolean(state) !== state ) { throw new Error(__filename + ': state must be boolean'); } | ||
if ( arguments.length !== 2 ) { | ||
throw new Error(__filename + ': wrong arguments number'); | ||
} | ||
if ( !($item instanceof Element) ) { | ||
throw new Error(__filename + ': wrong $item type'); | ||
} | ||
if ( $item.parentNode !== this.$body ) { | ||
throw new Error(__filename + ': wrong $item parent element'); | ||
} | ||
if ( Boolean(state) !== state ) { | ||
throw new Error(__filename + ': state must be boolean'); | ||
} | ||
} | ||
@@ -1007,0 +1083,0 @@ |
{ | ||
"name": "spa-component-list", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Base list implementation.", | ||
@@ -15,16 +15,17 @@ "author": { | ||
"sass": "node-sass --indent-width 4 --include-path ../../.. sass/develop.scss css/develop.css && node-sass --indent-width 4 --include-path ../../.. sass/release.scss css/release.css", | ||
"lint": "eslint .", | ||
"lint": "eslint --ignore-pattern '/docs/' .", | ||
"test": "npm run lint", | ||
"jsdoc": "jsdoc --destination doc *.js readme.md" | ||
"jsdoc": "jsdoc --destination docs *.js readme.md" | ||
}, | ||
"dependencies": { | ||
"spa-component": "1.*.*", | ||
"spa-keys": "1.*.*" | ||
"spa-component": "^1.5.0", | ||
"spa-keys": "^1.4.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "3.*.*", | ||
"spa-eslint-config": "1.*.*" | ||
"jsdoc": "^3.5.5", | ||
"spa-eslint": "^1.0.0" | ||
}, | ||
"keywords": [ | ||
"spa", | ||
"sdk", | ||
"spasdk", | ||
@@ -31,0 +32,0 @@ "framework", |
@@ -37,4 +37,4 @@ List component | ||
If you have any problem or suggestion please open an issue [here](https://github.com/spasdk/component-list/issues). | ||
Pull requests are welcomed with respect to the [JavaScript Code Style](https://github.com/DarkPark/jscs). | ||
If you have any problems or suggestions please open an [issue](https://github.com/spasdk/component-list/issues) | ||
according to the contribution [rules](.github/contributing.md). | ||
@@ -41,0 +41,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
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40476
11
1023
1
Updatedspa-component@^1.5.0
Updatedspa-keys@^1.4.1