diff --git a/.travis.yml b/.travis.yml index f98fed0..9d7745e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '14' - '12' - '10' - - '8' diff --git a/index.d.ts b/index.d.ts index 6d18a07..1a4d372 100644 --- a/index.d.ts +++ b/index.d.ts @@ -33,11 +33,11 @@ declare const terminalImage: { })(); ``` */ - buffer(imageBuffer: Buffer, options?: { - width?: number, - height?: number, - preserveAspectRatio?: boolean - }): Promise; + buffer: (imageBuffer: Readonly, options?: Readonly<{ + width?: number; + height?: number; + preserveAspectRatio?: boolean; + }>) => Promise; /** Display images in the terminal. Please note that the image will always be scaled to fit the size of the terminal. @@ -57,8 +57,6 @@ declare const terminalImage: { @param options.preserveAspectRatio - Optional: Whether to maintain image aspect ratio or not. Default: true. @returns The ANSI escape codes to display the image. - - @example ``` const terminalImage = require('terminal-image'); @@ -71,14 +69,14 @@ declare const terminalImage: { })(); ``` */ - file( + file: ( filePath: string, - options?: { - width?: number, - height?: number, - preserveAspectRatio?: boolean - } - ): Promise; -} + options?: Readonly<{ + width?: number; + height?: number; + preserveAspectRatio?: boolean; + }> + ) => Promise; +}; export = terminalImage; diff --git a/index.js b/index.js index 4087cb7..8cfaecd 100644 --- a/index.js +++ b/index.js @@ -92,10 +92,10 @@ async function render(buffer, {width: inputWidth, height: inputHeight, preserveA return result; } -exports.buffer = async (buffer, {height, width, preserveAspectRatio = true} = {}) => { +exports.buffer = async (buffer, {width = '100%', height = '100%', preserveAspectRatio = true} = {}) => { return termImg.string(buffer, { - width: width || '100%', - height: height || '100%', + width, + height, fallback: () => render(buffer, {height, width, preserveAspectRatio}) }); }; diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index d99a668..8476d3a 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,14 @@ "description": "Display images in the terminal", "license": "MIT", "repository": "sindresorhus/terminal-image", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "xo && ava && tsd" @@ -41,13 +42,13 @@ ], "dependencies": { "@sindresorhus/jimp": "^0.3.0", - "chalk": "^2.4.2", + "chalk": "^4.0.0", "term-img": "^4.1.0" }, "devDependencies": { - "@types/node": "^11.13.8", + "@types/node": "^13.13.5", "ava": "^1.4.1", - "tsd": "^0.7.2", - "xo": "^0.24.0" + "tsd": "^0.11.0", + "xo": "^0.30.0" } } diff --git a/readme.md b/readme.md index da6b1db..cf1b9ac 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# terminal-image [![Build Status](https://travis-ci.org/sindresorhus/terminal-image.svg?branch=master)](https://travis-ci.org/sindresorhus/terminal-image) +# terminal-image [![Build Status](https://travis-ci.com/sindresorhus/terminal-image.svg?branch=master)](https://travis-ci.com/sindresorhus/terminal-image) > Display images in the terminal