SlideShare a Scribd company logo
1 of 18
Download to read offline
kontainer-js
Megro.es #3
Apr. 19th, 2016 at Drecom
Kuu Miyazaki
GitHub: @kuu
Twitter: @miyazaqui
kontainer-js > MP4 parser
● A parser/editor library written in ES2015
● Runs both on Node.js and in the browser
● Provides its API as JSX
MP4 > nested boxes
MP4 > nested boxes
ftyp moov mdat
mvhd trak
tkhd mdia
...
length type property
Nested boxes > DOM
DOM > React > JSX
Nested boxes
How about writing MP4 in JSX?
How about writing MP4 in JSX?
render() {
return (
<file>
<ftyp majorBrand="isom" />
<moov>
<mvhd creationTime={new Date()} timeScale={1} nextTrackId={4} />
<trak>
<tkhd {...{trackId: 1, width: this.width, height: this.height}} />
<mdia>
...innerElements
</mdia>
</trak>
</moov>
<mdat data={buffer} />
</file>
);
}
That’s what I built!
How kontainer-js works
{
type: ‘ftype’,
props : {
majorBrand: ‘isom’,
},
},
{
type: ‘moov’,
children: [
{
type: ‘mvhd’,
props: {
timeScale: 1,
…
},
]
}
parse
serialize
Byte stream
JS object
transpile
JSX
Development workflow
Lint ● eslint
Test ● [Browser] karma-jasmine + browserify(baberify)
● [Node] jasmine-es6
Build/Deploy ● [Browser] browserify(baberify) + uglify-js
● [Node] dist-es6
JSX Transpile ● Self-built Babel plugin (transform-kontainer-js)
Transpilation is slow
So, defer it as long as possible
Dev Machine
GitHub
npm
ES5
ES6
push
publish
Dev Machine
GitHub
npm
ES6
push
transpile & publishslow!
Publish-time
transpilation
Dev-time
transpilation
ES6 ES6
ES5 ES5
transpile
Publish-time transpilation
● Testing with babel-runtime
● No “dist” directory
● Transpile in a “prepublish” command
dist-es6
// package.json
{
"name": "kontainer-js",
"main": "src/index.js",
"bin": {
"kontainer": "src/cli.js"
},
"files": [
"README.md",
"logo.png",
"lib"
],
"scripts": {
"prepublish": "dist-es6"
},
npm install (local)
npm publish
1) creates node_modules/.bin/kontainer
#!/usr/bin/env node
require('dist-es6/lib/run').module('../src/cli.js');
2) copies src to node_modules/kontainer-js
You can require('kontainer-js') in spec files.
README.md
etc.
./dist
(temp dir)
./src
package.json
npm
copy
convert
publish
Huge win
● Speed (no transpilation in dev-time)
● Less complexity (no “dist” dir)
● Easy to debug (directly with ES6 code)
Some caveats
● Dependencies bomb (+294)
● Some publishing issue
Thanks!
kontainer-js
dist-es6

More Related Content

What's hot

Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uring
ShapeBlue
 
Oreilly Webcast Jun17
Oreilly Webcast Jun17Oreilly Webcast Jun17
Oreilly Webcast Jun17
Sean Hull
 

What's hot (20)

Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uring
 
Oreilly Webcast Jun17
Oreilly Webcast Jun17Oreilly Webcast Jun17
Oreilly Webcast Jun17
 
Bsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessionsBsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessions
 
Docker Insight
Docker InsightDocker Insight
Docker Insight
 
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosOSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
 
Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.js
 
Building High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformBuilding High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure Platform
 
Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJS
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
Redis overview for Software Architecture Forum
Redis overview for Software Architecture ForumRedis overview for Software Architecture Forum
Redis overview for Software Architecture Forum
 
Easy access to open stack object storage
Easy access to open stack object storageEasy access to open stack object storage
Easy access to open stack object storage
 
Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...
Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...
Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...
 
Mongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded DatabasesMongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded Databases
 
MongoDB, Node.js And You: PART II
MongoDB, Node.js And You: PART IIMongoDB, Node.js And You: PART II
MongoDB, Node.js And You: PART II
 
Bullwinkle introduction
Bullwinkle introductionBullwinkle introduction
Bullwinkle introduction
 
what is docker
what is dockerwhat is docker
what is docker
 
Ruby on embedded devices rug::b Aug 2014
Ruby on embedded devices rug::b Aug 2014Ruby on embedded devices rug::b Aug 2014
Ruby on embedded devices rug::b Aug 2014
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
 
MongoDB Replication Cluster
MongoDB Replication ClusterMongoDB Replication Cluster
MongoDB Replication Cluster
 
Strategies for Backing Up MongoDB
Strategies for Backing Up MongoDBStrategies for Backing Up MongoDB
Strategies for Backing Up MongoDB
 

Viewers also liked

Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScript
Ryo Maruyama
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろう
kenji4569
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話
Junya Hayashi
 

Viewers also liked (20)

JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6
 
Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScript
 
jQuery勉強会#4
jQuery勉強会#4jQuery勉強会#4
jQuery勉強会#4
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめました
 
JavaScript.Next Returns
JavaScript.Next ReturnsJavaScript.Next Returns
JavaScript.Next Returns
 
ES6 - JavaCro 2016
ES6 - JavaCro 2016ES6 - JavaCro 2016
ES6 - JavaCro 2016
 
JavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, PerformanceJavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, Performance
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
 
150421 es6とかな話
150421 es6とかな話150421 es6とかな話
150421 es6とかな話
 
FileReader and canvas and server silde
FileReader and canvas and server sildeFileReader and canvas and server silde
FileReader and canvas and server silde
 
はじめてのWallaby.js
はじめてのWallaby.jsはじめてのWallaby.js
はじめてのWallaby.js
 
ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)
 
Startup JavaScript
Startup JavaScriptStartup JavaScript
Startup JavaScript
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろう
 
アニメーションの実装つらい話
アニメーションの実装つらい話アニメーションの実装つらい話
アニメーションの実装つらい話
 
Nds meetup8 lt
Nds meetup8 ltNds meetup8 lt
Nds meetup8 lt
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話
 
Hello npm
Hello npmHello npm
Hello npm
 
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
 
Learn ES2015
Learn ES2015Learn ES2015
Learn ES2015
 

Similar to kontainer-js

An MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected ContentAn MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected Content
Alpen-Adria-Universität
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
Justin Cataldo
 
Hartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter SapporoHartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter Sapporo
Jun OHWADA
 
Rest3d BOF presentation at SigGraph 2013
Rest3d BOF presentation at SigGraph 2013Rest3d BOF presentation at SigGraph 2013
Rest3d BOF presentation at SigGraph 2013
Remi Arnaud
 

Similar to kontainer-js (20)

Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
 
An MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected ContentAn MXM-based Application for Sharing Protected Content
An MXM-based Application for Sharing Protected Content
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 
Mongodb
MongodbMongodb
Mongodb
 
Like loggly using open source
Like loggly using open sourceLike loggly using open source
Like loggly using open source
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4
 
Fluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At FossasiaFluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At Fossasia
 
My name is Trinidad
My name is TrinidadMy name is Trinidad
My name is Trinidad
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layer
 
How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
RediSearch Mumbai Meetup 2020
RediSearch Mumbai Meetup 2020RediSearch Mumbai Meetup 2020
RediSearch Mumbai Meetup 2020
 
Gnocchi v3 brownbag
Gnocchi v3 brownbagGnocchi v3 brownbag
Gnocchi v3 brownbag
 
Sandboxing WebKitGTK (GUADEC 2019)
Sandboxing WebKitGTK (GUADEC 2019)Sandboxing WebKitGTK (GUADEC 2019)
Sandboxing WebKitGTK (GUADEC 2019)
 
Hartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter SapporoHartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter Sapporo
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Spatio-temporal Data Handling With GeoServer for MetOc And Remote Sensing
Spatio-temporal Data Handling With GeoServer for MetOc And Remote SensingSpatio-temporal Data Handling With GeoServer for MetOc And Remote Sensing
Spatio-temporal Data Handling With GeoServer for MetOc And Remote Sensing
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Rest3d BOF presentation at SigGraph 2013
Rest3d BOF presentation at SigGraph 2013Rest3d BOF presentation at SigGraph 2013
Rest3d BOF presentation at SigGraph 2013
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

kontainer-js

  • 1. kontainer-js Megro.es #3 Apr. 19th, 2016 at Drecom Kuu Miyazaki GitHub: @kuu Twitter: @miyazaqui
  • 2. kontainer-js > MP4 parser ● A parser/editor library written in ES2015 ● Runs both on Node.js and in the browser ● Provides its API as JSX
  • 3. MP4 > nested boxes
  • 4. MP4 > nested boxes ftyp moov mdat mvhd trak tkhd mdia ... length type property
  • 6. DOM > React > JSX Nested boxes
  • 7. How about writing MP4 in JSX?
  • 8. How about writing MP4 in JSX? render() { return ( <file> <ftyp majorBrand="isom" /> <moov> <mvhd creationTime={new Date()} timeScale={1} nextTrackId={4} /> <trak> <tkhd {...{trackId: 1, width: this.width, height: this.height}} /> <mdia> ...innerElements </mdia> </trak> </moov> <mdat data={buffer} /> </file> ); }
  • 10. How kontainer-js works { type: ‘ftype’, props : { majorBrand: ‘isom’, }, }, { type: ‘moov’, children: [ { type: ‘mvhd’, props: { timeScale: 1, … }, ] } parse serialize Byte stream JS object transpile JSX
  • 11. Development workflow Lint ● eslint Test ● [Browser] karma-jasmine + browserify(baberify) ● [Node] jasmine-es6 Build/Deploy ● [Browser] browserify(baberify) + uglify-js ● [Node] dist-es6 JSX Transpile ● Self-built Babel plugin (transform-kontainer-js)
  • 13. So, defer it as long as possible Dev Machine GitHub npm ES5 ES6 push publish Dev Machine GitHub npm ES6 push transpile & publishslow! Publish-time transpilation Dev-time transpilation ES6 ES6 ES5 ES5 transpile
  • 14. Publish-time transpilation ● Testing with babel-runtime ● No “dist” directory ● Transpile in a “prepublish” command
  • 15. dist-es6 // package.json { "name": "kontainer-js", "main": "src/index.js", "bin": { "kontainer": "src/cli.js" }, "files": [ "README.md", "logo.png", "lib" ], "scripts": { "prepublish": "dist-es6" }, npm install (local) npm publish 1) creates node_modules/.bin/kontainer #!/usr/bin/env node require('dist-es6/lib/run').module('../src/cli.js'); 2) copies src to node_modules/kontainer-js You can require('kontainer-js') in spec files. README.md etc. ./dist (temp dir) ./src package.json npm copy convert publish
  • 16. Huge win ● Speed (no transpilation in dev-time) ● Less complexity (no “dist” dir) ● Easy to debug (directly with ES6 code)
  • 17. Some caveats ● Dependencies bomb (+294) ● Some publishing issue