Skip to content

Commit

Permalink
Merge pull request #6 from nodejs/update-8-9-4
Browse files Browse the repository at this point in the history
Update to node 8.9.4.
  • Loading branch information
mcollina authored Mar 6, 2018
2 parents af3e518 + 3dbdece commit f12f26e
Show file tree
Hide file tree
Showing 21 changed files with 3,291 additions and 666 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# string_decoder

***Node-core v7.0.0 string_decoder for userland***
***Node-core v8.9.4 string_decoder for userland***


[![NPM](https://nodei.co/npm/string_decoder.png?downloads=true&downloadRank=true)](https://nodei.co/npm/string_decoder/)
Expand All @@ -15,7 +15,7 @@ npm install --save string_decoder

This package is a mirror of the string_decoder implementation in Node-core.

Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v7.8.0/docs/api/).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).

As of version 1.0.0 **string_decoder** uses semantic versioning.

Expand Down
63 changes: 43 additions & 20 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const hyperquest = require('hyperquest')
, nodeVersionRegexString = '\\d+\\.\\d+\\.\\d+'
, usageVersionRegex = RegExp('^' + nodeVersionRegexString + '$')
, readmeVersionRegex =
RegExp('((?:Node-core )|(?:https\:\/\/nodejs\.org\/dist\/)v)' + nodeVersionRegexString, 'g')
RegExp('((?:(?:Node-core )|(?:https\:\/\/nodejs\.org\/dist\/))v)' + nodeVersionRegexString, 'g')

, readmePath = path.join(__dirname, '..', 'README.md')
, files = require('./files')
Expand Down Expand Up @@ -49,21 +49,37 @@ function processFile (inputLoc, out, replacements) {
var arg2 = replacement[1]
if (typeof arg2 === 'function')
arg2 = arg2.bind(data)
if (arg2 === undefined) {
console.error('missing second arg for file', inputLoc, replacement)
throw new Error('missing second arg in replacement')
}
data = data.replace(regexp, arg2)
})
if (inputLoc.slice(-3) === '.js') {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
'transform-es2015-destructuring'
]
})
data = transformed.code
try {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread'
]
})
data = transformed.code
} catch (err) {
fs.writeFile(out + '.errored.js', data, encoding, function () {
console.log('Wrote errored', out)

throw err
})
return
}
}
fs.writeFile(out, data, encoding, function (err) {
if (err) throw err
Expand Down Expand Up @@ -112,7 +128,6 @@ pump(
throw err
}


//--------------------------------------------------------------------
// Grab & process files in ../lib/

Expand All @@ -137,15 +152,23 @@ pump(
//--------------------------------------------------------------------
// Grab the nodejs/node test/common.js

processFile(
testsrcurl.replace(/parallel\/$/, 'common.js')
, path.join(testourroot, '../common.js')
, testReplace['common.js']
)
glob(path.join(src, 'test/common/*'), function (err, list) {
if (err) {
throw err
}

list.forEach(function (file) {
file = path.basename(file)
processFile(
path.join(testsrcurl.replace(/parallel\/$/, 'common/'), file)
, path.join(testourroot.replace('parallel', 'common'), file)
, testReplace['common.js']
)
})
})

//--------------------------------------------------------------------
// Update Node version in README

processFile(readmePath, readmePath, [
[readmeVersionRegex, "$1" + nodeVersion]
])
Expand Down
59 changes: 59 additions & 0 deletions build/common-replacements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports.altForEachImplReplacement = [
/$/
, '\nfunction forEach (xs, f) {\n'
+ ' for (var i = 0, l = xs.length; i < l; i++) {\n'
+ ' f(xs[i], i);\n'
+ ' }\n'
+ '}\n'
]

module.exports.altForEachUseReplacement = [
/(\W)([\w\.\(\),\[\] ']+)(\.forEach\()/gm
, '$1forEach($2, '
]

module.exports.specialForEachReplacment = [
/(\W)(\[(?:\d\,\s)+\d\])(\.forEach\()/gm
, '$1forEach($2, '
]

module.exports.altIndexOfImplReplacement = [
/$/
, '\nfunction indexOf (xs, x) {\n'
+ ' for (var i = 0, l = xs.length; i < l; i++) {\n'
+ ' if (xs[i] === x) return i;\n'
+ ' }\n'
+ ' return -1;\n'
+ '}\n'
]

module.exports.altIndexOfUseReplacement = [
/(\W)([\w\.\(\),\[\]]+)(\.indexOf\()/gm
, '$1indexOf($2, '
]
module.exports.objectKeysDefine = [
/^('use strict';)$/m
, '$1\n\n/*<replacement>*/\nvar objectKeys = Object.keys || function (obj) {\n'
+ ' var keys = [];\n'
+ ' for (var key in obj) keys.push(key);\n'
+ ' return keys;\n'
+ '}\n/*</replacement>*/\n'
]

module.exports.objectKeysReplacement = [
/Object\.keys/g
, 'objectKeys'
]


module.exports.bufferShimFix = [
/^('use strict';)$/m,
`/*<replacement>*/
const bufferShim = require('safe-buffer').Buffer;
/*</replacement>*/`
]

module.exports.bufferStaticMethods = [
/Buffer\.((?:alloc)|(?:allocUnsafe)|(?:from))/g,
`bufferShim.$1`
]
7 changes: 5 additions & 2 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ module.exports['string_decoder.js'] = [
]

, [
/const Buffer = require\('buffer'\).Buffer;/
, 'var Buffer = require(\'safe-buffer\').Buffer;\n'
/(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/,
`/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
`
]

// add Buffer.isEncoding where missing
Expand Down
27 changes: 15 additions & 12 deletions build/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "string_decoder-build",
"name": "readable-stream-build",
"version": "0.0.0",
"description": "",
"main": "build.js",
"dependencies": {
"babel-core": "^6.5.2",
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.5.0",
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.18.0",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"bl": "^1.2.0",
"glob": "^7.1.1",
"gunzip-maybe": "^1.4.0",
"hyperquest": "^2.1.2",
"pump": "^1.0.2",
"rimraf": "^2.6.1",
"tar-fs": "^1.15.1"
"bl": "^1.2.1",
"glob": "^7.1.2",
"gunzip-maybe": "^1.4.1",
"hyperquest": "^2.1.3",
"pump": "^3.0.0",
"rimraf": "^2.6.2",
"tar-fs": "^1.16.0"
}
}
Loading

0 comments on commit f12f26e

Please sign in to comment.