Talk about Stream API difference between node.js and whatwg at #tng11 2016/08/08
Talk about Stream API difference between node.js and whatwg at #tng11 2016/08/08
There's been some confusion around the new fetch API recently. Let's clear things up. The first thing you'll notice about fetch is it's a massive improvement on XMLHttpRequest in terms of API design. Here's how to get some JSON using XHR: var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.responseType = 'json'; xhr.onload = function () { console.log(xhr.response); }; xhr.onerror = function
こんにちは丸山@h13i32maruです。 WHATWG Streams APIを少し触ってみたので、そのメモです。 ドキュメント WHATWG Streams このメモはLast Updated 21 January 2015を元に書いた whatwg/streams サンプルやリファレンス実装などがある このメモはcommit 879902を元に書いた Stream APIがブラウザにやってくる @jxckさんがnodeのStream APIと絡めてWHATWGのStreams APIを紹介している 概念 JavaScriptのプログラム中で処理する(大きめな)データの読み書きを統一的に扱うためのインターフェースをStreams APIとしてWHATWGが策定している。例えばXHRで大きなファイルを読み込んだ時にはすべてのデータを読み込んだあとにコールバックが呼ばれる*1。これだと読み
¶ Classifying Asynchrony For a while, I've been looking for a good way to explain the relationship between promises, streams, callbacks, and event emitters. Handily, Domenic Denicola recently illustrated the problem well on IRC. To paraphrase him here: there are two axes, plurality and synchrony. Plurality means "how many times will the operation be executed." Synchrony is divided between "synchro
Intro 今日は、フロントのプログラミングスタイルに、にまた一つ大きな変化をもたらすであろう Stream という API についてです。 この仕様は現時点でまだ策定中であるため、 API は変更される恐れがある点にご注意ください。 Stream API 以前 「Node.js の Stream API で「データの流れ」を扱う方法」 という記事を書きましたが、簡単に言うとあれがブラウザにもやってくるという話です。 非同期処理おさらい もう何度も書いた話なので駆け足で。 JS はシングルスレッドでイベント駆動な世界なので、何をするにも非同期であり、コールバックを登録することで完了した結果を受け取る API が基本です。 これは、ブラウザの DOM の API でも、 Node.js でも共通しています。 概念を疑似コードで書くと以下のような感じです。 console.log('1');
Please leave your sense of logic at the door, thanks! Streams October 30th, 2014 by Domenic Denicola in WHATWG We're happy to announce the addition of the Streams Standard to the list of specs maintained by the WHATWG! Streaming data shows up all over the web platform, and this new spec gives us a set of APIs for creating and interfacing with that data. We hope that streams will be a unifying prim
データをストリームとして表現する方法と、ストリームを変換する方法を紹介する。 ストリームはメッセージが流れる川である Pub/Subメッセージングモデルでメッセージを流すためのオブジェクトのことをストリームと呼ぶことにする。ストリームにはメッセージをPublishでき、またメッセージを受け取ったときの処理をSubscribeできる。例えばキーボードからの入力をPublishして、内容をコンソールに出力するような処理をSubscribeできる。 kamo.jsでストリームを表現する ストリームについて説明するために、kamo.jsというストリームを表現するためのライブラリをつくった。kamo.jsは、ストリームを作成するためのkamo.Streamというコンストラクタ関数を提供する。このコンストラクタ関数から作成されたオブジェクトは、publishとsubscribeというメソッド(※プロパ
最近調べたnode.jsのstreamに関連した雑多な内容を、思いつくままに適当に書く。 例えば、 function* createPiGenerator() { var result = 0; for (var i = 1;; i += 4) { yield result * 4; result += 1/i - 1/(i + 2); } } こんな感じのジェネレータがあったとして、それをファイルに出力したい場合 function createPiStream() { var r = new require('stream').Readable(); r.setEncoding('UTF-8'); // バッファじゃなくてstringとして処理したい var g = createPiGenerator(); // piの計算をするジェネレータ var tid; r._read = fun
(window.innerHeight * 0.02)) { this.headerClass = 'header--frosted'; if(window.location.pathname == '/') { this.bannerVideo = false; this.headerClass = 'header--frosted'; this.showNotice = false; } } else { this.headerClass = 'nope'; if(window.location.pathname == '/') { this.bannerVideo = true; this.headerClass = 'header--overvideo'; this.showNotice = true; } else { this.bannerVideo = false; this
さて、Java8で関数型っぽいことをやって遊んでみたわけですが、実際はそんな書き方しませんよね。 Java8で実際に使うのは、Streamです。 ということで、Streamの使い方をひととおり見てみます。 ※5/17 仕様変更があったので、修正しました 基本 まずは、Iterableインタフェースに用意されたforEachメソッドを見てみましょう。 List<String> names = Arrays.asList("hoge hoge", "foo bar", "naoki", "kishida"); names.forEach(s -> System.out.println(s)); これで次のように表示されます。 hoge hoge foo bar naoki kishida いままでの拡張forだと次のように書いてました List<String> names = Arrays.a
As soon as I saw a Flame Graph visualization I knew it would make a great addition to NYTProf. So I’m delighted that the new Devel::NYTProf version 5.00, just released, has a Flame Graph as the main feature of the index page. In this post I’ll explain the Flame Graph visualization, the new ‘subroutine calls event stream’ that makes the Flame Graph possible, and other recent changes, including impr
intro ちょっと反応が遅れてしまいましたが。 404 Blog Not Found:JSON - をnodeで整形する こちらの記事は Stream 厨として見逃す訳にはいきませんでした。 motivation JSONは本来JavaScriptから生じたものだからどうせならJavaScriptでやりたいし まあ、 JSON ですしね。 そのJavaScriptに今や標準搭載のJSON.stringify()は実はpretty printできるし 確かに stringify でできますね。(昔こちらにも書きました。) どうせなら標準入力だけではなくURIやファイル名で直アクセスしたいし 同意です。 しかし、実装を見てみると、、 (以下、主要な部分の抜粋) // stdout stdin.on("data", voorhees); // http http.get(req, functi
タイトルは釣り。どっちかというと Iteratee がメイン。(だってみんな Iteratee とか見ても記事開かないでしょ) 1週間くらい Stream について考え続けて、やっぱりわからなくて。でも、こんな基本的な概念、誰かが既に考えつくしてるに違いない、と思ってググってみたら、あった。そして、またお前か、Haskell。 Iteratee ほとんど Stream。モナドとかオートマトンとか言い始めるときりがないので演算子とその働きだけ大雑把に眺めてみた。 Gist: Iteratee とその演算子の働きとか。すっごく大雑把で、記号も適当ですが雰囲気だけ。 ================================================================== Enumerator -> Enumeratee -> Iteratee ============
intro この記事は、 Web Music Developers JP Advent Calendar 2012 の 22 日目の記事です。 今日は、モジュラーシンセサイザーの仕組みと、それがアーキテクチャ的にはモジュールの集まりで、 しかもそれらモジュールは Stream であると解釈できる点について紹介する。 このブログでは基本的に技術的なトピックしか扱わない。今回も限りなく音楽ネタに近い技術ネタ?だというつもりで書き始める。 "音" とは何か? 「音」とはなにか。 さて、ここから始めねばなるまい。 (と、書き出したかっただけで、読み返すとあまり必要はなかった) 音の世界の深淵に潜り込むと出てくる前に左小指が腱鞘炎になってしまうので、 ここはひとつ、音の「三大要素」にご登場願おう。(理科の時間に習ったよね?) 音圧 音程 音色 まず、音圧だがこれは面倒だから音量(大きさ) と同じだと
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く