From bd6cb02bdc699c6ede004988156560a043ca9adf Mon Sep 17 00:00:00 2001 From: anonyco Date: Sun, 16 Jul 2017 11:26:07 -0400 Subject: [PATCH 1/4] Update LICENSE --- LICENSE | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 7b77ded..33f060c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Loose-MIT License -Copyright (c) 2017 anonyco1 +Copyright (c) 2017 anonyco [1] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -10,10 +10,10 @@ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: If you do include any copyright notice(s) in copies of this software, then the -copyright notice(s) must include the above1 copyright notice at least once. +copyright notice(s) must include the above [1] copyright notice at least once. Likewise, if you do include any permission notice(s) in copies of this -software, then the permission notice(s) must include this2 permission notice -at least once.2 +software, then the permission notice(s) must include this [2] permission +notice at least once. [2] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, From 8dec095ad5e91c0a607ab8608b3cbd4e2ca2b68e Mon Sep 17 00:00:00 2001 From: anonyco Date: Sun, 16 Jul 2017 11:28:00 -0400 Subject: [PATCH 2/4] Update mapPolyfill.src.js --- mapPolyfill.src.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapPolyfill.src.js b/mapPolyfill.src.js index 7ae8d93..f8a9008 100644 --- a/mapPolyfill.src.js +++ b/mapPolyfill.src.js @@ -1,4 +1,4 @@ -//anonyco +//Copyright (c) 2017 anonyco if (!window.Map) (function(){ 'use-strict'; From 91ea3a4ec47dd39add15df01e6ecd16e38ff5a9f Mon Sep 17 00:00:00 2001 From: anonyco Date: Sun, 16 Jul 2017 11:28:21 -0400 Subject: [PATCH 3/4] Update mapPolyfill.min.js --- mapPolyfill.min.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mapPolyfill.min.js b/mapPolyfill.min.js index cfc2ef0..8af2e49 100644 --- a/mapPolyfill.min.js +++ b/mapPolyfill.min.js @@ -1 +1,2 @@ +//Copyright (c) 2017 anonyco window.Map||function(){"use-strict";var t,i,e,n=Object.create(null);n.size=0,n["delete"]=function(i){return t=this.k.lastIndexOf(i),~t?(this.k.splice(t,1),this.v.splice(t,1),--this.size,!0):!1},n.get=function(t){return this.v[this.k.lastIndexOf(t)]},n.set=function(i,e){t=this.k.lastIndexOf(i),~t||(this.k[t=this.size++]=i),this.v[t]=e},n.has=function(t){return-1!==this.k.lastIndexOf(t)},n.clear=function(t){this.k.splice(0,this.size),this.v.splice(0,this.size),this.size=0},n.forEach=function(t,n){for(i=n?t.bind(n):t,e=this.size;e--;)i(this.k[e],e,this)},n.entries=function(t){var i=0,e=this,n=this.size;return{next:function(){return i!==n?{value:[e.k[i++],e.v[i]],done:!1}:{done:!0}}}},n.keys=function(t){var i=0,e=this,n=this.size;return{next:function(){return i!==n?{value:e.k[i++],done:!1}:{done:!0}}}},n.values=function(t){var i=0,e=this,n=this.size;return{next:function(){return i!==n?{value:e.v[i++],done:!1}:{done:!0}}}},Map=function(i){if(i instanceof Array){this.size=t=i.length;for(var e=Array(t),n=Array(t);t--;)e[t]=i[t][0],n[t]=i[t][1];this.k=e,this.v=n}else this.k=[],this.v=[]},Map.prototype=n}(),window.WeakMap||Object.defineProperty((WeakMap=window.Map).prototype,"length",{get:function(){return this.size}}) From f7c3216bcedafb14d3f4ce28b69825f172a2dae0 Mon Sep 17 00:00:00 2001 From: anonyco Date: Sun, 16 Jul 2017 11:30:08 -0400 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c91dabf..7fbf6b0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A potential problem with this polyfill, or any other Map polyfills, are 'memory console.log(longString.length * myMap.length) ``` -The unavoidable, unfixable reason for this is because there currently is no way to assign weak references (or better yet, weak tables) to objects in javascript, which would allow the transpiler to know that its safe to ignore specific references to something. +The unavoidable, unfixable reason for this is because there currently is no way other than WeakMaps to assign weak references/arrays to objects in javascript, which would allow the transpiler to know that its safe to ignore specific references to something. # The SingleWeakMapMinimal.src.js file This is some code I wrote for my own project to create an absolute bare minimalistic way to get a single weak map for referencing DOM elements. I thought someone else might find it useful/helpful, so I posted it up here. Enjoy.