New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

genmo

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genmo - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

5

package.json
{
"name": "genmo",
"version": "0.1.2",
"version": "0.2.0",
"description": "Generates models based off of json-schemas",

@@ -19,3 +19,4 @@ "main": "index.js",

"dependencies": {
"lorem-ipsum": "^1.0.3"
"lorem-ipsum": "^1.0.3",
"randexp": "0.4.2"
},

@@ -22,0 +23,0 @@ "devDependencies": {

14

strategies/string.js
var loremIpsum = require('lorem-ipsum')
var randexp = require('randexp').randexp
module.exports = function (schema) {
return loremIpsum()
var minLength = schema.minLength || 1
var maxLength = schema.maxLength || minLength + 10
var pattern = schema.pattern
if (pattern) {
return randexp(pattern)
} else {
var string = loremIpsum({
count: maxLength
})
return string.substr(0, Math.floor(Math.random() * maxLength + 1) + minLength )
}
}

@@ -11,1 +11,39 @@ var tape = require('tape')

})
tape('string respects max character limit', function (t) {
var schema = {
type: 'string',
maxLength: 10
}
var allBelow = true
for (var i = 0; i < 100; i++) {
allBelow = string(schema).length <= schema.maxLength
}
t.equal(allBelow, true)
t.end()
})
tape('string respects min character limit', function (t) {
var schema = {
type: 'string',
minLength: 5
}
var allAbove = true
for (var i = 0; i < 100; i++) {
allAbove = string(schema).length > schema.minLength
}
t.equal(allAbove, true)
t.end()
})
tape('string will generate matches for regular expressions', function (t) {
var regex = '^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'
var schema = {
type: 'string',
pattern: regex
}
var s = string(schema)
console.log(s)
t.equal(new RegExp(regex).test(s), true)
t.end()
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc