Permalink
Browse files

Remove use of Object.assign() for Node v0.12 compatibility

  • Loading branch information...
1 parent b95125e commit ca32d42afce05e66c13ebf079b1e2520b7de5f62 bcronin committed Aug 23, 2016
Showing with 52 additions and 11 deletions.
  1. +2 −5 Makefile
  2. +16 −1 lib-debug/index.js
  3. +1 −1 lib-debug/index.js.map
  4. +16 −1 lib/index.js
  5. +1 −1 lib/index.js.map
  6. +1 −1 scripts/docker_test.sh
  7. +15 −1 src/index.js
View
@@ -70,14 +70,11 @@ test: build
test-no-coverage: build
NODE_ENV=debug node ./node_modules/.bin/_mocha test/unittest.js --check-leaks --color
-.PHONY: test_all
-test_all: build
+.PHONY: test-all
+test-all: build
scripts/docker_test.sh latest
scripts/docker_test.sh 5.8
- scripts/docker_test.sh 5.5
- scripts/docker_test.sh 5.0
scripts/docker_test.sh 4.4
- scripts/docker_test.sh 4.0
scripts/docker_test.sh 0.12
.PHONY: example
View
@@ -36,9 +36,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+// Object.assign() is not available on Node v0.12, so implement a similar
+// function here (subset of a proper polyfill).
+function _extend(target) {
+ for (var index = 1; index < arguments.length; index++) {
+ var source = arguments[index];
+ for (var key in source) {
+ // eslint-disable-line no-restricted-syntax
+ if (source.hasOwnProperty(key)) {
+ target[key] = source[key];
+ }
+ }
+ }
+ return target;
+}
+
// Use `module.exports` rather than `export` to avoid the need to use `.default`
// when requiring the package in ES5 code.
-module.exports = Object.assign({
+module.exports = _extend({
BinaryCarrier: _binary_carrier2.default,
Reference: _reference2.default,
SpanContext: _span_context2.default,
@@ -1 +1 @@
-{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;AAAA;;IAAY,Y;;AACZ;;IAAY,S;;AACZ;;IAAY,I;;AACZ;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;AAGA;AACA;AACA,OAAO,OAAP,GAAiB,OAAO,MAAP,CACb;AACI,2CADJ;AAEI,kCAFJ;AAGI,uCAHJ;AAII,wBAJJ;AAKI;AALJ,CADa,EAQb,SARa,EASb,YATa,CAAjB;;AAYA;AACA,KAAK,UAAL","file":"index.js","sourcesContent":["import * as GlobalTracer from './global_tracer';\nimport * as Constants from './constants';\nimport * as noop from './noop';\nimport BinaryCarrier from './binary_carrier';\nimport Reference from './reference';\nimport SpanContext from './span_context';\nimport Span from './span';\nimport Tracer from './tracer';\n\n\n// Use `module.exports` rather than `export` to avoid the need to use `.default`\n// when requiring the package in ES5 code.\nmodule.exports = Object.assign(\n {\n BinaryCarrier : BinaryCarrier,\n Reference : Reference,\n SpanContext : SpanContext,\n Span : Span,\n Tracer : Tracer,\n },\n Constants,\n GlobalTracer\n);\n\n// Initialize the noops last to avoid a dependecy cycle between the classes.\nnoop.initialize();\n"]}
+{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;AAAA;;IAAY,Y;;AACZ;;IAAY,S;;AACZ;;IAAY,I;;AACZ;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;AAEA;AACA;AACA,SAAS,OAAT,CAAiB,MAAjB,EAAyB;AACrB,SAAK,IAAI,QAAQ,CAAjB,EAAoB,QAAQ,UAAU,MAAtC,EAA8C,OAA9C,EAAuD;AACnD,YAAM,SAAS,UAAU,KAAV,CAAf;AACA,aAAK,IAAI,GAAT,IAAgB,MAAhB,EAAwB;AAAE;AACtB,gBAAI,OAAO,cAAP,CAAsB,GAAtB,CAAJ,EAAgC;AAC5B,uBAAO,GAAP,IAAc,OAAO,GAAP,CAAd;AACH;AACJ;AACJ;AACD,WAAO,MAAP;AACH;;AAGD;AACA;AACA,OAAO,OAAP,GAAiB,QACb;AACI,2CADJ;AAEI,kCAFJ;AAGI,uCAHJ;AAII,wBAJJ;AAKI;AALJ,CADa,EAQb,SARa,EASb,YATa,CAAjB;;AAYA;AACA,KAAK,UAAL","file":"index.js","sourcesContent":["import * as GlobalTracer from './global_tracer';\nimport * as Constants from './constants';\nimport * as noop from './noop';\nimport BinaryCarrier from './binary_carrier';\nimport Reference from './reference';\nimport SpanContext from './span_context';\nimport Span from './span';\nimport Tracer from './tracer';\n\n// Object.assign() is not available on Node v0.12, so implement a similar\n// function here (subset of a proper polyfill).\nfunction _extend(target) {\n for (let index = 1; index < arguments.length; index++) {\n const source = arguments[index];\n for (let key in source) { // eslint-disable-line no-restricted-syntax\n if (source.hasOwnProperty(key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n}\n\n\n// Use `module.exports` rather than `export` to avoid the need to use `.default`\n// when requiring the package in ES5 code.\nmodule.exports = _extend(\n {\n BinaryCarrier : BinaryCarrier,\n Reference : Reference,\n SpanContext : SpanContext,\n Span : Span,\n Tracer : Tracer,\n },\n Constants,\n GlobalTracer\n);\n\n// Initialize the noops last to avoid a dependecy cycle between the classes.\nnoop.initialize();\n"]}
View
@@ -36,9 +36,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+// Object.assign() is not available on Node v0.12, so implement a similar
+// function here (subset of a proper polyfill).
+function _extend(target) {
+ for (var index = 1; index < arguments.length; index++) {
+ var source = arguments[index];
+ for (var key in source) {
+ // eslint-disable-line no-restricted-syntax
+ if (source.hasOwnProperty(key)) {
+ target[key] = source[key];
+ }
+ }
+ }
+ return target;
+}
+
// Use `module.exports` rather than `export` to avoid the need to use `.default`
// when requiring the package in ES5 code.
-module.exports = Object.assign({
+module.exports = _extend({
BinaryCarrier: _binary_carrier2.default,
Reference: _reference2.default,
SpanContext: _span_context2.default,
View
@@ -1 +1 @@
-{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;AAAA;;IAAY,Y;;AACZ;;IAAY,S;;AACZ;;IAAY,I;;AACZ;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;AAGA;AACA;AACA,OAAO,OAAP,GAAiB,OAAO,MAAP,CACb;AACI,2CADJ;AAEI,kCAFJ;AAGI,uCAHJ;AAII,wBAJJ;AAKI;AALJ,CADa,EAQb,SARa,EASb,YATa,CAAjB;;AAYA;AACA,KAAK,UAAL","file":"index.js","sourcesContent":["import * as GlobalTracer from './global_tracer';\nimport * as Constants from './constants';\nimport * as noop from './noop';\nimport BinaryCarrier from './binary_carrier';\nimport Reference from './reference';\nimport SpanContext from './span_context';\nimport Span from './span';\nimport Tracer from './tracer';\n\n\n// Use `module.exports` rather than `export` to avoid the need to use `.default`\n// when requiring the package in ES5 code.\nmodule.exports = Object.assign(\n {\n BinaryCarrier : BinaryCarrier,\n Reference : Reference,\n SpanContext : SpanContext,\n Span : Span,\n Tracer : Tracer,\n },\n Constants,\n GlobalTracer\n);\n\n// Initialize the noops last to avoid a dependecy cycle between the classes.\nnoop.initialize();\n"]}
+{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;AAAA;;IAAY,Y;;AACZ;;IAAY,S;;AACZ;;IAAY,I;;AACZ;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;AAEA;AACA;AACA,SAAS,OAAT,CAAiB,MAAjB,EAAyB;AACrB,SAAK,IAAI,QAAQ,CAAjB,EAAoB,QAAQ,UAAU,MAAtC,EAA8C,OAA9C,EAAuD;AACnD,YAAM,SAAS,UAAU,KAAV,CAAf;AACA,aAAK,IAAI,GAAT,IAAgB,MAAhB,EAAwB;AAAE;AACtB,gBAAI,OAAO,cAAP,CAAsB,GAAtB,CAAJ,EAAgC;AAC5B,uBAAO,GAAP,IAAc,OAAO,GAAP,CAAd;AACH;AACJ;AACJ;AACD,WAAO,MAAP;AACH;;AAGD;AACA;AACA,OAAO,OAAP,GAAiB,QACb;AACI,2CADJ;AAEI,kCAFJ;AAGI,uCAHJ;AAII,wBAJJ;AAKI;AALJ,CADa,EAQb,SARa,EASb,YATa,CAAjB;;AAYA;AACA,KAAK,UAAL","file":"index.js","sourcesContent":["import * as GlobalTracer from './global_tracer';\nimport * as Constants from './constants';\nimport * as noop from './noop';\nimport BinaryCarrier from './binary_carrier';\nimport Reference from './reference';\nimport SpanContext from './span_context';\nimport Span from './span';\nimport Tracer from './tracer';\n\n// Object.assign() is not available on Node v0.12, so implement a similar\n// function here (subset of a proper polyfill).\nfunction _extend(target) {\n for (let index = 1; index < arguments.length; index++) {\n const source = arguments[index];\n for (let key in source) { // eslint-disable-line no-restricted-syntax\n if (source.hasOwnProperty(key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n}\n\n\n// Use `module.exports` rather than `export` to avoid the need to use `.default`\n// when requiring the package in ES5 code.\nmodule.exports = _extend(\n {\n BinaryCarrier : BinaryCarrier,\n Reference : Reference,\n SpanContext : SpanContext,\n Span : Span,\n Tracer : Tracer,\n },\n Constants,\n GlobalTracer\n);\n\n// Initialize the noops last to avoid a dependecy cycle between the classes.\nnoop.initialize();\n"]}
@@ -2,4 +2,4 @@
docker run -t --rm --name test-runner-opentracing-javascript \
-v ${PWD}:/usr/src/opentracing -w /usr/src/opentracing \
- node:$1 npm test
+ node:$1 make test-no-coverage
View
@@ -7,10 +7,24 @@ import SpanContext from './span_context';
import Span from './span';
import Tracer from './tracer';
+// Object.assign() is not available on Node v0.12, so implement a similar
+// function here (subset of a proper polyfill).
+function _extend(target) {
+ for (let index = 1; index < arguments.length; index++) {
+ const source = arguments[index];
+ for (let key in source) { // eslint-disable-line no-restricted-syntax
+ if (source.hasOwnProperty(key)) {
+ target[key] = source[key];
+ }
+ }
+ }
+ return target;
+}
+
// Use `module.exports` rather than `export` to avoid the need to use `.default`
// when requiring the package in ES5 code.
-module.exports = Object.assign(
+module.exports = _extend(
{
BinaryCarrier : BinaryCarrier,
Reference : Reference,

0 comments on commit ca32d42

Please sign in to comment.