Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 9dd4137

Browse files
author
Clément PREVOT
committed
feat(underscore): directly export in underscore
1 parent 079ba8f commit 9dd4137

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"main": "underscore.getSet.js",
66
"homepage": "https://github.com/clementprevot/underscore.getSet",
7-
"version": "1.0.0",
7+
"version": "2.0.0",
88
"repository":
99
{
1010
"type": "git",

underscore.getSet.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* underscore.getSet 1.0.0
3+
* underscore.getSet 2.0.0
44
* Copyright 2015 Clément Prévot <clementp at lumapps dot com>
55
* Largely based on Lodash 3.10.1 <https://lodash.com/license>
66
* Available under MIT license
@@ -158,8 +158,8 @@
158158

159159

160160
// Defining underscore.getSet
161-
var _gs = {
162-
VERSION: '1.0.0',
161+
var gs = {
162+
VERSION: '2.0.0',
163163

164164
get: function(object, path, defaultValue) {
165165
var result = object == null ? undefined : baseGet(object, toPath(path), (path + ''));
@@ -202,23 +202,29 @@
202202
if (typeof exports !== 'undefined') {
203203
if (typeof module !== 'undefined' && module.exports)
204204
{
205-
module.exports = _gs;
205+
module.exports = gs;
206206
}
207207

208-
exports._gs = _gs;
208+
exports.gs = gs;
209+
exports._gs = gs;
209210
}
210211

211212

212213
// Register as a named module with AMD.
213214
if (typeof define === 'function' && define.amd)
214215
{
215-
define('underscore.getSet', [], function(){ return _gs; });
216+
define('underscore.getSet', [], function(){ return gs; });
216217
}
217218

218219

219220
// Integrate with Underscore.js if defined
220221
// or create our own underscore object.
221222
root._ = root._ || {};
222-
root._.getSet = root._.gs = _gs;
223+
for (var functionName in gs) {
224+
if (gs.hasOwnProperties(functionName) && typeof gs[functionName] === 'function') {
225+
root._[functionName] = gs[functionName];
226+
}
227+
}
228+
root._.getSet = root._.gs = gs;
223229
}(this);
224230

0 commit comments

Comments
 (0)