# @eturino/ts-parse-boolean 中文文档

规范地址：https://npmcn.com/package/%40eturino/ts-parse-boolean/

版本：1\.1\.3
npm 元数据更新时间：2022-04-05T08:27:15.875Z
中文译文更新时间：2026-11-14T00:08:36.457Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40eturino/ts-parse-boolean
原文对照：https://npmcn.com/package/%40eturino/ts-parse-boolean/?lang=original
项目主页：https://github.com/eturino/ts-parse-boolean
源码仓库：https://github.com/eturino/ts-parse-boolean

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：16.2 kB，19 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=10\.0
- 运行依赖：0 个
- 首次发布：2019-10-23T10:04:47.958Z
- 最新版本发布：2021-01-26T11:44:45.145Z
- 近 30 天下载量：9282（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：5（近 12 个月 0 个）

## 中文简介

转换为布尔值 。 如果值为 falsy , 则返回虚假 。 如果它是真实的,它通过转换为字符串、修饰、提升和检查值是否不是来检查它 `FALSE` 或者说 `NO` 或者说 `0`。 。 。 .

## 安装

```sh
npm install @eturino/ts-parse-boolean
```

也可以使用：`pnpm add @eturino/ts-parse-boolean`、`yarn add @eturino/ts-parse-boolean`、`bun add @eturino/ts-parse-boolean`

## README

# `@eturino/ts-parse-boolean`

[![npm version](https://badge.fury.io/js/%40eturino%2Fts-parse-boolean.svg)](https://badge.fury.io/js/%40eturino%2Fts-parse-boolean) [![Build Status](https://travis-ci.org/eturino/ts-parse-boolean.svg?branch=master)](https://travis-ci.org/eturino/ts-parse-boolean) [![codebeat badge](https://codebeat.co/badges/ee945253-aaba-4ad7-b8ea-3d0fa9fa8b8c)](https://codebeat.co/projects/github-com-eturino-ts-parse-boolean-master) [![Maintainability](https://api.codeclimate.com/v1/badges/2b8116da70d362593c6a/maintainability)](https://codeclimate.com/github/eturino/ts-parse-boolean/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/2b8116da70d362593c6a/test_coverage)](https://codeclimate.com/github/eturino/ts-parse-boolean/test_coverage)

[类型 Doc 在此生成文件](https://eturino.github.io/ts-parse-boolean)

[Github 重播这里](https://github.com/eturino/ts-parse-boolean)

转换为布尔值 。 如果值为 falsy , 则返回虚假 。 如果它是真实的,它通过转换为字符串、修饰、提升和检查值是否不是来检查它 `FALSE` 或者说 `NO` 或者说 `0`。 。 。 .

如果我们通过一个不是 `boolean`, (中文(简体) ), `string`, (中文(简体) ), `number`, (中文(简体) ), `null` 或者说 `undefined`它会回来 `false`。 。 。 .

## 安装

`yarn add @eturino/ts-parse-boolean` 或者说 `npm install @eturino/ts-parse-boolean`。 。 。 .

## 使用量

```typescript
import parseBoolean from "@eturino/ts-parse-boolean";

parseBoolean(true); // => true
parseBoolean(false); // => false
parseBoolean(1); // => true
parseBoolean(0); // => false
parseBoolean(-8); // => true
parseBoolean(" 0 "); // => false
parseBoolean(" tRue   "); // => true
parseBoolean(" No   "); // => false
parseBoolean(" faLse   "); // => false
parseBoolean(" Whatever   "); // => true

// complex values are not parsed and we return false by default
parseBoolean(["a"]); // => false
parseBoolean({ a: 1 }); // => false
```

## 开发、提交、版本和出版

见文件促进发展

见 [Typescript-Starter 文档](https://github.com/bitjson/typescript-starter#bump-version-update-changelog-commit--tag-release)。 。 。 .

### 提交和更改

对于犯罪,你应该使用 [`commitizen`](https://github.com/commitizen/cz-cli)

```sh
yarn global add commitizen

#commit your changes:
git cz
```

作为打字符启动文件的表示 :

此项目是用于 [常规更改日志](https://github.com/conventional-changelog/conventional-changelog) 使管理释放更容易。 见 [标准版本](https://github.com/conventional-changelog/standard-version) 关于工作流程的更多信息的文件,或 [`CHANGELOG.md`](https://npmcn.com/package/%40eturino/ts-parse-boolean/CHANGELOG.md) 举个例子.

```sh
# bump package.json version, update CHANGELOG.md, git tag the release
yarn run version
```

你可以找到一个工具,比如 [**`wip`**](https://github.com/bitjson/wip) 在你准备好做出有意义的承诺之前 帮助管理正在进行的工作.

### 创建第一个版本

一旦您准备好创建第一个版本,请运行如下(注意: `reset` 具有破坏性,并将从目录中删除所有不在 git repo 中的文件.

```sh
# Reset the repo to the latest commit and build everything
yarn run reset && yarn run test && yarn run doc:html

# Then version it with standard-version options. e.g.:
# don't bump package.json version
yarn run version -- --first-release

# Other popular options include:

# PGP sign it:
# $ yarn run version -- --sign

# alpha release:
# $ yarn run version -- --prerelease alpha
```

之后,记住 [发布文件](https://npmcn.com/package/%40eturino/ts-parse-boolean/#readme-publish-the-docs)。 。 。 .

并最终将新标签推向github并发布到npm.

```sh
# Push to git
git push --follow-tags origin master

# Publish to NPM (allowing public access, required if the package name is namespaced like `@somewhere/some-lib`)
yarn publish --access public
```

### 发布文件

```sh
yarn run doc:html && yarn run doc:publish
```

这将生成文件并在 github 页面中发布 .

### 生成一个版本

准备新版有一个单一的线条命令. 见 [一步一步以 TypeScript- Startter 发布准备脚本](https://github.com/bitjson/typescript-starter#one-step-publish-preparation-script)

```sh
# Prepare a standard release
yarn prepare-release

# Push to git
git push --follow-tags origin master

# Publish to NPM (allowing public access, required if the package name is namespaced like `@somewhere/some-lib`)
yarn publish --access public
```

## 常见问题

### @eturino/ts-parse-boolean 是什么？

转换为布尔值 。 如果值为 falsy , 则返回虚假 。 如果它是真实的,它通过转换为字符串、修饰、提升和检查值是否不是来检查它 FALSE 或者说 NO 或者说 0。 。 。 \.

### 如何安装 @eturino/ts-parse-boolean？

在项目目录运行 npm install @eturino/ts-parse-boolean，或使用 pnpm add / yarn add / bun add。

### @eturino/ts-parse-boolean 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @eturino/ts-parse-boolean 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @eturino/ts-parse-boolean 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=10\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @eturino/ts-parse-boolean 可以商用吗？

@eturino/ts-parse-boolean 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @eturino/ts-parse-boolean 的下载量有多少？

根据 npm 官方下载统计，@eturino/ts-parse-boolean 在 2026/10/14 – 2026/11/12 这 30 天内被下载 9,282 次，日均约 309 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @eturino/ts-parse-boolean 还在维护吗？

最新版本 1\.1\.3 发布于 2021/01/26（5 年前）；至今共发布 5 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/10/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

