Skip to content

Commit

Permalink
use camelcase lib instead of local implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bertvannuffelen committed Apr 2, 2020
1 parent 1ee1b72 commit 6f2d042
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions json-ld-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const jsonfile = require('jsonfile')
// const jsonld = require('jsonld')
const Set = require('collections/set')
const Map = require('collections/map')
const camelCase = require('camelcase')

var program = require('commander')

Expand Down Expand Up @@ -82,15 +83,27 @@ function identify_duplicates (properties) {
};

// auxiliary function to convert a string into CamelCase
/*
const toCamelCase = str =>
str.toLowerCase()
.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase())
*/

const capitalizeFirst = (s) => {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}

// auxiliary function to convert to camelcase with dealing special cases
// TODO: what are the guidelines for contextual scoping in the labels?
function toCamelCase (str) {
str = camelCase(str)
// console.log(str)
str = str.replace(/\s\(source\)/g, '(source)').replace(/\s\(target\)/g, '(target)')
// console.log(' -> ' + str)
return str
};

// map an entity prop to its term
function map_identifier (prop) {
let identifier = ''
Expand Down

0 comments on commit 6f2d042

Please sign in to comment.