Skip to content

Commit

Permalink
es6 file
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Apr 11, 2017
1 parent 879d171 commit cb8281b
Show file tree
Hide file tree
Showing 15 changed files with 12,583 additions and 9,767 deletions.
8,824 changes: 8,824 additions & 0 deletions dist/indian-ocean.browser.es6.js

Large diffs are not rendered by default.

6,774 changes: 1,751 additions & 5,023 deletions dist/indian-ocean.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions dist/indian-ocean.min.js

Large diffs are not rendered by default.

6,686 changes: 1,973 additions & 4,713 deletions dist/indian-ocean.node.js

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"version": "2.0.2",
"description": "A library for reading in and writing out data in Node.js.",
"main": "dist/indian-ocean.node.js",
"browser": "dist/indian-ocean.browser.es6.js",
"module": "index.node.js",
"scripts": {
"docs-view": "npm run build-docs && npm run serve-docs",
"coverage": "istanbul cover mocha -- -R spec",
"build-docs": "documentation -g -f html -o docs -t ./docs/theme/",
"build:node": "rollup --config rollup.config.node.js",
"build:umd": "rollup --config rollup.config.browser.js --banner \"$(preamble)\" && uglifyjs --preamble \"$(preamble)\" -o dist/indian-ocean.min.js -cm -- dist/indian-ocean.js",
"build": "rm -rf dist && mkdir dist && npm run build:node && npm run build:umd",
"build:browser": "rollup --config rollup.config.browser.js --banner \"$(preamble)\" && uglifyjs --preamble \"$(preamble)\" -o dist/indian-ocean.min.js -cm -- dist/indian-ocean.js",
"build": "rm -rf dist && mkdir dist && npm run build:node && npm run build:browser",
"dev": "rm -rf dist && mkdir dist && rollup --config -w",
"serve-docs": "http-server docs -p 8080 -o",
"start": "npm run build && npm test",
Expand Down Expand Up @@ -55,7 +56,6 @@
"js-yaml": "^3.4.2",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"parse-json": "^2.2.0",
"shapefile": "^0.6.2",
"text-encoding": "^0.6.4"
},
Expand All @@ -73,8 +73,6 @@
"rollup": "^0.41.4",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-node-builtins": "^2.1.0",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-watch": "^3.2.2",
"standard": "^8.3.0",
Expand Down
14 changes: 11 additions & 3 deletions rollup.config.browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO, break this out into its own browser repo to avoid the need for builtins and globals
import babel from 'rollup-plugin-babel'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
Expand All @@ -6,8 +7,15 @@ import globals from 'rollup-plugin-node-globals'

export default {
entry: 'index.browser.js',
format: 'umd',
moduleName: 'io',
plugins: [ babel(), nodeResolve(), commonjs(), builtins(), globals() ],
dest: 'dist/indian-ocean.js'
plugins: [nodeResolve(), commonjs(), builtins(), globals(), babel()],
targets: [
{
format: 'umd',
dest: 'dist/indian-ocean.js'
}, {
format: 'es',
dest: 'dist/indian-ocean.browser.es6.js'
}
]
}
2 changes: 1 addition & 1 deletion rollup.config.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import commonjs from 'rollup-plugin-commonjs'
export default {
entry: 'index.node.js',
format: 'cjs',
plugins: [ babel(), nodeResolve(), commonjs() ],
plugins: [ nodeResolve(), commonjs(), babel() ],
dest: 'dist/indian-ocean.node.js',
external: ['fs', 'path', 'util']
}
9 changes: 4 additions & 5 deletions src/parsers/json.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import parseJson from 'parse-json'
import mapValues from 'lodash/mapValues'
import identity from '../utils/identity'
import map from 'lodash/map'
import _ from 'underscore'

export default function (str, parserOptions) {
parserOptions = parserOptions || {}
// Do a naive test whether this is a string or an object
var mapFn = parserOptions.map ? str.trim().charAt(0) === '[' ? map : mapValues : identity
var jsonParser = parserOptions.nativeParser === true ? JSON.parse : parseJson
var mapFn = parserOptions.map ? str.trim().charAt(0) === '[' ? _.map : _.mapObject : identity
var jsonParser = parserOptions.nativeParser === true ? JSON.parse : JSON.parse
// var jsonParser = parserOptions.nativeParser === true ? JSON.parse : parseJson
return mapFn(jsonParser(str, parserOptions.reviver, parserOptions.filename), parserOptions.map)
}
4 changes: 2 additions & 2 deletions src/readers/readData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getParser from '../helpers/getParser'
import discernParser from '../helpers/discernParser'
import discernFormat from '../helpers/discernFormat'
import {formatsIndex} from '../config/equivalentFormats'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'

/**
* Asynchronously read data given a path ending in the file format.
Expand Down Expand Up @@ -88,7 +88,7 @@ export default function readData (filePath, opts_, cb_) {
if (opts_.parser) {
parser = getParser(opts_.parser)
delete opts_.parser
if (isEmpty(opts_)) {
if (_.isEmpty(opts_)) {
opts_ = undefined
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/readers/readDataSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getParser from '../helpers/getParser'
import discernParser from '../helpers/discernParser'
import discernFormat from '../helpers/discernFormat'
import {formatsIndex} from '../config/equivalentFormats'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'

/**
* Syncronous version of {@link readers#readData}
Expand Down Expand Up @@ -66,7 +66,7 @@ export default function readDataSync (filePath, opts_) {
if (opts_.parser) {
parser = getParser(opts_.parser)
delete opts_.parser
if (isEmpty(opts_)) {
if (_.isEmpty(opts_)) {
opts_ = undefined
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/writers/appendData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'
import makeDirectories from '../helpers/makeDirectories'
import readData from '../readers/readData'
import writeData from './writeData'
Expand Down Expand Up @@ -51,7 +51,7 @@ export default function appendData (outPath, data, opts_, cb) {
if (!err) {
readData(outPath, function (err, existingData) {
if (!err) {
if (!isEmpty(existingData)) {
if (!_.isEmpty(existingData)) {
if (Array.isArray(existingData)) {
data = existingData.concat(data)
} else if (typeof existingData === 'object') {
Expand Down
4 changes: 2 additions & 2 deletions src/writers/appendDataSync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'
import makeDirectoriesSync from '../helpers/makeDirectoriesSync'
import readDataSync from '../readers/readDataSync'
import writeDataSync from './writeDataSync'
Expand All @@ -26,7 +26,7 @@ export default function appendDataSync (outPath, data, opts_) {
}
fs.appendFileSync(outPath, '')
var existingData = readDataSync(outPath)
if (!isEmpty(existingData)) {
if (!_.isEmpty(existingData)) {
if (Array.isArray(existingData)) {
data = existingData.concat(data)
} else if (typeof existingData === 'object') {
Expand Down
4 changes: 2 additions & 2 deletions src/writers/writeData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'
import warn from '../reporters/warn'
import discernFileFormatter from '../helpers/discernFileFormatter'
import makeDirectories from '../helpers/makeDirectories'
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function writeData (outPath, data, opts_, cb) {
cb = opts_
opts_ = undefined
}
if (isEmpty(data)) {
if (_.isEmpty(data)) {
warn('You didn\'t pass any data to write for file: `' + outPath + '`. Writing out an empty file...')
}

Expand Down
4 changes: 2 additions & 2 deletions src/writers/writeDataSync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import isEmpty from 'lodash/isEmpty'
import _ from 'underscore'
import warn from '../reporters/warn'
import discernFileFormatter from '../helpers/discernFileFormatter'
import makeDirectoriesSync from '../helpers/makeDirectoriesSync'
Expand Down Expand Up @@ -45,7 +45,7 @@ import makeDirectoriesSync from '../helpers/makeDirectoriesSync'
* })
*/
export default function writeDataSync (outPath, data, opts_) {
if (isEmpty(data)) {
if (_.isEmpty(data)) {
warn('You didn\'t pass any data to write for file: `' + outPath + '`. Writing out an empty file...')
}
var writeOptions
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ describe('shorthandReaders', function () {
describe('invalid', function () {
it('should raise an error', function (done) {
io.readJson(testDataPath('json/invalid.json'), function (err, json) {
assert.equal(err.message, 'Unexpected token \'w\' at 1:3\n{ wrong: }\n ^')
assert.equal(err.message, 'Unexpected token w in JSON at position 2')
done()
})
})
Expand Down

0 comments on commit cb8281b

Please sign in to comment.