Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ansi-truncate

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-truncate - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

3

dist/constants.d.ts
declare const ANSI_RE: RegExp;
declare const ELLIPSIS = "\u2026";
declare const ELLIPSIS_WIDTH = 1;
declare const RESET = "\u001B[0m";
export { ANSI_RE, ELLIPSIS, RESET };
export { ANSI_RE, ELLIPSIS, ELLIPSIS_WIDTH, RESET };
/* MAIN */
const ANSI_RE = /[\x1B\x9B]/;
const ELLIPSIS = '…';
const ELLIPSIS_WIDTH = 1;
const RESET = '\x1B[0m';
/* EXPORT */
export { ANSI_RE, ELLIPSIS, RESET };
export { ANSI_RE, ELLIPSIS, ELLIPSIS_WIDTH, RESET };
import type { Options } from './types';
declare const truncate: (input: string, width: number, options?: {
ellipsis?: string;
ellipsisWidth?: number;
}) => string;
export default truncate;
export type { Options };
/* IMPORT */
import fastStringTruncatedWidth from 'fast-string-truncated-width';
import { ANSI_RE, ELLIPSIS, RESET } from './constants.js';
import { ANSI_RE, ELLIPSIS, ELLIPSIS_WIDTH, RESET } from './constants.js';
/* MAIN */

@@ -9,3 +9,4 @@ //TODO: Maybe detect where "RESET" is necessary more precisely

const ellipsis = options?.ellipsis ?? ELLIPSIS;
const { index, ellipsed, truncated } = fastStringTruncatedWidth(input, { limit, ellipsis });
const ellipsisWidth = options?.ellipsisWidth ?? (ellipsis === ELLIPSIS ? ELLIPSIS_WIDTH : undefined);
const { index, ellipsed, truncated } = fastStringTruncatedWidth(input, { limit, ellipsis, ellipsisWidth });
if (!truncated)

@@ -12,0 +13,0 @@ return input;

@@ -5,3 +5,3 @@ {

"description": "A tiny function for truncating a string that may contain ANSI escape sequences.",
"version": "1.1.1",
"version": "1.1.2",
"type": "module",

@@ -24,3 +24,3 @@ "main": "dist/index.js",

"dependencies": {
"fast-string-truncated-width": "^1.0.4"
"fast-string-truncated-width": "^1.1.0"
},

@@ -27,0 +27,0 @@ "devDependencies": {

@@ -5,3 +5,6 @@

const ANSI_RE = /[\x1B\x9B]/;
const ELLIPSIS = '…';
const ELLIPSIS_WIDTH = 1;
const RESET = '\x1B[0m';

@@ -11,2 +14,2 @@

export {ANSI_RE, ELLIPSIS, RESET};
export {ANSI_RE, ELLIPSIS, ELLIPSIS_WIDTH, RESET};

@@ -5,3 +5,3 @@

import fastStringTruncatedWidth from 'fast-string-truncated-width';
import {ANSI_RE, ELLIPSIS, RESET} from './constants';
import {ANSI_RE, ELLIPSIS, ELLIPSIS_WIDTH, RESET} from './constants';
import type {Options} from './types';

@@ -13,7 +13,8 @@

const truncate = ( input: string, width: number, options?: { ellipsis?: string } ): string => {
const truncate = ( input: string, width: number, options?: { ellipsis?: string, ellipsisWidth?: number } ): string => {
const limit = width;
const ellipsis = options?.ellipsis ?? ELLIPSIS;
const {index, ellipsed, truncated} = fastStringTruncatedWidth ( input, { limit, ellipsis } );
const ellipsisWidth = options?.ellipsisWidth ?? ( ellipsis === ELLIPSIS ? ELLIPSIS_WIDTH : undefined );
const {index, ellipsed, truncated} = fastStringTruncatedWidth ( input, { limit, ellipsis, ellipsisWidth } );

@@ -20,0 +21,0 @@ if ( !truncated ) return input;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc