Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
eater
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Yosuke Furukawa
PRO
April 26, 2016
Programming
1.4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
eater
node 学園付属小学校の2回目で話した eater の話です。
Yosuke Furukawa
PRO
April 26, 2016
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Webの地図
yosuke_furukawa
PRO
6
5k
XHTMLが残したもの
yosuke_furukawa
PRO
2
880
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
430
デザインシステムが必須の時代に
yosuke_furukawa
PRO
2
320
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
10
5.4k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
4.9k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
370
Removing Corepack
yosuke_furukawa
PRO
9
2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
3.2k
Other Decks in Programming
See All in Programming
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
510
AWSに止められる覚悟してますか?
morizo_1984
2
490
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
210
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.2k
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
260
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.6k
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
260
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.6k
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
290
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
200
Featured
See All Featured
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
400
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Being A Developer After 40
akosma
91
590k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
Navigating Team Friction
lara
192
16k
How to make the Groovebox
asonas
2
2.5k
Leo the Paperboy
mayatellez
10
2.3k
How GitHub (no longer) Works
holman
316
150k
Transcript
Eater @yosuke_furukawa
@yosuke_furukawa
Hello, Noders. This is Full-time Papa committer
None
child_process.spawn()
None
Node Quiz
Quiz: child_process API ͷԼهͷ ҧ͍ԿͰ͠ΐ͏ 1. exec 2. spawn 3.
fork
A: spawn ͕Ұ൪ϩʔϨϕϧ exec/fork spawn ͷ wrapper
A: exec callback Ͱड͚Δɺ fork JavaScript ͷίʔυ Λ
Node.js ͱͯ͠࠶࣮ߦ͢Δ
child_process.spawn const spawn = require('child_process').spawn; const ls = spawn('ls', [‘-al']);
ls.stdout.on('data', (data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
child_process.exec const exec = require('child_process').exec; exec(‘ls -al‘, (err, stdout, stderr)
=> { console.log(`${stdout}`); console.error(`${stderr}`); if (error !== null) { console.error(`Error occurred`); } });
child_process.fork const fork = require('child_process').fork; const ls = fork(‘ls.js’); ls.stdout.on('data',
(data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
spawn > exec ͜ͷॱͰ simple exec > spawn ͜ͷॱͰ easy
spawn > fork ͜ͷॱͰ simple fork > spawn ͜ͷॱͰ easy
Easy / Simple ͷҧ͍
None
Simple !== Easy
Simple is “୯७” ٬؍తɺҰͭͷࣄ͔͠͠ͳ͍
Easy is “؆୯” ओ؍తɺ”୭͔”ʹͱͬͯ؆୯ “୭ʹͱͬͯ؆୯” ଘࡏ͠ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Easy ͷݴ༿ʹὃ͞Ε͕ͪ ୭ʹͱͬͯEasy ͳΜͯ͋Γ ͑ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Simple ͱ Easy Λࠞಉ͍ͯ͠ Δʹࠔ͞Ε͕ͪ
Eater
Eater is *Ea*sy *t*est runn*er*
Eater has one simple rule If test file outputs `stderr`
message, the test failed.
Easy => ୭ʹͱͬͯʁ `node` ͔͠Βͳ͍Α͏ͳਓ mocha/jestͷࡉ͔͍ߏจΛ֮ ͑ͯͳͯ͘ɺnode ίϚϯυ ͰεΫϦϓτͱ࣮ͯ͠ߦ͢Δ ͚ͩͰΠφϑͳਓ
Eaterͷtest script `node` command Ͱ࣮ߦͰ͖Δ
Easy => ୭ʹͱͬͯʁ mock/spyΛଟ༻͢Δ͚Ͳɺ mock/spyͷ։์࿙ΕΛΕ ͕ͪͳਓʹͱͬͯ
EaterͷtestҰͭҰ͕ͭผϓ ϩηεͰ࣮ߦ͞ΕΔ
mockΛ։์͠ͳͯ͘OK // you don’t need to fix mock/spy console.log =>
(message) { assert(message.match(/Foo Bar/)); }; const mockDate = new Date(2016, 3, 9); Date.now = () => { return mockDate.valueOf(); }; process.exit => (exitcode) { assert(exitcode === 1); };
͔͠ϓϩηείΞͰ ಄ଧͪʹͳΔ eater ——procs 4 ※procs optionͰՄม
Eater DEMO https://github.com/yosuke- furukawa/eater-demo
Happy Eater https://github.com/yosuke- furukawa/eater