Socket
Book a DemoInstallSign in
Socket

sweet-helpers

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweet-helpers

Collection of SweetJS macros.

latest
Source
npmnpm
Version
3.0.1
Version published
Maintainers
1
Created
Source

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.

Keywords

javascript

FAQs

Package last updated on 08 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts