강희주

Update package.json

Showing 1000 changed files with 3705 additions and 7 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +const axios = require("axios");
2 +const cheerio = require("cheerio");
3 +
4 +
5 +
6 +const getHTML = async() => {
7 + try{
8 + return await axios.get("https://www.youtube.com/results?search_query=tomboy")
9 + }catch(err) {
10 + console.log(err);
11 + }
12 +}
13 +
14 +
15 +const parsing = async() => {
16 + const html = await getHTML();
17 + const $ = cheerio.load(html.data);
18 + const $TitleList = $("ytd-video-renderer.style-scope.ytd-item-section-renderer");
19 +
20 + // ytd-two-column-search-results-renderer ytd-section-list-renderer
21 + $TitleList.each((inx, node) => {
22 + const key = $(node).find("a").attr("href");
23 + console.log(key);
24 + });
25 +
26 + // const key = $want.find('ytd-thumbnail.style-scope ytd-video-renderer a').attr('href')
27 + // console.log(key[0]);
28 +
29 +}
30 +
31 +parsing();
...\ No newline at end of file ...\ No newline at end of file
1 +//npm install youtube-node 후 실행
2 +
3 +var Youtube = require('youtube-node');
4 +var youtube = new Youtube();
5 +
6 +var keyword = 'tomboy'; // 검색어 지정
7 +var limit = 1; // 출력 갯수
8 +
9 +youtube.setKey('AIzaSyCXcFg7Aa9WkKfZc5wFcWdsMUJmYw1Yvmo');
10 +
11 +
12 +function search(word) {
13 + youtube.search(word, limit, function (err, result) { // 검색 실행
14 + if (err) { console.log(err); return; } // 에러일 경우 에러공지하고 빠져나감
15 +
16 + //console.log(JSON.stringify(result, null, 2)); // 받아온 전체 리스트 출력
17 +
18 + var items = result["items"]; // 결과 중 items 항목만 가져옴
19 + var it = items[0];
20 + var video_id = it["id"]["videoId"];
21 + var url = "https://www.youtube.com/watch?v=" + video_id;
22 + console.log(url);
23 +
24 + });
25 +}
26 +search(keyword);
27 +document.getElementById("url").innerHTML=url;
1 -var request = require('request'); 1 +var request = require("request");
2 const APIKEY = "ea903679a6e5a44da75a971c0231f4f4"; 2 const APIKEY = "ea903679a6e5a44da75a971c0231f4f4";
3 -var userLat = 37.65835990000001; 3 +
4 -var userLng = 126.8320201; 4 +
5 +var Lat = userLat.textContent;
6 +var Lng = userLng.textContent;
7 +
8 +var userLat = document.getElementById('latitude').innerText.trim(); // trim으로 공백을 제거하고 실제 값만 불러오기
9 +var userLng = document.getElementById('longitude').innerText.trim(); // trim으로 공백을 제거하고 실제 값만 불러오기
10 +
5 11
6 12
7 request("https://api.openweathermap.org/data/2.5/weather?lat=" + userLat + "&lon=" + userLng + "&appid=" + APIKEY + "&units=metric",function(error, response, body){ 13 request("https://api.openweathermap.org/data/2.5/weather?lat=" + userLat + "&lon=" + userLng + "&appid=" + APIKEY + "&units=metric",function(error, response, body){
......
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
11 "dependencies": { 11 "dependencies": {
12 "express": "^4.18.1", 12 "express": "^4.18.1",
13 "request": "^2.88.2" 13 "request": "^2.88.2"
14 - } 14 + },
15 + "type" : "module"
15 } 16 }
......
...@@ -9,7 +9,16 @@ ...@@ -9,7 +9,16 @@
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 -<script type="text/javascript" src="practice.js"></script> 12 +<div id = "lat"></div>
13 +<div id = "long"></div>
14 +<script type = "text/javascript" src = "practice.js" defer ></script>
15 +<ul>
16 + <li>위도:<span id="latitude"></span></li>
17 + <li>경도:<span id="longitude"></span></li>
18 +</ul>
19 +<script type = "text/javascript" src = "../WeatherCheckAPI/WeatherCheck.js" defer></script>
20 +
21 +
13 </body> 22 </body>
14 23
15 </html> 24 </html>
......
...@@ -4,13 +4,17 @@ if (navigator.geolocation) { ...@@ -4,13 +4,17 @@ if (navigator.geolocation) {
4 alert("Your browser is not support geolocation.")//navigator이 현재 브라우저에서 작동하지 않는 경우 4 alert("Your browser is not support geolocation.")//navigator이 현재 브라우저에서 작동하지 않는 경우
5 } 5 }
6 6
7 - function success(position) { 7 + function success(position) {
8 var latitude = position.coords.latitude; 8 var latitude = position.coords.latitude;
9 var longitude = position.coords.longitude 9 var longitude = position.coords.longitude
10 console.log(`Your latitude is ${latitude} and your longitude is ${longitude}`) // 위도와 경도 값을 console로 알려줌 10 console.log(`Your latitude is ${latitude} and your longitude is ${longitude}`) // 위도와 경도 값을 console로 알려줌
11 + // document.getElementById("lat").innerHTML=latitude;
12 + // document.getElementById("long").innerHTML=longitude;
11 return (latitude, longitude); 13 return (latitude, longitude);
14 +
12 } 15 }
13 16
17 +
14 function error() { 18 function error() {
15 alert("Can't detect your location. Try again later.") // error function 19 alert("Can't detect your location. Try again later.") // error function
16 - }
...\ No newline at end of file ...\ No newline at end of file
20 + }
......
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../JSONStream/bin.js" "$@"
10 +else
11 + exec node "$basedir/../JSONStream/bin.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\JSONStream\bin.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../JSONStream/bin.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../JSONStream/bin.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../JSONStream/bin.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../JSONStream/bin.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../acorn/bin/acorn" "$@"
10 +else
11 + exec node "$basedir/../acorn/bin/acorn" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\acorn\bin\acorn" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../acorn/bin/acorn" $args
23 + } else {
24 + & "node$exe" "$basedir/../acorn/bin/acorn" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../browser-pack/bin/cmd.js" "$@"
10 +else
11 + exec node "$basedir/../browser-pack/bin/cmd.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\browser-pack\bin\cmd.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../browser-pack/bin/cmd.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../browser-pack/bin/cmd.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../browser-pack/bin/cmd.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../browser-pack/bin/cmd.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../browserify/bin/cmd.js" "$@"
10 +else
11 + exec node "$basedir/../browserify/bin/cmd.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\browserify\bin\cmd.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../browserify/bin/cmd.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../browserify/bin/cmd.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../browserify/bin/cmd.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../browserify/bin/cmd.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../deps-sort/bin/cmd.js" "$@"
10 +else
11 + exec node "$basedir/../deps-sort/bin/cmd.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\deps-sort\bin\cmd.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../deps-sort/bin/cmd.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../deps-sort/bin/cmd.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../deps-sort/bin/cmd.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../deps-sort/bin/cmd.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../detective/bin/detective.js" "$@"
10 +else
11 + exec node "$basedir/../detective/bin/detective.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\detective\bin\detective.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../detective/bin/detective.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../detective/bin/detective.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../detective/bin/detective.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../detective/bin/detective.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../insert-module-globals/bin/cmd.js" "$@"
10 +else
11 + exec node "$basedir/../insert-module-globals/bin/cmd.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\insert-module-globals\bin\cmd.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../insert-module-globals/bin/cmd.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../insert-module-globals/bin/cmd.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../insert-module-globals/bin/cmd.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../insert-module-globals/bin/cmd.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../miller-rabin/bin/miller-rabin" "$@"
10 +else
11 + exec node "$basedir/../miller-rabin/bin/miller-rabin" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\miller-rabin\bin\miller-rabin" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../miller-rabin/bin/miller-rabin" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../miller-rabin/bin/miller-rabin" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../miller-rabin/bin/miller-rabin" $args
23 + } else {
24 + & "node$exe" "$basedir/../miller-rabin/bin/miller-rabin" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../module-deps/bin/cmd.js" "$@"
10 +else
11 + exec node "$basedir/../module-deps/bin/cmd.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\module-deps\bin\cmd.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../module-deps/bin/cmd.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../module-deps/bin/cmd.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../module-deps/bin/cmd.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../module-deps/bin/cmd.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../resolve/bin/resolve" "$@"
10 +else
11 + exec node "$basedir/../resolve/bin/resolve" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\resolve\bin\resolve" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../resolve/bin/resolve" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../resolve/bin/resolve" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../resolve/bin/resolve" $args
23 + } else {
24 + & "node$exe" "$basedir/../resolve/bin/resolve" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../sha.js/bin.js" "$@"
10 +else
11 + exec node "$basedir/../sha.js/bin.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\sha.js\bin.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../sha.js/bin.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../sha.js/bin.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../sha.js/bin.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../sha.js/bin.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../umd/bin/cli.js" "$@"
10 +else
11 + exec node "$basedir/../umd/bin/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\umd\bin\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../umd/bin/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../umd/bin/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../umd/bin/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../umd/bin/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../undeclared-identifiers/bin.js" "$@"
10 +else
11 + exec node "$basedir/../undeclared-identifiers/bin.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\undeclared-identifiers\bin.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../undeclared-identifiers/bin.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../undeclared-identifiers/bin.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../undeclared-identifiers/bin.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../undeclared-identifiers/bin.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../youtube-node/bin/youtube" "$@"
10 +else
11 + exec node "$basedir/../youtube-node/bin/youtube" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\youtube-node\bin\youtube" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../youtube-node/bin/youtube" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../youtube-node/bin/youtube" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../youtube-node/bin/youtube" $args
23 + } else {
24 + & "node$exe" "$basedir/../youtube-node/bin/youtube" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
This diff is collapsed. Click to expand it.
1 +MIT License
2 +
3 +Original Library
4 + - Copyright (c) Marak Squires
5 +
6 +Additional Functionality
7 + - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
8 + - Copyright (c) DABH (https://github.com/DABH)
9 +
10 +Permission is hereby granted, free of charge, to any person obtaining a copy
11 +of this software and associated documentation files (the "Software"), to deal
12 +in the Software without restriction, including without limitation the rights
13 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 +copies of the Software, and to permit persons to whom the Software is
15 +furnished to do so, subject to the following conditions:
16 +
17 +The above copyright notice and this permission notice shall be included in
18 +all copies or substantial portions of the Software.
19 +
20 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 +THE SOFTWARE.
1 +# @colors/colors ("colors.js")
2 +[![Build Status](https://github.com/DABH/colors.js/actions/workflows/ci.yml/badge.svg)](https://github.com/DABH/colors.js/actions/workflows/ci.yml)
3 +[![version](https://img.shields.io/npm/v/@colors/colors.svg)](https://www.npmjs.org/package/@colors/colors)
4 +
5 +Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback.
6 +
7 +## get color and style in your node.js console
8 +
9 +![Demo](https://raw.githubusercontent.com/DABH/colors.js/master/screenshots/colors.png)
10 +
11 +## Installation
12 +
13 + npm install @colors/colors
14 +
15 +## colors and styles!
16 +
17 +### text colors
18 +
19 + - black
20 + - red
21 + - green
22 + - yellow
23 + - blue
24 + - magenta
25 + - cyan
26 + - white
27 + - gray
28 + - grey
29 +
30 +### bright text colors
31 +
32 + - brightRed
33 + - brightGreen
34 + - brightYellow
35 + - brightBlue
36 + - brightMagenta
37 + - brightCyan
38 + - brightWhite
39 +
40 +### background colors
41 +
42 + - bgBlack
43 + - bgRed
44 + - bgGreen
45 + - bgYellow
46 + - bgBlue
47 + - bgMagenta
48 + - bgCyan
49 + - bgWhite
50 + - bgGray
51 + - bgGrey
52 +
53 +### bright background colors
54 +
55 + - bgBrightRed
56 + - bgBrightGreen
57 + - bgBrightYellow
58 + - bgBrightBlue
59 + - bgBrightMagenta
60 + - bgBrightCyan
61 + - bgBrightWhite
62 +
63 +### styles
64 +
65 + - reset
66 + - bold
67 + - dim
68 + - italic
69 + - underline
70 + - inverse
71 + - hidden
72 + - strikethrough
73 +
74 +### extras
75 +
76 + - rainbow
77 + - zebra
78 + - america
79 + - trap
80 + - random
81 +
82 +
83 +## Usage
84 +
85 +By popular demand, `@colors/colors` now ships with two types of usages!
86 +
87 +The super nifty way
88 +
89 +```js
90 +var colors = require('@colors/colors');
91 +
92 +console.log('hello'.green); // outputs green text
93 +console.log('i like cake and pies'.underline.red); // outputs red underlined text
94 +console.log('inverse the color'.inverse); // inverses the color
95 +console.log('OMG Rainbows!'.rainbow); // rainbow
96 +console.log('Run the trap'.trap); // Drops the bass
97 +
98 +```
99 +
100 +or a slightly less nifty way which doesn't extend `String.prototype`
101 +
102 +```js
103 +var colors = require('@colors/colors/safe');
104 +
105 +console.log(colors.green('hello')); // outputs green text
106 +console.log(colors.red.underline('i like cake and pies')); // outputs red underlined text
107 +console.log(colors.inverse('inverse the color')); // inverses the color
108 +console.log(colors.rainbow('OMG Rainbows!')); // rainbow
109 +console.log(colors.trap('Run the trap')); // Drops the bass
110 +
111 +```
112 +
113 +I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
114 +
115 +If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
116 +
117 +## Enabling/Disabling Colors
118 +
119 +The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
120 +
121 +```bash
122 +node myapp.js --no-color
123 +node myapp.js --color=false
124 +
125 +node myapp.js --color
126 +node myapp.js --color=true
127 +node myapp.js --color=always
128 +
129 +FORCE_COLOR=1 node myapp.js
130 +```
131 +
132 +Or in code:
133 +
134 +```javascript
135 +var colors = require('@colors/colors');
136 +colors.enable();
137 +colors.disable();
138 +```
139 +
140 +## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
141 +
142 +```js
143 +var name = 'Beowulf';
144 +console.log(colors.green('Hello %s'), name);
145 +// outputs -> 'Hello Beowulf'
146 +```
147 +
148 +## Custom themes
149 +
150 +### Using standard API
151 +
152 +```js
153 +
154 +var colors = require('@colors/colors');
155 +
156 +colors.setTheme({
157 + silly: 'rainbow',
158 + input: 'grey',
159 + verbose: 'cyan',
160 + prompt: 'grey',
161 + info: 'green',
162 + data: 'grey',
163 + help: 'cyan',
164 + warn: 'yellow',
165 + debug: 'blue',
166 + error: 'red'
167 +});
168 +
169 +// outputs red text
170 +console.log("this is an error".error);
171 +
172 +// outputs yellow text
173 +console.log("this is a warning".warn);
174 +```
175 +
176 +### Using string safe API
177 +
178 +```js
179 +var colors = require('@colors/colors/safe');
180 +
181 +// set single property
182 +var error = colors.red;
183 +error('this is red');
184 +
185 +// set theme
186 +colors.setTheme({
187 + silly: 'rainbow',
188 + input: 'grey',
189 + verbose: 'cyan',
190 + prompt: 'grey',
191 + info: 'green',
192 + data: 'grey',
193 + help: 'cyan',
194 + warn: 'yellow',
195 + debug: 'blue',
196 + error: 'red'
197 +});
198 +
199 +// outputs red text
200 +console.log(colors.error("this is an error"));
201 +
202 +// outputs yellow text
203 +console.log(colors.warn("this is a warning"));
204 +
205 +```
206 +
207 +### Combining Colors
208 +
209 +```javascript
210 +var colors = require('@colors/colors');
211 +
212 +colors.setTheme({
213 + custom: ['red', 'underline']
214 +});
215 +
216 +console.log('test'.custom);
217 +```
218 +
219 +*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
1 +var colors = require('../lib/index');
2 +
3 +console.log('First some yellow text'.yellow);
4 +
5 +console.log('Underline that text'.yellow.underline);
6 +
7 +console.log('Make it bold and red'.red.bold);
8 +
9 +console.log(('Double Raindows All Day Long').rainbow);
10 +
11 +console.log('Drop the bass'.trap);
12 +
13 +console.log('DROP THE RAINBOW BASS'.trap.rainbow);
14 +
15 +// styles not widely supported
16 +console.log('Chains are also cool.'.bold.italic.underline.red);
17 +
18 +// styles not widely supported
19 +console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
20 + + ' styles! '.yellow.bold);
21 +console.log('Zebras are so fun!'.zebra);
22 +
23 +//
24 +// Remark: .strikethrough may not work with Mac OS Terminal App
25 +//
26 +console.log('This is ' + 'not'.strikethrough + ' fun.');
27 +
28 +console.log('Background color attack!'.black.bgWhite);
29 +console.log('Use random styles on everything!'.random);
30 +console.log('America, Heck Yeah!'.america);
31 +
32 +// eslint-disable-next-line max-len
33 +console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
34 +
35 +console.log('Setting themes is useful');
36 +
37 +//
38 +// Custom themes
39 +//
40 +console.log('Generic logging theme as JSON'.green.bold.underline);
41 +// Load theme with JSON literal
42 +colors.setTheme({
43 + silly: 'rainbow',
44 + input: 'grey',
45 + verbose: 'cyan',
46 + prompt: 'grey',
47 + info: 'green',
48 + data: 'grey',
49 + help: 'cyan',
50 + warn: 'yellow',
51 + debug: 'blue',
52 + error: 'red',
53 +});
54 +
55 +// outputs red text
56 +console.log('this is an error'.error);
57 +
58 +// outputs yellow text
59 +console.log('this is a warning'.warn);
60 +
61 +// outputs grey text
62 +console.log('this is an input'.input);
63 +
64 +console.log('Generic logging theme as file'.green.bold.underline);
65 +
66 +// Load a theme from file
67 +try {
68 + colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
69 +} catch (err) {
70 + console.log(err);
71 +}
72 +
73 +// outputs red text
74 +console.log('this is an error'.error);
75 +
76 +// outputs yellow text
77 +console.log('this is a warning'.warn);
78 +
79 +// outputs grey text
80 +console.log('this is an input'.input);
81 +
82 +// console.log("Don't summon".zalgo)
83 +
1 +var colors = require('../safe');
2 +
3 +console.log(colors.yellow('First some yellow text'));
4 +
5 +console.log(colors.yellow.underline('Underline that text'));
6 +
7 +console.log(colors.red.bold('Make it bold and red'));
8 +
9 +console.log(colors.rainbow('Double Raindows All Day Long'));
10 +
11 +console.log(colors.trap('Drop the bass'));
12 +
13 +console.log(colors.rainbow(colors.trap('DROP THE RAINBOW BASS')));
14 +
15 +// styles not widely supported
16 +console.log(colors.bold.italic.underline.red('Chains are also cool.'));
17 +
18 +// styles not widely supported
19 +console.log(colors.green('So ') + colors.underline('are') + ' '
20 + + colors.inverse('inverse') + colors.yellow.bold(' styles! '));
21 +
22 +console.log(colors.zebra('Zebras are so fun!'));
23 +
24 +console.log('This is ' + colors.strikethrough('not') + ' fun.');
25 +
26 +
27 +console.log(colors.black.bgWhite('Background color attack!'));
28 +console.log(colors.random('Use random styles on everything!'));
29 +console.log(colors.america('America, Heck Yeah!'));
30 +
31 +// eslint-disable-next-line max-len
32 +console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));
33 +
34 +console.log('Setting themes is useful');
35 +
36 +//
37 +// Custom themes
38 +//
39 +// console.log('Generic logging theme as JSON'.green.bold.underline);
40 +// Load theme with JSON literal
41 +colors.setTheme({
42 + silly: 'rainbow',
43 + input: 'blue',
44 + verbose: 'cyan',
45 + prompt: 'grey',
46 + info: 'green',
47 + data: 'grey',
48 + help: 'cyan',
49 + warn: 'yellow',
50 + debug: 'blue',
51 + error: 'red',
52 +});
53 +
54 +// outputs red text
55 +console.log(colors.error('this is an error'));
56 +
57 +// outputs yellow text
58 +console.log(colors.warn('this is a warning'));
59 +
60 +// outputs blue text
61 +console.log(colors.input('this is an input'));
62 +
63 +
64 +// console.log('Generic logging theme as file'.green.bold.underline);
65 +
66 +// Load a theme from file
67 +colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
68 +
69 +// outputs red text
70 +console.log(colors.error('this is an error'));
71 +
72 +// outputs yellow text
73 +console.log(colors.warn('this is a warning'));
74 +
75 +// outputs grey text
76 +console.log(colors.input('this is an input'));
77 +
78 +// console.log(colors.zalgo("Don't summon him"))
79 +
80 +
1 +// Type definitions for @colors/colors 1.4+
2 +// Project: https://github.com/Marak/colors.js
3 +// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
4 +// Definitions: https://github.com/DABH/colors.js
5 +
6 +export interface Color {
7 + (text: string): string;
8 +
9 + strip: Color;
10 + stripColors: Color;
11 +
12 + black: Color;
13 + red: Color;
14 + green: Color;
15 + yellow: Color;
16 + blue: Color;
17 + magenta: Color;
18 + cyan: Color;
19 + white: Color;
20 + gray: Color;
21 + grey: Color;
22 +
23 + bgBlack: Color;
24 + bgRed: Color;
25 + bgGreen: Color;
26 + bgYellow: Color;
27 + bgBlue: Color;
28 + bgMagenta: Color;
29 + bgCyan: Color;
30 + bgWhite: Color;
31 +
32 + reset: Color;
33 + bold: Color;
34 + dim: Color;
35 + italic: Color;
36 + underline: Color;
37 + inverse: Color;
38 + hidden: Color;
39 + strikethrough: Color;
40 +
41 + rainbow: Color;
42 + zebra: Color;
43 + america: Color;
44 + trap: Color;
45 + random: Color;
46 + zalgo: Color;
47 +}
48 +
49 +export function enable(): void;
50 +export function disable(): void;
51 +export function setTheme(theme: any): void;
52 +
53 +export let enabled: boolean;
54 +
55 +export const strip: Color;
56 +export const stripColors: Color;
57 +
58 +export const black: Color;
59 +export const red: Color;
60 +export const green: Color;
61 +export const yellow: Color;
62 +export const blue: Color;
63 +export const magenta: Color;
64 +export const cyan: Color;
65 +export const white: Color;
66 +export const gray: Color;
67 +export const grey: Color;
68 +
69 +export const bgBlack: Color;
70 +export const bgRed: Color;
71 +export const bgGreen: Color;
72 +export const bgYellow: Color;
73 +export const bgBlue: Color;
74 +export const bgMagenta: Color;
75 +export const bgCyan: Color;
76 +export const bgWhite: Color;
77 +
78 +export const reset: Color;
79 +export const bold: Color;
80 +export const dim: Color;
81 +export const italic: Color;
82 +export const underline: Color;
83 +export const inverse: Color;
84 +export const hidden: Color;
85 +export const strikethrough: Color;
86 +
87 +export const rainbow: Color;
88 +export const zebra: Color;
89 +export const america: Color;
90 +export const trap: Color;
91 +export const random: Color;
92 +export const zalgo: Color;
93 +
94 +declare global {
95 + interface String {
96 + strip: string;
97 + stripColors: string;
98 +
99 + black: string;
100 + red: string;
101 + green: string;
102 + yellow: string;
103 + blue: string;
104 + magenta: string;
105 + cyan: string;
106 + white: string;
107 + gray: string;
108 + grey: string;
109 +
110 + bgBlack: string;
111 + bgRed: string;
112 + bgGreen: string;
113 + bgYellow: string;
114 + bgBlue: string;
115 + bgMagenta: string;
116 + bgCyan: string;
117 + bgWhite: string;
118 +
119 + reset: string;
120 + // @ts-ignore
121 + bold: string;
122 + dim: string;
123 + italic: string;
124 + underline: string;
125 + inverse: string;
126 + hidden: string;
127 + strikethrough: string;
128 +
129 + rainbow: string;
130 + zebra: string;
131 + america: string;
132 + trap: string;
133 + random: string;
134 + zalgo: string;
135 + }
136 +}
1 +/*
2 +
3 +The MIT License (MIT)
4 +
5 +Original Library
6 + - Copyright (c) Marak Squires
7 +
8 +Additional functionality
9 + - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
10 +
11 +Permission is hereby granted, free of charge, to any person obtaining a copy
12 +of this software and associated documentation files (the "Software"), to deal
13 +in the Software without restriction, including without limitation the rights
14 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 +copies of the Software, and to permit persons to whom the Software is
16 +furnished to do so, subject to the following conditions:
17 +
18 +The above copyright notice and this permission notice shall be included in
19 +all copies or substantial portions of the Software.
20 +
21 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 +THE SOFTWARE.
28 +
29 +*/
30 +
31 +var colors = {};
32 +module['exports'] = colors;
33 +
34 +colors.themes = {};
35 +
36 +var util = require('util');
37 +var ansiStyles = colors.styles = require('./styles');
38 +var defineProps = Object.defineProperties;
39 +var newLineRegex = new RegExp(/[\r\n]+/g);
40 +
41 +colors.supportsColor = require('./system/supports-colors').supportsColor;
42 +
43 +if (typeof colors.enabled === 'undefined') {
44 + colors.enabled = colors.supportsColor() !== false;
45 +}
46 +
47 +colors.enable = function() {
48 + colors.enabled = true;
49 +};
50 +
51 +colors.disable = function() {
52 + colors.enabled = false;
53 +};
54 +
55 +colors.stripColors = colors.strip = function(str) {
56 + return ('' + str).replace(/\x1B\[\d+m/g, '');
57 +};
58 +
59 +// eslint-disable-next-line no-unused-vars
60 +var stylize = colors.stylize = function stylize(str, style) {
61 + if (!colors.enabled) {
62 + return str+'';
63 + }
64 +
65 + var styleMap = ansiStyles[style];
66 +
67 + // Stylize should work for non-ANSI styles, too
68 + if (!styleMap && style in colors) {
69 + // Style maps like trap operate as functions on strings;
70 + // they don't have properties like open or close.
71 + return colors[style](str);
72 + }
73 +
74 + return styleMap.open + str + styleMap.close;
75 +};
76 +
77 +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
78 +var escapeStringRegexp = function(str) {
79 + if (typeof str !== 'string') {
80 + throw new TypeError('Expected a string');
81 + }
82 + return str.replace(matchOperatorsRe, '\\$&');
83 +};
84 +
85 +function build(_styles) {
86 + var builder = function builder() {
87 + return applyStyle.apply(builder, arguments);
88 + };
89 + builder._styles = _styles;
90 + // __proto__ is used because we must return a function, but there is
91 + // no way to create a function with a different prototype.
92 + builder.__proto__ = proto;
93 + return builder;
94 +}
95 +
96 +var styles = (function() {
97 + var ret = {};
98 + ansiStyles.grey = ansiStyles.gray;
99 + Object.keys(ansiStyles).forEach(function(key) {
100 + ansiStyles[key].closeRe =
101 + new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
102 + ret[key] = {
103 + get: function() {
104 + return build(this._styles.concat(key));
105 + },
106 + };
107 + });
108 + return ret;
109 +})();
110 +
111 +var proto = defineProps(function colors() {}, styles);
112 +
113 +function applyStyle() {
114 + var args = Array.prototype.slice.call(arguments);
115 +
116 + var str = args.map(function(arg) {
117 + // Use weak equality check so we can colorize null/undefined in safe mode
118 + if (arg != null && arg.constructor === String) {
119 + return arg;
120 + } else {
121 + return util.inspect(arg);
122 + }
123 + }).join(' ');
124 +
125 + if (!colors.enabled || !str) {
126 + return str;
127 + }
128 +
129 + var newLinesPresent = str.indexOf('\n') != -1;
130 +
131 + var nestedStyles = this._styles;
132 +
133 + var i = nestedStyles.length;
134 + while (i--) {
135 + var code = ansiStyles[nestedStyles[i]];
136 + str = code.open + str.replace(code.closeRe, code.open) + code.close;
137 + if (newLinesPresent) {
138 + str = str.replace(newLineRegex, function(match) {
139 + return code.close + match + code.open;
140 + });
141 + }
142 + }
143 +
144 + return str;
145 +}
146 +
147 +colors.setTheme = function(theme) {
148 + if (typeof theme === 'string') {
149 + console.log('colors.setTheme now only accepts an object, not a string. ' +
150 + 'If you are trying to set a theme from a file, it is now your (the ' +
151 + 'caller\'s) responsibility to require the file. The old syntax ' +
152 + 'looked like colors.setTheme(__dirname + ' +
153 + '\'/../themes/generic-logging.js\'); The new syntax looks like '+
154 + 'colors.setTheme(require(__dirname + ' +
155 + '\'/../themes/generic-logging.js\'));');
156 + return;
157 + }
158 + for (var style in theme) {
159 + (function(style) {
160 + colors[style] = function(str) {
161 + if (typeof theme[style] === 'object') {
162 + var out = str;
163 + for (var i in theme[style]) {
164 + out = colors[theme[style][i]](out);
165 + }
166 + return out;
167 + }
168 + return colors[theme[style]](str);
169 + };
170 + })(style);
171 + }
172 +};
173 +
174 +function init() {
175 + var ret = {};
176 + Object.keys(styles).forEach(function(name) {
177 + ret[name] = {
178 + get: function() {
179 + return build([name]);
180 + },
181 + };
182 + });
183 + return ret;
184 +}
185 +
186 +var sequencer = function sequencer(map, str) {
187 + var exploded = str.split('');
188 + exploded = exploded.map(map);
189 + return exploded.join('');
190 +};
191 +
192 +// custom formatter methods
193 +colors.trap = require('./custom/trap');
194 +colors.zalgo = require('./custom/zalgo');
195 +
196 +// maps
197 +colors.maps = {};
198 +colors.maps.america = require('./maps/america')(colors);
199 +colors.maps.zebra = require('./maps/zebra')(colors);
200 +colors.maps.rainbow = require('./maps/rainbow')(colors);
201 +colors.maps.random = require('./maps/random')(colors);
202 +
203 +for (var map in colors.maps) {
204 + (function(map) {
205 + colors[map] = function(str) {
206 + return sequencer(colors.maps[map], str);
207 + };
208 + })(map);
209 +}
210 +
211 +defineProps(colors, init());
1 +module['exports'] = function runTheTrap(text, options) {
2 + var result = '';
3 + text = text || 'Run the trap, drop the bass';
4 + text = text.split('');
5 + var trap = {
6 + a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'],
7 + b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'],
8 + c: ['\u00a9', '\u023b', '\u03fe'],
9 + d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
10 + e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
11 + '\u0a6c'],
12 + f: ['\u04fa'],
13 + g: ['\u0262'],
14 + h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
15 + i: ['\u0f0f'],
16 + j: ['\u0134'],
17 + k: ['\u0138', '\u04a0', '\u04c3', '\u051e'],
18 + l: ['\u0139'],
19 + m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
20 + n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
21 + o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
22 + '\u06dd', '\u0e4f'],
23 + p: ['\u01f7', '\u048e'],
24 + q: ['\u09cd'],
25 + r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
26 + s: ['\u00a7', '\u03de', '\u03df', '\u03e8'],
27 + t: ['\u0141', '\u0166', '\u0373'],
28 + u: ['\u01b1', '\u054d'],
29 + v: ['\u05d8'],
30 + w: ['\u0428', '\u0460', '\u047c', '\u0d70'],
31 + x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'],
32 + y: ['\u00a5', '\u04b0', '\u04cb'],
33 + z: ['\u01b5', '\u0240'],
34 + };
35 + text.forEach(function(c) {
36 + c = c.toLowerCase();
37 + var chars = trap[c] || [' '];
38 + var rand = Math.floor(Math.random() * chars.length);
39 + if (typeof trap[c] !== 'undefined') {
40 + result += trap[c][rand];
41 + } else {
42 + result += c;
43 + }
44 + });
45 + return result;
46 +};
1 +// please no
2 +module['exports'] = function zalgo(text, options) {
3 + text = text || ' he is here ';
4 + var soul = {
5 + 'up': [
6 + '̍', '̎', '̄', '̅',
7 + '̿', '̑', '̆', '̐',
8 + '͒', '͗', '͑', '̇',
9 + '̈', '̊', '͂', '̓',
10 + '̈', '͊', '͋', '͌',
11 + '̃', '̂', '̌', '͐',
12 + '̀', '́', '̋', '̏',
13 + '̒', '̓', '̔', '̽',
14 + '̉', 'ͣ', 'ͤ', 'ͥ',
15 + 'ͦ', 'ͧ', 'ͨ', 'ͩ',
16 + 'ͪ', 'ͫ', 'ͬ', 'ͭ',
17 + 'ͮ', 'ͯ', '̾', '͛',
18 + '͆', '̚',
19 + ],
20 + 'down': [
21 + '̖', '̗', '̘', '̙',
22 + '̜', '̝', '̞', '̟',
23 + '̠', '̤', '̥', '̦',
24 + '̩', '̪', '̫', '̬',
25 + '̭', '̮', '̯', '̰',
26 + '̱', '̲', '̳', '̹',
27 + '̺', '̻', '̼', 'ͅ',
28 + '͇', '͈', '͉', '͍',
29 + '͎', '͓', '͔', '͕',
30 + '͖', '͙', '͚', '̣',
31 + ],
32 + 'mid': [
33 + '̕', '̛', '̀', '́',
34 + '͘', '̡', '̢', '̧',
35 + '̨', '̴', '̵', '̶',
36 + '͜', '͝', '͞',
37 + '͟', '͠', '͢', '̸',
38 + '̷', '͡', ' ҉',
39 + ],
40 + };
41 + var all = [].concat(soul.up, soul.down, soul.mid);
42 +
43 + function randomNumber(range) {
44 + var r = Math.floor(Math.random() * range);
45 + return r;
46 + }
47 +
48 + function isChar(character) {
49 + var bool = false;
50 + all.filter(function(i) {
51 + bool = (i === character);
52 + });
53 + return bool;
54 + }
55 +
56 +
57 + function heComes(text, options) {
58 + var result = '';
59 + var counts;
60 + var l;
61 + options = options || {};
62 + options['up'] =
63 + typeof options['up'] !== 'undefined' ? options['up'] : true;
64 + options['mid'] =
65 + typeof options['mid'] !== 'undefined' ? options['mid'] : true;
66 + options['down'] =
67 + typeof options['down'] !== 'undefined' ? options['down'] : true;
68 + options['size'] =
69 + typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
70 + text = text.split('');
71 + for (l in text) {
72 + if (isChar(l)) {
73 + continue;
74 + }
75 + result = result + text[l];
76 + counts = {'up': 0, 'down': 0, 'mid': 0};
77 + switch (options.size) {
78 + case 'mini':
79 + counts.up = randomNumber(8);
80 + counts.mid = randomNumber(2);
81 + counts.down = randomNumber(8);
82 + break;
83 + case 'maxi':
84 + counts.up = randomNumber(16) + 3;
85 + counts.mid = randomNumber(4) + 1;
86 + counts.down = randomNumber(64) + 3;
87 + break;
88 + default:
89 + counts.up = randomNumber(8) + 1;
90 + counts.mid = randomNumber(6) / 2;
91 + counts.down = randomNumber(8) + 1;
92 + break;
93 + }
94 +
95 + var arr = ['up', 'mid', 'down'];
96 + for (var d in arr) {
97 + var index = arr[d];
98 + for (var i = 0; i <= counts[index]; i++) {
99 + if (options[index]) {
100 + result = result + soul[index][randomNumber(soul[index].length)];
101 + }
102 + }
103 + }
104 + }
105 + return result;
106 + }
107 + // don't summon him
108 + return heComes(text, options);
109 +};
110 +
1 +var colors = require('./colors');
2 +
3 +module['exports'] = function() {
4 + //
5 + // Extends prototype of native string object to allow for "foo".red syntax
6 + //
7 + var addProperty = function(color, func) {
8 + String.prototype.__defineGetter__(color, func);
9 + };
10 +
11 + addProperty('strip', function() {
12 + return colors.strip(this);
13 + });
14 +
15 + addProperty('stripColors', function() {
16 + return colors.strip(this);
17 + });
18 +
19 + addProperty('trap', function() {
20 + return colors.trap(this);
21 + });
22 +
23 + addProperty('zalgo', function() {
24 + return colors.zalgo(this);
25 + });
26 +
27 + addProperty('zebra', function() {
28 + return colors.zebra(this);
29 + });
30 +
31 + addProperty('rainbow', function() {
32 + return colors.rainbow(this);
33 + });
34 +
35 + addProperty('random', function() {
36 + return colors.random(this);
37 + });
38 +
39 + addProperty('america', function() {
40 + return colors.america(this);
41 + });
42 +
43 + //
44 + // Iterate through all default styles and colors
45 + //
46 + var x = Object.keys(colors.styles);
47 + x.forEach(function(style) {
48 + addProperty(style, function() {
49 + return colors.stylize(this, style);
50 + });
51 + });
52 +
53 + function applyTheme(theme) {
54 + //
55 + // Remark: This is a list of methods that exist
56 + // on String that you should not overwrite.
57 + //
58 + var stringPrototypeBlacklist = [
59 + '__defineGetter__', '__defineSetter__', '__lookupGetter__',
60 + '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty',
61 + 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString',
62 + 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length',
63 + 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice',
64 + 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase',
65 + 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight',
66 + ];
67 +
68 + Object.keys(theme).forEach(function(prop) {
69 + if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
70 + console.log('warn: '.red + ('String.prototype' + prop).magenta +
71 + ' is probably something you don\'t want to override. ' +
72 + 'Ignoring style name');
73 + } else {
74 + if (typeof(theme[prop]) === 'string') {
75 + colors[prop] = colors[theme[prop]];
76 + addProperty(prop, function() {
77 + return colors[prop](this);
78 + });
79 + } else {
80 + var themePropApplicator = function(str) {
81 + var ret = str || this;
82 + for (var t = 0; t < theme[prop].length; t++) {
83 + ret = colors[theme[prop][t]](ret);
84 + }
85 + return ret;
86 + };
87 + addProperty(prop, themePropApplicator);
88 + colors[prop] = function(str) {
89 + return themePropApplicator(str);
90 + };
91 + }
92 + }
93 + });
94 + }
95 +
96 + colors.setTheme = function(theme) {
97 + if (typeof theme === 'string') {
98 + console.log('colors.setTheme now only accepts an object, not a string. ' +
99 + 'If you are trying to set a theme from a file, it is now your (the ' +
100 + 'caller\'s) responsibility to require the file. The old syntax ' +
101 + 'looked like colors.setTheme(__dirname + ' +
102 + '\'/../themes/generic-logging.js\'); The new syntax looks like '+
103 + 'colors.setTheme(require(__dirname + ' +
104 + '\'/../themes/generic-logging.js\'));');
105 + return;
106 + } else {
107 + applyTheme(theme);
108 + }
109 + };
110 +};
1 +var colors = require('./colors');
2 +module['exports'] = colors;
3 +
4 +// Remark: By default, colors will add style properties to String.prototype.
5 +//
6 +// If you don't wish to extend String.prototype, you can do this instead and
7 +// native String will not be touched:
8 +//
9 +// var colors = require('colors/safe);
10 +// colors.red("foo")
11 +//
12 +//
13 +require('./extendStringPrototype')();
1 +module['exports'] = function(colors) {
2 + return function(letter, i, exploded) {
3 + if (letter === ' ') return letter;
4 + switch (i%3) {
5 + case 0: return colors.red(letter);
6 + case 1: return colors.white(letter);
7 + case 2: return colors.blue(letter);
8 + }
9 + };
10 +};
1 +module['exports'] = function(colors) {
2 + // RoY G BiV
3 + var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
4 + return function(letter, i, exploded) {
5 + if (letter === ' ') {
6 + return letter;
7 + } else {
8 + return colors[rainbowColors[i++ % rainbowColors.length]](letter);
9 + }
10 + };
11 +};
12 +
1 +module['exports'] = function(colors) {
2 + var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
3 + 'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
4 + 'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
5 + return function(letter, i, exploded) {
6 + return letter === ' ' ? letter :
7 + colors[
8 + available[Math.round(Math.random() * (available.length - 2))]
9 + ](letter);
10 + };
11 +};
1 +module['exports'] = function(colors) {
2 + return function(letter, i, exploded) {
3 + return i % 2 === 0 ? letter : colors.inverse(letter);
4 + };
5 +};
1 +/*
2 +The MIT License (MIT)
3 +
4 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining a copy
7 +of this software and associated documentation files (the "Software"), to deal
8 +in the Software without restriction, including without limitation the rights
9 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 +copies of the Software, and to permit persons to whom the Software is
11 +furnished to do so, subject to the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be included in
14 +all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 +THE SOFTWARE.
23 +
24 +*/
25 +
26 +var styles = {};
27 +module['exports'] = styles;
28 +
29 +var codes = {
30 + reset: [0, 0],
31 +
32 + bold: [1, 22],
33 + dim: [2, 22],
34 + italic: [3, 23],
35 + underline: [4, 24],
36 + inverse: [7, 27],
37 + hidden: [8, 28],
38 + strikethrough: [9, 29],
39 +
40 + black: [30, 39],
41 + red: [31, 39],
42 + green: [32, 39],
43 + yellow: [33, 39],
44 + blue: [34, 39],
45 + magenta: [35, 39],
46 + cyan: [36, 39],
47 + white: [37, 39],
48 + gray: [90, 39],
49 + grey: [90, 39],
50 +
51 + brightRed: [91, 39],
52 + brightGreen: [92, 39],
53 + brightYellow: [93, 39],
54 + brightBlue: [94, 39],
55 + brightMagenta: [95, 39],
56 + brightCyan: [96, 39],
57 + brightWhite: [97, 39],
58 +
59 + bgBlack: [40, 49],
60 + bgRed: [41, 49],
61 + bgGreen: [42, 49],
62 + bgYellow: [43, 49],
63 + bgBlue: [44, 49],
64 + bgMagenta: [45, 49],
65 + bgCyan: [46, 49],
66 + bgWhite: [47, 49],
67 + bgGray: [100, 49],
68 + bgGrey: [100, 49],
69 +
70 + bgBrightRed: [101, 49],
71 + bgBrightGreen: [102, 49],
72 + bgBrightYellow: [103, 49],
73 + bgBrightBlue: [104, 49],
74 + bgBrightMagenta: [105, 49],
75 + bgBrightCyan: [106, 49],
76 + bgBrightWhite: [107, 49],
77 +
78 + // legacy styles for colors pre v1.0.0
79 + blackBG: [40, 49],
80 + redBG: [41, 49],
81 + greenBG: [42, 49],
82 + yellowBG: [43, 49],
83 + blueBG: [44, 49],
84 + magentaBG: [45, 49],
85 + cyanBG: [46, 49],
86 + whiteBG: [47, 49],
87 +
88 +};
89 +
90 +Object.keys(codes).forEach(function(key) {
91 + var val = codes[key];
92 + var style = styles[key] = [];
93 + style.open = '\u001b[' + val[0] + 'm';
94 + style.close = '\u001b[' + val[1] + 'm';
95 +});
1 +/*
2 +MIT License
3 +
4 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
7 +this software and associated documentation files (the "Software"), to deal in
8 +the Software without restriction, including without limitation the rights to
9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10 +of the Software, and to permit persons to whom the Software is furnished to do
11 +so, subject to the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be included in all
14 +copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 +SOFTWARE.
23 +*/
24 +
25 +'use strict';
26 +
27 +module.exports = function(flag, argv) {
28 + argv = argv || process.argv;
29 +
30 + var terminatorPos = argv.indexOf('--');
31 + var prefix = /^-{1,2}/.test(flag) ? '' : '--';
32 + var pos = argv.indexOf(prefix + flag);
33 +
34 + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
35 +};
1 +/*
2 +The MIT License (MIT)
3 +
4 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining a copy
7 +of this software and associated documentation files (the "Software"), to deal
8 +in the Software without restriction, including without limitation the rights
9 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 +copies of the Software, and to permit persons to whom the Software is
11 +furnished to do so, subject to the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be included in
14 +all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 +THE SOFTWARE.
23 +
24 +*/
25 +
26 +'use strict';
27 +
28 +var os = require('os');
29 +var hasFlag = require('./has-flag.js');
30 +
31 +var env = process.env;
32 +
33 +var forceColor = void 0;
34 +if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
35 + forceColor = false;
36 +} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true')
37 + || hasFlag('color=always')) {
38 + forceColor = true;
39 +}
40 +if ('FORCE_COLOR' in env) {
41 + forceColor = env.FORCE_COLOR.length === 0
42 + || parseInt(env.FORCE_COLOR, 10) !== 0;
43 +}
44 +
45 +function translateLevel(level) {
46 + if (level === 0) {
47 + return false;
48 + }
49 +
50 + return {
51 + level: level,
52 + hasBasic: true,
53 + has256: level >= 2,
54 + has16m: level >= 3,
55 + };
56 +}
57 +
58 +function supportsColor(stream) {
59 + if (forceColor === false) {
60 + return 0;
61 + }
62 +
63 + if (hasFlag('color=16m') || hasFlag('color=full')
64 + || hasFlag('color=truecolor')) {
65 + return 3;
66 + }
67 +
68 + if (hasFlag('color=256')) {
69 + return 2;
70 + }
71 +
72 + if (stream && !stream.isTTY && forceColor !== true) {
73 + return 0;
74 + }
75 +
76 + var min = forceColor ? 1 : 0;
77 +
78 + if (process.platform === 'win32') {
79 + // Node.js 7.5.0 is the first version of Node.js to include a patch to
80 + // libuv that enables 256 color output on Windows. Anything earlier and it
81 + // won't work. However, here we target Node.js 8 at minimum as it is an LTS
82 + // release, and Node.js 7 is not. Windows 10 build 10586 is the first
83 + // Windows release that supports 256 colors. Windows 10 build 14931 is the
84 + // first release that supports 16m/TrueColor.
85 + var osRelease = os.release().split('.');
86 + if (Number(process.versions.node.split('.')[0]) >= 8
87 + && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
88 + return Number(osRelease[2]) >= 14931 ? 3 : 2;
89 + }
90 +
91 + return 1;
92 + }
93 +
94 + if ('CI' in env) {
95 + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) {
96 + return sign in env;
97 + }) || env.CI_NAME === 'codeship') {
98 + return 1;
99 + }
100 +
101 + return min;
102 + }
103 +
104 + if ('TEAMCITY_VERSION' in env) {
105 + return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0
106 + );
107 + }
108 +
109 + if ('TERM_PROGRAM' in env) {
110 + var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
111 +
112 + switch (env.TERM_PROGRAM) {
113 + case 'iTerm.app':
114 + return version >= 3 ? 3 : 2;
115 + case 'Hyper':
116 + return 3;
117 + case 'Apple_Terminal':
118 + return 2;
119 + // No default
120 + }
121 + }
122 +
123 + if (/-256(color)?$/i.test(env.TERM)) {
124 + return 2;
125 + }
126 +
127 + if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
128 + return 1;
129 + }
130 +
131 + if ('COLORTERM' in env) {
132 + return 1;
133 + }
134 +
135 + if (env.TERM === 'dumb') {
136 + return min;
137 + }
138 +
139 + return min;
140 +}
141 +
142 +function getSupportLevel(stream) {
143 + var level = supportsColor(stream);
144 + return translateLevel(level);
145 +}
146 +
147 +module.exports = {
148 + supportsColor: getSupportLevel,
149 + stdout: getSupportLevel(process.stdout),
150 + stderr: getSupportLevel(process.stderr),
151 +};
1 +{
2 + "name": "@colors/colors",
3 + "description": "get colors in your node.js console",
4 + "version": "1.5.0",
5 + "author": "DABH",
6 + "contributors": [
7 + {
8 + "name": "DABH",
9 + "url": "https://github.com/DABH"
10 + }
11 + ],
12 + "homepage": "https://github.com/DABH/colors.js",
13 + "bugs": "https://github.com/DABH/colors.js/issues",
14 + "keywords": [
15 + "ansi",
16 + "terminal",
17 + "colors"
18 + ],
19 + "repository": {
20 + "type": "git",
21 + "url": "http://github.com/DABH/colors.js.git"
22 + },
23 + "license": "MIT",
24 + "scripts": {
25 + "lint": "eslint . --fix",
26 + "test": "export FORCE_COLOR=1 && node tests/basic-test.js && node tests/safe-test.js"
27 + },
28 + "engines": {
29 + "node": ">=0.1.90"
30 + },
31 + "main": "lib/index.js",
32 + "files": [
33 + "examples",
34 + "lib",
35 + "LICENSE",
36 + "safe.js",
37 + "themes",
38 + "index.d.ts",
39 + "safe.d.ts"
40 + ],
41 + "devDependencies": {
42 + "eslint": "^5.2.0",
43 + "eslint-config-google": "^0.11.0"
44 + }
45 +}
1 +// Type definitions for Colors.js 1.2
2 +// Project: https://github.com/Marak/colors.js
3 +// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
4 +// Definitions: https://github.com/Marak/colors.js
5 +
6 +export const enabled: boolean;
7 +export function enable(): void;
8 +export function disable(): void;
9 +export function setTheme(theme: any): void;
10 +
11 +export function strip(str: string): string;
12 +export function stripColors(str: string): string;
13 +
14 +export function black(str: string): string;
15 +export function red(str: string): string;
16 +export function green(str: string): string;
17 +export function yellow(str: string): string;
18 +export function blue(str: string): string;
19 +export function magenta(str: string): string;
20 +export function cyan(str: string): string;
21 +export function white(str: string): string;
22 +export function gray(str: string): string;
23 +export function grey(str: string): string;
24 +
25 +export function bgBlack(str: string): string;
26 +export function bgRed(str: string): string;
27 +export function bgGreen(str: string): string;
28 +export function bgYellow(str: string): string;
29 +export function bgBlue(str: string): string;
30 +export function bgMagenta(str: string): string;
31 +export function bgCyan(str: string): string;
32 +export function bgWhite(str: string): string;
33 +
34 +export function reset(str: string): string;
35 +export function bold(str: string): string;
36 +export function dim(str: string): string;
37 +export function italic(str: string): string;
38 +export function underline(str: string): string;
39 +export function inverse(str: string): string;
40 +export function hidden(str: string): string;
41 +export function strikethrough(str: string): string;
42 +
43 +export function rainbow(str: string): string;
44 +export function zebra(str: string): string;
45 +export function america(str: string): string;
46 +export function trap(str: string): string;
47 +export function random(str: string): string;
48 +export function zalgo(str: string): string;
1 +//
2 +// Remark: Requiring this file will use the "safe" colors API,
3 +// which will not touch String.prototype.
4 +//
5 +// var colors = require('colors/safe');
6 +// colors.red("foo")
7 +//
8 +//
9 +var colors = require('./lib/colors');
10 +module['exports'] = colors;
1 +module['exports'] = {
2 + silly: 'rainbow',
3 + input: 'grey',
4 + verbose: 'cyan',
5 + prompt: 'grey',
6 + info: 'green',
7 + data: 'grey',
8 + help: 'cyan',
9 + warn: 'yellow',
10 + debug: 'blue',
11 + error: 'red',
12 +};
1 +language: node_js
2 +node_js:
3 + - 4
4 + - 5
5 + - 6
6 +sudo: false
7 +
8 +
1 +Apache License, Version 2.0
2 +
3 +Copyright (c) 2011 Dominic Tarr
4 +
5 +Licensed under the Apache License, Version 2.0 (the "License");
6 +you may not use this file except in compliance with the License.
7 +You may obtain a copy of the License at
8 +
9 + http://www.apache.org/licenses/LICENSE-2.0
10 +
11 +Unless required by applicable law or agreed to in writing, software
12 +distributed under the License is distributed on an "AS IS" BASIS,
13 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 +See the License for the specific language governing permissions and
15 +limitations under the License.
1 +The MIT License
2 +
3 +Copyright (c) 2011 Dominic Tarr
4 +
5 +Permission is hereby granted, free of charge,
6 +to any person obtaining a copy of this software and
7 +associated documentation files (the "Software"), to
8 +deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify,
10 +merge, publish, distribute, sublicense, and/or sell
11 +copies of the Software, and to permit persons to whom
12 +the Software is furnished to do so,
13 +subject to the following conditions:
14 +
15 +The above copyright notice and this permission notice
16 +shall be included in all copies or substantial portions of the Software.
17 +
18 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +#! /usr/bin/env node
2 +
3 +var JSONStream = require('./')
4 +
5 +if(!module.parent && process.title !== 'browser') {
6 + process.stdin
7 + .pipe(JSONStream.parse(process.argv[2]))
8 + .pipe(JSONStream.stringify('[', ',\n', ']\n', 2))
9 + .pipe(process.stdout)
10 +}
11 +
12 +
1 +var request = require('request')
2 + , JSONStream = require('JSONStream')
3 + , es = require('event-stream')
4 +
5 +var parser = JSONStream.parse(['rows', true]) //emit parts that match this path (any element of the rows array)
6 + , req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
7 + , logger = es.mapSync(function (data) { //create a stream that logs to stderr,
8 + console.error(data)
9 + return data
10 + })
11 +
12 +req.pipe(parser)
13 +parser.pipe(logger)
1 +'use strict'
2 +
3 +var Parser = require('jsonparse')
4 + , through = require('through')
5 +
6 +var bufferFrom = Buffer.from && Buffer.from !== Uint8Array.from
7 +
8 +/*
9 +
10 + the value of this.stack that creationix's jsonparse has is weird.
11 +
12 + it makes this code ugly, but his problem is way harder that mine,
13 + so i'll forgive him.
14 +
15 +*/
16 +
17 +exports.parse = function (path, map) {
18 + var header, footer
19 + var parser = new Parser()
20 + var stream = through(function (chunk) {
21 + if('string' === typeof chunk)
22 + chunk = bufferFrom ? Buffer.from(chunk) : new Buffer(chunk)
23 + parser.write(chunk)
24 + },
25 + function (data) {
26 + if(data)
27 + stream.write(data)
28 + if (header)
29 + stream.emit('header', header)
30 + if (footer)
31 + stream.emit('footer', footer)
32 + stream.queue(null)
33 + })
34 +
35 + if('string' === typeof path)
36 + path = path.split('.').map(function (e) {
37 + if (e === '$*')
38 + return {emitKey: true}
39 + else if (e === '*')
40 + return true
41 + else if (e === '') // '..'.split('.') returns an empty string
42 + return {recurse: true}
43 + else
44 + return e
45 + })
46 +
47 +
48 + var count = 0, _key
49 + if(!path || !path.length)
50 + path = null
51 +
52 + parser.onValue = function (value) {
53 + if (!this.root)
54 + stream.root = value
55 +
56 + if(! path) return
57 +
58 + var i = 0 // iterates on path
59 + var j = 0 // iterates on stack
60 + var emitKey = false;
61 + var emitPath = false;
62 + while (i < path.length) {
63 + var key = path[i]
64 + var c
65 + j++
66 +
67 + if (key && !key.recurse) {
68 + c = (j === this.stack.length) ? this : this.stack[j]
69 + if (!c) return
70 + if (! check(key, c.key)) {
71 + setHeaderFooter(c.key, value)
72 + return
73 + }
74 + emitKey = !!key.emitKey;
75 + emitPath = !!key.emitPath;
76 + i++
77 + } else {
78 + i++
79 + var nextKey = path[i]
80 + if (! nextKey) return
81 + while (true) {
82 + c = (j === this.stack.length) ? this : this.stack[j]
83 + if (!c) return
84 + if (check(nextKey, c.key)) {
85 + i++;
86 + if (!Object.isFrozen(this.stack[j]))
87 + this.stack[j].value = null
88 + break
89 + } else {
90 + setHeaderFooter(c.key, value)
91 + }
92 + j++
93 + }
94 + }
95 +
96 + }
97 +
98 + // emit header
99 + if (header) {
100 + stream.emit('header', header);
101 + header = false;
102 + }
103 + if (j !== this.stack.length) return
104 +
105 + count ++
106 + var actualPath = this.stack.slice(1).map(function(element) { return element.key }).concat([this.key])
107 + var data = value
108 + if(null != data)
109 + if(null != (data = map ? map(data, actualPath) : data)) {
110 + if (emitKey || emitPath) {
111 + data = { value: data };
112 + if (emitKey)
113 + data["key"] = this.key;
114 + if (emitPath)
115 + data["path"] = actualPath;
116 + }
117 +
118 + stream.queue(data)
119 + }
120 + if (this.value) delete this.value[this.key]
121 + for(var k in this.stack)
122 + if (!Object.isFrozen(this.stack[k]))
123 + this.stack[k].value = null
124 + }
125 + parser._onToken = parser.onToken;
126 +
127 + parser.onToken = function (token, value) {
128 + parser._onToken(token, value);
129 + if (this.stack.length === 0) {
130 + if (stream.root) {
131 + if(!path)
132 + stream.queue(stream.root)
133 + count = 0;
134 + stream.root = null;
135 + }
136 + }
137 + }
138 +
139 + parser.onError = function (err) {
140 + if(err.message.indexOf("at position") > -1)
141 + err.message = "Invalid JSON (" + err.message + ")";
142 + stream.emit('error', err)
143 + }
144 +
145 + return stream
146 +
147 + function setHeaderFooter(key, value) {
148 + // header has not been emitted yet
149 + if (header !== false) {
150 + header = header || {}
151 + header[key] = value
152 + }
153 +
154 + // footer has not been emitted yet but header has
155 + if (footer !== false && header === false) {
156 + footer = footer || {}
157 + footer[key] = value
158 + }
159 + }
160 +}
161 +
162 +function check (x, y) {
163 + if ('string' === typeof x)
164 + return y == x
165 + else if (x && 'function' === typeof x.exec)
166 + return x.exec(y)
167 + else if ('boolean' === typeof x || 'object' === typeof x)
168 + return x
169 + else if ('function' === typeof x)
170 + return x(y)
171 + return false
172 +}
173 +
174 +exports.stringify = function (op, sep, cl, indent) {
175 + indent = indent || 0
176 + if (op === false){
177 + op = ''
178 + sep = '\n'
179 + cl = ''
180 + } else if (op == null) {
181 +
182 + op = '[\n'
183 + sep = '\n,\n'
184 + cl = '\n]\n'
185 +
186 + }
187 +
188 + //else, what ever you like
189 +
190 + var stream
191 + , first = true
192 + , anyData = false
193 + stream = through(function (data) {
194 + anyData = true
195 + try {
196 + var json = JSON.stringify(data, null, indent)
197 + } catch (err) {
198 + return stream.emit('error', err)
199 + }
200 + if(first) { first = false ; stream.queue(op + json)}
201 + else stream.queue(sep + json)
202 + },
203 + function (data) {
204 + if(!anyData)
205 + stream.queue(op)
206 + stream.queue(cl)
207 + stream.queue(null)
208 + })
209 +
210 + return stream
211 +}
212 +
213 +exports.stringifyObject = function (op, sep, cl, indent) {
214 + indent = indent || 0
215 + if (op === false){
216 + op = ''
217 + sep = '\n'
218 + cl = ''
219 + } else if (op == null) {
220 +
221 + op = '{\n'
222 + sep = '\n,\n'
223 + cl = '\n}\n'
224 +
225 + }
226 +
227 + //else, what ever you like
228 +
229 + var first = true
230 + var anyData = false
231 + var stream = through(function (data) {
232 + anyData = true
233 + var json = JSON.stringify(data[0]) + ':' + JSON.stringify(data[1], null, indent)
234 + if(first) { first = false ; this.queue(op + json)}
235 + else this.queue(sep + json)
236 + },
237 + function (data) {
238 + if(!anyData) this.queue(op)
239 + this.queue(cl)
240 +
241 + this.queue(null)
242 + })
243 +
244 + return stream
245 +}
246 +
247 +
1 +{
2 + "name": "JSONStream",
3 + "version": "1.3.5",
4 + "description": "rawStream.pipe(JSONStream.parse()).pipe(streamOfObjects)",
5 + "homepage": "http://github.com/dominictarr/JSONStream",
6 + "repository": {
7 + "type": "git",
8 + "url": "git://github.com/dominictarr/JSONStream.git"
9 + },
10 + "license": "(MIT OR Apache-2.0)",
11 + "keywords": [
12 + "json",
13 + "stream",
14 + "streaming",
15 + "parser",
16 + "async",
17 + "parsing"
18 + ],
19 + "dependencies": {
20 + "jsonparse": "^1.2.0",
21 + "through": ">=2.2.7 <3"
22 + },
23 + "devDependencies": {
24 + "it-is": "~1",
25 + "assertions": "~2.2.2",
26 + "render": "~0.1.1",
27 + "trees": "~0.0.3",
28 + "event-stream": "~0.7.0",
29 + "tape": "~2.12.3"
30 + },
31 + "bin": "./bin.js",
32 + "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://bit.ly/dominictarr)",
33 + "scripts": {
34 + "test": "node test/run.js"
35 + },
36 + "optionalDependencies": {},
37 + "engines": {
38 + "node": "*"
39 + }
40 +}
1 +# JSONStream
2 +
3 +streaming JSON.parse and stringify
4 +
5 +![](https://secure.travis-ci.org/dominictarr/JSONStream.png?branch=master)
6 +
7 +## install
8 +```npm install JSONStream```
9 +
10 +## example
11 +
12 +``` js
13 +
14 +var request = require('request')
15 + , JSONStream = require('JSONStream')
16 + , es = require('event-stream')
17 +
18 +request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
19 + .pipe(JSONStream.parse('rows.*'))
20 + .pipe(es.mapSync(function (data) {
21 + console.error(data)
22 + return data
23 + }))
24 +```
25 +
26 +## JSONStream.parse(path)
27 +
28 +parse stream of values that match a path
29 +
30 +``` js
31 + JSONStream.parse('rows.*.doc')
32 +```
33 +
34 +The `..` operator is the recursive descent operator from [JSONPath](http://goessner.net/articles/JsonPath/), which will match a child at any depth (see examples below).
35 +
36 +If your keys have keys that include `.` or `*` etc, use an array instead.
37 +`['row', true, /^doc/]`.
38 +
39 +If you use an array, `RegExp`s, booleans, and/or functions. The `..` operator is also available in array representation, using `{recurse: true}`.
40 +any object that matches the path will be emitted as 'data' (and `pipe`d down stream)
41 +
42 +If `path` is empty or null, no 'data' events are emitted.
43 +
44 +If you want to have keys emitted, you can prefix your `*` operator with `$`: `obj.$*` - in this case the data passed to the stream is an object with a `key` holding the key and a `value` property holding the data.
45 +
46 +### Examples
47 +
48 +query a couchdb view:
49 +
50 +``` bash
51 +curl -sS localhost:5984/tests/_all_docs&include_docs=true
52 +```
53 +you will get something like this:
54 +
55 +``` js
56 +{"total_rows":129,"offset":0,"rows":[
57 + { "id":"change1_0.6995461115147918"
58 + , "key":"change1_0.6995461115147918"
59 + , "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"}
60 + , "doc":{
61 + "_id": "change1_0.6995461115147918"
62 + , "_rev": "1-e240bae28c7bb3667f02760f6398d508","hello":1}
63 + },
64 + { "id":"change2_0.6995461115147918"
65 + , "key":"change2_0.6995461115147918"
66 + , "value":{"rev":"1-13677d36b98c0c075145bb8975105153"}
67 + , "doc":{
68 + "_id":"change2_0.6995461115147918"
69 + , "_rev":"1-13677d36b98c0c075145bb8975105153"
70 + , "hello":2
71 + }
72 + },
73 +]}
74 +
75 +```
76 +
77 +we are probably most interested in the `rows.*.doc`
78 +
79 +create a `Stream` that parses the documents from the feed like this:
80 +
81 +``` js
82 +var stream = JSONStream.parse(['rows', true, 'doc']) //rows, ANYTHING, doc
83 +
84 +stream.on('data', function(data) {
85 + console.log('received:', data);
86 +});
87 +//emits anything from _before_ the first match
88 +stream.on('header', function (data) {
89 + console.log('header:', data) // => {"total_rows":129,"offset":0}
90 +})
91 +
92 +```
93 +awesome!
94 +
95 +In case you wanted the contents the doc emitted:
96 +
97 +``` js
98 +var stream = JSONStream.parse(['rows', true, 'doc', {emitKey: true}]) //rows, ANYTHING, doc, items in docs with keys
99 +
100 +stream.on('data', function(data) {
101 + console.log('key:', data.key);
102 + console.log('value:', data.value);
103 +});
104 +
105 +```
106 +
107 +You can also emit the path:
108 +
109 +``` js
110 +var stream = JSONStream.parse(['rows', true, 'doc', {emitPath: true}]) //rows, ANYTHING, doc, items in docs with keys
111 +
112 +stream.on('data', function(data) {
113 + console.log('path:', data.path);
114 + console.log('value:', data.value);
115 +});
116 +
117 +```
118 +
119 +### recursive patterns (..)
120 +
121 +`JSONStream.parse('docs..value')`
122 +(or `JSONStream.parse(['docs', {recurse: true}, 'value'])` using an array)
123 +will emit every `value` object that is a child, grand-child, etc. of the
124 +`docs` object. In this example, it will match exactly 5 times at various depth
125 +levels, emitting 0, 1, 2, 3 and 4 as results.
126 +
127 +```js
128 +{
129 + "total": 5,
130 + "docs": [
131 + {
132 + "key": {
133 + "value": 0,
134 + "some": "property"
135 + }
136 + },
137 + {"value": 1},
138 + {"value": 2},
139 + {"blbl": [{}, {"a":0, "b":1, "value":3}, 10]},
140 + {"value": 4}
141 + ]
142 +}
143 +```
144 +
145 +## JSONStream.parse(pattern, map)
146 +
147 +provide a function that can be used to map or filter
148 +the json output. `map` is passed the value at that node of the pattern,
149 +if `map` return non-nullish (anything but `null` or `undefined`)
150 +that value will be emitted in the stream. If it returns a nullish value,
151 +nothing will be emitted.
152 +
153 +`JSONStream` also emits `'header'` and `'footer'` events,
154 +the `'header'` event contains anything in the output that was before
155 +the first match, and the `'footer'`, is anything after the last match.
156 +
157 +## JSONStream.stringify(open, sep, close)
158 +
159 +Create a writable stream.
160 +
161 +you may pass in custom `open`, `close`, and `seperator` strings.
162 +But, by default, `JSONStream.stringify()` will create an array,
163 +(with default options `open='[\n', sep='\n,\n', close='\n]\n'`)
164 +
165 +If you call `JSONStream.stringify(false)`
166 +the elements will only be seperated by a newline.
167 +
168 +If you only write one item this will be valid JSON.
169 +
170 +If you write many items,
171 +you can use a `RegExp` to split it into valid chunks.
172 +
173 +## JSONStream.stringifyObject(open, sep, close)
174 +
175 +Very much like `JSONStream.stringify`,
176 +but creates a writable stream for objects instead of arrays.
177 +
178 +Accordingly, `open='{\n', sep='\n,\n', close='\n}\n'`.
179 +
180 +When you `.write()` to the stream you must supply an array with `[ key, data ]`
181 +as the first argument.
182 +
183 +## unix tool
184 +
185 +query npm to see all the modules that browserify has ever depended on.
186 +
187 +``` bash
188 +curl https://registry.npmjs.org/browserify | JSONStream 'versions.*.dependencies'
189 +```
190 +
191 +## numbers
192 +
193 +numbers will be emitted as numbers.
194 +huge numbers that cannot be represented in memory as javascript numbers will be emitted as strings.
195 +cf https://github.com/creationix/jsonparse/commit/044b268f01c4b8f97fb936fc85d3bcfba179e5bb for details.
196 +
197 +## Acknowlegements
198 +
199 +this module depends on https://github.com/creationix/jsonparse
200 +by Tim Caswell
201 +and also thanks to Florent Jaby for teaching me about parsing with:
202 +https://github.com/Floby/node-json-streams
203 +
204 +## license
205 +
206 +Dual-licensed under the MIT License or the Apache License, version 2.0
207 +
1 +
2 +var fs = require ('fs')
3 + , join = require('path').join
4 + , file = join(__dirname, 'fixtures','all_npm.json')
5 + , JSONStream = require('../')
6 + , it = require('it-is').style('colour')
7 +
8 + function randomObj () {
9 + return (
10 + Math.random () < 0.4
11 + ? {hello: 'eonuhckmqjk',
12 + whatever: 236515,
13 + lies: true,
14 + nothing: [null],
15 +// stuff: [Math.random(),Math.random(),Math.random()]
16 + }
17 + : ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]]
18 + )
19 + }
20 +
21 +var expected = []
22 + , stringify = JSONStream.stringify()
23 + , es = require('event-stream')
24 + , stringified = ''
25 + , called = 0
26 + , count = 10
27 + , ended = false
28 +
29 +while (count --)
30 + expected.push(randomObj())
31 +
32 + es.connect(
33 + es.readArray(expected),
34 + stringify,
35 + JSONStream.parse([true]),
36 + es.writeArray(function (err, lines) {
37 +
38 + it(lines).has(expected)
39 + console.error('PASSED')
40 + })
41 + )
1 +var test = require('tape')
2 +var JSONStream = require('../')
3 +var testData = '{"rows":[{"hello":"world"}, {"foo": "bar"}]}'
4 +
5 +test('basic parsing', function (t) {
6 + t.plan(2)
7 + var parsed = JSONStream.parse("rows.*")
8 + var parsedKeys = {}
9 + parsed.on('data', function(match) {
10 + parsedKeys[Object.keys(match)[0]] = true
11 + })
12 + parsed.on('end', function() {
13 + t.equal(!!parsedKeys['hello'], true)
14 + t.equal(!!parsedKeys['foo'], true)
15 + })
16 + parsed.write(testData)
17 + parsed.end()
18 +})
...\ No newline at end of file ...\ No newline at end of file
1 +var fs = require ('fs');
2 +var net = require('net');
3 +var join = require('path').join;
4 +var file = join(__dirname, 'fixtures','all_npm.json');
5 +var JSONStream = require('../');
6 +
7 +
8 +var server = net.createServer(function(client) {
9 + var parser = JSONStream.parse([]);
10 + parser.on('end', function() {
11 + console.log('close')
12 + console.error('PASSED');
13 + server.close();
14 + });
15 + client.pipe(parser);
16 + var n = 4
17 + client.on('data', function () {
18 + if(--n) return
19 + client.end();
20 + })
21 +});
22 +server.listen(9999);
23 +
24 +
25 +var client = net.connect({ port : 9999 }, function() {
26 + fs.createReadStream(file).pipe(client).on('data', console.log) //.resume();
27 +});
1 +var fs = require ('fs')
2 + , join = require('path').join
3 + , file = join(__dirname, 'fixtures','all_npm.json')
4 + , JSONStream = require('../')
5 + , it = require('it-is')
6 +
7 +var expected = JSON.parse(fs.readFileSync(file))
8 + , parser = JSONStream.parse('rows..rev')
9 + , called = 0
10 + , ended = false
11 + , parsed = []
12 +
13 +fs.createReadStream(file).pipe(parser)
14 +
15 +parser.on('data', function (data) {
16 + called ++
17 + parsed.push(data)
18 +})
19 +
20 +parser.on('end', function () {
21 + ended = true
22 +})
23 +
24 +process.on('exit', function () {
25 + it(called).equal(expected.rows.length)
26 + for (var i = 0 ; i < expected.rows.length ; i++)
27 + it(parsed[i]).deepEqual(expected.rows[i].value.rev)
28 + console.error('PASSED')
29 +})
1 + var fs = require ('fs')
2 + , join = require('path').join
3 + , file = join(__dirname, 'fixtures','depth.json')
4 + , JSONStream = require('../')
5 + , it = require('it-is')
6 +
7 + var expected = JSON.parse(fs.readFileSync(file))
8 + , parser = JSONStream.parse(['docs', {recurse: true}, 'value'])
9 + , called = 0
10 + , ended = false
11 + , parsed = []
12 +
13 + fs.createReadStream(file).pipe(parser)
14 +
15 + parser.on('data', function (data) {
16 + called ++
17 + parsed.push(data)
18 + })
19 +
20 + parser.on('end', function () {
21 + ended = true
22 + })
23 +
24 + process.on('exit', function () {
25 + var expectedValues = [0, [1], {"a": 2}, "3", 4]
26 + it(called).equal(expectedValues.length)
27 + for (var i = 0 ; i < 5 ; i++)
28 + it(parsed[i]).deepEqual(expectedValues[i])
29 + console.error('PASSED')
30 + })
1 +var JSONStream = require('../')
2 + , stream = require('stream')
3 + , it = require('it-is')
4 +
5 +var output = [ [], [] ]
6 +
7 +var parser1 = JSONStream.parse(['docs', /./])
8 +parser1.on('data', function(data) {
9 + output[0].push(data)
10 +})
11 +
12 +var parser2 = JSONStream.parse(['docs', /./])
13 +parser2.on('data', function(data) {
14 + output[1].push(data)
15 +})
16 +
17 +var pending = 2
18 +function onend () {
19 + if (--pending > 0) return
20 + it(output).deepEqual([
21 + [], [{hello: 'world'}]
22 + ])
23 + console.error('PASSED')
24 +}
25 +parser1.on('end', onend)
26 +parser2.on('end', onend)
27 +
28 +function makeReadableStream() {
29 + var readStream = new stream.Stream()
30 + readStream.readable = true
31 + readStream.write = function (data) { this.emit('data', data) }
32 + readStream.end = function (data) { this.emit('end') }
33 + return readStream
34 +}
35 +
36 +var emptyArray = makeReadableStream()
37 +emptyArray.pipe(parser1)
38 +emptyArray.write('{"docs":[]}')
39 +emptyArray.end()
40 +
41 +var objectArray = makeReadableStream()
42 +objectArray.pipe(parser2)
43 +objectArray.write('{"docs":[{"hello":"world"}]}')
44 +objectArray.end()
1 +
2 +
3 +var fs = require ('fs')
4 + , join = require('path').join
5 + , file = join(__dirname, 'fixtures','error.json')
6 + , JSONStream = require('../')
7 + , it = require('it-is')
8 +
9 +var expected = JSON.parse(fs.readFileSync(file))
10 + , parser = JSONStream.parse(['rows'])
11 + , called = 0
12 + , headerCalled = 0
13 + , footerCalled = 0
14 + , ended = false
15 + , parsed = []
16 +
17 +fs.createReadStream(file).pipe(parser)
18 +
19 +parser.on('header', function (data) {
20 + headerCalled ++
21 + it(data).deepEqual({
22 + error: 'error_code',
23 + message: 'this is an error message'
24 + })
25 +})
26 +
27 +parser.on('footer', function (data) {
28 + footerCalled ++
29 +})
30 +
31 +parser.on('data', function (data) {
32 + called ++
33 + parsed.push(data)
34 +})
35 +
36 +parser.on('end', function () {
37 + ended = true
38 +})
39 +
40 +process.on('exit', function () {
41 + it(called).equal(0)
42 + it(headerCalled).equal(1)
43 + it(footerCalled).equal(0)
44 + console.error('PASSED')
45 +})
This diff could not be displayed because it is too large.
1 +{"total_rows":129,"offset":0,"rows":[
2 + { "id":"change1_0.6995461115147918"
3 + , "key":"change1_0.6995461115147918"
4 + , "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"}
5 + , "doc":{
6 + "_id": "change1_0.6995461115147918"
7 + , "_rev": "1-e240bae28c7bb3667f02760f6398d508","hello":1}
8 + },
9 + { "id":"change2_0.6995461115147918"
10 + , "key":"change2_0.6995461115147918"
11 + , "value":{"rev":"1-13677d36b98c0c075145bb8975105153"}
12 + , "doc":{
13 + "_id":"change2_0.6995461115147918"
14 + , "_rev":"1-13677d36b98c0c075145bb8975105153"
15 + , "hello":2
16 + }
17 + },
18 +]}
1 +{
2 + "total": 5,
3 + "docs": [
4 + {
5 + "key": {
6 + "value": 0,
7 + "some": "property"
8 + }
9 + },
10 + {"value": [1]},
11 + {"value": {"a":2}},
12 + {"blbl": [{}, {"a":0, "b":1, "value":"3"}, 10]},
13 + {"value": 4}
14 + ]
15 +}
1 +{"error": "error_code", "message": "this is an error message"}
1 +{"total_rows":129,"offset":0,"rows":[
2 + { "id":"change1_0.6995461115147918"
3 + , "key":"change1_0.6995461115147918"
4 + , "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"}
5 + , "doc":{
6 + "_id": "change1_0.6995461115147918"
7 + , "_rev": "1-e240bae28c7bb3667f02760f6398d508","hello":1}
8 + },
9 + { "id":"change2_0.6995461115147918"
10 + , "key":"change2_0.6995461115147918"
11 + , "value":{"rev":"1-13677d36b98c0c075145bb8975105153"}
12 + , "doc":{
13 + "_id":"change2_0.6995461115147918"
14 + , "_rev":"1-13677d36b98c0c075145bb8975105153"
15 + , "hello":2
16 + }
17 + }
18 +],
19 +"foo": {"bar": "baz"}}
1 +
2 +
3 +var fs = require ('fs')
4 + , join = require('path').join
5 + , file = join(__dirname, 'fixtures','all_npm.json')
6 + , JSONStream = require('../')
7 + , it = require('it-is')
8 +
9 +function fn (s) {
10 + return !isNaN(parseInt(s, 10))
11 +}
12 +
13 +var expected = JSON.parse(fs.readFileSync(file))
14 + , parser = JSONStream.parse(['rows', fn])
15 + , called = 0
16 + , ended = false
17 + , parsed = []
18 +
19 +fs.createReadStream(file).pipe(parser)
20 +
21 +parser.on('data', function (data) {
22 + called ++
23 + it.has({
24 + id: it.typeof('string'),
25 + value: {rev: it.typeof('string')},
26 + key:it.typeof('string')
27 + })
28 + parsed.push(data)
29 +})
30 +
31 +parser.on('end', function () {
32 + ended = true
33 +})
34 +
35 +process.on('exit', function () {
36 + it(called).equal(expected.rows.length)
37 + it(parsed).deepEqual(expected.rows)
38 + console.error('PASSED')
39 +})
1 +return // dont run this test for now since tape is weird and broken on 0.10
2 +
3 +var fs = require('fs')
4 +var JSONStream = require('../')
5 +var file = process.argv[2] || '/tmp/JSONStream-test-large.json'
6 +var size = Number(process.argv[3] || 100000)
7 +var tape = require('tape')
8 +// if (process.title !== 'browser') {
9 + tape('out of mem', function (t) {
10 + t.plan(1)
11 + //////////////////////////////////////////////////////
12 + // Produces a random number between arg1 and arg2
13 + //////////////////////////////////////////////////////
14 + var randomNumber = function (min, max) {
15 + var number = Math.floor(Math.random() * (max - min + 1) + min);
16 + return number;
17 + };
18 +
19 + //////////////////////////////////////////////////////
20 + // Produces a random string of a length between arg1 and arg2
21 + //////////////////////////////////////////////////////
22 + var randomString = function (min, max) {
23 +
24 + // add several spaces to increase chanses of creating 'words'
25 + var chars = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
26 + var result = '';
27 +
28 + var randomLength = randomNumber(min, max);
29 +
30 + for (var i = randomLength; i > 0; --i) {
31 + result += chars[Math.round(Math.random() * (chars.length - 1))];
32 + }
33 + return result;
34 + };
35 +
36 + //////////////////////////////////////////////////////
37 + // Produces a random JSON document, as a string
38 + //////////////////////////////////////////////////////
39 + var randomJsonDoc = function () {
40 +
41 + var doc = {
42 + "CrashOccurenceID": randomNumber(10000, 50000),
43 + "CrashID": randomNumber(1000, 10000),
44 + "SiteName": randomString(10, 25),
45 + "MachineName": randomString(10, 25),
46 + "Date": randomString(26, 26),
47 + "ProcessDuration": randomString(18, 18),
48 + "ThreadIdentityName": null,
49 + "WindowsIdentityName": randomString(15, 40),
50 + "OperatingSystemName": randomString(35, 65),
51 + "DetailedExceptionInformation": randomString(100, 800)
52 + };
53 +
54 + doc = JSON.stringify(doc);
55 + doc = doc.replace(/\,/g, ',\n'); // add new lines after each attribute
56 + return doc;
57 + };
58 +
59 + //////////////////////////////////////////////////////
60 + // generates test data
61 + //////////////////////////////////////////////////////
62 + var generateTestData = function (cb) {
63 +
64 + console.log('generating large data file...');
65 +
66 + var stream = fs.createWriteStream(file, {
67 + encoding: 'utf8'
68 + });
69 +
70 + var i = 0;
71 + var max = size;
72 + var writing = false
73 + var split = ',\n';
74 + var doc = randomJsonDoc();
75 + stream.write('[');
76 +
77 + function write () {
78 + if(writing) return
79 + writing = true
80 + while(++i < max) {
81 + if(Math.random() < 0.001)
82 + console.log('generate..', i + ' / ' + size)
83 + if(!stream.write(doc + split)) {
84 + writing = false
85 + return stream.once('drain', write)
86 + }
87 + }
88 + stream.write(doc + ']')
89 + stream.end();
90 + console.log('END')
91 + }
92 + write()
93 + stream.on('close', cb)
94 + };
95 +
96 + //////////////////////////////////////////////////////
97 + // Shows that parsing 100000 instances using JSONStream fails
98 + //
99 + // After several seconds, you will get this crash
100 + // FATAL ERROR: JS Allocation failed - process out of memory
101 + //////////////////////////////////////////////////////
102 + var testJSONStreamParse_causesOutOfMem = function (done) {
103 + var items = 0
104 + console.log('parsing data files using JSONStream...');
105 +
106 + var parser = JSONStream.parse([true]);
107 + var stream = fs.createReadStream(file);
108 + stream.pipe(parser);
109 +
110 + parser.on('data', function (data) {
111 + items++
112 + if(Math.random() < 0.01) console.log(items, '...')
113 + });
114 +
115 + parser.on('end', function () {
116 + t.equal(items, size)
117 + });
118 +
119 + };
120 +
121 + //////////////////////////////////////////////////////
122 + // main
123 + //////////////////////////////////////////////////////
124 +
125 + fs.stat(file, function (err, stat) {
126 + console.log(stat)
127 + if(err)
128 + generateTestData(testJSONStreamParse_causesOutOfMem);
129 + else
130 + testJSONStreamParse_causesOutOfMem()
131 + })
132 +
133 + })
134 +
135 +// }
1 +
2 +
3 +var fs = require ('fs')
4 + , join = require('path').join
5 + , file = join(__dirname, 'fixtures','header_footer.json')
6 + , JSONStream = require('../')
7 + , it = require('it-is')
8 +
9 +var expected = JSON.parse(fs.readFileSync(file))
10 + , parser = JSONStream.parse(['rows', /\d+/ /*, 'value'*/])
11 + , called = 0
12 + , headerCalled = 0
13 + , footerCalled = 0
14 + , ended = false
15 + , parsed = []
16 +
17 +fs.createReadStream(file).pipe(parser)
18 +
19 +parser.on('header', function (data) {
20 + headerCalled ++
21 + it(data).deepEqual({
22 + total_rows: 129,
23 + offset: 0
24 + })
25 +})
26 +
27 +parser.on('footer', function (data) {
28 + footerCalled ++
29 + it(data).deepEqual({
30 + foo: { bar: 'baz' }
31 + })
32 +})
33 +
34 +parser.on('data', function (data) {
35 + called ++
36 + it.has({
37 + id: it.typeof('string'),
38 + value: {rev: it.typeof('string')},
39 + key:it.typeof('string')
40 + })
41 + it(headerCalled).equal(1)
42 + parsed.push(data)
43 +})
44 +
45 +parser.on('end', function () {
46 + ended = true
47 +})
48 +
49 +process.on('exit', function () {
50 + it(called).equal(expected.rows.length)
51 + it(headerCalled).equal(1)
52 + it(footerCalled).equal(1)
53 + it(parsed).deepEqual(expected.rows)
54 + console.error('PASSED')
55 +})
1 +var JSONStream = require('../');
2 +var test = require('tape')
3 +
4 +test('#66', function (t) {
5 + var error = 0;
6 + var stream = JSONStream
7 + .parse()
8 + .on('error', function (err) {
9 + t.ok(err);
10 + error++;
11 + })
12 + .on('end', function () {
13 + t.ok(error === 1);
14 + t.end();
15 + });
16 +
17 + stream.write('["foo":bar[');
18 + stream.end();
19 +
20 +});
21 +
22 +test('#81 - failure to parse nested objects', function (t) {
23 + var stream = JSONStream
24 + .parse('.bar.foo')
25 + .on('error', function (err) {
26 + t.error(err);
27 + })
28 + .on('end', function () {
29 + t.end();
30 + });
31 +
32 + stream.write('{"bar":{"foo":"baz"}}');
33 + stream.end();
34 +});
1 +var test = require('tape');
2 +var fs = require ('fs');
3 +var join = require('path').join;
4 +var couch_sample_file = join(__dirname, 'fixtures','couch_sample.json');
5 +var JSONStream = require('../');
6 +
7 +var fixture = {
8 + obj: {
9 + one: 1,
10 + two: 2,
11 + three: 3
12 + }
13 +};
14 +
15 +function assertFixtureKeys(stream, t) {
16 + var keys = [];
17 + var values = [];
18 + stream.on('data', function(data) {
19 + keys.push(data.key);
20 + values.push(data.value);
21 + });
22 +
23 + stream.on('end', function() {
24 + t.deepEqual(keys, ['one', 'two', 'three']);
25 + t.deepEqual(values, [1,2,3]);
26 + t.end();
27 + });
28 + stream.write(JSON.stringify(fixture));
29 + stream.end();
30 +}
31 +
32 +test('keys via string', function(t) {
33 + var stream = JSONStream.parse('obj.$*');
34 + assertFixtureKeys(stream, t);
35 +});
36 +
37 +test('keys via array', function(t) {
38 + var stream = JSONStream.parse(['obj',{emitKey: true}]);
39 + assertFixtureKeys(stream, t);
40 +});
41 +
42 +test('path via array', function(t) {
43 + var stream = JSONStream.parse(['obj',{emitPath: true}]);
44 +
45 + var paths = [];
46 + var values = [];
47 + stream.on('data', function(data) {
48 + console.log(JSON.stringify(data));
49 + paths.push(data.path);
50 + values.push(data.value);
51 + });
52 +
53 + stream.on('end', function() {
54 + t.deepEqual(paths, [['obj', 'one'], ['obj', 'two'], ['obj', 'three']]);
55 + t.deepEqual(values, [1,2,3]);
56 + t.end();
57 + });
58 + stream.write(JSON.stringify(fixture));
59 + stream.end();
60 +});
61 +
62 +test('advanced keys', function(t) {
63 + var advanced = fs.readFileSync(couch_sample_file);
64 + var stream = JSONStream.parse(['rows', true, 'doc', {emitKey: true}]);
65 +
66 + var keys = [];
67 + var values = [];
68 + stream.on('data', function(data) {
69 + keys.push(data.key);
70 + values.push(data.value);
71 + });
72 +
73 + stream.on('end', function() {
74 + t.deepEqual(keys, [
75 + '_id', '_rev', 'hello',
76 + '_id', '_rev', 'hello'
77 + ]);
78 + t.deepEqual(values, [
79 + "change1_0.6995461115147918", "1-e240bae28c7bb3667f02760f6398d508", 1,
80 + "change2_0.6995461115147918", "1-13677d36b98c0c075145bb8975105153", 2
81 + ]);
82 + t.end();
83 + });
84 + stream.write(advanced);
85 + stream.end();
86 +});
87 +
88 +test('parent keys', function(t) {
89 + var stream = JSONStream.parse('$*');
90 + var d = null;
91 + stream.on('data', function(data) {
92 + if(d) t.fail('should only be called once');
93 + d = data;
94 + });
95 +
96 + stream.on('end', function() {
97 + t.deepEqual(d,{
98 + key: 'obj',
99 + value: fixture.obj
100 + });
101 + t.end();
102 + });
103 + stream.write(JSON.stringify(fixture));
104 + stream.end();
105 +})
1 +
2 +var test = require('tape')
3 +
4 +var JSONStream = require('../')
5 +
6 +test('map function', function (t) {
7 +
8 + var actual = []
9 +
10 + stream = JSONStream.parse([true], function (e) { return e*10 })
11 + stream.on('data', function (v) { actual.push(v)})
12 + stream.on('end', function () {
13 + t.deepEqual(actual, [10,20,30,40,50,60])
14 + t.end()
15 +
16 + })
17 +
18 + stream.write(JSON.stringify([1,2,3,4,5,6], null, 2))
19 + stream.end()
20 +
21 +})
22 +
23 +test('filter function', function (t) {
24 +
25 + var actual = []
26 +
27 + stream = JSONStream
28 + .parse([true], function (e) { return e%2 ? e : null})
29 + .on('data', function (v) { actual.push(v)})
30 + .on('end', function () {
31 + t.deepEqual(actual, [1,3,5])
32 + t.end()
33 +
34 + })
35 +
36 + stream.write(JSON.stringify([1,2,3,4,5,6], null, 2))
37 + stream.end()
38 +
39 +})
40 +
1 +var fs = require ('fs');
2 +var net = require('net');
3 +var join = require('path').join;
4 +var file = join(__dirname, 'fixtures','all_npm.json');
5 +var it = require('it-is');
6 +var JSONStream = require('../');
7 +
8 +var str = fs.readFileSync(file);
9 +
10 +var datas = {}
11 +
12 +var server = net.createServer(function(client) {
13 + var data_calls = 0;
14 + var parser = JSONStream.parse(['rows', true, 'key']);
15 + parser.on('data', function(data) {
16 + ++ data_calls;
17 + datas[data] = (datas[data] || 0) + 1
18 + it(data).typeof('string')
19 + });
20 +
21 + parser.on('end', function() {
22 + console.log('END')
23 + var min = Infinity
24 + for (var d in datas)
25 + min = min > datas[d] ? datas[d] : min
26 + it(min).equal(3);
27 + server.close();
28 + });
29 + client.pipe(parser);
30 +});
31 +server.listen(9999);
32 +
33 +var client = net.connect({ port : 9999 }, function() {
34 + var msgs = str + ' ' + str + '\n\n' + str
35 + client.end(msgs);
36 +});
1 +var fs = require ('fs');
2 +var net = require('net');
3 +var join = require('path').join;
4 +var file = join(__dirname, 'fixtures','all_npm.json');
5 +var it = require('it-is');
6 +var JSONStream = require('../');
7 +
8 +var str = fs.readFileSync(file);
9 +
10 +var server = net.createServer(function(client) {
11 + var data_calls = 0;
12 + var parser = JSONStream.parse();
13 + parser.on('error', function(err) {
14 + console.log(err);
15 + server.close();
16 + });
17 +
18 + parser.on('end', function() {
19 + console.log('END');
20 + server.close();
21 + });
22 + client.pipe(parser);
23 +});
24 +server.listen(9999);
25 +
26 +var client = net.connect({ port : 9999 }, function() {
27 + var msgs = str + '}';
28 + client.end(msgs);
29 +});
1 +var JSONStream = require('../')
2 +
3 +var data = [
4 + {ID: 1, optional: null},
5 + {ID: 2, optional: null},
6 + {ID: 3, optional: 20},
7 + {ID: 4, optional: null},
8 + {ID: 5, optional: 'hello'},
9 + {ID: 6, optional: null}
10 +]
11 +
12 +
13 +var test = require('tape')
14 +
15 +test ('null properties', function (t) {
16 + var actual = []
17 + var stream =
18 +
19 + JSONStream.parse('*.optional')
20 + .on('data', function (v) { actual.push(v) })
21 + .on('end', function () {
22 + t.deepEqual(actual, [20, 'hello'])
23 + t.end()
24 + })
25 +
26 + stream.write(JSON.stringify(data, null, 2))
27 + stream.end()
28 +})
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.