Skip to content

Commit f86d35b

Browse files
committed
added documentation
1 parent c9b2cdc commit f86d35b

File tree

5 files changed

+65
-21
lines changed

5 files changed

+65
-21
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ isFu methods will accept <em>anything</em> as an argument and gracefully return
5656
toFu methods will accept <em>anything</em> as an argument and aggressively attempt to coerce the value into the type you have specified
5757
<ul><li>toCamel</li><li>toChain</li><li>toDash</li><li>toHuman</li><li>toJSON</li><li>toLink</li><li>toMix</li><li>toNumber</li><li>toOrdinal</li><li>toParam</li><li>toPercent</li><li>toPlural</li><li>toReverse</li><li>toShuffle</li><li>toSingle</li><li>toTitle</li><li>toTrim</li><li>toUnderscore</li><li>toWrap</li></ul>
5858
<h2>getFu - the art of the swift getter</h2>
59-
<ul><li>getMinutes</li><li>getMonth</li><li>getSeconds</li><li>getFirst</li><li>getFunctions</li><li>getIndex</li><li>getKeys</li><li>getLast</li><li>getLeft</li><li>getLinks</li><li>getNode</li><li>getRandom</li><li>getRight</li><li>getValues</li></ul>
59+
<ul><li>getFirst</li><li>getFunctions</li><li>getIndex</li><li>getKeys</li><li>getLast</li><li>getLeft</li><li>getLinks</li><li>getNode</li><li>getRandom</li><li>getRight</li><li>getValues</li></ul>
6060
<h2>dateTimeFu - the art of space and time</h2>
6161
<a href = "#">Try out the interactive demo of Date.format()</a><br/>
6262

build/docs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ isFu methods will accept <em>anything</em> as an argument and gracefully return
5656
toFu methods will accept <em>anything</em> as an argument and aggressively attempt to coerce the value into the type you have specified
5757
<ul><li>toCamel</li><li>toChain</li><li>toDash</li><li>toHuman</li><li>toJSON</li><li>toLink</li><li>toMix</li><li>toNumber</li><li>toOrdinal</li><li>toParam</li><li>toPercent</li><li>toPlural</li><li>toReverse</li><li>toShuffle</li><li>toSingle</li><li>toTitle</li><li>toTrim</li><li>toUnderscore</li><li>toWrap</li></ul>
5858
<h2>getFu - the art of the swift getter</h2>
59-
<ul><li>getMinutes</li><li>getMonth</li><li>getSeconds</li><li>getFirst</li><li>getFunctions</li><li>getIndex</li><li>getKeys</li><li>getLast</li><li>getLeft</li><li>getLinks</li><li>getNode</li><li>getRandom</li><li>getRight</li><li>getValues</li></ul>
59+
<ul><li>getFirst</li><li>getFunctions</li><li>getIndex</li><li>getKeys</li><li>getLast</li><li>getLeft</li><li>getLinks</li><li>getNode</li><li>getRandom</li><li>getRight</li><li>getValues</li></ul>
6060
<h2>dateTimeFu - the art of space and time</h2>
6161
<a href = "#">Try out the interactive demo of Date.format()</a><br/>
6262

lib/getFu.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ exports.getRight = function( str, n ){
1515
1616
*/
1717

18-
19-
// returns DOM nodes
20-
exports.getNode = function ( selector ){
21-
// TODO : add queryselectorall check and jquery check then default to a basic id lookup
22-
return str;
23-
};
18+
// Docs
19+
var D = {};
2420

2521
exports.getRandom = function(range) {
2622
r = Math.floor(Math.random()*range);
2723
return r;
2824
};
2925

26+
D.getRandom = {
27+
"example":"getRandom( range );",
28+
"message":"picks a random number from a range",
29+
"code":exports.getRandom.toString()
30+
};
31+
3032
exports.getKeys = function( object ) {
3133
keys = [];
3234
for (var key in object) {
@@ -35,6 +37,12 @@ exports.getKeys = function( object ) {
3537
return keys;
3638
};
3739

40+
D.getKeys = {
41+
"example":"getKeys( object );",
42+
"message":"returns an array of keys for an object",
43+
"code":exports.getKeys.toString()
44+
};
45+
3846
exports.getValues = function( object ) {
3947
values = [];
4048
for (var key in object) {
@@ -43,23 +51,47 @@ exports.getValues = function( object ) {
4351
return values;
4452
};
4553

54+
D.getValues = {
55+
"example":"getValues( object );",
56+
"message":"returns an array of values for an object",
57+
"code":exports.getValues.toString()
58+
};
59+
4660
exports.getRight = function(string, n) {
4761
return string.substring(n, string.length);
4862
};
4963

64+
D.getRight = {
65+
"example":"getRight(string, character_index );",
66+
"message":"returns a substring to the right of character position given",
67+
"code":exports.getRight.toString()
68+
};
69+
5070
exports.getLeft = function(string, n) {
5171
return toFu.toReverse(toFu.toReverse(string).substring(0, n));
5272
};
5373

74+
D.getLeft = {
75+
"example":"getLeft(string, character_index );",
76+
"message":"returns a substring to the left of character position given",
77+
"code":exports.getLeft.toString()
78+
};
79+
5480
// If the browser doesn't supply us with indexOf (I'm looking at you, MSIE),
5581
// we need this function. Return the position of the first occurence of an
5682
// item in an array, or -1 if the item is not included in the array.
5783
// Delegates to JavaScript 1.8's native indexOf if available.
5884
exports.getIndex = function( array, item ){
59-
for (var i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;
85+
for (var i = 0, l = array.length; i < l; i++) if (isFu.isEqual(array[i], item)) return i;
6086
return -1;
6187
};
6288

89+
D.getIndex = {
90+
"example":"getIndex(array, object );",
91+
"message":"returns index of object's placement in array",
92+
"code":exports.getIndex.toString()
93+
};
94+
6395
// Returns a sorted list of the names of every method in an object — that is to say, the name of every function property of the object.
6496
exports.getFunctions = function( object ){
6597
// todo add check for iterating through an object and returning an array of all functions (isFunction())

lib/isFu.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ exports.isArray = function(obj){
118118
D.isArray = {
119119
"example":"isArray( anything );",
120120
"message":"checks if anything is array",
121-
"code":exports.isArray.toString(),
122-
"tests":[]
121+
"code":exports.isArray.toString()
123122
};
124123

125124
exports.isJSON = function(jsony){
@@ -128,15 +127,15 @@ exports.isJSON = function(jsony){
128127
D.isJSON = {
129128
"example":"isJSON( anything );",
130129
"message":"checks if anything is a JSON string",
131-
"code":exports.isJSON.toString(),
132-
"tests":[]
130+
"code":exports.isJSON.toString()
133131
};
134132

135133

136134
exports.isNaN = function(obj) {
137135
return this.isNumber(obj) && isNaN(obj);
138136
};
139137

138+
140139
exports.isObject = function(objecty){
141140
if(this.isFunction(objecty)) {
142141
return false;
@@ -149,8 +148,7 @@ exports.isObject = function(objecty){
149148
D.isObject = {
150149
"example":"isObject( anything );",
151150
"message":"checks if anything is an object",
152-
"code":exports.isObject.toString(),
153-
"tests":[]
151+
"code":exports.isObject.toString()
154152
};
155153

156154

@@ -160,8 +158,7 @@ exports.isFunction = function(functiony){
160158
D.isFunction = {
161159
"example":"isFunction( anything );",
162160
"message":"checks if anything is a function",
163-
"code":exports.isFunction.toString(),
164-
"tests":[]
161+
"code":exports.isFunction.toString()
165162
};
166163

167164
exports.isEmpty = function(obj){
@@ -177,8 +174,7 @@ exports.isEmpty = function(obj){
177174
D.isFunction = {
178175
"example":"isEmpty( anything );",
179176
"message":"checks if anything is empty",
180-
"code":exports.isFunction.toString(),
181-
"tests":[]
177+
"code":exports.isFunction.toString()
182178
};
183179

184180
exports.isNode = function(){

test/getFu-test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,33 @@ vows.describe('format.js lib/getFu').addBatch({
3232
},
3333
"getRight()": {
3434
topic: "I am a very model of a model major general",
35-
"extracted right of number":function( string ){
35+
"extracted right of string":function( string ){
3636
var result = format.getFu.getRight(string, 7);
3737
assert.equal(result, "very model of a model major general");
3838
}
3939
},
4040
"getLeft()": {
4141
topic: "I am a very model of a model major general",
42-
"extracted right of number":function( string ){
42+
"extracted left of string":function( string ){
4343
var result = format.getFu.getLeft(string, 7);
4444
assert.equal(result, "general");
4545
}
46+
},
47+
"getIndex()": {
48+
"on complex object": {
49+
topic: ["I", "am", "a", [1,2,3]],
50+
"extracted index if complex object from arra":function( array ){
51+
var result = format.getFu.getIndex(array, [1,2,3]);
52+
assert.equal(result, 3);
53+
}
54+
},
55+
"on complex object": {
56+
topic: ["I", "am", "a", [1,2,3]],
57+
"extracted index if simple object from arra":function( array ){
58+
var result = format.getFu.getIndex(array, "am");
59+
assert.equal(result, 1);
60+
}
61+
}
4662
}
4763

4864
}).run();

0 commit comments

Comments
 (0)