Skip to content

Commit 3f0c1fe

Browse files
committed
added AMD support
1 parent 7decab0 commit 3f0c1fe

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,23 @@ console.log( Strings.oneSpaceAndTrim(sparse) );
4444
```
4545

4646
___
47-
<br/>
47+
**node.js**
4848
Made for browser and/or node.js. You can use `npm install strings.js` if you like.
49-
<br/>
49+
50+
**AMD**
51+
When using AMD, you can load strings.js like so:
52+
```javascript
53+
require.config({
54+
paths: {
55+
'strings', [ '../path/to/strings.min' ]
56+
}
57+
});
58+
59+
require( ['strings'], function( Strings ){
60+
console.log( Strings.empty('') );
61+
// true
62+
});
63+
```
5064
<br/>
5165
___
5266
General description:
@@ -868,7 +882,10 @@ __________
868882

869883
change log
870884
==========
885+
**1.2.5**
871886

887+
Added AMD support.
888+
___
872889
**1.2.3**
873890

874891
Added Strings.prototype.isUpper(), Strings.prototype.isLower(), Strings.isUpper() and Strings.isLower().

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "strings.js",
3-
"version": "1.2.3",
4-
"description": "A flexible, robust and powerful Javascript string manipulation library.",
3+
"version": "1.2.5",
4+
"description": "A flexible Javascript string manipulation library.",
55
"main": "strings.min.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"

strings.coffee

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ mapStringToNumber= ( array ) ->
103103
array[ index ]= nr
104104
return array.length
105105

106-
# _ (selection of tools.js)
106+
# _ (selection of tools)
107107

108108
class _ extends Types
109109

@@ -446,17 +446,6 @@ class Strings extends Chars
446446
ending= new RegExp Strings.regEscape( ending )+ '$'
447447
return ending.test string
448448

449-
# @formatNumber: ( number, interval= 3 ) ->
450-
# return number if '' is number= _.forceString number
451-
# formatted= ''
452-
# length= number.length- 1
453-
# interval= _.forceNumber interval, 3
454-
# for index in [0..length]
455-
# formatted+= number[ index ]
456-
# if ( (length- index)% interval is 0 ) and ( index < length )
457-
# formatted+= '.'
458-
# return formatted
459-
460449
# test below this line:
461450
@wrap: ( prepend= '', append= '' ) ->
462451
wrapper= ( string ) -> Strings.create prepend, string, append
@@ -559,8 +548,6 @@ class Strings extends Chars
559548

560549
endsWith: ( ending ) -> Strings.endsWith @string, ending
561550

562-
# formatNumber: ( formatting ) -> Strings.format @string, formatting
563-
564551
setWrap: ( prepend, append ) ->
565552
if _.isNull @wrapMethod then @wrapMethod= Strings.wrap prepend, append
566553
else @wrapMethod.wrap prepend, append
@@ -587,5 +574,9 @@ Strings.crop= Strings.slice
587574
Strings::crop= Strings::slice
588575
Strings::append= Strings::push
589576

577+
578+
if ( 'function' is typeof define ) and define.amd
579+
define 'strings', [], -> Strings
580+
590581
if window? then window.Strings= Strings
591-
else module.exports= Strings
582+
else if module? then module.exports= Strings

strings.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

strings.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)