js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包…

js 子节点父节点兄弟节点

Node.js is great for reusing code — and the backbone of reusing code is NPM packages.

Node.js非常适合重用代码-重用代码的基础是NPM软件包。

NPM packages save us tons of time and effort. Need a date libraryThere’s a package for it. Need a utility libraryNo problem, just install the package. Whenever you need to solve a problem with code, the chances are there’s a package tailored to your needs.

NPM软件包节省了我们大量的时间和精力。 需要日期库吗有一个包装。 需要实用程序库吗没问题,只需安装软件包即可。 每当您需要解决代码问题时,都有机会根据您的需求量身定制一个软件包。

Here’s a list of packages I think every Node.js developer should know. Treat these NPM packages as time savers and magic fairy helpers.

这是我认为每个Node.js开发人员都应该知道的软件包列表。 将这些NPM软件包视为节省时间和魔术仙子的助手。

沙哑 (husky)

Husky makes it straightforward to implement git hooks. Work with a team and want to enforce coding standards across the teamNo problem! Husky lets you require everyone to automatically lint and tests their code before committing or pushing to the repository.

Husky使实现git挂钩变得简单明了。 与团队合作,并希望在整个团队中实施编码标准没问题! 赫斯基(Husky)使您要求所有人在提交或推送到存储库之前自动完成测试并测试其代码。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/typicode/husky //github.com/typicode/husky

如何安装 (How to install)

用法 (Usage)

Here’s an example of how you can implement husky hooks:

这是一个如何实现沙哑的钩子的示例:

Husky hooks example
沙哑的钩子示例

The hooks will run before you commit to the repository.

挂钩将在您提交到存储库之前运行。

The hook runs before you push the code to the repository.

在将代码推送到存储库之前,将运行挂钩。

Dotenv (dotenv)

Dotenv is a zero-dependency module that loads environment variables from a file into . Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

Dotenv是一个零依赖模块,可将环境变量从文件加载到 。 将配置与代码分开存储在环境中是基于“十二因子应用程序”方法的。

dotenv

Dotenv

如何安装 (How to install)

用法 (Usage)

As early as possible in your application, require and configure dotenv:

尽早在您的应用程序中,要求并配置dotenv:

Create a file in the root directory of your project. Add environment-specific variables on new lines in the form of . For example:

在项目的根目录中创建一个文件。 在新行上以的形式添加特定于环境的变量。 例如:

now has the keys and values you defined in your file:

现在具有您在文件中定义的键和值:

日期-fns (date-fns)

Date-fns is like lodash, but for dates. It includes many utility functions that make it easier to work with dates.

Date-fns就像lodash,但用于日期。 它包含许多实用程序功能,这些功能使处理日期变得更加容易。

date-fns provides the most comprehensive, yet simple and consistent toolsetfor manipulating JavaScript dates in a browser & Node.js.

date-fns提供最全面,最简单且一致的工具集,用于在浏览器和Node.js中处理JavaScript日期。

date-fns

日期-fns

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/date-fns/date-fns https://github.com/date-fns/date-fns

如何安装 (How to install)

用法 (Usage)

Here’s a quick sample of the date-fns library:

这是date-fns库的快速示例:

Check out the documentation for further examples and use cases.

查看文档以获取更多示例和用例。

本扬 (Bunyan)

Bunyan is an easy-to-grasp and performant JSON logging library for Node.

Bunyan是Node的易于掌握且性能卓越的JSON日志记录库。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/trentm/node-bunyan https://github.com/trentm/node-bunyan

如何安装 (How to install)

Tip: The CLI tool is written to be compatible (within reason) with all versions of Bunyan logs. Therefore you might want to to get the Bunyan CLI on your PATH, then use local Bunyan installs for node.js library usage of Bunyan in your apps.

提示: CLI工具被编写为与所有版本的Bunyan日志兼容(在一定程度上)。 因此,您可能希望以在您的PATH上获取Bunyan CLI,然后将本地Bunyan安装用于应用程序中Bunyan的node.js库使用。

用法 (Usage)

Bunyan is a simple and fast JSON logging library for node.js services.

Bunyan是用于node.js服务的简单快速的JSON日志记录库。

Here’s what’s being returned to the console if you run .

如果您运行这就是返回控制台的 。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...

拉姆达 (Ramda)

Rambda is a practical, functional, utility library for JavaScript programmers. Ramda emphasizes a purer functional style.

Rambda是一个面向JavaScript程序员的实用,实用的实用程序库。 Ramda强调纯正的功能风格。

Immutability and side-effect free functions are at the heart of Ramda’s design philosophy. This can help you get the job done with simple, elegant code.

不变性和无副作用的功能是Ramda设计理念的核心。 这可以帮助您使用简单,优雅的代码完成工作。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/ramda/ramda https://github.com/ramda/ramda

如何安装 (How to install)

用法 (Usage)

Here’s the code example above.

这是上面的代码示例 。

调试 (debug)

Debug is a tiny JavaScript debugging utility modeled after Node.js core’s debugging technique.

Debug是一个小巧JavaScript调试实用程序,其模仿Node.js核心的调试技术。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/visionmedia/debug //github.com/visionmedia/debug

如何安装 (How to install)

用法 (Usage)

exposes a function — simply pass this function the name of your module and it will return a decorated version of for you to pass debug statements to.

公开了一个函数—只需将此函数传递给模块名称即可,它将返回经过修饰的版本,以便您将debug语句传递给该函数。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/visionmedia/debug //github.com/visionmedia/debug

如何安装 (How to install)

用法 (Usage)

debug example
调试示例

This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.

这将允许您为模块的不同部分以及整个模块切换调试输出。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...

平面 (flat)

flat takes a nested Javascript object and flattens it. You can also unflatten an object with delimited keys.

flat接受一个嵌套的Javascript对象并将其展平。 您也可以使用分隔键取消展平对象。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/hughsk/flat //github.com/hughsk/flat

安装 (Installation)

用法 (Usage)

JSON5 (JSON5)

The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.

JSON5数据交换格式(JSON5)是JSON的超集,旨在通过扩展其语法以包含ECMAScript 5.1的某些产品来减轻JSON的某些限制。

JSON5

JSON5

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/json5/json5 https://github.com/json5/json5

如何安装 (How to install)

用法 (Usage)

Notice the file extension. JSON5 is an extension and superset of JSON.

注意文件扩展名。 JSON5是JSON的扩展和超集。

ESLint (ESLint)

ESLint is a wonderful tool for avoiding bugs and forcing coding standards for development teams. ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.

ESLint是一个很好的工具,可以避免错误并强制开发团队使用编码标准。 ESLint是用于识别和报告ECMAScript / JavaScript代码中的模式的工具。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...
https://github.com/eslint/eslint https://github.com/eslint/eslint

如何安装和使用 (How to install and use)

You should then set up a configuration file:

然后,您应该设置一个配置文件:

After that, you can run ESLint on any file or directory like this:

之后,您可以在任何文件或目录上运行ESLint,如下所示:

For further explanations, please refer to the official documentation. There are lots of examples of getting started and configuration.

有关更多说明,请参阅官方文档 。 有许多入门和配置示例。

下午2 (PM2)

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without the downtime, and to facilitate common system admin tasks.

PM2是具有内置负载平衡器的Node.js应用程序的生产过程管理器。 它使您可以使应用程序永远保持活动状态,可以在不停机的情况下重新加载它们,并简化常见的系统管理任务。

js 子节点父节点兄弟节点_每个节点js开发人员都应该知道的12个有用的软件包...

来源:一二三是五六十

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年8月5日
下一篇 2020年8月5日

相关推荐