Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a487985

Browse files
Remove custom error handler & Add undefined as an empty type
1 parent d4d032d commit a487985

File tree

8 files changed

+13
-36
lines changed

8 files changed

+13
-36
lines changed

‎dist/json-knife.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-knife",
3-
"version": "1.2.2",
3+
"version": "1.3.0",
44
"description": "Bulk set properties recursively in huge, complex and deep JSON string with a robust regular expression based engine",
55
"main": "src/entry.js",
66
"scripts": {

‎public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
console.log(re1);
118118
JSON.parse(re1)
119119

120-
let re2 = Pattern.sculptJson(original, 'friends', 300);
120+
/* let re2 = Pattern.sculptJson(original, 'friends', 300);
121121
console.log('Bulk update - friends : 300');
122122
console.log(re2);
123123
JSON.parse(re2);
@@ -135,7 +135,7 @@
135135
let re5 = Pattern.sculptJson(src, 'dose', 15.333);
136136
console.log('Bulk update - dose : 15.333');
137137
console.log(re5);
138-
JSON.parse(re5);
138+
JSON.parse(re5);*/
139139

140140

141141

‎src/controller.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Service from './service';
2-
import ValidationError from './error-handler';
32

43
/**
54
* @brief
@@ -13,13 +12,13 @@ import ValidationError from './error-handler';
1312
function sculptJson(original, key, value){
1413

1514
if (!(original && typeof original === 'string')) {
16-
throw new ValidationError('the variable "original" must be a string type and not be null.');
15+
throw new Error('the variable "original" must be a string type and not be null.');
1716
}else if (!(key && typeof key === 'string')) {
18-
throw new ValidationError('the variable "key" must be a string type and not be null.');
17+
throw new Error('the variable "key" must be a string type and not be null.');
1918
}else if (/"/.test(key)) {
20-
throw new ValidationError('the variable "key" must not contain double quotes, but this can be allowed in the next version.');
19+
throw new Error('the variable "key" must not contain double quotes, but this can be allowed in the next version.');
2120
}else if (! ((value && (typeof value === 'string' || typeof value === 'number'|| typeof value === 'boolean')) || (typeof value == 'object' && value == null))) {
22-
throw new ValidationError('the variable "value" must be a string or number or boolean or null.');
21+
throw new Error('the variable "value" must be a string or number or boolean or null.');
2322
}
2423

2524
if(value && typeof value === 'string') {

‎src/error-handler.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎src/pattern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const jsonBase = {
3838
// 6
3939
array: '(\\[)',
4040
// 7
41-
empty: '(null)',
41+
empty: '(null|undefined)',
4242
// 7
4343
emptyObject: '{' + commons.spaceOrNot + '}',
4444

‎src/service.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Pattern from './pattern';
2-
import ValidationError from './error-handler';
32
import Util from './util';
43

54

@@ -218,7 +217,7 @@ function getMaterials(original, key, value) {
218217

219218
extractedAreas.push({
220219
value: value,
221-
aaa : match[matchedGroupNumber],
220+
//aaa : match[matchedGroupNumber],
222221
matchedKeyValue: matchedKeyValue,
223222
newMatchedKeyValue: newMatchedKeyValue,
224223
startIndex: startIndex,
@@ -228,9 +227,9 @@ function getMaterials(original, key, value) {
228227
idx += 1;
229228
}
230229

231-
// console.log('(注記) getMaterials');
232-
// console.log(keySteps);
233-
// console.log(extractedAreas);
230+
//console.log('(注記) getMaterials');
231+
//console.log(keySteps);
232+
//console.log(extractedAreas);
234233

235234
return extractedAreas;
236235
}

‎src/util.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* Private : Utils
33
* */
4-
import ValidationError from './error-handler';
54
import Pattern from './pattern';
65

76
const Text = {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /