summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-05-02 11:12:18 +0100
committerMichael Williamson <mike@zwobble.org>2020-05-02 11:12:18 +0100
commite7471d1a36ab71abdab4d1f3cd8f246108b42eb6 (patch)
tree65f1d59bb8a3761c0c4fd3eec75ee4980e1eb60c /README.rst
parentfa7399eb01fce0a81e617af03d752527093e7d72 (diff)
Add convenience functions
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index 1217c3c..a3af21d 100644
--- a/README.rst
+++ b/README.rst
@@ -110,6 +110,16 @@ Call ``iter()`` to get all of the output elements as an iterator:
assert next(iterator, None) == 4
assert next(iterator, None) == None
+Convenience functions are available to get the output for a program and input in one call:
+
+.. code-block:: python
+
+ assert jq.first(".[] + 1", [1, 2, 3]) == 2
+ assert jq.first(".[] + 1", text="[1, 2, 3]") == 2
+ assert jq.text(".[] + 1", [1, 2, 3]) == "2\n3\n4"
+ assert jq.all(".[] + 1", [1, 2, 3]) == [2, 3, 4]
+ assert list(jq.iter(".[] + 1", [1, 2, 3])) == [2, 3, 4]
+
The original program string is available on a compiled program as the ``program_string`` attribute:
.. code-block:: python