mirror of
				https://github.com/flynx/diff.js.git
				synced 2025-10-31 03:50:13 +00:00 
			
		
		
		
	more tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									a4a525b84a
								
							
						
					
					
						commit
						9e76bf867b
					
				
							
								
								
									
										24
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								README.md
									
									
									
									
									
								
							| @ -15,6 +15,7 @@ | |||||||
| 	- [Diff](#diff) | 	- [Diff](#diff) | ||||||
| 		- [Diff class API](#diff-class-api) | 		- [Diff class API](#diff-class-api) | ||||||
| 		- [Diff object API](#diff-object-api) | 		- [Diff object API](#diff-object-api) | ||||||
|  | 		- [Shorthands and functions](#shorthands-and-functions) | ||||||
| 		- [Supported JavaScript objects](#supported-javascript-objects) | 		- [Supported JavaScript objects](#supported-javascript-objects) | ||||||
| 		- [Extended 'Text' object support](#extended-text-object-support) | 		- [Extended 'Text' object support](#extended-text-object-support) | ||||||
| 		- [Options](#options) | 		- [Options](#options) | ||||||
| @ -267,7 +268,10 @@ var diff = new Diff(A, B) | |||||||
| `Diff.cmp(A, B) -> bool`   | `Diff.cmp(A, B) -> bool`   | ||||||
| Deep compare `A` to `B`. | Deep compare `A` to `B`. | ||||||
| 
 | 
 | ||||||
| `Diff.clone(<title>)`   | `Diff.vars(pattern, A) -> obj`   | ||||||
|  | Get variable values defined (via `VAR`/`LIKE`) in `pattern` matching corresponding values in `obj`. | ||||||
|  | 
 | ||||||
|  | `Diff.clone(title)`   | ||||||
| Clone the `Diff` constructor, useful for extending or tweaking the type handlers (see: [Extending](#extending-diff) below). | Clone the `Diff` constructor, useful for extending or tweaking the type handlers (see: [Extending](#extending-diff) below). | ||||||
| 
 | 
 | ||||||
| `Diff.fromJSON(json) -> diff`   | `Diff.fromJSON(json) -> diff`   | ||||||
| @ -313,6 +317,24 @@ Return the *parent diff* that was used to generate the current *child diff* or t | |||||||
| Serialize the *diff* to JSON. Note that the output may or may not be JSON compatible depending on the inputs. | Serialize the *diff* to JSON. Note that the output may or may not be JSON compatible depending on the inputs. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | ### Shorthands and functions | ||||||
|  | 
 | ||||||
|  | `cmp(A, B) -> bool`   | ||||||
|  | Deep compare `A` and `B`. | ||||||
|  | 
 | ||||||
|  | This is a shorthand to: `Diff.cmp(A, B) -> bool` | ||||||
|  | 
 | ||||||
|  | `patch(diff, A) -> A'`   | ||||||
|  | Apply changes in `diff` to `A` (*patch*). | ||||||
|  | 
 | ||||||
|  | This is a shorthand to: `diff.patch(A) -> A'` | ||||||
|  | 
 | ||||||
|  | `vars(pattern, A) -> obj`   | ||||||
|  | Get variable values defined (via `VAR`/`LIKE`) in `pattern` matching corresponding values in `obj`. | ||||||
|  | 
 | ||||||
|  | This is a shorthand to: `Diff.vars(pattern, B) -> obj` | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| ### Supported JavaScript objects | ### Supported JavaScript objects | ||||||
| 
 | 
 | ||||||
| The object support can be split into two, basic objects that are stored as-is and containers that support item changes when their types match. | The object support can be split into two, basic objects that are stored as-is and containers that support item changes when their types match. | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								diff.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								diff.js
									
									
									
									
									
								
							| @ -2347,6 +2347,11 @@ var DiffClassPrototype = { | |||||||
| 
 | 
 | ||||||
| 	// proxy generic stuff to .types...
 | 	// proxy generic stuff to .types...
 | ||||||
| 	cmp: proxy('types.cmp'), | 	cmp: proxy('types.cmp'), | ||||||
|  | 	vars: function(pattern, obj){ | ||||||
|  | 		var o = {} | ||||||
|  | 		this.cmp(pattern, obj, null, o) | ||||||
|  | 		return o.ns || {} | ||||||
|  | 	}, | ||||||
| 
 | 
 | ||||||
| 	// XXX do format/version conversion...
 | 	// XXX do format/version conversion...
 | ||||||
| 	fromJSON: function(json){ | 	fromJSON: function(json){ | ||||||
| @ -2529,6 +2534,13 @@ function(diff, obj, options, types){ | |||||||
| 		.patch(obj, options) } | 		.patch(obj, options) } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // Extract pattern VAR/LIKE matching values from obj...
 | ||||||
|  | //
 | ||||||
|  | var vars = | ||||||
|  | module.vars = | ||||||
|  | function(pattern, obj){ | ||||||
|  | 	return Diff.vars(pattern, obj) } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user