ansi-to-react
Advanced tools
Comparing version 0.0.0 to 0.0.1
42
index.js
@@ -1,1 +0,41 @@ | ||
console.log('soon'); | ||
const React = require('react'); | ||
const ansiToJSON = require('ansi-to-json'); | ||
function ansiJSONtoStyleBundle(ansiBundle) { | ||
const style = {}; | ||
if (ansiBundle.bg) { | ||
style.backgroundColor = `rgb(${ansiBundle.bg})`; | ||
} | ||
if (ansiBundle.fg) { | ||
style.color = `rgb(${ansiBundle.fg})`; | ||
} | ||
return { | ||
content: ansiBundle.content, | ||
style, | ||
}; | ||
} | ||
function ansiToInlineStyle(text) { | ||
return ansiToJSON(text).map(ansiJSONtoStyleBundle); | ||
} | ||
function inlineBundleToReact(bundle, key) { | ||
return React.createElement('span', { | ||
style: bundle.style, | ||
key, | ||
}, bundle.content); | ||
} | ||
function Ansi(props) { | ||
return React.createElement( | ||
'code', | ||
{}, | ||
ansiToInlineStyle(props.children).map(inlineBundleToReact)); | ||
} | ||
Ansi.propTypes = { | ||
children: React.PropTypes.string, | ||
}; | ||
module.exports = Ansi; |
{ | ||
"name": "ansi-to-react", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "ANSI to React Elements", | ||
@@ -14,3 +14,6 @@ "main": "index.js", | ||
"author": "Kyle Kelley <rgbkrk@gmail.com>", | ||
"license": "BSD-3-Clause" | ||
"license": "MPL-2.0", | ||
"dependencies": { | ||
"ansi-to-json": "^1.0.0" | ||
} | ||
} |
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1706
3
34
0
1
2
70
+ Addedansi-to-json@^1.0.0
+ Addedanser@1.4.10(transitive)
+ Addedansi-to-json@1.0.15(transitive)