Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from canjs/deprecate-can-cid-map-and-set
Deprecate cid-map and cid-set
- Loading branch information
Showing
11 changed files
with
24 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,15 @@ | ||
'use strict'; | ||
|
||
var GLOBAL = require('can-globals/global/global'); | ||
var each = require("../each/each"); | ||
var getCID = require("../cid/get-cid"); | ||
//var canDev = require("can-util/js/dev/dev"); | ||
|
||
var CIDMap; | ||
/** | ||
* @module can-util/js/cid-map/cid-map cid-map | ||
* @parent can-util/js | ||
* @description Deprecated. Use [can-cid/map/map] instead. | ||
*/ | ||
|
||
if(GLOBAL().Map) { | ||
CIDMap = GLOBAL().Map; | ||
} else { | ||
var CIDMap = function(){ | ||
this.values = {}; | ||
}; | ||
CIDMap.prototype.set = function(key, value){ | ||
this.values[getCID(key)] = {key: key, value: value}; | ||
}; | ||
CIDMap.prototype["delete"] = function(key){ | ||
var has = getCID(key) in this.values; | ||
if(has) { | ||
delete this.values[getCID(key)]; | ||
} | ||
return has; | ||
}; | ||
CIDMap.prototype.forEach = function(cb, thisArg) { | ||
each(this.values, function(pair){ | ||
return cb.call(thisArg || this, pair.value, pair.key, this); | ||
}, this); | ||
}; | ||
CIDMap.prototype.has = function(key) { | ||
return getCID(key) in this.values; | ||
}; | ||
CIDMap.prototype.get = function(key) { | ||
var obj = this.values[getCID(key)]; | ||
return obj && obj.value; | ||
}; | ||
CIDMap.prototype.clear = function(key) { | ||
return this.values = {}; | ||
}; | ||
Object.defineProperty(CIDMap.prototype,"size",{ | ||
get: function(){ | ||
var size = 0; | ||
each(this.values, function(){ | ||
size++; | ||
}); | ||
return size; | ||
} | ||
}); | ||
} | ||
//!steal-remove-start | ||
// canDev.warn('js/cid-map/cid-map is deprecated; please use can-globals instead: https://github.com/canjs/can-cid'); | ||
//!steal-remove-end | ||
|
||
module.exports = CIDMap; | ||
module.exports = require('can-cid/map/map'); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,15 @@ | ||
'use strict'; | ||
|
||
var GLOBAL = require('can-globals/global/global'); | ||
var each = require("../each/each"); | ||
var getCID = require("../cid/get-cid"); | ||
//var canDev = require("can-util/js/dev/dev"); | ||
|
||
var CIDSet; | ||
/** | ||
* @module can-util/js/cid-set/cid-set cid-set | ||
* @parent can-util/js | ||
* @description Deprecated. Use [can-cid/set/set] instead. | ||
*/ | ||
|
||
if(GLOBAL().Set) { | ||
CIDSet = GLOBAL().Set; | ||
} else { | ||
var CIDSet = function(){ | ||
this.values = {}; | ||
}; | ||
CIDSet.prototype.add = function(value){ | ||
this.values[getCID(value)] = value; | ||
}; | ||
CIDSet.prototype["delete"] = function(key){ | ||
var has = getCID(key) in this.values; | ||
if(has) { | ||
delete this.values[getCID(key)]; | ||
} | ||
return has; | ||
}; | ||
CIDSet.prototype.forEach = function(cb, thisArg) { | ||
each(this.values, cb, thisArg); | ||
}; | ||
CIDSet.prototype.has = function(value) { | ||
return (getCID(value) in this.values); | ||
}; | ||
CIDSet.prototype.clear = function(key) { | ||
return this.values = {}; | ||
}; | ||
Object.defineProperty(CIDSet.prototype,"size",{ | ||
get: function(){ | ||
var size = 0; | ||
each(this.values, function(){ | ||
size++; | ||
}); | ||
return size; | ||
} | ||
}); | ||
} | ||
//!steal-remove-start | ||
// canDev.warn('js/cid-set/cid-set is deprecated; please use can-globals instead: https://github.com/canjs/can-cid'); | ||
//!steal-remove-end | ||
|
||
module.exports = CIDSet; | ||
module.exports = require('can-cid/set/set'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters