Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Indentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
johnste committed Mar 12, 2016
1 parent 76834dc commit dc1a6c7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ Getify is a utility to grab nested values from objects. Like lodash's `_.get`, o

```
import getify from 'getify'
const obj = {
deeply: {
nested: ['the', 'values', 'are', 'here']
}
}
const value = getify(obj).deeply.nested[1](); // === "values"
const missing = getify(obj).cant['find'].anything.here() // === undefined
const defaultValue = getify(obj).nothing.here.as.well('oops!') // === "oops!"
```

Expand Down
44 changes: 22 additions & 22 deletions lib/getify.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.getify = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.getify = factory();
}
}(this, function () {

Expand All @@ -29,14 +29,14 @@

function handler() {
return {
get: function(target, key){
if (typeof key == 'symbol' || key == '__proto__') {
return target[key]
}
get: function(target, key){
if (typeof key == 'symbol' || key == '__proto__') {
return target[key]
}

path.push(key)
return getProxy(getValueFromPath(obj))
}
path.push(key)
return getProxy(getValueFromPath(obj))
}
}
}

Expand All @@ -48,8 +48,8 @@
return getProxy(() => obj, path)
}

// Just return a value to define the module export.
// This example returns an object, but the module
// can return a function as the exported value.
return getify;
// Just return a value to define the module export.
// This example returns an object, but the module
// can return a function as the exported value.
return getify;
}));
8 changes: 4 additions & 4 deletions test/getify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ define(['lib/getify'], (getify) => {
},
f: [undefined, { g: "321" }]
}
expect(getify(obj).a.b(), 'obj.a.b').to.be.undefined
expect(getify(obj).b[4](), 'obj.b[4]').to.be.undefined
expect(getify(obj).d(), 'obj.d').to.be.undefined
expect(getify(obj).f[1].x.x(), 'obj.f[1].x.x').to.be.undefined
expect(getify(obj).a.b(), 'obj.a.b').to.be.undefined
expect(getify(obj).b[4](), 'obj.b[4]').to.be.undefined
expect(getify(obj).d(), 'obj.d').to.be.undefined
expect(getify(obj).f[1].x.x(), 'obj.f[1].x.x').to.be.undefined

})

Expand Down
26 changes: 13 additions & 13 deletions test/test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ var TEST_REGEXP = /(spec|test)\.js$/i;

// Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '');
allTestFiles.push(normalizedTestModule);
}
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '');
allTestFiles.push(normalizedTestModule);
}
});

require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',

// dynamically load all test files
deps: allTestFiles,
// dynamically load all test files
deps: allTestFiles,

// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});

0 comments on commit dc1a6c7

Please sign in to comment.