Skip to content

Commit

Permalink
Remove ES6 reserved word "protected" from variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
toomim committed Sep 15, 2022
1 parent a39e96c commit d420dfb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "statebus",
"version": "7.0.11",
"version": "7.0.12",
"description": "Synchronize state.",
"main": "statebus.js",
"scripts": {
Expand Down
12 changes: 7 additions & 5 deletions server-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,9 @@ function import_server (bus, make_statebus, options)
o.val.pass = o.val.pass && require('bcrypt-nodejs').hashSync(o.val.pass)
u.val.pass = o.val.pass || u.val.pass

// // Users can have pictures (remove this soon)
// // Allow clients to save a base64 image in the .pic field,
// // which we'll convert into an image file here. (Note: removed.
// // There are more elegant solutions possible now.)
// // Bug: if user changes name, this picture's url doesn't change.
// if (o.pic && o.pic.indexOf('data:image') > -1) {
// var img_type = o.pic.match(/^data:image\/(\w+);base64,/)[1]
Expand All @@ -2063,19 +2065,19 @@ function import_server (bus, make_statebus, options)
// // ensure that the uploads directory exists
// if (!fs.existsSync(upload_dir))
// fs.mkdirSync(upload_dir)

//
// // bug: users with the same name can overwrite each other's files
// u.pic = u.name + '.' + img_type
// fs.writeFile(upload_dir + u.pic, b64, {encoding: 'base64'})
// }

// For anything else, go ahead and add it to the user object
var protected = {key:1, name:1, /*pic:1,*/ pass:1}
var reserved = {'key':true, 'name':true, 'pass':true}
for (var k in o.val)
if (!protected.hasOwnProperty(k))
if (!reserved.hasOwnProperty(k))
u.val[k] = o.val[k]
for (var k in u.val)
if (!protected.hasOwnProperty(k) && !o.val.hasOwnProperty(k))
if (!reserved.hasOwnProperty(k) && !o.val.hasOwnProperty(k))
delete u.val[k]

master.set(u)
Expand Down
3 changes: 3 additions & 0 deletions statebus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@
// funk.react().
//
// ...which will make it re-run with the original arg1 and arg2 .
//
// Each subsequent time you call f(arg1, arg2), it will change the
// remembered args and re-run the funk.
function funk () {
console.assert(executing_funk === global_funk
|| executing_funk !== funk, 'Recursive funk', funk.func)
Expand Down

0 comments on commit d420dfb

Please sign in to comment.