JavaScriptCore is a built-in iOS library that enables you to use JavaScript in apps alongside Objective-C and Swift. It lets developers read JavaScript from a string, execute it from Objective-C or Swift, and share data structures and functions across languages. We JavaScriptCore to share code between Web and iOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let list = [1, 2] | |
list = list.concat(3) | |
console.log(list) // [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let whatAmI = document.body | |
whatAmI = [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style lang="sass"> | |
</style> | |
<template> | |
<input | |
class="input-text" | |
@input="update" | |
:placeholder="args.placeholder" | |
:value="value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPO=$1 | |
VERSION=$2 | |
cd ../$REPO | |
git fetch | |
git checkout v$VERSION | |
npm link | |
cd - | |
npm link $REPO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# written with @felkerch | |
REPO=$1 | |
VERSION=$2 | |
cd ../$REPO | |
git fetch | |
git checkout v$VERSION | |
npm link | |
cd - | |
npm link $REPO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Architecture 1 | |
function callApi(x, y, z) { | |
manipulate params | |
manipulate params some more ... | |
return fetch(...) | |
.then(result => { | |
if (result.status === ...) { | |
handle status stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Architecture 2 | |
function callApi(x, y, z) { | |
const request = buildRequest(x, y, z) | |
return fetch(request) | |
.then(assertStatus('callApi', x, y, z)) | |
.then(parseResponse) |
**Diagram 1: Types of Code**
high
^ ||
^ ||
^ boring I/O || interesting I/O
^ ||
cost of testing ^ ================================
^ ||
**Diagram 2: Should I unit test?**
high
^ ||
^ ||
^ don't test || maybe test
^ ||
cost of testing ^ ================================
^ ||