This file contains hidden or 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
function AttachmentCtrl($scope, $location, $timeout, Docs) { | |
$(function() { | |
$('#detail-form-doc').fileupload({ | |
dataType: 'json', | |
url: '/angular-ib/app/fileupload?id=' + $location.search().id, | |
add: function(e, data) { | |
$scope.$apply(function(scope) { | |
// Turn the FileList object into an Array | |
for (var i = 0; i < data.files.length; i++) { | |
$scope.project.files.push(data.files[i]); |
This file contains hidden or 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
-- Paste into http://elm-lang.org/try and press compile to try it. | |
import Html exposing (Html, div) | |
import Html.App as App | |
import Svg exposing (..) | |
import Svg.Attributes exposing (..) | |
import Time exposing (Time, second) | |
main = |
This file contains hidden or 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
const result = [1,2,3,4,5,6,7,8,9,10] | |
.map(n => n * 2) | |
.filter(n => n > 4) | |
.map(n => ' Num: ' + n) | |
.reduce((acc, str) => acc + str, 'Start:'); | |
console.log(result); // Start: Num: 6 Num: 8 Num: 10 Num: 12 Num: 14 Num: 16 Num: 18 Num: 20 |
This file contains hidden or 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 result; | |
from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).pipe( | |
map(n => n * 2), | |
filter(n => n > 4), | |
map(n => ' Num: ' + n), | |
reduce((acc, str) => acc + str, 'Start:') | |
).subscribe(r => result = r); | |
console.log(result); // Start: Num: 6 Num: 8 Num: 10 Num: 12 Num: 14 Num: 16 Num: 18 Num: 20 |
This file contains hidden or 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
import { transducer } from 'rxjs-transducer'; | |
const result = transducer([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])( | |
map(n => n * 2), | |
filter(n => n > 4), | |
map(n => ' Num: ' + n), | |
reduce((acc, str) => acc + str, 'Start:') | |
); | |
console.log(result); |
This file contains hidden or 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
function* integers() { | |
let i = 0; | |
while (true) { | |
yield i++; | |
} | |
} | |
const result = transducer(integers())( | |
skip(10), | |
filter(n => n % 3 === 0), |
This file contains hidden or 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
const source = Array(1000000).fill(1).map((_, i) => Math.random()); | |
console.time('array chaining'); | |
const arrayResult = source | |
.map(n => n * 2) | |
.filter(n => n > 0.5) | |
.reduce((m, c) => Math.max(m, c)); | |
console.timeEnd('array chaining'); // 310.901ms | |
console.time('rxjs transducer'); |
This file contains hidden or 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
interface BankAccount { | |
readonly id: string; | |
readonly name: string; | |
readonly number: string; | |
readonly balance: number; | |
readonly secret: boolean; | |
} | |
interface UpdateAccount { | |
readonly kind: 'update'; |
This file contains hidden or 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
interface BankAccount { | |
readonly id: string; | |
readonly name: string; | |
readonly number: string; | |
readonly balance: number; | |
readonly secret: boolean; | |
} | |
interface UpdateAccount { | |
readonly kind: 'update'; |