just_underscore 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 211b564e6ed76eefbea773008da0fc2b6bbb749f
4
+ data.tar.gz: 637a5ee03019ff1431e5c8d66b05bc3827bd98d0
5
+ SHA512:
6
+ metadata.gz: ead7d087bbf85393f01e7ce338a78f1002ed5f381cf9ce2e823cd43b18dfce666ab2e5300d327c1de1b5e2925a198306849119a15d4748938039e1d99f7db49e
7
+ data.tar.gz: c8c5ac8c476511c3bb48c5402bee6a3d11910fb1caf8ffb3c6d5e96fcfa7f713b226b6ec54b95bc5a016bfb44962df6a81b9e7b363195cd360ce60f945253348
@@ -1,3 +1,3 @@
1
1
  module JustUnderscore
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -1,6 +1,6 @@
1
- // Underscore.js 1.4.3
1
+ // Underscore.js 1.4.4
2
2
  // http://underscorejs.org
3
- // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
4
4
  // Underscore may be freely distributed under the MIT license.
5
5
 
6
6
  (function() {
@@ -64,7 +64,7 @@
64
64
  }
65
65
 
66
66
  // Current version.
67
- _.VERSION = '1.4.3';
67
+ _.VERSION = '1.4.4';
68
68
 
69
69
  // Collection Functions
70
70
  // --------------------
@@ -224,8 +224,9 @@
224
224
  // Invoke a method (with arguments) on every item in a collection.
225
225
  _.invoke = function(obj, method) {
226
226
  var args = slice.call(arguments, 2);
227
+ var isFunc = _.isFunction(method);
227
228
  return _.map(obj, function(value) {
228
- return (_.isFunction(method) ? method : value[method]).apply(value, args);
229
+ return (isFunc ? method : value[method]).apply(value, args);
229
230
  });
230
231
  };
231
232
 
@@ -235,10 +236,10 @@
235
236
  };
236
237
 
237
238
  // Convenience version of a common use case of `filter`: selecting only objects
238
- // with specific `key:value` pairs.
239
- _.where = function(obj, attrs) {
240
- if (_.isEmpty(attrs)) return [];
241
- return _.filter(obj, function(value) {
239
+ // containing specific `key:value` pairs.
240
+ _.where = function(obj, attrs, first) {
241
+ if (_.isEmpty(attrs)) return first ? null : [];
242
+ return _[first ? 'find' : 'filter'](obj, function(value) {
242
243
  for (var key in attrs) {
243
244
  if (attrs[key] !== value[key]) return false;
244
245
  }
@@ -246,6 +247,12 @@
246
247
  });
247
248
  };
248
249
 
250
+ // Convenience version of a common use case of `find`: getting the first object
251
+ // containing specific `key:value` pairs.
252
+ _.findWhere = function(obj, attrs) {
253
+ return _.where(obj, attrs, true);
254
+ };
255
+
249
256
  // Return the maximum element or (element-based computation).
250
257
  // Can't optimize arrays of integers longer than 65,535 elements.
251
258
  // See: https://bugs.webkit.org/show_bug.cgi?id=80797
@@ -567,26 +574,23 @@
567
574
  // Function (ahem) Functions
568
575
  // ------------------
569
576
 
570
- // Reusable constructor function for prototype setting.
571
- var ctor = function(){};
572
-
573
577
  // Create a function bound to a given object (assigning `this`, and arguments,
574
- // optionally). Binding with arguments is also known as `curry`.
575
- // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
576
- // We check for `func.bind` first, to fail fast when `func` is undefined.
578
+ // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
579
+ // available.
577
580
  _.bind = function(func, context) {
578
- var args, bound;
579
581
  if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
580
- if (!_.isFunction(func)) throw new TypeError;
581
- args = slice.call(arguments, 2);
582
- return bound = function() {
583
- if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
584
- ctor.prototype = func.prototype;
585
- var self = new ctor;
586
- ctor.prototype = null;
587
- var result = func.apply(self, args.concat(slice.call(arguments)));
588
- if (Object(result) === result) return result;
589
- return self;
582
+ var args = slice.call(arguments, 2);
583
+ return function() {
584
+ return func.apply(context, args.concat(slice.call(arguments)));
585
+ };
586
+ };
587
+
588
+ // Partially apply a function by creating a version that has had some of its
589
+ // arguments pre-filled, without changing its dynamic `this` context.
590
+ _.partial = function(func) {
591
+ var args = slice.call(arguments, 1);
592
+ return function() {
593
+ return func.apply(this, args.concat(slice.call(arguments)));
590
594
  };
591
595
  };
592
596
 
@@ -594,7 +598,7 @@
594
598
  // all callbacks defined on an object belong to it.
595
599
  _.bindAll = function(obj) {
596
600
  var funcs = slice.call(arguments, 1);
597
- if (funcs.length == 0) funcs = _.functions(obj);
601
+ if (funcs.length === 0) funcs = _.functions(obj);
598
602
  each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
599
603
  return obj;
600
604
  };
@@ -1019,7 +1023,7 @@
1019
1023
  max = min;
1020
1024
  min = 0;
1021
1025
  }
1022
- return min + (0 | Math.random() * (max - min + 1));
1026
+ return min + Math.floor(Math.random() * (max - min + 1));
1023
1027
  };
1024
1028
 
1025
1029
  // List of HTML entities for escaping.
@@ -1075,7 +1079,7 @@
1075
1079
  // Useful for temporary DOM ids.
1076
1080
  var idCounter = 0;
1077
1081
  _.uniqueId = function(prefix) {
1078
- var id = '' + ++idCounter;
1082
+ var id = ++idCounter + '';
1079
1083
  return prefix ? prefix + id : id;
1080
1084
  };
1081
1085
 
@@ -1110,6 +1114,7 @@
1110
1114
  // Underscore templating handles arbitrary delimiters, preserves whitespace,
1111
1115
  // and correctly escapes quotes within interpolated code.
1112
1116
  _.template = function(text, data, settings) {
1117
+ var render;
1113
1118
  settings = _.defaults({}, settings, _.templateSettings);
1114
1119
 
1115
1120
  // Combine delimiters into one regular expression via alternation.
@@ -1148,7 +1153,7 @@
1148
1153
  source + "return __p;\n";
1149
1154
 
1150
1155
  try {
1151
- var render = new Function(settings.variable || 'obj', '_', source);
1156
+ render = new Function(settings.variable || 'obj', '_', source);
1152
1157
  } catch (e) {
1153
1158
  e.source = source;
1154
1159
  throw e;
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just_underscore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
5
- prerelease:
4
+ version: 1.4.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Alexander
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
11
+ date: 2013-02-13 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Just underscore.js.
15
14
  email:
@@ -30,26 +29,25 @@ files:
30
29
  - vendor/assets/javascripts/underscore.js
31
30
  homepage: https://github.com/balexand/just_underscore
32
31
  licenses: []
32
+ metadata: {}
33
33
  post_install_message:
34
34
  rdoc_options: []
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
- none: false
39
38
  requirements:
40
- - - ! '>='
39
+ - - '>='
41
40
  - !ruby/object:Gem::Version
42
41
  version: '0'
43
42
  required_rubygems_version: !ruby/object:Gem::Requirement
44
- none: false
45
43
  requirements:
46
- - - ! '>='
44
+ - - '>='
47
45
  - !ruby/object:Gem::Version
48
46
  version: '0'
49
47
  requirements: []
50
48
  rubyforge_project:
51
- rubygems_version: 1.8.24
49
+ rubygems_version: 2.0.0.rc.2
52
50
  signing_key:
53
- specification_version: 3
51
+ specification_version: 4
54
52
  summary: Just underscore.js.
55
53
  test_files: []