npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

string-plus

v1.4.3

Published

string字符串增强类

Readme

string-plus

JS字符串增强类

#快速入门

引入模块

	let StringPlus = require("string-plus");

创建对象

	let str = new StringPlus(val);
	let str = new StringPlus("Hello");

添加字符

	str.append(val);
	str.append("World");  // HelloWorld

判断是否为空

	str.isNullOrEmpty(); // false

判断字符串是否为Null或者为空字符串或者全是空格。

	str.isNullOrWhiteSpace(); // false

判断字符串是否包含指定的内容

	str.isContains(val);
	str.isContains("Hello"); // true

返回反转后副本

	str.reverse();

去除字符串左边的空格

	str.ltrim();

去除字符串右边的空格

	str.rtrim();

去除字符串两边的空格

	str.trim();

判断字符串是否以指定内容开头

	str.startsWith(val);
	str.startsWith("He"); // true

判断字符串是否以指定内容结尾

	str.endsWith();
	str = new StringPlus("HelloWorld");
	str.endsWith("orld"); // true

判断字符串是否是长日期

	date.isLongDate();
	new StringPlus("2017-4-11 15:27:01").isLongDate(); // true

判断字符串是否是短日期

	date.isShortDate();
	new StringPlus("2017-4-11").isShortDate(); // true

判断字符串是否是日期

	date.isDate();
	new StringPlus("2017-4-11 15:27:01").isDate(); // true

判断字符串是否是电话

	str.isMobile();
	new StringPlus("13416666666").isMobile(); // true

判断字符串是否是电子邮箱

	str.isEmail();
	new StringPlus("[email protected]").isEmail(); // true

判断字符串是否存在汉字

	str.isExistChinese(); // false

判断字符串是否全是汉字

	str.isChinese(); // false

判断字符串是否全是字母

	str.isAbc(); // true

将字符串日期转换成日期类型

	str.toDate();

将字符串转换成对应的bool值

	str.toBool();

将字符串转换成对应的int

	str.toInt();

将字符串转换成对应的Double

	str.toDouble();

将字符串转换成对应的json对象

	str.toJson();

将字符串转成字符数组。

	str.toCharArray();

保留数字

	str.getNum();

保留中文

	str.getCN();

得到字符串表现形式

	str.toString();

联系作者: email:[email protected]