@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Diviner: fix "Javascript" -> "JavaScript" and minor change

Test Plan:
- look at Diviner and say "Java..."
- Diviner will look at you saying "...Script"
- you land, satisfied

If Diviner says "...script" instead (lowercase "S"), abandon the ship.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25075

+33 -21
+1 -1
src/docs/book/flavor.book
··· 21 21 ], 22 22 "groups": { 23 23 "javascript": { 24 - "name": "Javascript" 24 + "name": "JavaScript" 25 25 }, 26 26 "lore": { 27 27 "name": "Phorge Lore"
+22 -10
src/docs/flavor/javascript_object_array.diviner
··· 1 - @title Javascript Object and Array 1 + @title JavaScript Object and Array 2 2 @group javascript 3 3 4 - This document describes the behaviors of Object and Array in Javascript, and 4 + This document describes the behaviors of Object and Array in JavaScript, and 5 5 a specific approach to their use which produces basically reasonable language 6 6 behavior. 7 7 8 8 = Primitives = 9 9 10 - Javascript has two native datatype primitives, Object and Array. Both are 10 + JavaScript has two native datatype primitives, Object and Array. Both are 11 11 classes, so you can use `new` to instantiate new objects and arrays: 12 12 13 13 COUNTEREXAMPLE ··· 43 43 = Objects are Maps, Arrays are Lists = 44 44 45 45 PHP has a single `array` datatype which behaves like as both map and a list, 46 - and a common mistake is to treat Javascript arrays (or objects) in the same way. 46 + and a common mistake is to treat JavaScript arrays (or objects) in the same way. 47 47 **Don't do this.** It sort of works until it doesn't. Instead, learn how 48 - Javascript's native datatypes work and use them properly. 48 + JavaScript's native datatypes work and use them properly. 49 49 50 - In Javascript, you should think of Objects as maps ("dictionaries") and Arrays 50 + In JavaScript, you should think of Objects as maps ("dictionaries") and Arrays 51 51 as lists ("vectors"). 52 52 53 53 You store keys-value pairs in a map, and store ordered values in a list. So, ··· 58 58 species: 'zebra' 59 59 }; 60 60 61 - console.log(o.name); 61 + o.paws = 4; 62 + 63 + o['numberOfEars'] = 2; 64 + 65 + console.log(o.name); 66 + console.log(o.paws); 67 + console.log(o.numberOfEars); 62 68 63 69 ...and store ordered values in Arrays. 64 70 ··· 71 77 var a = []; 72 78 a['name'] = 'Hubert'; // No! Don't do this! 73 79 74 - This technically works because Arrays are Objects and you think everything is 75 - fine and dandy, but it won't do what you want and will burn you. 80 + Technically, both work because Arrays //are// Objects and you think everything 81 + is fine and dandy, but it won't do what you want and will burn you. For example, 82 + using `.length` will play tricks on you. 83 + 84 + In short, trust me: 85 + 86 + * use `[]` only to create a stack of consecutive elements numerically indexed 87 + * use `{}` to create associative maps ("associative arrays") 76 88 77 89 = Iterating over Maps and Lists = 78 90 ··· 140 152 continue; 141 153 } 142 154 f(list[ii]); 143 - } 155 + } 144 156 145 157 Avoid sparse arrays if possible. 146 158
+8 -8
src/docs/flavor/javascript_pitfalls.diviner
··· 1 - @title Javascript Pitfalls 1 + @title JavaScript Pitfalls 2 2 @group javascript 3 3 4 - This document discusses pitfalls and flaws in the Javascript language, and how 4 + This document discusses pitfalls and flaws in the JavaScript language, and how 5 5 to avoid, work around, or at least understand them. 6 6 7 7 = Implicit Semicolons = 8 8 9 - Javascript tries to insert semicolons if you forgot them. This is a pretty 9 + JavaScript tries to insert semicolons if you forgot them. This is a pretty 10 10 horrible idea. Notably, it can mask syntax errors by transforming subexpressions 11 11 on their own lines into statements with no effect: 12 12 ··· 46 46 47 47 There is essentially only one reasonable, consistent way to use these primitives 48 48 but it is not obvious. Navigate these troubled waters with 49 - @{article:Javascript Object and Array}. 49 + @{article:JavaScript Object and Array}. 50 50 51 51 = typeof null == "object" = 52 52 53 - This statement is true in Javascript: 53 + This statement is true in JavaScript: 54 54 55 55 typeof null == 'object' 56 56 ··· 58 58 59 59 = Number, String, and Boolean objects = 60 60 61 - Like Java, Javascript has primitive versions of number, string, and boolean, 61 + Like Java, JavaScript has primitive versions of number, string, and boolean, 62 62 and object versions. In Java, there's some argument for this distinction. In 63 - Javascript, it's pretty much completely worthless and the behavior of these 63 + JavaScript, it's pretty much completely worthless and the behavior of these 64 64 objects is wrong. String and Boolean in particular are essentially unusable: 65 65 66 66 lang=js ··· 83 83 worst strictly wrong. 84 84 85 85 **Never use** `new Number()`, `new String()` or `new Boolean()` unless 86 - your Javascript is God Tier and you are absolutely sure you know what you are 86 + your JavaScript is God Tier and you are absolutely sure you know what you are 87 87 doing.
+1 -1
src/docs/flavor/php_pitfalls.diviner
··· 256 256 echo get_class($obj); // Outputs 'stdClass'. 257 257 ``` 258 258 259 - This is occasionally useful, mostly to force an object to become a Javascript 259 + This is occasionally useful, mostly to force an object to become a JavaScript 260 260 dictionary (vs a list) when passed to `json_encode()`. 261 261 262 262 = Invoking `new` With an Argument Vector is Really Hard =
+1 -1
src/docs/flavor/project_history.diviner
··· 34 34 Through 2007 and 2008 Evan worked mostly on frontend and support infrastructure; 35 35 among other things, he wrote a static resource management system called Haste. 36 36 In 2009 Evan worked on the Facebook Lite site, where he built the Javelin 37 - Javascript library and an MVC-flavored framework called Alite. 37 + JavaScript library and an MVC-flavored framework called Alite. 38 38 39 39 But by early 2010, Diffcamp was in pretty bad shape. Two years of having random 40 40 features grafted onto it without real direction had left it slow and difficult