File tree Expand file tree Collapse file tree 5 files changed +54
-6
lines changed
Expand file tree Collapse file tree 5 files changed +54
-6
lines changed Original file line number Diff line number Diff line change 11var hash = require ( './hash' )
22var fit = require ( './internal/fit' )
3+ var conj = require ( './internal/conj' )
34
45function int ( input , opts ) {
56 opts = opts || 0
@@ -10,8 +11,12 @@ function int(input, opts) {
1011}
1112
1213int . options = function intOptions ( opts ) {
13- return function intOptionsFn ( input ) {
14- return int ( input , opts )
14+ var base = this
15+ intFn . options = int . options
16+ return intFn
17+
18+ function intFn ( input , overrides ) {
19+ return base ( input , conj ( opts , overrides ) )
1520 }
1621}
1722
Original file line number Diff line number Diff line change 1+ var hasOwnProperty = Object . prototype . hasOwnProperty
2+
3+ module . exports = function conj ( a , b ) {
4+ var result = { }
5+ var k
6+
7+ if ( a ) {
8+ for ( k in a ) {
9+ if ( hasOwnProperty . call ( a , k ) ) {
10+ result [ k ] = a [ k ]
11+ }
12+ }
13+ }
14+
15+ if ( b ) {
16+ for ( k in b ) {
17+ if ( hasOwnProperty . call ( b , k ) ) {
18+ result [ k ] = b [ k ]
19+ }
20+ }
21+ }
22+
23+ return result
24+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ tap.test('min and max', t => {
99} )
1010
1111tap . test ( '.options()' , t => {
12- t . equals ( int . options ( { max : 2 } ) ( 'foo' ) , int ( 'foo' , { max : 2 } ) )
12+ t . equals (
13+ int
14+ . options ( {
15+ min : 2 ,
16+ max : 2
17+ } )
18+ . options ( { min : 1 } ) ( 'foo' ) ,
19+ int ( 'foo' , {
20+ min : 1 ,
21+ max : 2
22+ } )
23+ )
1324 t . end ( )
1425} )
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ tap.test('capitalize', t => {
99
1010tap . test ( '.options()' , t => {
1111 t . equals (
12- word . options ( { capitalize : false } ) ( 23 ) ,
12+ word
13+ . options ( { capitalize : false } )
14+ . options ( { capitalize : true } )
15+ . options ( { capitalize : false } ) ( 23 ) ,
1316 word ( 23 , { capitalize : false } )
1417 )
1518
Original file line number Diff line number Diff line change 11var hash = require ( './hash' )
2+ var conj = require ( './internal/conj' )
23var defaults = require ( './internal/defaults' )
34
45var VOWELS = 'aeiou'
@@ -31,8 +32,12 @@ function word(input, opts) {
3132}
3233
3334word . options = function wordOptions ( opts ) {
34- return function wordOptionsFn ( input ) {
35- return word ( input , opts )
35+ var base = this
36+ wordFn . options = word . options
37+ return wordFn
38+
39+ function wordFn ( input , overrides ) {
40+ return base ( input , conj ( opts , overrides ) )
3641 }
3742}
3843
You can’t perform that action at this time.
0 commit comments