Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 78 lines (57 sloc) 2.991 kb
93b0b26 Clean up README
Ryan Patterson authored
1 # jsgrep / jspatch - toolkit for searching and modifying JavaScript
b676cbf Added a README file.
Ryan Patterson authored
2
93b0b26 Clean up README
Ryan Patterson authored
3 **Jsgrep** is program that searches for a particular JavaScript pattern using
4 the abstract syntax tree (AST) of the program. This enables matching expressions
4c6b655 Add support for loose object matching
Ryan Patterson authored
5 based on their JavaScript meaning, rather than based on simple strings.
93b0b26 Clean up README
Ryan Patterson authored
6 **Jspatch** is a tool to take that information and programmatically modify the
7 original source code.
b676cbf Added a README file.
Ryan Patterson authored
8
93b0b26 Clean up README
Ryan Patterson authored
9 ## Example
2cf1d47 Add support for ...
Ryan Patterson authored
10
93b0b26 Clean up README
Ryan Patterson authored
11 **Jsgrep: find Javelin classes that have a 'path' property**
4c6b655 Add support for loose object matching
Ryan Patterson authored
12
13 $ jsgrep -p C "JX.install(C, { properties: { path: X } })" tests/*.js
14 tests/javelin.js: 'Event'
15 tests/javelin.js: 'URI'
16
93b0b26 Clean up README
Ryan Patterson authored
17 Jsgrep allows easily drilling into the structure of JavaScript classes. In this
18 example, jsgrep finds Javelin classes that contain a 'path' property. The class
19 name is stored in the metavariable C, which will be output.
759c7c1 Sed mode for jspatch
Ryan Patterson authored
20
93b0b26 Clean up README
Ryan Patterson authored
21 **Jspatch: replace setTimeout with window.setTimeout in jQuery**
759c7c1 Sed mode for jspatch
Ryan Patterson authored
22
25774f5 Improved patch file processing
Ryan Patterson authored
23 $ jspatch -e 's/setTimeout( A, B )/window.setTimeout( A, B )/' tests/jquery.js
759c7c1 Sed mode for jspatch
Ryan Patterson authored
24 --- tests/jquery.js 2012-01-10 14:51:36.000000000 -0800
25 +++ /tmp/jspatch.jquery.js 2012-01-11 17:13:56.000000000 -0800
26 @@ -420,7 +420,7 @@
27 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
28 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
29 if ( !document.body ) {
30 - return setTimeout( jQuery.ready, 1 );
31 + return window.setTimeout( jQuery.ready, 1 );
32 }
33
34 // Remember that the DOM is ready
35 @@ -1987,7 +1987,7 @@
36 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
37 // Give room for hard-coded callbacks to fire first
38 // and eventually mark/queue something else on the element
39 - setTimeout( function() {
40 + window.setTimeout( function() {
41 if ( !jQuery._data( elem, queueDataKey ) &&
42 !jQuery._data( elem, markDataKey ) ) {
43 jQuery.removeData( elem, deferDataKey, true );
44
93b0b26 Clean up README
Ryan Patterson authored
45 Jspatch supports a versatile patch file format that can perform far more complex
46 transformations as well. For more information, see the
47 [online documentation](https://github.com/facebook/jsgrep/wiki).
48
49 ## Installation
50
51 npm install jsgrep-toolkit
52
53 To install from source code:
54
d59ed60 Fix installation remote
Ryan Patterson authored
55 git clone https://github.com/facebook/jsgrep.git
93b0b26 Clean up README
Ryan Patterson authored
56 cd jsgrep
57 git submodule update --init
58 npm install
25774f5 Improved patch file processing
Ryan Patterson authored
59
58384b5 Updated README
Ryan Patterson authored
60 ## TODO
61
8bb3d60 Add some protection to metavars
Ryan Patterson authored
62 * Consider a metavar that matches but doesn't save, to prevent ambiguities.
25774f5 Improved patch file processing
Ryan Patterson authored
63 * Rewrite forEachNode to be iterative rather than recursive (to fix ...)
2cf1d47 Add support for ...
Ryan Patterson authored
64 * Consider support for --where/--eval and/or not-patterns
4c6b655 Add support for loose object matching
Ryan Patterson authored
65 * Support for most statements in patterns
612f1f0 [WIP] jspatch
Ryan Patterson authored
66 * Formally testing the pattern matchers
58384b5 Updated README
Ryan Patterson authored
67
759c7c1 Sed mode for jspatch
Ryan Patterson authored
68 jspatch:
69
25774f5 Improved patch file processing
Ryan Patterson authored
70 * Testing
759c7c1 Sed mode for jspatch
Ryan Patterson authored
71
58384b5 Updated README
Ryan Patterson authored
72 ## Contributors
73
74 Jsgrep was written by Ryan Patterson at Facebook. Inspiration for this project
75 draws heavily from pfff, a source code analyzer written at Facebook.
76
77 * pfff - https://github.com/facebook/pfff
Something went wrong with that request. Please try again.