# cms7-underscore

> - ### _: which is a shortcut for import _ from 'underscore'

Latest version **1.0.5** (published 2019-02-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install cms7-underscore
pnpm add cms7-underscore
yarn add cms7-underscore
bun add cms7-underscore
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-02-22 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | saeidfarahi |

## Links

- npm: https://www.npmjs.com/package/cms7-underscore
- npm.io page: https://npm.io/package/cms7-underscore

## Dependencies (6)

- [jquery](https://npm.io/package/jquery.md) ^3.3.1
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [underscore](https://npm.io/package/underscore.md) ^1.9.1
- [es6-promise](https://npm.io/package/es6-promise.md) ^4.2.6
- [moment-hijri](https://npm.io/package/moment-hijri.md) ^2.1.1
- [moment-jalaali](https://npm.io/package/moment-jalaali.md) ^0.8.3

## Recent versions

- 1.0.5 (latest) — 2019-02-22
- 1.0.4 — 2019-02-22
- 1.0.3 — 2019-02-22
- 1.0.2 — 2019-02-22
- 1.0.1 — 2019-02-22

## README

# underscore extensions

## Adds following variables to __window__ variable:
- ### _: which is a shortcut for import _ from 'underscore'

## Exports:
- ### __isVoid function(value) -> Boolean__: checks if the _value_ is either _null_ or _undefined_
    > isVoid(null) <br/>
    > returns: true
- ### __isJquery function(value) -> Boolean__: checks if the _value_ is an instance of _jQuery_
    > isJquery($('.test')) <br>
    > returns: true
- ### __toJquery function(value) -> jQuery__: if the _value_ is not a _jQuery instance_, assumes that _value_ is a _jquery selector_ and returns the jquery instance of that selector
    > toJquery($('.test')) <br>
    > returns: $('.test') variable <br>
    > toJquery('.test') <br>
    > returns: $('.test') variable
- ### __callSafe function(func) -> return value of func__: calls the given function if it is available
- ### __guid function() -> String__: returns a c# Guid.NewGuid().ToString("N") like string
    > guid() <br>
    > returns: 976edaa0d2464573a6ea01aabaa98899
- ### __newId function() -> String__: returns guid() plus a prefix to make it suitable for html id attributes
    > newId() <br>
    > returns: e_976edaa0d2464573a6ea01a4bca98899
- ### __kebab_case_to_camelCase function(kebabCase) -> String__: converts kebab-case string into camelCase equivalent
    > kebab_case_to_camelCase('cms7-underscore') <br>
    > returns: cms7Underscore
- ### __containsArabic function(value) -> Boolean__: checks if a string contains persian or arabic characters
- ### __isKeyAlphaNumeric function(keyCode) -> Boolean__: checks if the given _keyCode_ of a jquery's _keyup_ or _keydown_ events is either digit or letter
- ### __isKeyTextInput function(keyCode) -> Boolean__: checks if the given _keyCode_ of a jquery's _keyup_ or _keydown_ events is either digit or letter and is __NOT__ _backspace: 8_ nor _delete: 46_
- ### __spinLock class(locked: func, unlocked: func)__:
    - ### methods:
        - lock() -> void: locks the object
        - unlock() -> void: unlocks the object
        - isLocked() -> Boolean: tells if the object is locked
        - waitForLock(callback: func) -> void: invokes the _callback_ asynchronously when the object is unlocked
- ### __render function(template: String, data: Object) -> String__: renders a template using the data as its model with underscorejs template engine
- ### __culture function(culture) -> String__: sets or gets current culture
- ### __dir function(culture) -> String__: gets current direction based on the given culture or current culture (if culture is null)
- ### __cultures function(cultures) -> Array__: sets or gets current allowed cultures
- ### __xsrfHeaderName function(xsrfHeaderName) -> String__: sets or gets current XSRF header name
- ### __xsrfValue function(containerSelector, tagName) -> String__: sets or gets current XSRF value
- ### __googletMapApiKey function(apiKey) -> String__: sets or gets current google map api key
- ### __googleAnalyticsId function(gaid) -> String__: sets or gets current google analytics id
- ### __calendar function() -> calendars__: gets current calendar based on current culture
- ### __newDat function(calendar, year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0) -> dat__: creates a new dat
- ### __dateTimeFormats__: 
    __all__: "year-month-day-hour-minute-second-millisecond",<br>
    __ymdhms__: "year-month-day-hour-minute-second",<br>
    __ymdhm__: "year-month-day-hour-minute",<br>
    __ymdh__: "year-month-day-hour",<br>
    __ymd__: "year-month-day",<br>
    __ym__: "year-month",<br>
    __y__: "year",<br>
    __hmsm__: "hour-minute-second-millisecond",<br>
    __hms__: "hour-minute-second",<br>
    __hm__: "hour-minute",<br>
    __h__: "hour"
- ### __calendars__: 
    __gregorian__: moment, <br>
    __jalaali__: jmoment,<br>
    __hijri__: imoment<br>
- ### __dat__: dat class for date-time operations
- ### __registerXsrfHeaderInAjaxPost function() -> void__: registers current _xsrfHeaderName_ and _xsrfValue_ in ajax-post
- ### __createUrl function(url) -> String__: gets localized url
- ### __createAjaxOptions function(method, url, data, success, error, completed) -> jQuery ajax options__
- ### __send function(method, url, data, success, error, completed) -> void__
- ### __sendGet function(url, data, success, error, completed) -> void__
- ### __sendPost function(url, data, success, error, completed) -> void__

## Adds the above methods to any __underscore__ variable:
for example _.isVoid, _.isJquery, ...

---
_Source: https://npm.io/package/cms7-underscore · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
