I hereby claim:
- I am toddmantell on github.
- I am toddmantell (https://keybase.io/toddmantell) on keybase.
- I have a public key ASCQlLgPGbwAExM1x8Ed7ppDqp54-Us_-58sRDFrBVDkhQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Self Testing Code: https://martinfowler.com/bliki/SelfTestingCode.html
Naming: https://medium.com/coding-skills/clean-code-101-meaningful-names-and-functions-bf450456d90c
Stepdown Rule: http://tidyjava.com/stepdown-rule/
Function Length: https://martinfowler.com/bliki/FunctionLength.html
Beck 4 Rules: https://martinfowler.com/bliki/BeckDesignRules.html
| { | |
| "editor.wrappingColumn": 0, | |
| "typescript.check.tscVersion": false, | |
| "workbench.colorTheme": "Operator Mono Dark Theme", | |
| "editor.tabSize": 2, | |
| "workbench.iconTheme": "vscode-icons", | |
| "[javascript]": { "editor.tabSize": 2, "editor.insertSpaces": false, "editor.detectIndentation": false } | |
| } |
| const numbers = [1,2,3,4,5,6,7,8]; | |
| Array.prototype.logValues = function() { | |
| for (i = 0; i < this.length; i++) { | |
| console.log(this[i]); | |
| } | |
| }; | |
| numbers.logValues(); |
| /*Object.create() vs new constructor(): constructor will have __proto__ and a "prototype" property, but a regular object will only have __proto__*/ | |
| //Object.create() just creates a new object and assigns it the prototype that you provide as the first argument | |
| const person = { | |
| name: 'Name', | |
| age: 100, | |
| sayHello: function () { | |
| console.log(`Hello, my name is ${this.name} and I am ${this.age} years old`); | |
| } | |
| }; |
| //Should transform: import {Component} from 'react'; | |
| //to: const _Component = require('react').Component; | |
| export default function ({types: t}) { | |
| return { | |
| visitor: { | |
| ImportDeclaration(path) { | |
| const {node} = path; | |
| path.replaceWith( | |
| t.variableDeclaration('var', |
| //copy this into AST Explorer and run it against a standard import statement, like import React from 'react'; | |
| export default function ({types: t}) { | |
| return { | |
| visitor: { | |
| ImportDeclaration(path) { | |
| const {node} = path; | |
| path.replaceWith( | |
| t.variableDeclaration('var', [ | |
| t.variableDeclarator(t.identifier(`_${node.specifiers[0].local.name}`), |
| export default function () { | |
| return { | |
| visitor: { | |
| VariableDeclaration(path) { | |
| path.node.declarations[0].id.name = 'TransformedInVariableDeclaration'; | |
| const template = path.node.declarations[0].init.quasis[0].value.raw; | |
| console.log(template); | |
| }, | |
| TemplateLiteral(path) { | |
| const template = path.node.quasis[0].value.raw; |
| const baseArray = [1, 2, 3, 4]; | |
| const newArr = Object.assign([...baseArray], {2: 5}); | |
| console.log(newArr); // [1, 2, 5, 4] |
| // Original logic for reference: | |
| component ? ( // component prop gets first priority, only called if there's a match | |
| match ? React.createElement(component, props) : null | |
| ) : render ? ( // render prop is next, only called if there's a match | |
| match ? render(props) : null | |
| ) : children ? ( // children come last, always called | |
| typeof children === 'function' ? ( | |
| children(props) | |
| ) : !Array.isArray(children) || children.length ? ( // Preact defaults to empty children array | |
| React.Children.only(children) |