GeezerVison is showing github.com — :recycle: cleaner typeof · nullstack/nullstack@eed0986
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: client/instanceProxyHandler.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ const instanceProxyHandler = { | 6 | 6 | get(target, name) { | 7 | 7 | if (name === '_isProxy') return true; | 8 | 8 | if (target.constructor[name]?.name === '_invoke') return target.constructor[name].bind(target.constructor) | 9 | | - if (!target[name]?.name?.startsWith('_') && !name.startsWith('_') && typeof (target[name]) === 'function' && name !== 'constructor') { | | 9 | + if (!target[name]?.name?.startsWith('_') && !name.startsWith('_') && typeof target[name] === 'function' && name !== 'constructor') { | 10 | 10 | const { [name]: named } = { | 11 | 11 | [name]: (args) => { | 12 | 12 | const context = generateContext({ ...target._attributes, ...args, self: target._self }); | |
Collapse file Copy file name to clipboardExpand all lines: client/render.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,7 +45,7 @@ export default function render(node, options) { | 45 | 45 | eventSubjects.set(node.element, node.attributes) | 46 | 46 | } | 47 | 47 | } else { | 48 | | - const type = typeof (node.attributes[name]); | | 48 | + const type = typeof node.attributes[name]; | 49 | 49 | if (type !== 'object' && type !== 'function') { | 50 | 50 | if (name != 'value' && node.attributes[name] === true) { | 51 | 51 | node.element.setAttribute(name, ''); | |
Collapse file Copy file name to clipboardExpand all lines: client/rerender.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,7 @@ function updateAttributes(selector, current, next) { | 40 | 40 | eventSubjects.set(selector, next.attributes) | 41 | 41 | } | 42 | 42 | } else { | 43 | | - const type = typeof (next.attributes[name]); | | 43 | + const type = typeof next.attributes[name]; | 44 | 44 | if (type !== 'object' && type !== 'function') { | 45 | 45 | if (current.attributes[name] !== undefined && next.attributes[name] === undefined) { | 46 | 46 | selector.removeAttribute(name); | |
Collapse file Copy file name to clipboardExpand all lines: server/index.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,7 +65,7 @@ class Nullstack { | 65 | 65 | toJSON() { | 66 | 66 | const serialized = {}; | 67 | 67 | for (const name of Object.getOwnPropertyNames(this)) { | 68 | | - if (typeof (this[name]) !== 'function' && !name.startsWith('_') && name !== 'attributes') { | | 68 | + if (typeof this[name] !== 'function' && !name.startsWith('_') && name !== 'attributes') { | 69 | 69 | serialized[name] = this[name]; | 70 | 70 | } | 71 | 71 | } | |
Collapse file Copy file name to clipboardExpand all lines: server/instanceProxyHandler.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | const instanceProxyHandler = { | 2 | 2 | get(target, name) { | 3 | | - if (!target[name]?.name?.startsWith('_') && !name.startsWith('_') && typeof (target[name]) === 'function' && name !== 'constructor') { | | 3 | + if (!target[name]?.name?.startsWith('_') && !name.startsWith('_') && typeof target[name] === 'function' && name !== 'constructor') { | 4 | 4 | return (args) => { | 5 | 5 | const context = target._scope.generateContext({ ...target._attributes, ...args, self: target._self }); | 6 | 6 | return target[name](context); | |
Collapse file Copy file name to clipboardExpand all lines: server/render.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,7 +35,7 @@ export default function render(node, scope, next) { | 35 | 35 |
| 36 | 36 | for (let name in node.attributes) { | 37 | 37 | if (!name.startsWith('on') && name !== 'html') { | 38 | | - const type = typeof (node.attributes[name]); | | 38 | + const type = typeof node.attributes[name]; | 39 | 39 | if (type !== 'object' && type !== 'function') { | 40 | 40 | if (name != 'value' && node.attributes[name] === true) { | 41 | 41 | element += ` ${name}`; | |
Collapse file Copy file name to clipboardExpand all lines: server/server.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ function createResponse(callback) { | 88 | 88 | }; | 89 | 89 | res.getHeader = (x) => headers[x]; | 90 | 90 | res.redirect = function (_code, url) { | 91 | | - if (typeof (_code) !== 'number') { | | 91 | + if (typeof _code !== 'number') { | 92 | 92 | code = 301; | 93 | 93 | url = _code; | 94 | 94 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: server/template.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,7 @@ export default function ({ head, body, context, instances }) { | 13 | 13 | const serializableContext = {}; | 14 | 14 | const blacklist = ['scope', 'router', 'page', 'environment', 'settings', 'worker', 'params', 'project', 'instances']; | 15 | 15 | for (const [key, value] of Object.entries(context)) { | 16 | | - if (!blacklist.includes(key) && typeof (value) !== 'function') { | | 16 | + if (!blacklist.includes(key) && typeof value !== 'function') { | 17 | 17 | serializableContext[key] = value; | 18 | 18 | } | 19 | 19 | } | |
Collapse file Copy file name to clipboardExpand all lines: shared/nodes.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,11 +9,11 @@ export function isFalse(node) { | 9 | 9 | } | 10 | 10 |
| 11 | 11 | export function isClass(node) { | 12 | | - return typeof (node.type) === 'function' && node.type.prototype && typeof (node.type.prototype.render) === 'function'; | | 12 | + return typeof node.type === 'function' && node.type.prototype && typeof node.type.prototype.render === 'function'; | 13 | 13 | } | 14 | 14 |
| 15 | 15 | export function isFunction(node) { | 16 | | - return typeof (node.type) === 'function'; | | 16 | + return typeof node.type === 'function'; | 17 | 17 | } | 18 | 18 |
| 19 | 19 | export function isText(node) { | |
Collapse file Copy file name to clipboardExpand all lines: tests/src/TwoWayBindings.njs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,8 +36,8 @@ class TwoWayBindings extends Nullstack { | 36 | 36 | <div> | 37 | 37 | <input bind={this.zero} /> | 38 | 38 | <div data-number={this.number} /> | 39 | | - {!this.boolean && <div data-boolean-type={typeof (this.boolean)} />} | 40 | | - {this.number > 1 && <div data-number-type={typeof (this.number)} />} | | 39 | + {!this.boolean && <div data-boolean-type={typeof this.boolean} />} | | 40 | + {this.number > 1 && <div data-number-type={typeof this.number} />} | 41 | 41 | <input bind={this.number} oninput={this.updateCharacter} /> | 42 | 42 | <textarea bind={this.text} /> | 43 | 43 | <div data-character={this.character} /> | |
|