summaryrefslogtreecommitdiff
path: root/gnu/packages/javascript.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2017-08-03 15:54:16 +0200
committerRicardo Wurmus <rekado@elephly.net>2017-08-04 11:23:52 +0200
commit68ffb6c586de4dfd4dd5c972d3481a4243ba8bde (patch)
treee8a2b0291b404689ccdf085844e1edb298a00f13 /gnu/packages/javascript.scm
parented69963b03d71928f8c926ed62e5d6f5e78d9b2a (diff)
gnu: Add js-json2.
* gnu/packages/javascript.scm (js-json2): New variable.
Diffstat (limited to 'gnu/packages/javascript.scm')
-rw-r--r--gnu/packages/javascript.scm49
1 files changed, 48 insertions, 1 deletions
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 83646519189..a806cb0745d 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -26,7 +26,9 @@
26 #:use-module (gnu packages lisp) 26 #:use-module (gnu packages lisp)
27 #:use-module (guix packages) 27 #:use-module (guix packages)
28 #:use-module (guix download) 28 #:use-module (guix download)
29 #:use-module (guix build-system trivial)) 29 #:use-module (guix git-download)
30 #:use-module (guix build-system trivial)
31 #:use-module (guix build-system minify))
30 32
31(define-public js-mathjax 33(define-public js-mathjax
32 (package 34 (package
@@ -159,3 +161,48 @@ Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
159 ;; version 2). This means you are free to choose with which of both 161 ;; version 2). This means you are free to choose with which of both
160 ;; licenses (MIT or GPL version 2) you want to use this library. 162 ;; licenses (MIT or GPL version 2) you want to use this library.
161 (license (list license:expat license:gpl2)))) 163 (license (list license:expat license:gpl2))))
164
165(define-public js-json2
166 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
167 (revision "1"))
168 (package
169 (name "js-json2")
170 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
171 (source (origin
172 (method git-fetch)
173 (uri (git-reference
174 (url "https://github.com/douglascrockford/JSON-js.git")
175 (commit commit)))
176 (file-name (string-append name "-" version "-checkout"))
177 (sha256
178 (base32
179 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
180 (build-system minify-build-system)
181 (arguments
182 `(#:javascript-files '("json2.js"
183 "json_parse.js"
184 "json_parse_state.js"
185 "cycle.js")))
186 (home-page "https://github.com/douglascrockford/JSON-js")
187 (synopsis "JSON encoders and decoders")
188 (description "The files in this collection implement JSON
189encoders/decoders in JavaScript.
190
191@code{json2.js}: This file creates a JSON property in the global object, if
192there isn't already one, setting its value to an object containing a stringify
193method and a parse method. The @code{parse} method uses the @code{eval}
194method to do the parsing, guarding it with several regular expressions to
195defend against accidental code execution hazards. On current browsers, this
196file does nothing, preferring the built-in JSON object.
197
198@code{json_parse.js}: This file contains an alternative JSON @code{parse}
199function that uses recursive descent instead of @code{eval}.
200
201@code{json_parse_state.js}: This files contains an alternative JSON
202@code{parse} function that uses a state machine instead of @code{eval}.
203
204@code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
205@code{JSON.retrocycle}, which make it possible to encode cyclical structures
206and DAGs in JSON, and to then recover them. This is a capability that is not
207provided by ES5. @code{JSONPath} is used to represent the links.")
208 (license license:public-domain))))