mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-20 10:16:29 +10:00
1 line
3.6 KiB
JavaScript
1 line
3.6 KiB
JavaScript
function Set(){"use strict";var t=Array.prototype.slice.call(arguments,0);return Set.from(t)}var SequenceModule=require("./Sequence"),ImmutableMap=require("./Map"),Sequence=SequenceModule.Sequence,IndexedSequence=SequenceModule.IndexedSequence;for(var Sequence____Key in Sequence)Sequence.hasOwnProperty(Sequence____Key)&&(Set[Sequence____Key]=Sequence[Sequence____Key]);var ____SuperProtoOfSequence=null===Sequence?null:Sequence.prototype;Set.prototype=Object.create(____SuperProtoOfSequence),Set.prototype.constructor=Set,Set.__superConstructor__=Sequence,Set.empty=function(){"use strict";return __EMPTY_SET||(__EMPTY_SET=Set.$Set_make())},Set.from=function(t){"use strict";return t&&t.constructor===Set?t:t&&0!==t.length?Set.empty().union(t):Set.empty()},Set.fromKeys=function(t){"use strict";return Set.from(Sequence(t).flip())},Set.prototype.toString=function(){"use strict";return this.__toString("Set {","}")},Set.prototype.has=function(t){"use strict";return this.$Set_map?this.$Set_map.has(t):!1},Set.prototype.get=function(t,e){"use strict";return this.has(t)?t:e},Set.prototype.add=function(t){"use strict";if(null==t)return this;var e=this.$Set_map;return e||(e=ImmutableMap.empty().__ensureOwner(this.__ownerID)),e=e.set(t,null),this.__ownerID?(this.length=e.length,this.$Set_map=e,this):e===this.$Set_map?this:Set.$Set_make(e)},Set.prototype.delete=function(t){"use strict";if(null==t||null==this.$Set_map)return this;var e=this.$Set_map.delete(t);return 0===e.length?this.clear():this.__ownerID?(this.length=e.length,this.$Set_map=e,this):e===this.$Set_map?this:Set.$Set_make(e)},Set.prototype.clear=function(){"use strict";return this.__ownerID?(this.length=0,this.$Set_map=null,this):Set.empty()},Set.prototype.union=function(){"use strict";var t=arguments;return 0===t.length?this:this.withMutations(function(e){for(var r=0;r<t.length;r++){var n=t[r];n=n.forEach?n:Sequence(n),n.forEach(function(t){return e.add(t)})}})},Set.prototype.intersect=function(){"use strict";var t=Array.prototype.slice.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return Sequence(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.every(function(t){return t.contains(e)})||r.delete(e)})})},Set.prototype.subtract=function(){"use strict";var t=Array.prototype.slice.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return Sequence(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.some(function(t){return t.contains(e)})&&r.delete(e)})})},Set.prototype.isSubset=function(t){"use strict";return t=Sequence(t),this.every(function(e){return t.contains(e)})},Set.prototype.isSuperset=function(t){"use strict";var e=this;return t=Sequence(t),t.every(function(t){return e.contains(t)})},Set.prototype.__ensureOwner=function(t){"use strict";if(t===this.__ownerID)return this;var e=this.$Set_map&&this.$Set_map.__ensureOwner(t);return t?Set.$Set_make(e,t):(this.__ownerID=t,this.$Set_map=e,this)},Set.prototype.__deepEquals=function(t){"use strict";return!(this.$Set_map||t.$Set_map)||this.$Set_map.equals(t.$Set_map)},Set.prototype.__iterate=function(t,e){"use strict";var r=this;return this.$Set_map?this.$Set_map.__iterate(function(e,n){return t(n,n,r)},e):0},Set.$Set_make=function(t,e){"use strict";var r=Object.create(Set.prototype);return r.length=t?t.length:0,r.$Set_map=t,r.__ownerID=e,r},Set.prototype.contains=Set.prototype.has,Set.prototype.withMutations=ImmutableMap.prototype.withMutations,Set.prototype.__toJS=IndexedSequence.prototype.__toJS,Set.prototype.__toStringMapper=IndexedSequence.prototype.__toStringMapper;var __EMPTY_SET;module.exports=Set; |