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 🙏

© 2024 – Pkg Stats / Ryan Hefner

assertrue

v1.0.5

Published

extends assert of node

Downloads

2

Readme

Assertrue

GitHub release Github Releases (by Release) npm npm Travis branch

extends assert of node 扩展node原生的Assert功能

Usage 用法

Usage for English is Coming soon...

Start 开始使用

1. 引入

使用nodejs

$ npm install --save assertrue
const assert = require('assertrue');
  • 说明:assertrue中已经包含原生assert的全部功能,不需要再额外引入assert

扩展功能

1. isTrue(actual, [message])

assert.isTrue(true); //ok
assert.isTrue(1); //ok
assert.isTrue('a'); //ok
assert.isTrue(false); //AssertionError
assert.isTrue(0); //AssertionError
assert.isTrue(''); //AssertionError

2. isStrictTrue(actual, [message])

assert.isStrictTrue(true); //ok
assert.isStrictTrue(1); //AssertionError
assert.isStrictTrue('a'); //AssertionError
assert.isStrictTrue(false); //AssertionError
assert.isStrictTrue(0); //AssertionError
assert.isStrictTrue(''); //AssertionError

3. isFalse(actual, [message])

4. isStrictFalse(actual, [message])

5. isNaN(actual, [message])

assert.isNaN(NaN); //ok
assert.isNaN('a'); //ok
assert.isNaN({}); //ok
assert.isNaN(1); //AssertionError
assert.isNaN('1'); //AssertionError
assert.isNaN(true); //AssertionError

6. isStrictNaN(actual, [message])

assert.isStrictNaN(NaN); //ok
assert.isStrictNaN('a'); //AssertionError
assert.isStrictNaN({}); //AssertionError
assert.isStrictNaN(1); //AssertionError
assert.isStrictNaN('1'); //AssertionError
assert.isStrictNaN(true); //AssertionError

7. isNotNaN(actual, [message])

8. isNotStrictNaN(actual, [message])

9. isStrictString(actual, [message])

assert.isStrictString('a'); //ok

10. isNotStrictString(actual, [message])

11. isStrictArray(actual, [message])

assert.isStrictString(['a']); //ok

12. isNotStrictArray(actual, [message])

13. isStrictFunction(actual, [message])

assert.isStrictFunction(()=>{}); //ok

14. isNotStrictFunction(actual, [message])

15. isStrictRegExp(actual, [message])

assert.isStrictRegExp(/\w+/ig); //ok

16. isNotStrictRegExp(actual, [message])

17. isStrictBoolean(actual, [message])

assert.isStrictBoolean(true); //ok

18. isNotStrictBoolean(actual, [message])

19. isStrictNumber(actual, [message])

assert.isStrictNumber(1); //ok

20. isNotStrictNumber(actual, [message])

21. is(actual, expectedType, [message])

assert.is(1, Number); //ok
assert.is(1, 'Number'); //ok

class Super {}
class Sub extends Super {}

assert.is(new Sub(), Sub); //ok
assert.is(new Sub(), Super); //ok
assert.is(new Super(), Super); //ok
assert.is(new Super(), Sub); //AssertionError
assert.is(new Sub(), 'Super'); //AssertionError

22. isNot(actual, expectedType, [message])

23. isAssignableFrom(superType, subType, [message])

class Super {}
class Sub extends Super {}

assert.isAssignableFrom(Super, Sub); //ok
assert.isAssignableFrom(Super, Super); //ok
assert.isAssignableFrom(Sub, Sub); //ok
assert.isAssignableFrom(Sub, Super); //AssertionError

24. isNotAssignableFrom(superType, subType, [message])

25 isAssignableTo(subType, superType, [message])

class Super {}
class Sub extends Super {}

assert.isAssignableFrom(Sub, Super); //ok
assert.isAssignableFrom(Super, Super); //ok
assert.isAssignableFrom(Sub, Sub); //ok
assert.isAssignableFrom(Super, Sub); //AssertionError

26 isNotAssignableTo(subType, superType, [message])

Change list 更新日志

2020-05-12 v1.0.5

增加对class继承关系的断言

2017-03-22 v1.0.4

重命名为assertrue

2017-03-17 v1.0.3

增加 Travis CI 支持
新增对各种类型的断言

v1.0.2

正式启动项目

More docs and examples, to be continue... 更多接口文档的案例,未完待补充...