Skip to content

Commit

Permalink
Merge pull request #546 from optoolco/reduce-deps
Browse files Browse the repository at this point in the history
Remove the temporary util.promisify dependency
  • Loading branch information
Leonidas-from-XIV authored Dec 19, 2019
2 parents aefc64a + 3c2c99a commit bb266cf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 135 deletions.
16 changes: 12 additions & 4 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 0 additions & 125 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
},
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0",
"util.promisify": "~1.0.0"
"xmlbuilder": "~11.0.0"
},
"devDependencies": {
"coffee-script": ">=1.10.0",
Expand Down
8 changes: 6 additions & 2 deletions src/parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ bom = require './bom'
processors = require './processors'
setImmediate = require('timers').setImmediate
defaults = require('./defaults').defaults
promisify = require 'util.promisify'

# Underscore has a nice function for this, but we try to go without dependencies
isEmpty = (thing) ->
Expand Down Expand Up @@ -255,7 +254,12 @@ class exports.Parser extends events
throw err

parseStringPromise: (str) =>
promisify(@parseString) str
new Promise (resolve, reject) =>
@parseString str, (err, value) =>
if err
reject err
else
resolve value

exports.parseString = (str, a, b) ->
# let's determine what we got as arguments
Expand Down
9 changes: 7 additions & 2 deletions test/parser.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ util = require 'util'
assert = require 'assert'
path = require 'path'
os = require 'os'
promisify = require 'util.promisify'

fileName = path.join __dirname, '/fixtures/sample.xml'

readFilePromise = promisify fs.readFile
readFilePromise = (fileName) ->
new Promise (resolve, reject) =>
fs.readFile fileName, (err, value) =>
if err
reject err
else
resolve value

skeleton = (options, checks) ->
(test) ->
Expand Down

0 comments on commit bb266cf

Please sign in to comment.