Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
colo_js_ojisan
Search
Yosuke Furukawa
PRO
September 16, 2014
Programming
0
1.7k
colo_js_ojisan
JSオジサンの発表資料 colo についての話
Yosuke Furukawa
PRO
September 16, 2014
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
0
230
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
150
Removing Corepack
yosuke_furukawa
PRO
9
1.3k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.5k
Strip Types と Storage
yosuke_furukawa
PRO
4
340
Module Harmony について
yosuke_furukawa
PRO
3
1.5k
LTのやり方
yosuke_furukawa
PRO
16
2.2k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
700
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.3k
Other Decks in Programming
See All in Programming
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
160
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1.1k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
140
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
300
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
2.9k
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
270
Contemporary Test Cases
maaretp
0
140
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.9k
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
初めてDefinitelyTypedにPRを出した話
syumai
0
430
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
250
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
What's in a price? How to price your products and services
michaelherold
243
12k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Bash Introduction
62gerente
608
210k
How to train your dragon (web standard)
notwaldorf
88
5.7k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Transcript
colo @yosuke_furukawa
Twitter: @yosuke_furukawa Github: yosuke-furukawa Real Name: Yosuke Furukawa
Node.jsຊϢʔβʔάϧʔϓද
console.log(“hoge”) ͯ͠·͔͢?
console.log(“hoge”) ʹ৭Λ͚Δํ๏ͬͯ·͔͢?
node.jsͰ?
Node.jsͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log('\033[31m' + 'Hello World'+ '\033[39m'); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log('\033[33m'+
'Hello World'+ '\033[39m'); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log('\033[36m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log('\033[90m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log('\033[32m ' + 'Hello World'+ ' \033[39m');
browserͰ?
browserͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log(‘%cHello World’, ‘color : red;’); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log(‘%cHello
World’, ‘color : yellow;’); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log(‘%cHello World’, ‘color : blue;’); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log(‘%cHello World’, ‘color : grey;’); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log(‘%cHello World’, ‘color : green;’);
Node.jsͰͷํ๏
͜ͷํ๏ͷ
Node.jsͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log('\033[31m' + 'Hello World'+ '\033[39m'); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log('\033[33m'+
'Hello World'+ '\033[39m'); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log('\033[36m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log('\033[90m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log('\033[32m ' + 'Hello World'+ ' \033[39m');
Node.jsͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log('\033[31m' + 'Hello World'+ '\033[39m'); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log('\033[33m'+
'Hello World'+ '\033[39m'); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log('\033[36m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log('\033[90m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log('\033[32m ' + 'Hello World'+ ' \033[39m'); ֮͑ΒΕͳ͍ɻ
Node.jsͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log('\033[31m' + 'Hello World'+ '\033[39m'); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log('\033[33m'+
'Hello World'+ '\033[39m'); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log('\033[36m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log('\033[90m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log('\033[32m ' + 'Hello World'+ ' \033[39m');
Node.jsͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log('\033[31m' + 'Hello World'+ '\033[39m'); ! //ίϯιʔϧԫ৭͘͢Δɿ console.log('\033[33m'+
'Hello World'+ '\033[39m'); ! //ίϯιʔϧ੨৭ʹ͢Δɿ console.log('\033[36m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧփ৭ʹ͢Δɿ console.log('\033[90m' + 'Hello World' + '\033[39m'); ! //ίϯιʔϧ৭ʹ͢Δɿ console.log('\033[32m ' + 'Hello World'+ ' \033[39m'); a͕`VTFTUSJDU` ҎԼͰౖΒΕΔ
ଞͷcolorizeϞδϡʔϧ
colors Stringͷprototype ֦ுͯ͠͠·͏ɻ //ίϯιʔϧ͘͢Δɿ console.log('Hello World’.red);
colorize ಠࣗߏจΛ֮͑Δඞཁ͕͋Δ //ίϯιʔϧ͘͢Δɿ console.log(colorize.ansify(“#red[Hello World]”));
ansi-color-stream શͯStreamͷsubstackۘ //ίϯιʔϧ͘͢Δɿ a.pipe(colorize(“red”)).pipe(process.stdout);
chalk Ұ൪͍͚ͯΔ͚Ͳ ػೳ͕ଟͯ͘ɺґଘ͕ଟ͍ (browserαϙʔτͯ͠ͳ͍) //ίϯιʔϧ͘͢Δɿ console.log(chalk.red(“Hello World”));
chalk Ұ൪͍͚ͯΔ͚Ͳ ػೳ͕ଟͯ͘ɺґଘ͕ଟ͍ //ίϯιʔϧ͘͢Δɿ console.log(chalk.red(“Hello World”)); ͭ·Γɺ͋Μ·Γ ͍͚ͯΔͷ͕ͳ͍
colo
code examples
coloͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log(colo.red(‘colo colo’)); ! //ίϯιʔϧΛcyan + boldʹ͢Δɿ console.log(colo.cyan.bold(‘colo colo’));
! //ίϯιʔϧΛgreen + underlineʹ͢Δɿ console.log(colo.green.underline(‘colo colo’)); ! //ίϯιʔϧΛmagenta + italicʹ͢Δɿ console.log(colo.magenta.italic(‘colo colo’)); ! //ίϯιʔϧΛgrey + inverseʹ͢Δɿ console.log(colo.grey.inverse(‘colo colo’));
coloͰͷํ๏ //ίϯιʔϧ͘͢Δɿ console.log(colo.red(‘colo colo’)); ! //ίϯιʔϧΛcyan + boldʹ͢Δɿ console.log(colo.cyan.bold(‘colo colo’));
! //ίϯιʔϧΛgreen + underlineʹ͢Δɿ console.log(colo.green.underline(‘colo colo’)); ! //ίϯιʔϧΛmagenta + italicʹ͢Δɿ console.log(colo.magenta.italic(‘colo colo’)); ! //ίϯιʔϧΛgrey + inverseʹ͢Δɿ console.log(colo.grey.inverse(‘colo colo’));
DSL like!
colo DSL colo.red("RED"); colo.red.bold("RED and BOLD"); colo.red.bold.underline("RED and BOLD and
UNDERLINE”);
colo DSL colo.red("RED"); colo.red.bold("RED and BOLD"); colo.red.bold.underline("RED and BOLD and
UNDERLINE”);
colo DSL colo.red("RED"); colo.red.bold("RED and BOLD"); colo.red.bold.underline("RED and BOLD and
UNDERLINE”); QSPQFSUZΞΫηεͬΆ͘ ॏͶ͕͚Ͱ͖Δɻ
Browser support! (Chrome, SafariͷΈ)
colo supports browser // DEMO colog(colo.red(“colo colo")); colog(colo.cyan.bold("colo colo")); colog(colo.green.underline("colo
colo")); colog(colo.magenta.italic.bold("colo colo")); colog(colo.grey.bold.italic.underline("colo colo")); #SPXTFSͰDPMPHΛͬͯ දࣔͰ͖Δɻ
DEMO
colo inside
colo inside Object.definePropertiesͷωετ __proto__Λͬͯಈతʹprototype chainΛ࣮ݱ ґଘϞδϡʔϧθϩͰ࣮ݱ
colo code (github) https://github.com/yosuke-furukawa/colo