Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bellajs

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bellajs

A set of helpful and usual functions for browser and node.

  • 3.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
increased by10.43%
Maintainers
1
Weekly downloads
 
Created
Source

bella.js

A set of helpful and usual functions for browser and node.

#Methods

##DataType detection

Bella.isString(Anything val)
Bella.isNumber(Anything val)
Bella.isObject(Anything val)
Bella.isArray(Anything val)
Bella.isFunction(Anything val)
Bella.isBoolean(Anything val)
Bella.isElement(Anything val)
Bella.isDef(Anything val)
Bella.isNull(Anything val)
Bella.isEmpty(Anything val)

##String manipulation

Bella.createId(Number length [, String prefix])
Bella.encode(String s)
Bella.decode(String s)
Bella.trim(String s)
Bella.strtolower(String s)
Bella.strtoupper(String s)
Bella.ucfirst(String s)
Bella.ucwords(String s)
Bella.escapeHTML(String s)
Bella.unescapeHTML(String s)
Bella.stripTags(String s)
Bella.truncate(String s, Number limit)
Bella.leftPad(String s, Number limit, String pad)
Bella.rightPad(String s, Number limit, String pad)
Bella.replaceAll(String s, String|Array search, String|Array replace)

##Array & Object manipulation

Bella.unique(Array a)
Bella.max(Array a)
Bella.min(Array a)
Bella.empty(Array a)
Bella.contains(Array a, String|Object search [, String key])
Bella.msort(Array a [, String key [, 'asc'|'desc'] ])
Bella.inherits(Proto o)
Bella.clone(Array|Object|Date o)
Bella.copies(Array|Object src, Array|Object dest [, Boolean mustMatch[, Array exclude] ])
Bella.bind(Object o, Function f)

##DOM

Bella.dom.one(String selectors)
Bella.dom.all(String selectors)
Bella.dom.get(String ID)
Bella.dom.add(Element dom)
Bella.dom.create(Element dom)

##Event

Bella.event.listen(String|Element s, String eventName, Function callback)
Bella.event.ignore(String|Element s, String eventName, Function callback)
Bella.event.simulate(String|Element s, String eventName)
Bella.event.exit(Event e)
Bella.event.locate(Event e)

##DateTime

Bella.date.format(String pattern, Date|Number|String input)
Bella.date.relativize(Date|Number|String input)
Bella.date.local(Date|Number|String input)
Bella.date.utc(Date|Number|String input)
Bella.date.strtotime(String input)
Bella.date.pattern([String pattern])

##Scheduler

Bella.scheduler.every(String pattern, Function callback)
Bella.scheduler.once(String pattern, Function callback)
Bella.scheduler.hourly(String pattern, Function callback)
Bella.scheduler.daily(String pattern, Function callback)
Bella.scheduler.monthly(String pattern, Function callback)
Bella.scheduler.yearly(String pattern, Function callback)

I like to use Bella.scheduler instead of setInterval or setTimeout, because it runs only one timer for the entire process. Regarding parameter "pattern" for Bella.scheduler.every, it may be:

1, A string in the format of 'Y m d H i s'. For example:

  • "2040 05 16 15 30 10" --> run callback at 15:30:10 on May 16, 2040
    • "* 05 16 15 30 10" --> run callback at 15:30:10 on May 16 of years --> similar to yearly('05 16 15 30 10', callback)
  • "* * 16 15 30 10" --> run callback at 15:30:10 on the 16th of months --> similar to monthly('16 15 30 10', callback)
  • "* * * 15 30 10" --> run callback at 15:30:10 of days --> similar to daily('15 30 10', callback)
  • "* * * * 30 10" --> run callback at the 10th second of the 30th minute of hours --> similar to hourly('30 10', callback)
  • "* * * * * 10" --> run callback at the 10th second of minutes.

2, A string in the format of 'weekday H:i:s'. For example:

  • "sunday 15:30:10" --> run callback on Sundays at 15:30:10 --> similar to 'sun 15:30:10'
  • "sunday 15:30" --> run callback on Sundays at 15:30:00 --> similar to 'sun 15:30'
  • "sunday 15" --> run callback on Sundays at 15:00:00 --> similar to 'sun 15'

3, A string in the format of 'N unit'. For example:

  • Bella.scheduler.every('5m', callback) --> call callback after every 5 minutes
  • Bella.scheduler.once('5h', callback) --> call callback after 5 minutes, then stop

The available units: d (days), h (hours), m (minutes), s (seconds).

Bella.scheduler.once do the same thing as Bella.scheduler.every, but just once. The remain fours methods just are the shortcuts.

#Propertiess

Bella.id
Bella.device

Test with Jasmine

/test/SpecRunner.html

FAQs

Package last updated on 24 Apr 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc