log-update
Advanced tools
Comparing version 3.1.1 to 3.2.0
111
index.d.ts
/// <reference types="node"/> | ||
export interface LogUpdate { | ||
(...text: string[]): void; | ||
declare namespace logUpdate { | ||
interface LogUpdate { | ||
/** | ||
Log to `stdout` by overwriting the previous output in the terminal. | ||
/** | ||
* Clear the logged output. | ||
*/ | ||
clear(): void; | ||
@param text - The text to log to `stdout`. | ||
/** | ||
* Persist the logged output. Useful if you want to start a new log session below the current one. | ||
*/ | ||
done(): void; | ||
@example | ||
``` | ||
import logUpdate = require('log-update'); | ||
const frames = ['-', '\\', '|', '/']; | ||
let i = 0; | ||
setInterval(() => { | ||
const frame = frames[i = ++i % frames.length]; | ||
logUpdate( | ||
` | ||
♥♥ | ||
${frame} unicorns ${frame} | ||
♥♥ | ||
` | ||
); | ||
}, 80); | ||
``` | ||
*/ | ||
(...text: string[]): void; | ||
/** | ||
Clear the logged output. | ||
*/ | ||
clear(): void; | ||
/** | ||
Persist the logged output. Useful if you want to start a new log session below the current one. | ||
*/ | ||
done(): void; | ||
} | ||
interface Options { | ||
/** | ||
Show the cursor. This can be useful when a CLI accepts input from a user. | ||
@example | ||
``` | ||
import logUpdate = require('log-update'); | ||
// Write output but don't hide the cursor | ||
const log = logUpdate.create(process.stdout, { | ||
showCursor: true | ||
}); | ||
``` | ||
*/ | ||
readonly showCursor?: boolean; | ||
} | ||
} | ||
export interface Options { | ||
declare const logUpdate: logUpdate.LogUpdate & { | ||
/** | ||
* Show the cursor. This can be useful when a CLI accepts input from a user. | ||
* | ||
* @example | ||
* | ||
* // Write output but don't hide the cursor | ||
* const log = logUpdate.create(process.stdout, { | ||
* showCursor: true | ||
* }); | ||
*/ | ||
readonly showCursor?: boolean; | ||
} | ||
Log to `stderr` by overwriting the previous output in the terminal. | ||
/** | ||
* Log to `stdout` by overwriting the previous output in the terminal. | ||
* | ||
* @param text - The text to log to `stdout`. | ||
*/ | ||
declare const logUpdate: LogUpdate & { | ||
@param text - The text to log to `stderr`. | ||
*/ | ||
readonly stderr: logUpdate.LogUpdate; | ||
/** | ||
* Log to `stderr` by overwriting the previous output in the terminal. | ||
* | ||
* @param text - The text to log to `stderr`. | ||
*/ | ||
readonly stderr: LogUpdate; | ||
Get a `logUpdate` method that logs to the specified stream. | ||
/** | ||
* Get a `logUpdate` method that logs to the specified stream. | ||
* | ||
* @param stream - The stream to log to. | ||
*/ | ||
readonly create: (stream: NodeJS.WritableStream, options?: Options) => LogUpdate; | ||
@param stream - The stream to log to. | ||
*/ | ||
readonly create: ( | ||
stream: NodeJS.WritableStream, | ||
options?: logUpdate.Options | ||
) => logUpdate.LogUpdate; | ||
// TODO: Remove this for the next major release | ||
default: typeof logUpdate; | ||
}; | ||
export default logUpdate; | ||
export = logUpdate; |
@@ -61,4 +61,5 @@ 'use strict'; | ||
module.exports = main(process.stdout); | ||
// TODO: Remove this for the next major release | ||
module.exports.default = module.exports; | ||
module.exports.stderr = main(process.stderr); | ||
module.exports.create = main; |
{ | ||
"name": "log-update", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -47,8 +47,8 @@ "files": [ | ||
"devDependencies": { | ||
"@types/node": "^11.10.4", | ||
"ava": "^1.2.1", | ||
"@types/node": "^11.12.2", | ||
"ava": "^1.4.1", | ||
"terminal.js": "^1.0.10", | ||
"tsd-check": "^0.3.0", | ||
"tsd": "^0.7.1", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -76,2 +76,4 @@ # log-update [![Build Status](https://travis-ci.org/sindresorhus/log-update.svg?branch=master)](https://travis-ci.org/sindresorhus/log-update) | ||
```js | ||
const logUpdate = require('log-update'); | ||
// Write output but don't hide the cursor | ||
@@ -78,0 +80,0 @@ const log = logUpdate.create(process.stdout, { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6658
117
95