Skip to content

Commit 350a6a7

Browse files
committed
Initial commit.
0 parents  commit 350a6a7

File tree

7 files changed

+1157
-0
lines changed

7 files changed

+1157
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
components
2+
build

History.md

Whitespace-only changes.

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
build: components index.js
3+
@component build --dev
4+
5+
components: component.json
6+
@component install --dev
7+
8+
clean:
9+
rm -fr build components template.js
10+
11+
.PHONY: clean

Readme.md

+226
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
2+
# patch
3+
4+
Creates patches from diffs, and applies them. This component is a simple wrapper around [diff match patch](https://code.google.com/p/google-diff-match-patch/), by Neil Fraser from Google.
5+
6+
This component is a companion to https://github.com/component/diff .
7+
8+
## Installation
9+
10+
Install with [component(1)](http://component.io):
11+
12+
$ component install component/patch
13+
14+
## API
15+
16+
### patch(oldText, diff)
17+
18+
Creates a patch from the original text and a diff generated by `component/diff`. *This is the most efficient and prefered call for creating a patch.*
19+
20+
### patch(oldText, delta)
21+
22+
(For convenience) Creates a patch from the original text and a delta string generated by `component/diff`. The diff is produced internally from the old text and the delta string.
23+
24+
### patch(diff)
25+
26+
Creates a patch from a diff generated by `component/diff`. The old text is extracted internally from the diff.
27+
28+
### patch.apply(p, text[, report])
29+
30+
Fuzzily applies the patch `p` to `text`, on a best-effort basis.
31+
32+
Thanks to the *Diff Match Patch* library used internally, this function is smart enough
33+
to accomodate for small changes on the text where the patch is being applied, allowing for
34+
merges.
35+
36+
The optional `report` parameter specifies
37+
whether a report (containing what pieces of the patch were succesfully applied)
38+
should also be returned. If this parameter is set to `true`, the function returns
39+
an array with two elements: the resulting text and an array of boolean values.
40+
41+
### patch.toText()
42+
43+
Converts a patch to a string representation
44+
45+
### patch.fromText()
46+
47+
Converts a string representation of a patch back into a patch
48+
49+
## License
50+
51+
Apache License
52+
Version 2.0, January 2004
53+
http://www.apache.org/licenses/
54+
55+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
56+
57+
1. Definitions.
58+
59+
"License" shall mean the terms and conditions for use, reproduction,
60+
and distribution as defined by Sections 1 through 9 of this document.
61+
62+
"Licensor" shall mean the copyright owner or entity authorized by
63+
the copyright owner that is granting the License.
64+
65+
"Legal Entity" shall mean the union of the acting entity and all
66+
other entities that control, are controlled by, or are under common
67+
control with that entity. For the purposes of this definition,
68+
"control" means (i) the power, direct or indirect, to cause the
69+
direction or management of such entity, whether by contract or
70+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
71+
outstanding shares, or (iii) beneficial ownership of such entity.
72+
73+
"You" (or "Your") shall mean an individual or Legal Entity
74+
exercising permissions granted by this License.
75+
76+
"Source" form shall mean the preferred form for making modifications,
77+
including but not limited to software source code, documentation
78+
source, and configuration files.
79+
80+
"Object" form shall mean any form resulting from mechanical
81+
transformation or translation of a Source form, including but
82+
not limited to compiled object code, generated documentation,
83+
and conversions to other media types.
84+
85+
"Work" shall mean the work of authorship, whether in Source or
86+
Object form, made available under the License, as indicated by a
87+
copyright notice that is included in or attached to the work
88+
(an example is provided in the Appendix below).
89+
90+
"Derivative Works" shall mean any work, whether in Source or Object
91+
form, that is based on (or derived from) the Work and for which the
92+
editorial revisions, annotations, elaborations, or other modifications
93+
represent, as a whole, an original work of authorship. For the purposes
94+
of this License, Derivative Works shall not include works that remain
95+
separable from, or merely link (or bind by name) to the interfaces of,
96+
the Work and Derivative Works thereof.
97+
98+
"Contribution" shall mean any work of authorship, including
99+
the original version of the Work and any modifications or additions
100+
to that Work or Derivative Works thereof, that is intentionally
101+
submitted to Licensor for inclusion in the Work by the copyright owner
102+
or by an individual or Legal Entity authorized to submit on behalf of
103+
the copyright owner. For the purposes of this definition, "submitted"
104+
means any form of electronic, verbal, or written communication sent
105+
to the Licensor or its representatives, including but not limited to
106+
communication on electronic mailing lists, source code control systems,
107+
and issue tracking systems that are managed by, or on behalf of, the
108+
Licensor for the purpose of discussing and improving the Work, but
109+
excluding communication that is conspicuously marked or otherwise
110+
designated in writing by the copyright owner as "Not a Contribution."
111+
112+
"Contributor" shall mean Licensor and any individual or Legal Entity
113+
on behalf of whom a Contribution has been received by Licensor and
114+
subsequently incorporated within the Work.
115+
116+
2. Grant of Copyright License. Subject to the terms and conditions of
117+
this License, each Contributor hereby grants to You a perpetual,
118+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
119+
copyright license to reproduce, prepare Derivative Works of,
120+
publicly display, publicly perform, sublicense, and distribute the
121+
Work and such Derivative Works in Source or Object form.
122+
123+
3. Grant of Patent License. Subject to the terms and conditions of
124+
this License, each Contributor hereby grants to You a perpetual,
125+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
126+
(except as stated in this section) patent license to make, have made,
127+
use, offer to sell, sell, import, and otherwise transfer the Work,
128+
where such license applies only to those patent claims licensable
129+
by such Contributor that are necessarily infringed by their
130+
Contribution(s) alone or by combination of their Contribution(s)
131+
with the Work to which such Contribution(s) was submitted. If You
132+
institute patent litigation against any entity (including a
133+
cross-claim or counterclaim in a lawsuit) alleging that the Work
134+
or a Contribution incorporated within the Work constitutes direct
135+
or contributory patent infringement, then any patent licenses
136+
granted to You under this License for that Work shall terminate
137+
as of the date such litigation is filed.
138+
139+
4. Redistribution. You may reproduce and distribute copies of the
140+
Work or Derivative Works thereof in any medium, with or without
141+
modifications, and in Source or Object form, provided that You
142+
meet the following conditions:
143+
144+
(a) You must give any other recipients of the Work or
145+
Derivative Works a copy of this License; and
146+
147+
(b) You must cause any modified files to carry prominent notices
148+
stating that You changed the files; and
149+
150+
(c) You must retain, in the Source form of any Derivative Works
151+
that You distribute, all copyright, patent, trademark, and
152+
attribution notices from the Source form of the Work,
153+
excluding those notices that do not pertain to any part of
154+
the Derivative Works; and
155+
156+
(d) If the Work includes a "NOTICE" text file as part of its
157+
distribution, then any Derivative Works that You distribute must
158+
include a readable copy of the attribution notices contained
159+
within such NOTICE file, excluding those notices that do not
160+
pertain to any part of the Derivative Works, in at least one
161+
of the following places: within a NOTICE text file distributed
162+
as part of the Derivative Works; within the Source form or
163+
documentation, if provided along with the Derivative Works; or,
164+
within a display generated by the Derivative Works, if and
165+
wherever such third-party notices normally appear. The contents
166+
of the NOTICE file are for informational purposes only and
167+
do not modify the License. You may add Your own attribution
168+
notices within Derivative Works that You distribute, alongside
169+
or as an addendum to the NOTICE text from the Work, provided
170+
that such additional attribution notices cannot be construed
171+
as modifying the License.
172+
173+
You may add Your own copyright statement to Your modifications and
174+
may provide additional or different license terms and conditions
175+
for use, reproduction, or distribution of Your modifications, or
176+
for any such Derivative Works as a whole, provided Your use,
177+
reproduction, and distribution of the Work otherwise complies with
178+
the conditions stated in this License.
179+
180+
5. Submission of Contributions. Unless You explicitly state otherwise,
181+
any Contribution intentionally submitted for inclusion in the Work
182+
by You to the Licensor shall be under the terms and conditions of
183+
this License, without any additional terms or conditions.
184+
Notwithstanding the above, nothing herein shall supersede or modify
185+
the terms of any separate license agreement you may have executed
186+
with Licensor regarding such Contributions.
187+
188+
6. Trademarks. This License does not grant permission to use the trade
189+
names, trademarks, service marks, or product names of the Licensor,
190+
except as required for reasonable and customary use in describing the
191+
origin of the Work and reproducing the content of the NOTICE file.
192+
193+
7. Disclaimer of Warranty. Unless required by applicable law or
194+
agreed to in writing, Licensor provides the Work (and each
195+
Contributor provides its Contributions) on an "AS IS" BASIS,
196+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
197+
implied, including, without limitation, any warranties or conditions
198+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
199+
PARTICULAR PURPOSE. You are solely responsible for determining the
200+
appropriateness of using or redistributing the Work and assume any
201+
risks associated with Your exercise of permissions under this License.
202+
203+
8. Limitation of Liability. In no event and under no legal theory,
204+
whether in tort (including negligence), contract, or otherwise,
205+
unless required by applicable law (such as deliberate and grossly
206+
negligent acts) or agreed to in writing, shall any Contributor be
207+
liable to You for damages, including any direct, indirect, special,
208+
incidental, or consequential damages of any character arising as a
209+
result of this License or out of the use or inability to use the
210+
Work (including but not limited to damages for loss of goodwill,
211+
work stoppage, computer failure or malfunction, or any and all
212+
other commercial damages or losses), even if such Contributor
213+
has been advised of the possibility of such damages.
214+
215+
9. Accepting Warranty or Additional Liability. While redistributing
216+
the Work or Derivative Works thereof, You may choose to offer,
217+
and charge a fee for, acceptance of support, warranty, indemnity,
218+
or other liability obligations and/or rights consistent with this
219+
License. However, in accepting such obligations, You may act only
220+
on Your own behalf and on Your sole responsibility, not on behalf
221+
of any other Contributor, and only if You agree to indemnify,
222+
defend, and hold each Contributor harmless for any liability
223+
incurred by, or claims asserted against, such Contributor by reason
224+
of your accepting any such warranty or additional liability.
225+
226+
END OF TERMS AND CONDITIONS

component.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "patch",
3+
"repo": "component/patch",
4+
"description": "applies patches created by component/diff",
5+
"version": "0.0.1",
6+
"keywords": ["patch", "fuzzy", "diff", "merge"],
7+
"dependencies": {
8+
"component/diff": "*"
9+
},
10+
"development": {},
11+
"license": "Apache 2.0",
12+
"main": "index.js",
13+
"scripts": [
14+
"index.js",
15+
"diff_match_patch.js"
16+
]
17+
}

0 commit comments

Comments
 (0)