Skip to content

Commit e251403

Browse files
committed
Minor tweaks and folder rename
1 parent 2926894 commit e251403

13 files changed

+529
-538
lines changed

dist/json-schema-form-core.js

Lines changed: 471 additions & 483 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import * as schemaDefaultsImp from './lib/schemaDefaults';
2-
import * as sfPathImp from './lib/sfPath';
3-
import canonicalTitleMapImp from './lib/canonicalTitleMap';
4-
5-
export * from './lib/merge.js';
6-
export * from './lib/select.js';
7-
export * from './lib/traverse.js';
8-
export * from './lib/validate.js';
9-
10-
export const sfPath = sfPathImp;
11-
export const schemaDefaults = schemaDefaultsImp;
12-
export const canonicalTitleMap = canonicalTitleMapImp;
1+
export { schemaDefaults } from './src/schemaDefaults';
2+
export { canonicalTitleMap } from './src/canonicalTitleMap';
3+
export { sfPath } from './src/sfPath';
4+
export { merge } from './src/merge';
5+
export { select } from './src/select';
6+
export { traverse } from './src/traverse';
7+
export { validate } from './src/validate';

lib/sfPath.js

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

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-form-core",
3-
"version": "1.0.0-alpha.2",
3+
"version": "1.0.0-alpha.3",
44
"description": "Core library",
55
"main": "dist/json-schema-form-core.js",
66
"scripts": {
@@ -30,12 +30,14 @@
3030
},
3131
"devDependencies": {
3232
"babel-core": "^6.6.5",
33-
"babel-loader": "^6.2.4",
33+
"babel-loader": "^6.2.8",
3434
"babel-preset-es2015": "^6.6.0",
35+
"babel-preset-es2016": "^6.16.0",
36+
"babel-preset-latest": "^6.16.0",
3537
"chai": "^3.5.0",
3638
"mocha": "^2.4.5",
3739
"tv4": "^1.2.7",
38-
"webpack": "^1.12.14"
40+
"webpack": "^1.13.3"
3941
},
4042
"licenses": [
4143
{

lib/canonicalTitleMap.js renamed to src/canonicalTitleMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Takes a titleMap in either object or list format and returns one in
22
// in the list format.
3-
export default function(titleMap, originalEnum) {
3+
const canonicalTitleMap = function (titleMap, originalEnum) {
44
if (!Array.isArray(titleMap)) {
55
const canonical = [];
66
if (originalEnum) {
@@ -16,3 +16,5 @@ export default function(titleMap, originalEnum) {
1616
}
1717
return titleMap;
1818
}
19+
20+
export { canonicalTitleMap };

lib/merge.js renamed to src/merge.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {stringify, parse} from './sfPath';
2-
import canonicalTitleMap from './canonicalTitleMap';
2+
import { canonicalTitleMap } from './canonicalTitleMap';
33

44
//export function merge(schema, form, schemaDefaultTypes, ignore, options, readonly, asyncTemplates) {
5-
export function merge(lookup, form, options, readonly, asyncTemplates) {
5+
const merge = function (lookup, form, options, readonly, asyncTemplates) {
66
form = form || [];
77
options = options || {};
88

@@ -76,3 +76,4 @@ export function merge(lookup, form, options, readonly, asyncTemplates) {
7676
return obj;
7777
});
7878
}
79+
export { merge };

lib/schemaDefaults.js renamed to src/schemaDefaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {stringify} from './sfPath';
2-
import canonicalTitleMap from './canonicalTitleMap';
1+
import { stringify } from './sfPath';
2+
import { canonicalTitleMap } from './canonicalTitleMap';
33

44
/* Utils */
55
const stripNullType = (type) => {

lib/select.js renamed to src/select.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import sfPath from './sfPath';
2+
import { parse } from './sfPath';
33

44
const numRe = /^\d+$/;
55

@@ -19,12 +19,12 @@ const numRe = /^\d+$/;
1919
* @returns {Any|undefined} returns the value at the end of the projection path
2020
* or undefined if there is none.
2121
*/
22-
export function select(projection, obj, valueToSet) {
22+
const select = (projection, obj, valueToSet) => {
2323
if (!obj) {
2424
obj = this;
2525
}
2626
//Support [] array syntax
27-
var parts = typeof projection === 'string' ? sfPath.parse(projection) : projection;
27+
var parts = typeof projection === 'string' ? parse(projection) : projection;
2828

2929
if (typeof valueToSet !== 'undefined' && parts.length === 1) {
3030
//special case, just setting one variable
@@ -67,3 +67,5 @@ export function select(projection, obj, valueToSet) {
6767
}
6868
return value;
6969
}
70+
71+
export { select };

src/sfPath.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { parse, stringify, normalize } from 'objectpath';
2+
3+
const name = function(key, separator, formName, omitNumbers) {
4+
if(key) {
5+
var fieldKey = key.slice();
6+
var fieldSeparator = separator || '-';
7+
8+
if(omitNumbers){
9+
fieldKey = fieldKey.filter(function(key){
10+
return typeof key !== 'number';
11+
});
12+
};
13+
14+
return ((formName) ? formName + fieldSeparator : '') + fieldKey.join(fieldSeparator);
15+
};
16+
17+
return '';
18+
};
19+
20+
export { name, parse, stringify, normalize };

lib/traverse.js renamed to src/traverse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Traverse a schema, applying a function(schema,path) on every sub schema
33
* i.e. every property of an object.
44
*/
5-
export function traverseSchema(schema, fn, path, ignoreArrays) {
5+
const traverseSchema = function (schema, fn, path, ignoreArrays) {
66
ignoreArrays = ignoreArrays === undefined ? true : ignoreArrays;
77

88
path = path || [];
@@ -45,3 +45,4 @@ export function traverseForm(form, fn) {
4545
});
4646
}
4747
}
48+
export { traverseSchema };

lib/validate.js renamed to src/validate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import tv4 from 'tv4';
1010
* @param {Any} value the value to validate.
1111
* @return {Object} a tv4js result object.
1212
*/
13-
export function validate(form, value) {
13+
const validate = function (form, value) {
1414
if (!form) {
1515
return { valid: true };
1616
};
@@ -51,3 +51,5 @@ export function validate(form, value) {
5151

5252
return tv4.validateResult(valueWrap, wrap);
5353
};
54+
55+
export { validate };

test/schemaDefaults-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import chai from 'chai';
3-
import {describe, it} from 'mocha';
4-
import {defaultForm, createDefaults } from '../lib/schemaDefaults';
3+
import { describe, it} from 'mocha';
4+
import { defaultForm, createDefaults } from '../src/schemaDefaults';
55

66
chai.should();
77

webpack.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
var webpack = require('webpack');
33
var path = require('path');
44
var pjson = require('./package.json');
5+
var library = 'JSONSchemaFormCore';
56
console.log('JSON Schema Form Core v' + pjson.version);
67

78
module.exports = {
89
entry: [ './index.js' ],
910
output: {
1011
path: path.join(__dirname, 'dist'),
1112
filename: 'json-schema-form-core.js',
12-
libraryTarget: 'umd'
13+
library: library,
14+
libraryTarget: 'umd',
15+
umdNamedDefine: true
1316
},
1417
resolve: { extensions: [ '', '.js' ] },
1518
module: {
@@ -27,9 +30,8 @@ module.exports = {
2730
},
2831
plugins: [
2932
new webpack.BannerPlugin(
30-
'json-schema-form\n' +
31-
'@version ' +
32-
pjson.version + '\n' +
33+
'json-schema-form-core\n' +
34+
'@version ' + pjson.version + '\n' +
3335
'@link https://github.com/json-schema-form/json-schema-form-core\n' +
3436
'@license MIT\n' +
3537
'Copyright (c) 2016 JSON Schema Form')

0 commit comments

Comments
 (0)