dancasey / json-schema-default-instance

Creates an object as an instance of the given schema using its default properties.
https://www.npmjs.com/package/json-schema-default-instance
3 stars 1 forks source link

Rewrite as classless functions #4

Open dancasey opened 7 years ago

dancasey commented 7 years ago

As @alexkuz pointed out, there's not a need for this module to be a class. My initial thought would be to make the user instantiate ajv with the schema, and then pass this module's function the ajv instance and the schema id string.

alexkuz commented 7 years ago

Yes, that would be the best option. Currently I moved ajv instance creation inside constructor (otherwise there could be conflicts since different instances use the same ajv instance), but it would be easier to handle ajv myself and pass it to a function.