Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-restructure

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-restructure - npm Package Compare versions

Comparing version 1.0.5 to 1.0.7

2

index.js

@@ -5,3 +5,3 @@ module.exports = function matcher(obj, flags) {

var re = new RegExp(props.reduce(function(p, c) {
if(isNaN(c)) {
if(!isNaN(c)) {
throw new TypeError("Object with numeric keys are not supported");

@@ -8,0 +8,0 @@ }

{
"name": "js-restructure",
"version": "1.0.5",
"version": "1.0.7",
"description": "This package provides a nifty way to match against regular expressions\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001bconstruct and match against regular expressions.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -80,2 +80,12 @@ # js-restructure

## Browser Support
Any ES5 capable browser is supported meaning IE9+, Firefox, Chrome, Safari and all modern mobile browsers.
## Contribution
Contribution is very welcome and friendliness is a project goal. Feel free to open issues and feature requests. Pull requests are also very welcome.
We indent with two spaces and the code is ES5.
## Todo

@@ -82,0 +92,0 @@

@@ -8,3 +8,3 @@ var matcher = require("./index.js");

});
it("matches two string", function(){
it("matches two string", function() {
var m = matcher({x:"[A-Z]", y:"[A-Z]"})("AB");

@@ -14,15 +14,15 @@ assert.equal(m.x, "A");

});
it("matches multi character strings", function(){
it("matches multi character strings", function() {
var m = matcher({x:"[A-Z]+"})("AB");
assert.equal(m.x, "AB");
});
it("matches lazily when it has to", function(){
it("matches lazily when it has to", function() {
var m = matcher({x:"[A-Z]+?", _:"C"})("ABCD");
assert.equal(m.x, "AB");
});
it("matches numbers", function(){
it("matches numbers", function() {
var m = matcher({x:"\\d+"})("123123");
assert.equal(m.x, "123123");
});
it("matches emails", function(){
it("matches emails", function() {
var m = matcher({

@@ -38,3 +38,3 @@ _ : "^",

});
it("matches primitive http/s urls", function(){
it("matches primitive http/s urls", function() {
var m = matcher({

@@ -53,3 +53,3 @@ protocol : "http|https",

});
it("parses 'primitive' CSV", function(){
it("parses 'primitive' CSV", function() {
var p = matcher({

@@ -68,2 +68,8 @@ first : "\\w+?",

});
it("works with dynamic objects", function() {
var o = {};
o["A"] = "A";
var p = matcher(o)("A").A;
assert.equal(p, "A");
});
it("parses HTML", function(){

@@ -90,3 +96,3 @@ var he = matcher({

});
it("matches emails with RE syntax", function(){
it("matches emails with RE syntax", function() {
var m = matcher({

@@ -102,3 +108,3 @@ _ : /^/,

});
it("accepts flags as a second parameter", function(){
it("accepts flags as a second parameter", function() {
var m = matcher({

@@ -109,3 +115,3 @@ x: "a+",

});
it("behaves like native RE on invalid flags", function(){
it("behaves like native RE on invalid flags", function() {
assert.throws(function() {

@@ -115,4 +121,23 @@ var m = matcher({

}, "13qwshfd")("aAAAAA");
);
});
});
it("throws on objects with numeric keys (inconsistent iteration order)",
function(){
assert.throws(function() {
var m = matcher([1,2,3]);
});
});
it("works with a large number of properties", function() {
var o = {};
var str = "";
for(var i = 0; i < 100; i++) {
o["x_" + i] = "A";
str += "A"
}
var parser = matcher(o);
var o2 = parser(str);
assert.equal(o2.x_50, "A");
assert.equal(o2.x_99, "A");
assert.equal(o2.x_0, "A");
});
});
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