@ -32,9 +32,9 @@ var Queue = require('./Queue');
*
* @ param { Array } [ data ] Optional array with initial data
* @ param { Object } [ options ] Available options :
* { S tring} fieldId Field name of the id in the
* { s tring} fieldId Field name of the id in the
* items , 'id' by default .
* { Object . < String , S tring} type
* { Object . < string , s tring} type
* A map with field names as key ,
* and the field type as value .
* { Object } queue Queue changes to the DataSet ,
@ -117,12 +117,12 @@ DataSet.prototype.setOptions = function(options) {
/ * *
* Subscribe to an event , add an event listener
* @ param { S tring} event Event name . Available events : 'add' , 'update' ,
* @ param { s tring} event Event name . Available events : 'add' , 'update' ,
* 'remove'
* @ param { function } callback Callback method . Called with three parameters :
* { S tring} event
* { s tring} event
* { Object | null } params
* { String | N umber} senderId
* { string | n umber} senderId
* /
DataSet . prototype . on = function ( event , callback ) {
var subscribers = this . _subscribers [ event ] ;
@ -138,7 +138,7 @@ DataSet.prototype.on = function(event, callback) {
/ * *
* Unsubscribe from an event , remove an event listener
* @ param { S tring} event
* @ param { s tring} event
* @ param { function } callback
* /
DataSet . prototype . off = function ( event , callback ) {
@ -150,9 +150,9 @@ DataSet.prototype.off = function(event, callback) {
/ * *
* Trigger an event
* @ param { S tring} event
* @ param { s tring} event
* @ param { Object | null } params
* @ param { S tring} [ senderId ] Optional id of the sender .
* @ param { s tring} [ senderId ] Optional id of the sender .
* @ private
* /
DataSet . prototype . _trigger = function ( event , params , senderId ) {
@ -180,8 +180,8 @@ DataSet.prototype._trigger = function (event, params, senderId) {
* Add data .
* Adding an item will fail when there already is an item with the same id .
* @ param { Object | Array } data
* @ param { S tring} [ senderId ] Optional sender id
* @ return { Array } addedIds Array with the ids of the added items
* @ param { s tring} [ senderId ] Optional sender id
* @ return { Array . < string | number > } addedIds Array with the ids of the added items
* /
DataSet . prototype . add = function ( data , senderId ) {
var addedIds = [ ] ,
@ -214,8 +214,8 @@ DataSet.prototype.add = function (data, senderId) {
/ * *
* Update existing items . When an item does not exist , it will be created
* @ param { Object | Array } data
* @ param { S tring} [ senderId ] Optional sender id
* @ return { Array } updatedIds The ids of the added or updated items
* @ param { s tring} [ senderId ] Optional sender id
* @ return { Array . < string | number > } updatedIds The ids of the added or updated items
* @ throws { Error } Unknown Datatype
* /
DataSet . prototype . update = function ( data , senderId ) {
@ -287,23 +287,23 @@ DataSet.prototype.update = function (data, senderId) {
* get ( )
* get ( options : Object )
*
* get ( id : Number | S tring)
* get ( id : Number | S tring, options : Object )
* get ( id : number | s tring)
* get ( id : number | s tring, options : Object )
*
* get ( ids : N umber[ ] | S tring[ ] )
* get ( ids : N umber[ ] | S tring[ ] , options : Object )
* get ( ids : n umber[ ] | s tring[ ] )
* get ( ids : n umber[ ] | s tring[ ] , options : Object )
*
* Where :
*
* { Number | S tring} id The id of an item
* { N umber[ ] | S tring{ } } ids An array with ids of items
* { number | s tring} id The id of an item
* { n umber[ ] | s tring{ } } ids An array with ids of items
* { Object } options An Object with options . Available options :
* { S tring} [ returnType ] Type of data to be returned .
* { s tring} [ returnType ] Type of data to be returned .
* Can be 'Array' ( default ) or 'Object' .
* { Object . < String , S tring> } [ type ]
* { S tring[ ] } [ fields ] field names to be returned
* { Object . < string , s tring> } [ type ]
* { s tring[ ] } [ fields ] field names to be returned
* { function } [ filter ] filter items
* { S tring | function } [ order ] Order the items by a field name or custom sort function .
* { s tring | function } [ order ] Order the items by a field name or custom sort function .
* @ param { Array } args
* @ returns { DataSet }
* @ throws Error
@ -417,9 +417,9 @@ DataSet.prototype.get = function (args) { // eslint-disable-line no-unused-vars
* Get ids of all items or from a filtered set of items .
* @ param { Object } [ options ] An Object with options . Available options :
* { function } [ filter ] filter items
* { S tring | function } [ order ] Order the items by
* { s tring | function } [ order ] Order the items by
* a field name or custom sort function .
* @ return { Array } ids
* @ return { Array . < string | number > } ids
* /
DataSet . prototype . getIds = function ( options ) {
var data = this . _data ,
@ -506,10 +506,10 @@ DataSet.prototype.getDataSet = function () {
* Execute a callback function for every item in the dataset .
* @ param { function } callback
* @ param { Object } [ options ] Available options :
* { Object . < String , S tring> } [ type ]
* { S tring[ ] } [ fields ] filter fields
* { Object . < string , s tring> } [ type ]
* { s tring[ ] } [ fields ] filter fields
* { function } [ filter ] filter items
* { S tring | function } [ order ] Order the items by
* { s tring | function } [ order ] Order the items by
* a field name or custom sort function .
* /
DataSet . prototype . forEach = function ( callback , options ) {
@ -548,10 +548,10 @@ DataSet.prototype.forEach = function (callback, options) {
* Map every item in the dataset .
* @ param { function } callback
* @ param { Object } [ options ] Available options :
* { Object . < String , S tring> } [ type ]
* { S tring[ ] } [ fields ] filter fields
* { Object . < string , s tring> } [ type ]
* { s tring[ ] } [ fields ] filter fields
* { function } [ filter ] filter items
* { S tring | function } [ order ] Order the items by
* { s tring | function } [ order ] Order the items by
* a field name or custom sort function .
* @ return { Object [ ] } mappedItems
* /
@ -586,7 +586,7 @@ DataSet.prototype.map = function (callback, options) {
/ * *
* Filter the fields of an item
* @ param { Object | null } item
* @ param { S tring[ ] } fields Field names
* @ param { s tring[ ] } fields Field names
* @ return { Object | null } filteredItem or null if no item is provided
* @ private
* /
@ -623,7 +623,7 @@ DataSet.prototype._filterFields = function (item, fields) {
/ * *
* Sort the provided array with items
* @ param { Object [ ] } items
* @ param { S tring | function } order A field name or custom sort function .
* @ param { s tring | function } order A field name or custom sort function .
* @ private
* /
DataSet . prototype . _sort = function ( items , order ) {
@ -640,7 +640,7 @@ DataSet.prototype._sort = function (items, order) {
// order by sort function
items . sort ( order ) ;
}
// TODO: extend order by an Object {field:String, direction:S tring}
// TODO: extend order by an Object {field:string, direction:s tring}
// where direction can be 'asc' or 'desc'
else {
throw new TypeError ( 'Order must be a function or a string' ) ;
@ -649,10 +649,10 @@ DataSet.prototype._sort = function (items, order) {
/ * *
* Remove an object by pointer or by id
* @ param { String | N umber | Object | Array } id Object or id , or an array with
* @ param { string | n umber | Object | Array . < string | number > } id Object or id , or an array with
* objects or ids to be removed
* @ param { S tring} [ senderId ] Optional sender id
* @ return { Array } removedIds
* @ param { s tring} [ senderId ] Optional sender id
* @ return { Array . < string | number > } removedIds
* /
DataSet . prototype . remove = function ( id , senderId ) {
var removedIds = [ ] ,
@ -683,8 +683,8 @@ DataSet.prototype.remove = function (id, senderId) {
/ * *
* Remove an item by its id
* @ param { Number | S tring | Object } id id or item
* @ returns { Number | S tring | null } id
* @ param { number | s tring | Object } id id or item
* @ returns { number | s tring | null } id
* @ private
* /
DataSet . prototype . _remove = function ( id ) {
@ -711,8 +711,8 @@ DataSet.prototype._remove = function (id) {
/ * *
* Clear the data
* @ param { S tring} [ senderId ] Optional sender id
* @ return { Array } removedIds The ids of all removed items
* @ param { s tring} [ senderId ] Optional sender id
* @ return { Array . < string | number > } removedIds The ids of all removed items
* /
DataSet . prototype . clear = function ( senderId ) {
var i , len ;
@ -733,7 +733,7 @@ DataSet.prototype.clear = function (senderId) {
/ * *
* Find the item with maximum value of a specified field
* @ param { S tring} field
* @ param { s tring} field
* @ return { Object | null } item Item containing max value , or null if no items
* /
DataSet . prototype . max = function ( field ) {
@ -759,7 +759,7 @@ DataSet.prototype.max = function (field) {
/ * *
* Find the item with minimum value of a specified field
* @ param { S tring} field
* @ param { s tring} field
* @ return { Object | null } item Item containing max value , or null if no items
* /
DataSet . prototype . min = function ( field ) {
@ -785,7 +785,7 @@ DataSet.prototype.min = function (field) {
/ * *
* Find all distinct values of a specified field
* @ param { S tring} field
* @ param { s tring} field
* @ return { Array } values Array containing all distinct values . If data items
* do not contain the specified field are ignored .
* The returned array is unordered .
@ -829,7 +829,7 @@ DataSet.prototype.distinct = function (field) {
/ * *
* Add a single item . Will fail when an item with the same id already exists .
* @ param { Object } item
* @ return { S tring} id
* @ return { s tring} id
* @ private
* /
DataSet . prototype . _addItem = function ( item ) {
@ -865,8 +865,8 @@ DataSet.prototype._addItem = function (item) {
/ * *
* Get an item . Fields can be converted to a specific type
* @ param { S tring} id
* @ param { Object . < String , S tring> } [ types ] field types to convert
* @ param { s tring} id
* @ param { Object . < string , s tring> } [ types ] field types to convert
* @ return { Object | null } item
* @ private
* /
@ -911,7 +911,7 @@ DataSet.prototype._getItem = function (id, types) {
* Will fail when the item has no id , or when there does not exist an item
* with the same id .
* @ param { Object } item
* @ return { S tring} id
* @ return { s tring} id
* @ private
* /
DataSet . prototype . _updateItem = function ( item ) {