Installations
npm install anser
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
22.8.0
NPM Version
10.8.2
Score
99.9
Supply Chain
100
Quality
77.9
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
IonicaBizau
Download Statistics
Total Downloads
476,110,820
Last Day
466,280
Last Week
2,118,268
Last Month
9,638,359
Last Year
116,966,185
GitHub Statistics
68 Stars
215 Commits
18 Forks
4 Watching
1 Branches
22 Contributors
Bundle Size
6.85 kB
Minified
2.44 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.3.0
Package Id
anser@2.3.0
Unpacked Size
55.28 kB
Size
14.10 kB
File Count
5
NPM Version
10.8.2
Node Version
22.8.0
Publised On
26 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
476,110,820
Last day
-8.4%
466,280
Compared to previous day
Last week
-17.4%
2,118,268
Compared to previous week
Last month
4.7%
9,638,359
Compared to previous month
Last year
20.1%
116,966,185
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
anser
A low level parser for ANSI sequences.
:rocket: Features
- Converts text containing ANSI color escape codes into equivalent HTML elements.
- Allows converting the input into JSON output.
- HTML escaping
- Converts links into HTML elements
- Friendly APIs to use with virtual dom libraries
:cloud: Installation
1# Using npm 2npm install --save anser 3 4# Using yarn 5yarn add anser
:clipboard: Example
1const Anser = require("anser"); 2 3const txt = "\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m"; 4 5console.log(Anser.ansiToHtml(txt)); 6// <span style="color:rgb(255, 0, 0)">Hello</span> <span style="background-color:rgb(255, 255, 0)">World</span> 7 8console.log(Anser.ansiToHtml(txt, { use_classes: true })); 9// <span class="ansi-palette-196-fg">Hello</span> <span class="ansi-palette-226-bg">World</span> 10 11console.log(Anser.ansiToJson(txt)); 12// [ { content: '', 13// fg: null, 14// bg: null, 15// fg_truecolor: null, 16// bg_truecolor: null, 17// clearLine: undefined, 18// decoration: null, 19// was_processed: false, 20// isEmpty: [Function: isEmpty] }, 21// { content: 'Hello', 22// fg: '255, 0, 0', 23// bg: null, 24// fg_truecolor: null, 25// bg_truecolor: null, 26// clearLine: false, 27// decoration: null, 28// was_processed: true, 29// isEmpty: [Function: isEmpty] }, 30// { content: ' ', 31// fg: null, 32// bg: null, 33// fg_truecolor: null, 34// bg_truecolor: null, 35// clearLine: false, 36// decoration: null, 37// was_processed: false, 38// isEmpty: [Function: isEmpty] }, 39// { content: 'World', 40// fg: null, 41// bg: '255, 255, 0', 42// fg_truecolor: null, 43// bg_truecolor: null, 44// clearLine: false, 45// decoration: null, 46// was_processed: true, 47// isEmpty: [Function: isEmpty] }, 48// { content: '', 49// fg: null, 50// bg: null, 51// fg_truecolor: null, 52// bg_truecolor: null, 53// clearLine: false, 54// decoration: null, 55// was_processed: false, 56// isEmpty: [Function: isEmpty] } ]
When using TypeScript without --esModuleInterop enabled you can do the following:
1import Anser = require('anser'); 2const txt = "\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m"; 3console.log(Anser.ansiToHtml(txt)); 4// <span style="color:rgb(255, 0, 0)">Hello</span> <span style="background-color:rgb(255, 255, 0)">World</span>
Or with --esModuleInterop enabled you can do the following:
1import Anser from 'anser'; 2const txt = "\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m"; 3console.log(Anser.ansiToHtml(txt)); 4// <span style="color:rgb(255, 0, 0)">Hello</span> <span style="background-color:rgb(255, 255, 0)">World</span>
:question: Get Help
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. :bug:
- For direct and quick help, you can use Codementor. :rocket:
:memo: Documentation
Add several widely used style codes
processChunk(text, options, markup)
Processes the current chunk of text.
Params
- String
text
: The input text. - Object
options
: An object containing the following fields: json
(Boolean): Iftrue
, the result will be an object.use_classes
(Boolean): Iftrue
, HTML classes will be appended to the HTML output.- Boolean
markup
: If false, the colors will not be parsed.
Return
- Object|String The result (object if
json
is wanted back or string otherwise).
:yum: How to contribute
Have an idea? Found a bug? See how to contribute.
:sparkling_heart: Support my projects
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
-
Starring and sharing the projects you like :rocket:
-
—I love books! I will remember you after years if you buy me one. :grin: :book:
-
—You can make one-time donations via PayPal. I'll probably buy a
coffeetea. :tea: -
—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
-
Bitcoin—You can send me bitcoins at this address (or scanning the code below):
1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6
Thanks! :heart:
:cake: Thanks
This project is highly based on ansi_up
, by @drudru. Thanks! :cake:
:dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:
@_nomtek/react-native-shimmer-animation
@adatechnology/react-native-android-getnet-pos
@adembacaj/react-native-google-pay
@affinidi/affinidi-auth-sdk-kernel
@agbishop/react-ansi-18
@ajaykewat/myboilerplate
@ali5049/react-native-buttons
@alloc/react-error-overlay
@amirdiafi/react-native-ios-haptics
@apardellass/react-native-audio-stream
@ascorbic/gatsby
@assystant/firebase
@atom-ide-community/nuclide-commons-ui
@axio/react-dev-utils
@aysea/react-native-ui-library
@azalpacir/react-native-dhp-printer
@baloochat/react-native-svg-uri
@blkmarketco/components-library
@brantalikp/rn-resize
@callstack/react-native-visionos
@classflow/react-dev-utils
@classyllama/code-style
@cldcvr/flow-log
@cocalc/ansi-to-react
@codedown/ansi-to-react
@codesandbox/sandpack-react
@codewars/jest-reporter
@con-test/react-native-concent-common
@corelmax/react-native-my2c2p-sdk
@cs6/react-native-test-native-view-library
@cubejs-client/playground
@curvenote/ansi-to-react
@damian.lnc/core
@damruravihara/react-native-testing-package
@davidmccabe/sandpack-react
@deix/paganini-ui
@devpodio/console
@digibear/socket-bridge
@distasy/react-native-fix
@ehyland-org/react-error-overlay
@enkeledi/react-native-week-month-date-picker
@expensify/react-native
@felipesimmi/react-native-datalogic-module
@geeky-apo/react-native-advanced-clipboard
@glyw/react-native-tabbed-section-list
@hbglobal/react-native-actions-shortcuts
@hemith/react-native-tnk
@heora/cubejs-client-playground
@hitomeng/ide-debug-mod
@hjopel/react-native
@idas1/ui-component-lib
@jfilipe-sparta/react-native-module_2
@ko-developerhong/react-native-multiple-image-picker
@kui-shell/plugin-client-common
@labiebhn_/react-native-multiplier
@lehuyaa/my-assets
@leonchabbey/react-native-tvos
@navabi/react-native-ssl-pinning
@naze/error
@ndjoe/react-native-bluetooth-escpos-printer
@next/react-dev-overlay
@nonfx/flow-log
@npm_fluentco/adflow-react-native-sdk
@office-iss/react-native-win32
@oiti/rn-liveness2d
@ollion/flow-log
@openpolitica/matomo-next
@opensumi/ide-debug
@pandaninjas3017/react-native
@phong95/react-native-multiple-image-picker
@plansys/react-dev-utils
@popbot/react-native-macos
@praella/localisationist
@prague-digi/react-error-overlay
@prozilla-os/terminal
@react-native-ui-design/button
@redux-devtools/inspector-monitor-trace-tab
@routebuddies/react-native-mapbox-navigation
@ryfow/react-native-windows
@saad27/react-native-bottom-tab-tour
@sebastien_rts/react-native-tvos
@sephriot/react-native-persistable-uri
@shuvi/error-overlay
@sidghimire/react-native-mapbox-navigation
@soyjak/utils
@sridharetikala/react-native-rn-lib-custom-components
@status-im/react-native-transparent-video
@suen/react-native-tvos
@taingo97/react-native-bluetooth-escpos-printer
@taingo97/react-native-bluetooth-xprinter
@taingo97/react-native-expo-key-rsa-kt
@taingo97/react-native-generate-key-rsa
@taingo97/react-native-key-rsa
@taingo97/react-native-print-xprinter
@taingo97/react-native-printer-imin
@taingo97/react-native-rsa-expo
@taingo97/react-native-sunmi-printer
@taingo97/react-native-telpo-printer
@tasumaniadiabori/react-native-draggable-flatlist
@tg1518/react-native-lewin-aliyunplayer
@th3rdwave/react-native
@theia/console
@thinxviewx/core-rn
@throttleup/gatsby
@tlgeo/react-native-gdal
@trackier/react-native-trackier
@unforgiven/react-native
@viankakrisna/react-dev-utils
@viankakrisna/react-error-overlay
@vidit-me/react-native-wheely
@wecraftapps/react-native-use-keyboard
@wouterds/react-native-tvos
@zotasys/native
@zrnik/react-native
act_mvvm_shop_cart
ada-pack
adyen-rn
affinidi-auth-sdk-kernel
ansi-html-themed
ansi-log-renderer
ansi-to-json
ansi-to-react
ansi-to-react-18
ansi-to-react-with-options
ansi-to-vue3
ansicolor-utils
archlibrary
awesome-module-kd
biometric-st
birken-react-native-community-image-editor
bn-react-native
callstack-task-react-dev-utils
callstack-task-react-error-overlay
checkbox-component
cycle-dev-utils
dogandev-simple-toast
dulcet-error-overlay
fawaterak-online-payment
fluent.adflow.reactnativesdk
fluent.adflow.reactnativesdk-alpha
fmsl
framework_test_library_sixdee
framework_test_library_sixdee_new
framework_test_library_sixdee_new_new
gamification-integration-new
gatsby
gaurav-react-native-loop
genz-native-elements
ipynb2html
ipynb2html-fix
jordy-frijters-test-lib
jrennsoh88-react-native-scroll-indicator
khaled-salem-custom-components
kunai
lambda-dev-utils
linklog
mesh-devtool
multi-term
native-apple-login
native-date-picker-module
native-google-login
native-kakao-login
native-modal-damage-vehicle
new-awesome-4321
nove-repository
npm_one_12_34_1_
npm_one_1_2_3
npm_one_2_2
npm_qwerty
nuclide
nuclide-commons-ui
payutesting
pnm-yph-react-native-custom-components
procrealms-client
raact-native-arunramya151
reac-native-arun-ramya-test
react-ansi
react-ansi-eighteen
react-dev-utils-custom-hmr
react-dev-utils-extra
react-dev-utils-sebfl-update
react-error-guard
react-error-overlay-canary
react-error-overlay-dangerous
react-ipynb-renderer-katex
react-native
react-native-adarsh_react_native_video_player
react-native-addition
react-native-android-native-view
react-native-android-scoped-storage
react-native-android-video-player-view
react-native-animate-text
react-native-ansi-view
react-native-app-bubble
react-native-app-integrity-checksum
react-native-arps-authorize-net
react-native-arun-ramya-test
react-native-arunjeyam1987
react-native-arunmeena1987
react-native-arunramya151
react-native-auth-service-client
react-native-aventonfacetec-aventon
react-native-awesome-android-123
react-native-awesome-android-123-zeotap
react-native-awesome-module-dharmesh
react-native-awesome-module-latest
react-native-awesome-module-two
react-native-azure-communication-services
react-native-badge-control
react-native-basic-app
react-native-basic-screen
react-native-biometric-authenticate
react-native-bleccs-components
react-native-bluetooth-device-detect
react-native-bridge-package
react-native-bubble-chart
react-native-build-vesion-getter
react-native-check-component
react-native-chenaar
react-native-components-design
react-native-conekta-card-tokenizer
react-native-contact-list
react-native-cplus
react-native-create-video-thumbnail
react-native-ctp-odp
react-native-custom-poccomponent
react-native-custom-poccomponent-next
react-native-datacapture-core
react-native-dff-components-demo
react-native-dhp-printer
react-native-dimensions-layout
react-native-dish
react-native-dm-player
react-native-dsphoto-module
react-native-dummy-view
react-native-escape
react-native-expendable-view
react-native-expo-read-sms-ts-kf
react-native-fedlight-dsm
react-native-firebase-messaging
react-native-flyy
react-native-get-countries
react-native-ghn-ekyc
react-native-hlf-wrapper
react-native-innity-2
react-native-innity-remaster
react-native-input-library
react-native-is7
react-native-jsi-device-info
react-native-kakao-maps
react-native-klarify-ios
react-native-klarify-ui
react-native-klc
react-native-lib-test-rn-1
react-native-library-testing-422522
react-native-line-login-android
react-native-login-demo-test
react-native-lowlatency
react-native-loyalty-platforms
react-native-macos
react-native-manh-test
react-native-manual-ios-sdk
react-native-meon-edoc
react-native-meonsdk
react-native-meontool
react-native-modal-progress-bar
react-native-module-for-testing
react-native-multi-bluetooth-printer
react-native-multiplier-altroncoso
react-native-multiplier-component
react-native-multiplier-demo
react-native-multiplier2
react-native-multiply
react-native-multiply-component
react-native-multiselector
react-native-mun-kit
react-native-my-first-try-arun-ramya
react-native-mymap
react-native-native-audio-engine
react-native-native-ios-test1
react-native-nativewind
react-native-nghia-sharering
react-native-nice-learning
react-native-nyx-printer
react-native-offline-notice
react-native-okhttp-fork
react-native-omental-framework
react-native-onramp
react-native-otp-custom-library
react-native-patch-java
react-native-paynow-generator
react-native-payu-payment-testing
react-native-plugpag-wrapper
react-native-pme-loading
react-native-priya-demo-button
react-native-progress-arrow
react-native-pulsator-native
react-native-rabbitmq-all
react-native-radio-bic-group-lib
react-native-reanimated-sortable-list
react-native-recent-framework-update
react-native-remote-clover
react-native-responsive-helper
react-native-responsive-size
react-native-return-usb-data
react-native-rn-common-components-example
react-native-rn-icons-library
react-native-rn-tolkaplayer
react-native-rom-components
react-native-rtn-ips-poslin-test
react-native-sandycomponent
react-native-savczuk-feature-library
react-native-sayhello-module
react-native-screen-idle-timer
react-native-scroll-tab-to-index
react-native-sf
react-native-shared-gesture
react-native-sharing-intent
react-native-simple-timeline
react-native-sixdee_test_lib
react-native-smartcall-videodemo
react-native-sp-test-common
react-native-sunmi-printer-hk
react-native-swal
react-native-teads-sdk-module
react-native-tejab41097-sample-library
react-native-teknoctrl-components
react-native-test-comlibrary
react-native-test-module-hhh
react-native-test-tooltip
react-native-test-view
react-native-testweb
react-native-ticker-tape
react-native-tilt-ble
react-native-tone-framework
react-native-tones
react-native-trackier
react-native-transtracker-library
react-native-tvos
react-native-tvos-nz
react-native-ui-components-library
react-native-uvc-camera-android
react-native-version-app
react-native-volume-phisical
react-native-windows
react-native-withframework-check
react-native-wtf
react-native-xprinter-thermal-ble
react-native-ytximkit
react-webpack-build-helper
react_native_pandey_marquee
reactnatively
reat-native-multiplierkpr
redux-devtools-trace-monitor
renu-pack
rn-adyen-dropin
rn-check-btn
rn-circular-chart
rn-counter-demo
rn-flatlist-fork
rn-horizontal-list
rn-keyboard-avoiding-view
rn-my-library
rn-pay-sdk
rn-session-multiplier-demo
rn-tm-notify
rn-use-modal-hook
rn_unique_device_id
rnttlock
singularityui-tailer
smart_one_connect
smile-ansi-to-react
stack-frame-overlay
test-haptik-lib
test-library-123
test-zeo-collect
timer-react-dev-utils
transformime
userfetch
uyun-react-dev-utils
vision-camera-base64-resized
vision-camera-plugin-face-detector
vision-camera-plugin-scan-faces
webpack-isomorphic-dev-middleware
webpack-universal-compiler
wifi_configuration_package
wildev-react-native
yarn-react-hook-form
zc-react-dev-utils
zf-rn-testaa
:scroll: License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
Reason
Found 4/11 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
2.8
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to anser
anser-contigo-sit-est
12312312# simple-template
web3-decor-anser-elenora
This is the README file for the web3-decor-anser-elenora package.
uzma_anser.06
This is a [Next.js](https://nextjs.org/) project bootstrapped with [](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
kamran_anser.21
This is a [Next.js](https://nextjs.org/) project bootstrapped with [](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).