-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [ "es2015" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"extends": "airbnb", | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"es6": true, | ||
"mocha": true, | ||
}, | ||
"ecmaFeatures": { | ||
"generators": true, | ||
}, | ||
"globals": { | ||
"__DEV__": true, | ||
}, | ||
"parser": "babel-eslint", | ||
"rules": { | ||
"babel/generator-star-spacing": 1, | ||
"babel/new-cap": 1, | ||
"babel/object-shorthand": 1, | ||
"babel/arrow-parens": 1, | ||
"babel/no-await-in-loop": 1, | ||
"array-bracket-spacing": [1, "always", { | ||
"singleValue": true, | ||
"objectsInArrays": false, | ||
"arraysInArrays": true, | ||
}], | ||
}, | ||
"plugins": [ | ||
"babel", | ||
"react", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
.DS_Store | ||
src | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "5.3.0" | ||
- "4.0" | ||
- "0.12" | ||
- "0.11" | ||
- "0.10" | ||
- "0.7.8" | ||
|
||
compiler: clang-3.6 | ||
|
||
env: | ||
- CXX=clang-3.6 | ||
|
||
addons: | ||
apt: | ||
sources: | ||
- llvm-toolchain-precise-3.6 | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- clang-3.6 | ||
- g++-4.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# proxies-and-reflect | ||
# identity-obj-proxy | ||
An identity object using ES6 proxies. Useful for testing trivial webpack imports. For instance, you can tell Jest to mock this object as imported ![CSS modules](https://github.com/css-modules/css-modules); then all your `className` lookup on the imported `styles` object will be returned as-is. | ||
|
||
## Requirement | ||
`node --harmony_proxies` flag (>= v0.7.8) | ||
|
||
## Example | ||
``` javascript | ||
import idObj from 'identity-obj-proxy'; | ||
console.log(idObj.foo); // 'foo' | ||
console.log(idObj.bar); // 'bar' | ||
console.log(idObj[1]); // '1' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "identity-obj-proxy", | ||
"version": "1.0.0", | ||
"description": "an identity object using ES6 proxies", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"clean": "rimraf build", | ||
"lint": "eslint src test", | ||
"test": "NODE_ENV=test mocha --harmony-proxies", | ||
"test:watch": "npm test -- --watch", | ||
"build:babel": "babel src --out-dir build", | ||
"build": "npm run clean && npm run lint && npm test && npm run build:babel", | ||
"postinstall": "npm run build" | ||
}, | ||
"engines": { | ||
"node": ">=0.7.8" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/keyanzhang/identity-obj-proxy.git" | ||
}, | ||
"keywords": [ | ||
"proxy", | ||
"proxies", | ||
"identity", | ||
"jest", | ||
"mock" | ||
], | ||
"author": "Keyan Zhang <[email protected]> (https://keya.nz)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/keyanzhang/identity-obj-proxy/issues" | ||
}, | ||
"homepage": "https://github.com/keyanzhang/identity-obj-proxy#readme", | ||
"dependencies": { | ||
"harmony-reflect": "^1.4.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.3.17", | ||
"babel-core": "^6.3.26", | ||
"babel-eslint": "^5.0.0-beta6", | ||
"babel-preset-es2015": "^6.3.13", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^2.1.1", | ||
"eslint-plugin-babel": "^3.0.0", | ||
"eslint-plugin-react": "^3.13.0", | ||
"expect": "^1.13.4", | ||
"mocha": "^2.3.4", | ||
"rimraf": "^2.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const Reflect = require('harmony-reflect'); // eslint-disable-line no-unused-vars | ||
|
||
const idObjHandler = { | ||
get: (target, key) => key, | ||
}; | ||
|
||
const idObj = new Proxy({}, idObjHandler); | ||
|
||
export default idObj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const Reflect = require('harmony-reflect'); // eslint-disable-line no-unused-vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import expect from 'expect'; | ||
import idObj from '../src'; | ||
|
||
describe('idObj', () => { | ||
it('should return the key as a string', () => { | ||
expect(idObj.foo).toBe('foo'); | ||
}); | ||
it('should support dot notation', () => { | ||
expect(idObj.bar).toBe('bar'); | ||
}); | ||
it('should support bracket notation', () => { | ||
expect(idObj[1]).toBe('1'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--require ./test/__setup__/polyfills.js | ||
--compilers js:babel-core/register | ||
--recursive |