Skip to content
This repository
Browse code

* added some jsdoc

* jslint fix
  • Loading branch information...
commit ef96fcbc438a61e9b57b9312923e3b4a54591194 1 parent be19902
Julien Polo authored February 14, 2012

Showing 2 changed files with 108 additions and 36 deletions. Show diff stats Hide diff stats

  1. 140  es6.js
  2. 4  stj.js
140  es6.js
@@ -257,7 +257,6 @@
257 257
     /**
258 258
      * Math
259 259
      */
260  
-    /*
261 260
     (function () {
262 261
         var 
263 262
         is = Object.is,
@@ -268,94 +267,165 @@
268 267
         factorial = function factorial(value) {
269 268
             var result = 1, i;
270 269
             for (i = value; i > 0; i--) {
271  
-                sum = sum * i;
  270
+                result = result * i;
272 271
             }
273  
-            return sum;
  272
+            return result;
274 273
         },
275 274
         LN2_INV = 1 / Math.LN2,
276 275
         LN10_INV = (1 / Math.LN10);
277 276
         
278 277
         shim(Math, {
279  
-            acosh: function acosh(value) {
280  
-                return log(value + sqrt(value * value - 1));
  278
+            /**
  279
+             * 
  280
+             * @param {number} numberValue
  281
+             * @return {number}
  282
+             */
  283
+            acosh: function acosh(numberValue) {
  284
+                return log(numberValue + sqrt(numberValue * numberValue - 1));
281 285
             },
282 286
             
283  
-            asinh: function asinh(value) {
284  
-                return log(value + sqrt(value * value + 1));
  287
+            /**
  288
+             * 
  289
+             * @param {number} numberValue
  290
+             * @return {number}
  291
+             */
  292
+            asinh: function asinh(numberValue) {
  293
+                return log(numberValue + sqrt(numberValue * numberValue + 1));
285 294
             },
286 295
             
287  
-            atanh: function atanh(value) {
288  
-                return 0.5 * log((1 + value) / (1 - value));
  296
+            /**
  297
+             * 
  298
+             * @param {number} numberValue
  299
+             * @return {number}
  300
+             */
  301
+            atanh: function atanh(numberValue) {
  302
+                return 0.5 * log((1 + numberValue) / (1 - numberValue));
289 303
             },
290 304
     
291  
-            cosh: function cosh(value) {
  305
+            /**
  306
+             * 
  307
+             * @param {number} numberValue
  308
+             * @return {number}
  309
+             */
  310
+            cosh: function cosh(numberValue) {
  311
+                if (numberValue < 0) {
  312
+                    numberValue = -numberValue;
  313
+                }
292 314
                 return (
293  
-                  (value < 0) ? value = -value :
294  
-                  (value > 21) ? exp(value) / 2 :
295  
-                  (exp(value) + exp(-value)) / 2
  315
+                  (numberValue > 21) ? exp(numberValue) / 2 :
  316
+                  (exp(numberValue) + exp(-numberValue)) / 2
296 317
                 );
297 318
             },
298 319
             
299  
-            expm1: function expm1(value) {
  320
+            /**
  321
+             * 
  322
+             * @param {number} numberValue
  323
+             * @return {number}
  324
+             */
  325
+            expm1: function expm1(numberValue) {
300 326
                 var 
301 327
                 result = 0,           
302 328
                 n = 50, i;
303 329
                 for (i = 1; i < n; i++) {
304  
-                    result += pow(value, i) / factorial(i);
  330
+                    result += pow(numberValue, i) / factorial(i);
305 331
                 }
306 332
                 return result;
307 333
             },
308 334
             
309  
-            hypot: function hypot(x, y) {
310  
-                return sqrt(x * x + y * y) || 0;
  335
+            /**
  336
+             * Return the hypothenuse of `sideA`/ `sideB`
  337
+             * 
  338
+             * @param {number} sideA
  339
+             * @param {number} sideB
  340
+             * @return {number}
  341
+             */
  342
+            hypot: function hypot(sideA, sideB) {
  343
+                return sqrt(sideA * sideA + sideB * sideB) || 0;
311 344
             },
312 345
     
313  
-            log2: function log2(value) {
314  
-                return log(value) * LN2_INV;
  346
+            /**
  347
+             * 
  348
+             * @param {number} numberValue
  349
+             * @returns {number}
  350
+             */
  351
+            log2: function log2(numberValue) {
  352
+                return log(numberValue) * LN2_INV;
315 353
             },
316 354
             
317  
-            log10: function log10(value) {
318  
-                return log(value) * LN10_INV;
  355
+            /**
  356
+             * 
  357
+             * @param {number} numberValue
  358
+             * @returns {number}
  359
+             */
  360
+            log10: function log10(numberValue) {
  361
+                return log(numberValue) * LN10_INV;
319 362
             },
320 363
             
321  
-            log1p: function log1p(value) {
  364
+            /**
  365
+             * 
  366
+             * @param {number} numberValue
  367
+             * @returns {number}
  368
+             */
  369
+            log1p: function log1p(numberValue) {
322 370
                 var 
323 371
                 result = 0,
324 372
                 n = 50, i, sign = 1;
325 373
     
326  
-                if (value <= -1) {
  374
+                if (numberValue <= -1) {
327 375
                     return -Infinity;
328 376
                 }
329  
-                if (value < 0 || value > 1) {
330  
-                    return log(1 + value);
  377
+                if (numberValue < 0 || numberValue > 1) {
  378
+                    return log(1 + numberValue);
331 379
                 }
332 380
                 for (i = 1; i < n; i += 1) {
333  
-                    result += (sign * pow(value, i) / i);
  381
+                    result += (sign * pow(numberValue, i) / i);
334 382
                     sign *= -1;
335 383
                 }
336 384
                 return result;
337 385
             },
338 386
     
  387
+            /**
  388
+             * Return -1 if negative number or 1 else
  389
+             * 
  390
+             * @param {number} numberValue
  391
+             * @returns {number}
  392
+             */
339 393
             sign: function sign(value) {
340 394
                 var number = +value;
341 395
                 return (is(number, NaN) || number === 0) ? number : (number < 0) ? -1 : 1;
342 396
             },
343 397
             
344  
-            sinh: function sinh(value) {
345  
-                return (exp(value) - exp(-value)) / 2;
  398
+            /**
  399
+             * 
  400
+             * @param {number} numberValue
  401
+             * @returns {number}
  402
+             */
  403
+            sinh: function sinh(numberValue) {
  404
+                return (exp(numberValue) - exp(-numberValue)) / 2;
346 405
             },
347 406
             
348  
-            tanh: function tanh(value) {
349  
-                var expV = exp(value),
350  
-                    expVMinus = exp(-value);
351  
-                return (expV - expVMinus) / (expV + expVMinus);
  407
+            /**
  408
+             * 
  409
+             * @param {number} numberValue
  410
+             * @returns {number}
  411
+             */
  412
+            tanh: function tanh(numberValue) {
  413
+                var 
  414
+                expValue = exp(numberValue),
  415
+                expValueMinus = exp(-numberValue);
  416
+                return (expValue - expValueMinus) / (expValue + expValueMinus);
352 417
             },
353 418
             
354  
-            trunc: function trunc(value) {
355  
-                return ~~value;
  419
+            /**
  420
+             * 
  421
+             * @param {number} numberValue
  422
+             * @returns {number}
  423
+             */
  424
+            trunc: function trunc(numberValue) {
  425
+                return ~~numberValue;
356 426
             }
357 427
         });
358  
-    }());*/
  428
+    }());
359 429
 
360 430
     
361 431
 }));
4  stj.js
@@ -200,7 +200,9 @@ define("stj/stj", function () {
200 200
     stj.shim = function shim(object, properties, onProto) {
201 201
         stj.use_(object, function () {
202 202
             var 
203  
-            def = stj.def_,
  203
+            def = typeof object === "function" ? stj.def_ : function (property, descriptor) {
  204
+                stj.defineProperty(object, property, descriptor);
  205
+            },
204 206
             property;
205 207
             for (property in properties) {
206 208
                 if (hasOwn.call(properties, property) && !hasOwn.call(object, property)) {

0 notes on commit ef96fcb

Please sign in to comment.
Something went wrong with that request. Please try again.