{"action":"created","issue":{"url":"https://api.github.com/repos/TabDigital/strummer/issues/25","labels_url":"https://api.github.com/repos/TabDigital/strummer/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/TabDigital/strummer/issues/25/comments","events_url":"https://api.github.com/repos/TabDigital/strummer/issues/25/events","html_url":"https://github.com/TabDigital/strummer/pull/25","id":68853415,"number":25,"title":"Work in progress: faster prototype-based version","user":{"login":"rprieto","id":189105,"avatar_url":"https://avatars.githubusercontent.com/u/189105?v=3","gravatar_id":"","url":"https://api.github.com/users/rprieto","html_url":"https://github.com/rprieto","followers_url":"https://api.github.com/users/rprieto/followers","following_url":"https://api.github.com/users/rprieto/following{/other_user}","gists_url":"https://api.github.com/users/rprieto/gists{/gist_id}","starred_url":"https://api.github.com/users/rprieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rprieto/subscriptions","organizations_url":"https://api.github.com/users/rprieto/orgs","repos_url":"https://api.github.com/users/rprieto/repos","events_url":"https://api.github.com/users/rprieto/events{/privacy}","received_events_url":"https://api.github.com/users/rprieto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-16T06:12:51Z","updated_at":"2015-04-18T12:35:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/TabDigital/strummer/pulls/25","html_url":"https://github.com/TabDigital/strummer/pull/25","diff_url":"https://github.com/TabDigital/strummer/pull/25.diff","patch_url":"https://github.com/TabDigital/strummer/pull/25.patch"},"body":":bulb: Idea: strummer based on prototypes to avoid functions being re-created all the time :bulb: \r\n\r\n- seems about `2x` as fast, based on `performance.spec.js`\r\n\r\n| strummer version | iterations | time       |\r\n|-------------------------|--------------|------------|\r\n| v1 | 10,000 | 235ms\r\n| v2 | 10,000 |  122ms\r\n\r\n- haven't made any other tests pass yet\r\n\r\n:sob: \r\n\r\n- changes the syntax slightly\r\n\r\n```js\r\nnew s.object({name: 'string'})\r\n```\r\n\r\n- fixes inconsistencies \r\n\r\n```js\r\n// with the old strummer\r\ns({name: 'string'})(value) //ok\r\ns.object({name: 'string'})(value) // not ok, you need to pass <path> as a first arg\r\ns(s.object({name: 'string')) // ok\r\n\r\n// with the new strummer, both work\r\nnew s.object({name: 'string'}).match(value)\r\nnew s.object({name: 'string'}).match(path, value)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/TabDigital/strummer/issues/comments/94162768","html_url":"https://github.com/TabDigital/strummer/pull/25#issuecomment-94162768","issue_url":"https://api.github.com/repos/TabDigital/strummer/issues/25","id":94162768,"user":{"login":"kiddkai","id":1309053,"avatar_url":"https://avatars.githubusercontent.com/u/1309053?v=3","gravatar_id":"","url":"https://api.github.com/users/kiddkai","html_url":"https://github.com/kiddkai","followers_url":"https://api.github.com/users/kiddkai/followers","following_url":"https://api.github.com/users/kiddkai/following{/other_user}","gists_url":"https://api.github.com/users/kiddkai/gists{/gist_id}","starred_url":"https://api.github.com/users/kiddkai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiddkai/subscriptions","organizations_url":"https://api.github.com/users/kiddkai/orgs","repos_url":"https://api.github.com/users/kiddkai/repos","events_url":"https://api.github.com/users/kiddkai/events{/privacy}","received_events_url":"https://api.github.com/users/kiddkai/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T12:35:51Z","updated_at":"2015-04-18T12:35:51Z","body":"Yeah, but using the prototype way to doing this, we can using some kind of object composition to to that, like:\r\n\r\n```js\r\nvar CustomMatcher = s.createMatcher({\r\n  initialize: function() {\r\n    this.subMatcher =  new s.number();\r\n  },\r\n  match: function(path, value) {\r\n    return this.subMatcher.match(path, value);\r\n  }\r\n});\r\n```\r\n\r\nAnyway, we can make something like the previous functional, just few line changes of the compile function to adepts `a matcher can return anther matcher`, just want some actual example to see if it's make sense in this prototype version.\r\n\r\nThe `createMatcher` or `factory` is pretty simple now. Adding `babeljs` is a great idea. The reason why I didn't add it is because I am  not quite sure if we really needs the whole `babel` to supports the only `class` inherits syntax. But it's more fun to doing that way. For the other developers not using `babel` I think it may still necessary to adding some kind of `helper` to create a Matcher to hide the Matcher inherit in our side. Like some library:\r\n\r\n```js\r\nvar CommentBox = React.createClass({\r\n  render: function() {\r\n    return (\r\n    );\r\n  }\r\n});\r\n\r\n"}}