-
Notifications
You must be signed in to change notification settings - Fork 120
Support, Helpers, and Utils
Lance Pollard edited this page Oct 17, 2012
·
5 revisions
Helpers and such included in Tower.
- underscore.js
- underscore.string.js
- moment.js (date/time)
- mustache.js
- socket.io
- pluralization
- schema.org (https://github.com/indexzero/node-schema-org)
- geo: https://github.com/manuelbieh/Geolib
- kibo for keyboard
- tiny-require.js (browser + node)
- useragent (npm install useragent)
- shift.js (templating)
- async.js (callbacks)
- mimetypes
- unicode character lookup
User.within(miles: 10)
- extractArgs (args)
- extractOptions
- extractBlock
- sortBy
- isInt
- isFloat
- cloneHash
- cloneArray
- deepMerge
- deepMergeWithArray
- alias
- defineProperty
- accessor
- getter
- setter
- methods
- delegate
- isHash
- kind
- isPresent
- isBlank
- has
- isA
- functionName
- parameterize
- constantize
- camelize
- underscore
- singularize
- pluralize
- capitalize
- interpolate
- trim
- regexpEscape
- now
- date
Most helpers in Tower are included in the underscore _
namespace, because they are generic enough to be useable outside of Tower itself. The rest are included in the Tower
namespace.
Tower.urlFor
Tower.get
Tower.post
Tower.put
Tower.action
Tower.constant
_.pluralize('business') #=> 'businesses'
_.pluralize('businesses') #=> 'businesses'
_.pluralize('person') #=> 'people'
_.pluralize('people') #=> 'people'
_.singularize('business') #=> 'business'
_.singularize('businesses') #=> 'business'
_.singularize('person') #=> 'person'
_.singularize('people') #=> 'person'
_.isHash({}) #=> true
_.isHash({key: 'value'}) #=> true
_.isHash(new App.User) #=> false
_.isObject({}) #=> true
_.isObject({key: 'value'}) #=> true
_.isObject(new App.User) #=> true
_(number)[interval]()[timeframe]()
_(2).days().fromNow().toDate()
_(3).years().ago().toDate()
_('Dec 25, 2012').toDate()
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in US and Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.