Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Create a common util module that can be used by all the translators. #39

Open
sanjaiganesh opened this issue Aug 6, 2016 · 2 comments

Comments

@sanjaiganesh
Copy link
Contributor

An example:

function validateArgumentType(arg, argName, expectedType) {
if (typeof arg === 'undefined') {
throw new Error('Missing argument: ' + argName + '. ' +
'Expected type: ' + expectedType + '.');
} else if (typeof arg !== expectedType) {
throw new Error('Invalid argument: ' + argName + '. ' +
'Expected type: ' + expectedType + ', got: ' + (typeof arg));
}
}

@tjaffri
Copy link
Contributor

tjaffri commented Aug 22, 2016

Just to poke this issue a bit... @jeanpa @jasongin @arjun-msft what do you guys think? Where does such common code live long term?

My suggestion:

  1. We create a new node module opent2t-translator and put all functionality core to translators inside this module. We start with this argument validator but put other stuff (e.g. common logging methods) in there that all translators will need.
  2. We put this new module under a new top-level repo called opent2t-translator.

What do you guys think? For now we can have lots of code duplication but we need to clean this up as we write more translators.

@jasongin
Copy link
Contributor

jasongin commented Aug 22, 2016

new top-level repo called opent2t-translator

I'm not opposed to a new repo, but I think that name would be super confusing.

I might be in favor of just putting that kind of common code in the opent2t repo. Translator packages already have a dependency on part of that opent2t package for the schema readers. And just like the schema readers it could be under a separate directory (effectively a sub-package), and it would not necessarily need to be projected in client APIs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants