Skip to content

Commit 44f9f5a

Browse files
authored
Merge pull request #389 from lutovich/1.6-padStart-not-a-function
Fix 'padStart is not a function' error in NodeJS 4 and 6
2 parents 0ce603e + 3347080 commit 44f9f5a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"gulp-util": "^3.0.6",
5353
"gulp-watch": "^4.3.5",
5454
"jasmine-console-reporter": "^2.0.1",
55-
"karma": "^1.7.1",
55+
"karma": "^2.0.3",
5656
"karma-chrome-launcher": "^2.2.0",
5757
"karma-edge-launcher": "^0.4.2",
58-
"karma-firefox-launcher": "^1.0.1",
58+
"karma-firefox-launcher": "^1.1.0",
5959
"karma-ie-launcher": "^1.0.0",
60-
"karma-jasmine": "^1.1.0",
61-
"karma-spec-reporter": "^0.0.31",
60+
"karma-jasmine": "^1.1.2",
61+
"karma-spec-reporter": "^0.0.32",
6262
"lodash": "^4.17.4",
6363
"lolex": "^1.5.2",
6464
"minimist": "^1.2.0",

src/v1/internal/temporal-util.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,13 @@ function formatNumber(num, stringLength = undefined) {
383383
if (isNegative) {
384384
num = num.negate();
385385
}
386-
const numString = num.toString();
387-
const paddedNumString = stringLength ? numString.padStart(stringLength, '0') : numString;
388-
return isNegative ? '-' + paddedNumString : paddedNumString;
386+
387+
let numString = num.toString();
388+
if (stringLength) {
389+
// left pad the string with zeroes
390+
while (numString.length < stringLength) {
391+
numString = '0' + numString;
392+
}
393+
}
394+
return isNegative ? '-' + numString : numString;
389395
}

test/v1/session.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ describe('session', () => {
291291
const sum = result.summary;
292292
expect(sum.hasPlan()).toBe(true);
293293
expect(sum.hasProfile()).toBe(false);
294-
expect(sum.plan.operatorType).toBe('ProduceResults');
294+
expect(sum.plan.operatorType).toBeDefined();
295295
expect(isString(sum.plan.arguments.runtime)).toBeTruthy();
296296
expect(sum.plan.identifiers[0]).toBe('n');
297-
expect(sum.plan.children[0].operatorType).toBe('CreateNode');
297+
expect(sum.plan.children[0].operatorType).toBeDefined();
298298
done();
299299
});
300300
});
@@ -310,7 +310,7 @@ describe('session', () => {
310310
const sum = result.summary;
311311
expect(sum.hasPlan()).toBe(true); //When there's a profile, there's a plan
312312
expect(sum.hasProfile()).toBe(true);
313-
expect(sum.profile.operatorType).toBe('ProduceResults');
313+
expect(sum.profile.operatorType).toBeDefined();
314314
expect(isString(sum.profile.arguments.runtime)).toBeTruthy();
315315
expect(sum.profile.identifiers[0]).toBe('n');
316316
expect(sum.profile.children[0].operatorType).toBeDefined();

0 commit comments

Comments
 (0)