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

sweet-helpers

v3.0.1

Published

Collection of SweetJS macros.

Downloads

3

Readme

SweetHelpers

Collection of SweetJS macros.

NPM version NPM dependencies NPM devDependencies

Install

npm install sweet-helpers --save-dev

Using with Gulp

var gulp = require('gulp'),
    sweetjs = requier('gulp-sweetjs');

gulp.task('sweetjs', function () {
  gulp.src('./myFile.js')
    .pipe(sweetjs({modules: ['./node_modules/sweet-helpers/index.sjs']}))
    .pipe(gulp.dest('./public/js'));
});

gulp.task('default', ['sweetjs']);

Macros

undef$

Template

undef$

Result

void 0

isUndef$

Returns true if the specified value is undefined.

Template

isUndef$(foo)

Or

foo::isUndef$()

Result

typeof foo === 'undefined'

isNotUndef$

Returns true if the specified value isn't undefined.

Template

isNotUndef$(foo)

Or

foo::isNotUndef$()

Result

typeof foo !== 'undefined'

isSet$

Returns true if the specified value isn't null or undefined.

Template

isSet$(foo)

Or

foo::isSet$()

Result

typeof foo !== 'undefined' && foo !== null

isNotSet$

Returns true if the specified value is null or undefined.

Template

isNotSet$(foo)

Or

foo::isNotSet$()

Result

typeof foo === 'undefined' || foo === null

isNull$

Returns true if the specified value is null.

Template

isNull$(foo)

Or

foo::isNull$()

Result

typeof foo !== 'undefined' && foo === null

isNotNull$

Returns true if the specified value isn't null.

Template

isNotNull$(foo)

Or

foo::isNotNull$()

Result

typeof foo === 'undefined' || foo !== null

isBoolean$

Returns true if the specified value is boolean.

Template

isBoolean$(foo)

Or

foo::isBoolean$()

Result

typeof foo === 'boolean'

isNotBoolean$

Returns true if the specified value isn't boolean.

Template

isNotBoolean$(foo)

Or

foo::isNotBoolean$()

Result

typeof foo !== 'boolean'

isString$

Returns true if the specified value is a string.

Template

isString$(foo)

Or

foo::isString$()

Result

typeof foo === 'string'

isNotString$

Returns true if the specified value isn't a string.

Template

isNotString$(foo)

Or

foo::isNotString$()

Result

typeof foo !== 'string'

isNumber$

Returns true if the specified value is a number.

Template

isNumber$(foo)

Or

foo::isNumber$()

Result

typeof foo === 'number'

isNotNumber$

Returns true if the specified value is a number.

Template

isNotNumber$(foo)

Or

foo::isNotNumber$()

Result

typeof foo !== 'number'

isNumeric$

Returns true if the specified value is numeric.

Template

isNumber$(foo)

Or

foo::isNumber$()

Result

typeof foo === 'number' && isFinite(foo)

isNotNumeric$

Returns true if the specified value isn't numeric.

Template

isNotNumeric$(foo)

Or

foo::isNotNumeric$()

Result

typeof foo !== 'number' || !isFinite(foo)

isRealNaN$

Returns true if the specified value is NaN.

Template

isRealNaN$(foo)

Or

foo::isRealNaN$()

Result

typeof foo === 'number' && isNaN(foo)

isNotRealNaN$

Returns true if the specified value isn't NaN.

Template

isNotRealNaN$(foo)

Or

foo::isNotRealNaN$()

Result

typeof foo !== 'number' || !isNaN(foo)

isFunction$

Returns true if the specified value is a function.

Template

isFunction$(foo)

Or

foo::isFunction$()

Result

typeof foo === 'function'

isNotFunction$

Returns true if the specified value isn't a function.

Template

isNotFunction$(foo)

Or

foo::isNotFunction$()

Result

typeof foo !== 'function'

instanceof$

Returns true if the specified value instance of a base object.

Template

instanceof$(foo, String)

Or

foo::instanceof$(String)

Result

foo instanceof String || foo && foo.constructor && foo.constructor.name === String.name

type$

Returns [[class]] of the specified value.

Template

type$(foo)

Or

foo::type$()

Result

({}).toString.call(foo)

iterator$

Returns a link for an iterator of the specified value.

Template

iterator$(foo)

Or

foo::iterator$()

Result

typeof foo !== 'undefined' && foo !== null ?
  (typeof foo['@@iterator'] === 'function' ?
    foo['@@iterator'] : typeof Symbol === 'function' ?
      foo[Symbol['iterator']] : void 0) : void 0

number$

Converts the specified value to a number.

Template

number$(foo)

Or

foo::number$()

Result

(+foo)

string$

Converts the specified value to a string.

Template

string$(foo)

Or

foo::string$()

Result

(foo + '')

boolean$

Converts the specified value to boolean.

Template

boolean$(foo)

Or

foo::boolean$()

Result

!!foo

use$

Returns an object for working with macro functions.

get

Gets the first non false property from an object.

Template

use$(foo).get('foo', 'bar')

Or

foo::get$('foo', 'bar')

Result

foo['foo'] || foo['bar']

in

Returns true if all specified properties are exists in an object.

Template

use$(foo).in('foo', 'bar')

Or

foo::in$('foo', 'bar')

Result

'foo' in foo && 'bar' in foo

not

Returns true if all specified properties aren't exists in an object.

Template

use$(foo).not('foo', 'bar')

Or

foo::not$('foo', 'bar')

Result

'foo' in foo === false && 'bar' in foo === false

some

Returns true if any of specified properties are exists in an object.

Template

use$(foo).some('foo', 'bar')

Or

foo::some$('foo', 'bar')

Result

'foo' in foo || 'bar' in foo

decorate$

Decorates a function.

Template

var foo = decorate$(bar, car) :: function () {
  return 1;
};

Or

var foo = decorate$(bar, car) || function () {
  return 1;
};

Result

var foo = car(bar(function () {
  return 1;
}));

License

The MIT License.