From f229d32442f34859be169e38a42ffecdfb8fc48a Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 17 Nov 2016 13:49:46 -0800 Subject: Replace old random-id code with incrementing id generator --- app/scripts/lib/random-id.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/scripts/lib/random-id.js (limited to 'app/scripts/lib/random-id.js') diff --git a/app/scripts/lib/random-id.js b/app/scripts/lib/random-id.js new file mode 100644 index 000000000..3c5ae5600 --- /dev/null +++ b/app/scripts/lib/random-id.js @@ -0,0 +1,9 @@ +const MAX = 1000000000 + +let idCounter = Math.round( Math.random() * MAX ) +function createRandomId() { + idCounter = idCounter % MAX + return idCounter++ +} + +module.exports = createRandomId -- cgit From 39e0a33bba2709971edec0304027f646cb2db3cc Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 17 Nov 2016 14:29:35 -0800 Subject: random-id - use Number.MAX_SAFE_INTEGER as max --- app/scripts/lib/random-id.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/lib/random-id.js') diff --git a/app/scripts/lib/random-id.js b/app/scripts/lib/random-id.js index 3c5ae5600..78d9e34a5 100644 --- a/app/scripts/lib/random-id.js +++ b/app/scripts/lib/random-id.js @@ -1,4 +1,4 @@ -const MAX = 1000000000 +const MAX = Number.MAX_SAFE_INTEGER let idCounter = Math.round( Math.random() * MAX ) function createRandomId() { -- cgit From d6286cd13aef8b861d84b078b468b02b302ba801 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 18 Nov 2016 16:27:26 -0800 Subject: Maintain linting. --- app/scripts/lib/random-id.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/scripts/lib/random-id.js') diff --git a/app/scripts/lib/random-id.js b/app/scripts/lib/random-id.js index 78d9e34a5..788f3370f 100644 --- a/app/scripts/lib/random-id.js +++ b/app/scripts/lib/random-id.js @@ -1,7 +1,7 @@ const MAX = Number.MAX_SAFE_INTEGER -let idCounter = Math.round( Math.random() * MAX ) -function createRandomId() { +let idCounter = Math.round(Math.random() * MAX) +function createRandomId () { idCounter = idCounter % MAX return idCounter++ } -- cgit