old_sql 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/public/javascripts/old_sql/MochiKit-1.4.2/Changes +362 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/LICENSE.txt +69 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/MANIFEST +179 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/META.json +17 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Async.html +814 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Base.html +1703 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Color.html +755 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DOM.html +1197 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DateTime.html +168 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DragAndDrop.html +187 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Format.html +300 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Iter.html +524 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Logging.html +420 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/LoggingPane.html +142 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Position.html +38 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Selector.html +240 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Signal.html +508 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Sortable.html +244 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Style.html +385 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/VersionHistory.html +384 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Visual.html +1161 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/index.html +447 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/js/toc.js +113 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Async.rst +767 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Base.rst +1445 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Color.rst +651 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DOM.rst +1143 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DateTime.rst +145 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DragAndDrop.rst +197 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Format.rst +258 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Iter.rst +454 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Logging.rst +348 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/LoggingPane.rst +128 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Position.rst +26 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Selector.rst +203 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Signal.rst +498 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Sortable.rst +186 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Style.rst +353 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/VersionHistory.rst +362 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Visual.rst +895 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/index.rst +83 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/ajax_tables.css +69 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/ajax_tables.js +401 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/domains.json +10 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/domains.xml +40 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/index.html +96 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/color_wheel.css +4 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/color_wheel.js +95 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/index.html +31 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/dnd_sortable.css +23 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/dropmarker.png +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/icon.png +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/index.html +54 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable2_test.html +150 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable3_test.html +42 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable4_test.html +90 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable5_test.html +29 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable_test.html +38 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable_tree_test.html +189 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/draggable.css +28 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/draggable.js +73 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/index.html +38 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_bigslide.html +36 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_blind.html +65 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_blindslide.html +31 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_combi.css +18 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_fadeappear.html +61 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_grow_shrink.html +38 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_onload.html +67 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_queue.html +67 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_queue_limit.html +30 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_scroll.html +483 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_slide.html +62 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/full.html +71 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/icon.png +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/index.html +150 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/index.html +88 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/interpreter.css +54 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/interpreter.js +373 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/index.html +78 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/key_events.css +5 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/key_events.js +85 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/index.html +46 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/logging_pane.css +78 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/logging_pane.js +11 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/index.html +74 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/mochiregexp.css +73 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/mochiregexp.js +125 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/index.html +88 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/mouse_events.css +17 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/mouse_events.js +59 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/index.html +28 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/rounded_corners.css +3 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/rounded_corners.js +19 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_boxes.html +45 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_full.html +119 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_ghost.html +40 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_hoverclass.html +43 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_scroll.html +91 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_snap.html +54 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/index.html +93 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/simple_dnd.css +64 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/index.html +71 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/sortable_tables.css +66 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/sortable_tables.js +203 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/SyntaxHighlighter.css +177 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/Tests.html +339 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushCSharp.js +30 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushDelphi.js +31 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushJScript.js +22 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushPhp.js +23 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushPython.js +71 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushSql.js +40 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushVb.js +29 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushXml.js +61 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shCore.js +622 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.css +1 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.html +19 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.js +70 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/bg_docheader.gif +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/g_bullet.gif +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/g_logo_doc.gif +0 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/include/css/documentation.css +130 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/include/css/general.css +48 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Async.js +682 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Base.js +1489 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Color.js +863 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DOM.js +1256 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DateTime.js +222 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DragAndDrop.js +793 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Format.js +304 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Iter.js +844 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Logging.js +315 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/LoggingPane.js +353 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/MochiKit.js +188 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/MockDOM.js +115 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Position.js +236 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Selector.js +415 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Signal.js +897 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Sortable.js +589 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Style.js +594 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Test.js +162 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Visual.js +2026 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/__package__.js +18 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/MochiKit.js +7829 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/__package__.js +6 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/customize.html +251 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/FakeJSAN.js +40 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/SimpleTest.js +381 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/TestRunner.js +159 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/test.css +28 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/cli.js +6 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/index.html +25 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/standalone.js +16 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Base.js +577 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Color.js +137 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_DateTime.js +52 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_DragAndDrop.js +30 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Format.js +89 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Iter.js +186 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Logging.js +88 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Async.html +408 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Async.json +1 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Base.html +34 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Color.html +84 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DOM-Safari.html +48 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DOM.html +363 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DateTime.html +39 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DragAndDrop.html +54 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Format.html +39 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Iter.html +38 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-JSAN.html +32 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Logging.html +40 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-MochiKit.html +18 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Selector.html +295 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Signal.html +43 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Style.html +223 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Visual.html +197 -0
- data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Signal.js +481 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/COPYING +28 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Base.js +406 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Canvas.js +683 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/EasyPlot.js +161 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Layout.js +756 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/PlotKit.js +151 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/PlotKit_Packed.js +2177 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SVG.js +705 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SweetCanvas.js +348 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SweetSVG.js +247 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/dummy.svg +9 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/excanvas.js +723 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/README +1 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/MochiKitAdditions.html +2 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/MochiKitAdditions.txt +2 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Base.html +302 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Base.txt +139 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Canvas.html +172 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Canvas.txt +81 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.EasyPlot.html +155 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.EasyPlot.txt +50 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Layout.html +428 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Layout.txt +330 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.QuickStart.html +368 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.QuickStart.txt +256 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Renderer.html +436 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Renderer.txt +299 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SVG.html +159 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SVG.txt +64 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetCanvas.html +131 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetCanvas.txt +34 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetSVG.html +131 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetSVG.txt +34 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.html +334 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.txt +151 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/SVGCanvasCompat.html +304 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/SVGCanvasCompat.txt +144 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/barsample.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/black.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/blue.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/cyan.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/doc.css +62 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/generate.py +37 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/green.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/orange.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/piesample.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/purple.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/doc/red.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/scripts/custom_rhino.jar +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/scripts/pack.py +58 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/axis.html +31 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/basic.html +25 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/basic.js +143 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/debug.html +56 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo-svg.html +58 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo-svg.js +133 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo.html +57 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo.js +136 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/dynamic.html +161 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/firefox.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/konqueror.png +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/mozilla.ico +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/msie.gif +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/opera.ico +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/safari.gif +0 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/labels-img.html +38 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/labels.html +43 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/prototype_compat.html +28 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-easy.html +29 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-horiz.html +53 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-neg.html +29 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-svg.html +61 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart.html +57 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/sample.txt +6 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg-sweet.html +29 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg-sweet.js +141 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg.html +26 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg.js +147 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/sweet.html +24 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/sweet.js +89 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/tests.css +66 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/testsvg.html +20 -0
- data/public/javascripts/old_sql/plotkit-0.9.1/tests/testsvg.js +31 -0
- metadata +264 -2
@@ -0,0 +1,1703 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
|
8
|
+
<title>MochiKit.Base - functional programming and useful comparisons</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../../../include/css/documentation.css" type="text/css" />
|
11
|
+
<script type="text/javascript" src="../../../packed/lib/MochiKit/MochiKit.js"></script>
|
12
|
+
<script type="text/javascript" src="../../js/toc.js"></script>
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<a href="http://mochikit.com"><img id="mainlink" src="../../../include/_img/g_logo_doc.gif" alt="MochiKit" /></a>
|
16
|
+
<a class='indexlink' href='index.html'>Back to docs index</a>
|
17
|
+
<div class="document">
|
18
|
+
<div class="section">
|
19
|
+
<h1><a id="name" name="name">Name</a></h1>
|
20
|
+
<p>MochiKit.Base - functional programming and useful comparisons</p>
|
21
|
+
</div>
|
22
|
+
<div class="section">
|
23
|
+
<h1><a id="synopsis" name="synopsis">Synopsis</a></h1>
|
24
|
+
<pre class="literal-block">
|
25
|
+
myObjectRepr = function () {
|
26
|
+
// gives a nice, stable string representation for objects,
|
27
|
+
// ignoring any methods
|
28
|
+
var keyValuePairs = [];
|
29
|
+
for (var k in this) {
|
30
|
+
var v = this[k];
|
31
|
+
if (typeof(v) != 'function') {
|
32
|
+
keyValuePairs.push([k, v]);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
keyValuePairs.sort(compare);
|
36
|
+
return "{" + map(
|
37
|
+
function (pair) {
|
38
|
+
return map(repr, pair).join(":");
|
39
|
+
},
|
40
|
+
keyValuePairs
|
41
|
+
).join(", ") + "}";
|
42
|
+
};
|
43
|
+
|
44
|
+
// repr() will look for objects that have a repr method
|
45
|
+
myObjectArray = [
|
46
|
+
{"a": 3, "b": 2, "repr": myObjectRepr},
|
47
|
+
{"a": 1, "b": 2, "repr": myObjectRepr}
|
48
|
+
];
|
49
|
+
|
50
|
+
// sort it by the "a" property, check to see if it matches
|
51
|
+
myObjectArray.sort(keyComparator("a"));
|
52
|
+
expectedRepr = '[{"a": 1, "b": 2}, {"a": 3, "b": 2}]';
|
53
|
+
assert( repr(myObjectArray) == expectedRepr );
|
54
|
+
|
55
|
+
// get just the "a" values out into an array
|
56
|
+
sortedAValues = map(itemgetter("a"), myObjectArray);
|
57
|
+
assert( compare(sortedAValues, [1, 3]) == 0 );
|
58
|
+
|
59
|
+
// serialize an array as JSON, unserialize it, expect something equivalent
|
60
|
+
myArray = [1, 2, "3", null, undefined];
|
61
|
+
assert( objEqual(evalJSON(serializeJSON(myArray)), myArray) );
|
62
|
+
</pre>
|
63
|
+
</div>
|
64
|
+
<div class="section">
|
65
|
+
<h1><a id="description" name="description">Description</a></h1>
|
66
|
+
<p><a class="mochiref reference" href="Base.html">MochiKit.Base</a> is the foundation for the MochiKit suite.
|
67
|
+
It provides:</p>
|
68
|
+
<ul class="simple">
|
69
|
+
<li>An extensible comparison facility
|
70
|
+
(<a class="mochiref reference" href="#fn-compare">compare</a>, <a class="mochiref reference" href="#fn-registercomparator">registerComparator</a>)</li>
|
71
|
+
<li>An extensible programmer representation facility
|
72
|
+
(<a class="mochiref reference" href="#fn-repr">repr</a>, <a class="mochiref reference" href="#fn-registerrepr">registerRepr</a>)</li>
|
73
|
+
<li>An extensible JSON <a class="footnote-reference" href="#id7" id="id1" name="id1">[1]</a> serialization and evaluation facility
|
74
|
+
(<a class="mochiref reference" href="#fn-serializejson">serializeJSON</a>, <a class="mochiref reference" href="#fn-evaljson">evalJSON</a>,
|
75
|
+
<a class="mochiref reference" href="#fn-registerjson">registerJSON</a>)</li>
|
76
|
+
<li>A simple adaptation facility (<a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a>)</li>
|
77
|
+
<li>Convenience functions for manipulating objects and Arrays
|
78
|
+
(<a class="mochiref reference" href="#fn-update">update</a>, <a class="mochiref reference" href="#fn-setdefault">setdefault</a>, <a class="mochiref reference" href="#fn-extend">extend</a>, etc.)</li>
|
79
|
+
<li>Array-based functional programming
|
80
|
+
(<a class="mochiref reference" href="#fn-map">map</a>, <a class="mochiref reference" href="#fn-filter">filter</a>, etc.)</li>
|
81
|
+
<li>Bound and partially applied functions
|
82
|
+
(<a class="mochiref reference" href="#fn-bind">bind</a>, <a class="mochiref reference" href="#fn-method">method</a>, <a class="mochiref reference" href="#fn-partial">partial</a>)</li>
|
83
|
+
</ul>
|
84
|
+
<p>Python users will feel at home with <a class="mochiref reference" href="Base.html">MochiKit.Base</a>, as the
|
85
|
+
facilities are quite similar to those available as part of Python and
|
86
|
+
the Python standard library.</p>
|
87
|
+
</div>
|
88
|
+
<div class="section">
|
89
|
+
<h1><a id="dependencies" name="dependencies">Dependencies</a></h1>
|
90
|
+
<p>None.</p>
|
91
|
+
</div>
|
92
|
+
<div class="section">
|
93
|
+
<h1><a id="overview" name="overview">Overview</a></h1>
|
94
|
+
<div class="section">
|
95
|
+
<h2><a id="comparison" name="comparison">Comparison</a></h2>
|
96
|
+
<p>The comparators (operators for comparison) in JavaScript are deeply
|
97
|
+
broken, and it is not possible to teach them new tricks.</p>
|
98
|
+
<p>MochiKit exposes an extensible comparison facility as a simple
|
99
|
+
<a class="mochiref reference" href="#fn-compare">compare(a, b)</a> function, which should be used in lieu of
|
100
|
+
JavaScript's operators whenever comparing objects other than numbers
|
101
|
+
or strings (though you can certainly use <a class="mochiref reference" href="#fn-compare">compare</a> for
|
102
|
+
those, too!).</p>
|
103
|
+
<p>The <a class="mochiref reference" href="#fn-compare">compare</a> function has the same signature and return
|
104
|
+
value as a sort function for <tt class="docutils literal"><span class="pre">Array.prototype.sort</span></tt>, and is often
|
105
|
+
used in that context.</p>
|
106
|
+
<p>Defining new comparators for the <a class="mochiref reference" href="#fn-compare">compare</a> function to use
|
107
|
+
is done by adding an entry to its <a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a> with the
|
108
|
+
<a class="mochiref reference" href="#fn-registercomparator">registerComparator</a> function.</p>
|
109
|
+
</div>
|
110
|
+
<div class="section">
|
111
|
+
<h2><a id="programmer-representation" name="programmer-representation">Programmer Representation</a></h2>
|
112
|
+
<p>JavaScript's default representation mechanism, <tt class="docutils literal"><span class="pre">toString</span></tt>, is
|
113
|
+
notorious for having terrible default behavior. It's also very unwise
|
114
|
+
to change that default, as other JavaScript code you may be using may
|
115
|
+
depend on it.</p>
|
116
|
+
<p>It's also useful to separate the concept of a "string representation"
|
117
|
+
and a "string representation for programmers", much like Python does
|
118
|
+
with its str and repr protocols.</p>
|
119
|
+
<p><a class="mochiref reference" href="#fn-repr">repr</a> provides this programmer representation for
|
120
|
+
JavaScript, in a way that doesn't require object prototype hacking:
|
121
|
+
using an <a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a>.</p>
|
122
|
+
<p>Objects that implement the repr protocol can either implement a
|
123
|
+
<tt class="docutils literal"><span class="pre">.repr()</span></tt> or <tt class="docutils literal"><span class="pre">.__repr__()</span></tt> method, or they can simply have an
|
124
|
+
adapter setup to generate programmer representations. By default, the
|
125
|
+
registry provides nice representations for <tt class="docutils literal"><span class="pre">null</span></tt>, <tt class="docutils literal"><span class="pre">undefined</span></tt>,
|
126
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>, and objects or functions with a <tt class="docutils literal"><span class="pre">NAME</span></tt> attribute that use
|
127
|
+
the default <tt class="docutils literal"><span class="pre">toString</span></tt>. For objects that <tt class="docutils literal"><span class="pre">repr</span></tt> doesn't already
|
128
|
+
understand, it simply defaults to <tt class="docutils literal"><span class="pre">toString</span></tt>, so it will integrate
|
129
|
+
seamlessly with code that implements the idiomatic JavaScript
|
130
|
+
<tt class="docutils literal"><span class="pre">toString</span></tt> method!</p>
|
131
|
+
<p>To define a programmer representation for your own objects, simply add
|
132
|
+
a <tt class="docutils literal"><span class="pre">.repr()</span></tt> or <tt class="docutils literal"><span class="pre">.__repr__()</span></tt> method that returns a string. For
|
133
|
+
objects that you didn't create (e.g., from a script you didn't write,
|
134
|
+
or a built-in object), it is instead recommended that you create an
|
135
|
+
adapter with <a class="mochiref reference" href="#fn-registerrepr">registerRepr</a>.</p>
|
136
|
+
</div>
|
137
|
+
<div class="section">
|
138
|
+
<h2><a id="json-serialization" name="json-serialization">JSON Serialization</a></h2>
|
139
|
+
<p>JSON <a class="footnote-reference" href="#id7" id="id2" name="id2">[1]</a>, JavaScript Object Notation, is a widely used serialization
|
140
|
+
format in the context of web development. It's extremely simple,
|
141
|
+
lightweight, and fast. In its essence, JSON is a restricted subset of
|
142
|
+
JavaScript syntax suitable for sending over the wire that can be
|
143
|
+
unserialized with a simple eval. It's often used as an alternative to
|
144
|
+
XML in "AJAX" contexts because it is compact, fast, and much simpler
|
145
|
+
to use for most purposes.</p>
|
146
|
+
<p>To create a JSON serialization of any object, simply call
|
147
|
+
<a class="mochiref reference" href="#fn-serializejson">serializeJSON()</a> with that object. To unserialize a JSON
|
148
|
+
string, simply call <a class="mochiref reference" href="#fn-evaljson">evalJSON()</a> with the serialization.</p>
|
149
|
+
<p>In order of precedence, <a class="mochiref reference" href="#fn-serializejson">serializeJSON</a> coerces the given
|
150
|
+
argument into a JSON serialization:</p>
|
151
|
+
<ol class="arabic simple">
|
152
|
+
<li>Primitive types are returned as their JSON representation:
|
153
|
+
<tt class="docutils literal"><span class="pre">string</span></tt>, <tt class="docutils literal"><span class="pre">number</span></tt>, <tt class="docutils literal"><span class="pre">boolean</span></tt>, <tt class="docutils literal"><span class="pre">null</span></tt>.</li>
|
154
|
+
<li>If the object has a <tt class="docutils literal"><span class="pre">__json__</span></tt> or <tt class="docutils literal"><span class="pre">json</span></tt> method, then it is
|
155
|
+
called with no arguments. If the result of this method is not the
|
156
|
+
object itself, then the new object goes through rule processing
|
157
|
+
again (e.g. it may return a string, which is then serialized in
|
158
|
+
JSON format).</li>
|
159
|
+
<li>If the object is <tt class="docutils literal"><span class="pre">Array</span></tt>-like (has a <tt class="docutils literal"><span class="pre">length</span></tt> property that is
|
160
|
+
a number, and is not a function), then it is serialized as a JSON
|
161
|
+
array. Each element will be processed according to these rules in
|
162
|
+
order. Elements that can not be serialized (e.g. functions) will
|
163
|
+
be replaced with <tt class="docutils literal"><span class="pre">undefined</span></tt>.</li>
|
164
|
+
<li>The <tt class="docutils literal"><span class="pre">jsonRegistry</span></tt> <a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a> is consulted for
|
165
|
+
an adapter for this object. JSON adapters take one argument (the
|
166
|
+
object), and are expected to behave like a <tt class="docutils literal"><span class="pre">__json__</span></tt> or
|
167
|
+
<tt class="docutils literal"><span class="pre">json</span></tt> method (return another object to be serialized, or
|
168
|
+
itself).</li>
|
169
|
+
<li>If the object is <tt class="docutils literal"><span class="pre">undefined</span></tt>, a <tt class="docutils literal"><span class="pre">TypeError</span></tt> is thrown. If you
|
170
|
+
wish to serialize <tt class="docutils literal"><span class="pre">undefined</span></tt> as <tt class="docutils literal"><span class="pre">null</span></tt> or some other value, you
|
171
|
+
should create an adapter to do so.</li>
|
172
|
+
<li>If no adapter is available, the object is enumerated and
|
173
|
+
serialized as a JSON object (name:value pairs). All names are
|
174
|
+
expected to be strings. Each value is serialized according to
|
175
|
+
these rules, and if it can not be serialized (e.g. methods), then
|
176
|
+
that name:value pair will be skipped.</li>
|
177
|
+
</ol>
|
178
|
+
</div>
|
179
|
+
<div class="section">
|
180
|
+
<h2><a id="adapter-registries" name="adapter-registries">Adapter Registries</a></h2>
|
181
|
+
<p>MochiKit makes extensive use of adapter registries, which enable you
|
182
|
+
to implement object-specific behaviors for objects that you do not
|
183
|
+
necessarily want to modify, such as built-in objects. This is
|
184
|
+
especially useful because JavaScript does not provide a method for
|
185
|
+
hiding user-defined properties from <tt class="docutils literal"><span class="pre">for</span> <span class="pre">propName</span> <span class="pre">in</span> <span class="pre">obj</span></tt>
|
186
|
+
enumeration.</p>
|
187
|
+
<p><a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a> is simply an encapsulation for an ordered
|
188
|
+
list of "check" and "wrap" function pairs. Each
|
189
|
+
<a class="mochiref reference" href="#fn-adapterregistry">AdapterRegistry</a> instance should perform one function, but
|
190
|
+
may have multiple ways to achieve that function based upon the
|
191
|
+
arguments. One way to think of it is as a poor man's generic function,
|
192
|
+
or multiple dispatch (on arbitrary functions, not just type!).</p>
|
193
|
+
<p>Check functions take one or more arguments, and return <tt class="docutils literal"><span class="pre">true</span></tt> if the
|
194
|
+
argument list is suitable for the wrap function. Check functions
|
195
|
+
should perform "cheap" checks of an object's type or contents, before
|
196
|
+
the "expensive" wrap function is called.</p>
|
197
|
+
<p>Wrap functions take the same arguments as check functions and do some
|
198
|
+
operation, such as creating a programmer representation or comparing
|
199
|
+
both arguments.</p>
|
200
|
+
</div>
|
201
|
+
<div class="section">
|
202
|
+
<h2><a id="convenience-functions" name="convenience-functions">Convenience Functions</a></h2>
|
203
|
+
<p>Much of <a class="mochiref reference" href="Base.html">MochiKit.Base</a> is there to simply remove the grunt
|
204
|
+
work of doing generic JavaScript programming.</p>
|
205
|
+
<p>Need to take every property from one object and set them on another?
|
206
|
+
No problem, just call <a class="mochiref reference" href="#fn-update">update(dest, src)</a>! What if you just
|
207
|
+
wanted to update keys that weren't already set? Look no further than
|
208
|
+
<a class="mochiref reference" href="#fn-setdefault">setdefault(dest, src[, ...])</a>.</p>
|
209
|
+
<p>Want to return a mutable object, but don't want to suffer the
|
210
|
+
consequences if the user mutates it? Just <a class="mochiref reference" href="#fn-clone">clone(it)</a> and
|
211
|
+
you'll get a copy-on-write clone. Cheaper than a copy!</p>
|
212
|
+
<p>Need to extend an <tt class="docutils literal"><span class="pre">Array</span></tt> with another array? Or even an
|
213
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like object such as a <tt class="docutils literal"><span class="pre">NodeList</span></tt> or the special
|
214
|
+
<tt class="docutils literal"><span class="pre">arguments</span></tt> object? Even if you need to skip the first few elements
|
215
|
+
of the source <tt class="docutils literal"><span class="pre">Array</span></tt>-like object, it's no problem with
|
216
|
+
<a class="mochiref reference" href="#fn-extend">extend(dstArray, srcArrayLike[, skip])</a>!</p>
|
217
|
+
<p>Wouldn't it be convenient to have all of the JavaScript operators were
|
218
|
+
available as functions somewhere? That's what the
|
219
|
+
<a class="mochiref reference" href="#fn-operators">operators</a> table is for, and it even comes with additional
|
220
|
+
operators based on the <a class="mochiref reference" href="#fn-compare">compare</a> function.</p>
|
221
|
+
<p>Need to walk some tree of objects and manipulate or find something in
|
222
|
+
it? A DOM element tree perhaps? Use <a class="mochiref reference" href="#fn-nodewalk">nodeWalk(node,
|
223
|
+
visitor)</a>!</p>
|
224
|
+
<p>There's plenty more, so check out the <a class="reference" href="#api-reference">API Reference</a> below.</p>
|
225
|
+
</div>
|
226
|
+
<div class="section">
|
227
|
+
<h2><a id="functional-programming" name="functional-programming">Functional Programming</a></h2>
|
228
|
+
<p>Functional programming constructs such as <a class="mochiref reference" href="#fn-map">map</a> and
|
229
|
+
<a class="mochiref reference" href="#fn-filter">filter</a> can save you a lot of time, because JavaScript
|
230
|
+
iteration is error-prone and arduous. Writing less code is the best
|
231
|
+
way to prevent bugs, and functional programming can help you do that.</p>
|
232
|
+
<p><a class="mochiref reference" href="Base.html">MochiKit.Base</a> ships with a few simple Array-based
|
233
|
+
functional programming constructs, namely <a class="mochiref reference" href="#fn-map">map</a> and
|
234
|
+
<a class="mochiref reference" href="#fn-filter">filter</a>, and their "extended" brethren, <a class="mochiref reference" href="#fn-xmap">xmap</a>
|
235
|
+
and <a class="mochiref reference" href="#fn-xfilter">xfilter</a>.</p>
|
236
|
+
<p><a class="mochiref reference" href="#fn-map">map(func, arrayLike[, ...])</a> takes a function and an
|
237
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like object, and creates a new <tt class="docutils literal"><span class="pre">Array</span></tt>. The new <tt class="docutils literal"><span class="pre">Array</span></tt>
|
238
|
+
is the result of <tt class="docutils literal"><span class="pre">func(element)</span></tt> for every element of <tt class="docutils literal"><span class="pre">arrayLike</span></tt>,
|
239
|
+
much like the <tt class="docutils literal"><span class="pre">Array.prototype.map</span></tt> extension in Mozilla. However,
|
240
|
+
<a class="mochiref reference" href="Base.html">MochiKit.Base</a> takes that a step further and gives you the
|
241
|
+
full blown Python version of <a class="mochiref reference" href="#fn-map">map</a>, which will take several
|
242
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like objects, and calls the function with one argument per
|
243
|
+
given <tt class="docutils literal"><span class="pre">Array</span></tt>-like, e.g.:</p>
|
244
|
+
<pre class="literal-block">
|
245
|
+
var arrayOne = [1, 2, 3, 4, 5];
|
246
|
+
var arrayTwo = [1, 5, 2, 4, 3];
|
247
|
+
var arrayThree = [5, 2, 1, 3, 4];
|
248
|
+
var biggestElements = map(objMax, arrayOne, arrayTwo, arrayThree);
|
249
|
+
assert( objEqual(biggestElements, [5, 5, 3, 4, 5]) );
|
250
|
+
</pre>
|
251
|
+
<p><a class="mochiref reference" href="#fn-filter">filter(func, arrayLike[, self])</a> takes a function and an
|
252
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like object, and returns a new <tt class="docutils literal"><span class="pre">Array</span></tt>. This is basically
|
253
|
+
identical to the <tt class="docutils literal"><span class="pre">Array.prototype.filter</span></tt> extension in
|
254
|
+
Mozilla. self, if given, will be used as <tt class="docutils literal"><span class="pre">this</span></tt> in the context of
|
255
|
+
func when called.</p>
|
256
|
+
<p><a class="mochiref reference" href="#fn-xmap">xmap</a> and <a class="mochiref reference" href="#fn-xfilter">xfilter</a> are just special forms of
|
257
|
+
<a class="mochiref reference" href="#fn-map">map</a> and <a class="mochiref reference" href="#fn-filter">filter</a> that accept a function as the
|
258
|
+
first argument, and use the extra arguments as the <tt class="docutils literal"><span class="pre">Array</span></tt>-like. Not
|
259
|
+
terribly interesting, but a definite time-saver in some cases.</p>
|
260
|
+
<p>If you appreciate the functional programming facilities here, you
|
261
|
+
should definitely check out <a class="mochiref reference" href="Iter.html">MochiKit.Iter</a>, which provides
|
262
|
+
full blown iterators, <a class="mochiref reference" href="Iter.html#fn-range">MochiKit.Iter.range</a>,
|
263
|
+
<a class="mochiref reference" href="Iter.html#fn-reduce">MochiKit.Iter.reduce</a>, and a near-complete port of Python's
|
264
|
+
itertools <a class="footnote-reference" href="#id8" id="id3" name="id3">[2]</a> module, with some extra stuff thrown in for good
|
265
|
+
measure!</p>
|
266
|
+
</div>
|
267
|
+
<div class="section">
|
268
|
+
<h2><a id="bound-and-partial-functions" name="bound-and-partial-functions">Bound and Partial Functions</a></h2>
|
269
|
+
<p>JavaScript's method-calling special form and lack of bound functions
|
270
|
+
(functions that know what <tt class="docutils literal"><span class="pre">this</span></tt> should be) are one of the first
|
271
|
+
stumbling blocks that programmers new to JavaScript face. The
|
272
|
+
<a class="mochiref reference" href="#fn-bind">bind(func, self)</a> method fixes that right up by returning a
|
273
|
+
new function that calls func with the right <tt class="docutils literal"><span class="pre">this</span></tt>.</p>
|
274
|
+
<p>In order to take real advantage of all this fancy functional
|
275
|
+
programming stuff, you're probably going to want partial
|
276
|
+
application. This allows you to create a new function from an existing
|
277
|
+
function that remembers some of the arguments. For example, if you
|
278
|
+
wanted to compare a given object to a slew of other objects, you could
|
279
|
+
do something like this:</p>
|
280
|
+
<pre class="literal-block">
|
281
|
+
compareWithOne = partial(compare, 1);
|
282
|
+
results = map(compareWithOne, [0, 1, 2, 3]);
|
283
|
+
assert( objEqual(results, [-1, 0, 1, 1]) );
|
284
|
+
</pre>
|
285
|
+
<p>One of the better uses of partial functions is in
|
286
|
+
<a class="mochiref reference" href="DOM.html">MochiKit.DOM</a>, which is certainly a must-see for those of
|
287
|
+
you creating lots of DOM elements with JavaScript!</p>
|
288
|
+
</div>
|
289
|
+
</div>
|
290
|
+
<div class="section">
|
291
|
+
<h1><a id="api-reference" name="api-reference">API Reference</a></h1>
|
292
|
+
<div class="section">
|
293
|
+
<h2><a id="errors" name="errors">Errors</a></h2>
|
294
|
+
<p>
|
295
|
+
<a name="fn-notfound"></a>
|
296
|
+
<a class="mochidef reference" href="#fn-notfound">NotFound</a>:</p>
|
297
|
+
<blockquote>
|
298
|
+
<p>A singleton error raised when no suitable adapter is found</p>
|
299
|
+
<dl class="docutils">
|
300
|
+
<dt><em>Availability</em>:</dt>
|
301
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
302
|
+
</dl>
|
303
|
+
</blockquote>
|
304
|
+
</div>
|
305
|
+
<div class="section">
|
306
|
+
<h2><a id="constructors" name="constructors">Constructors</a></h2>
|
307
|
+
<p>
|
308
|
+
<a name="fn-adapterregistry"></a>
|
309
|
+
<a class="mochidef reference" href="#fn-adapterregistry">AdapterRegistry</a>:</p>
|
310
|
+
<blockquote>
|
311
|
+
<p>A registry to facilitate adaptation.</p>
|
312
|
+
<p>All <tt class="docutils literal"><span class="pre">check</span></tt>/<tt class="docutils literal"><span class="pre">wrap</span></tt> function pairs in a given registry should
|
313
|
+
take the same number of arguments.</p>
|
314
|
+
<dl class="docutils">
|
315
|
+
<dt><em>Availability</em>:</dt>
|
316
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
317
|
+
</dl>
|
318
|
+
</blockquote>
|
319
|
+
<p>
|
320
|
+
<a name="fn-adapterregistry.prototype.register"></a>
|
321
|
+
<a class="mochidef reference" href="#fn-adapterregistry.prototype.register">AdapterRegistry.prototype.register(name, check, wrap[, override])</a>:</p>
|
322
|
+
<blockquote>
|
323
|
+
<dl class="docutils">
|
324
|
+
<dt><tt class="docutils literal"><span class="pre">name</span></tt>:</dt>
|
325
|
+
<dd>a unique identifier used to identify this adapter so that it
|
326
|
+
may be unregistered.</dd>
|
327
|
+
<dt><tt class="docutils literal"><span class="pre">check</span></tt>:</dt>
|
328
|
+
<dd>function that should return <tt class="docutils literal"><span class="pre">true</span></tt> if the given arguments
|
329
|
+
are appropriate for the <tt class="docutils literal"><span class="pre">wrap</span></tt> function.</dd>
|
330
|
+
<dt><tt class="docutils literal"><span class="pre">wrap</span></tt>:</dt>
|
331
|
+
<dd>function that takes the same parameters as <tt class="docutils literal"><span class="pre">check</span></tt> and does
|
332
|
+
the adaptation. Every <tt class="docutils literal"><span class="pre">wrap</span></tt>/<tt class="docutils literal"><span class="pre">check</span></tt> function pair in the
|
333
|
+
registry should have the same number of arguments.</dd>
|
334
|
+
<dt><tt class="docutils literal"><span class="pre">override</span></tt>:</dt>
|
335
|
+
<dd>if <tt class="docutils literal"><span class="pre">true</span></tt>, the <tt class="docutils literal"><span class="pre">check</span></tt> function will be
|
336
|
+
given highest priority. Otherwise, the lowest.</dd>
|
337
|
+
<dt><em>Availability</em>:</dt>
|
338
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
339
|
+
</dl>
|
340
|
+
</blockquote>
|
341
|
+
<p>
|
342
|
+
<a name="fn-adapterregistry.prototype.match"></a>
|
343
|
+
<a class="mochidef reference" href="#fn-adapterregistry.prototype.match">AdapterRegistry.prototype.match(obj[, ...])</a>:</p>
|
344
|
+
<blockquote>
|
345
|
+
<p>Find an adapter for the given arguments by calling every <tt class="docutils literal"><span class="pre">check</span></tt>
|
346
|
+
function until one returns <tt class="docutils literal"><span class="pre">true</span></tt>.</p>
|
347
|
+
<p>If no suitable adapter is found, throws <a class="mochiref reference" href="#fn-notfound">NotFound</a>.</p>
|
348
|
+
<dl class="docutils">
|
349
|
+
<dt><em>Availability</em>:</dt>
|
350
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
351
|
+
</dl>
|
352
|
+
</blockquote>
|
353
|
+
<p>
|
354
|
+
<a name="fn-adapterregistry.prototype.unregister"></a>
|
355
|
+
<a class="mochidef reference" href="#fn-adapterregistry.prototype.unregister">AdapterRegistry.prototype.unregister(name)</a>:</p>
|
356
|
+
<blockquote>
|
357
|
+
<p>Remove a named adapter from the registry</p>
|
358
|
+
<dl class="docutils">
|
359
|
+
<dt><em>Availability</em>:</dt>
|
360
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
361
|
+
</dl>
|
362
|
+
</blockquote>
|
363
|
+
<p>
|
364
|
+
<a name="fn-namederror"></a>
|
365
|
+
<a class="mochidef reference" href="#fn-namederror">NamedError</a>:</p>
|
366
|
+
<blockquote>
|
367
|
+
<p>Convenience constructor for creating new errors
|
368
|
+
(e.g. <a class="mochiref reference" href="#fn-notfound">NotFound</a>)</p>
|
369
|
+
<dl class="docutils">
|
370
|
+
<dt><em>Availability</em>:</dt>
|
371
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
372
|
+
</dl>
|
373
|
+
</blockquote>
|
374
|
+
</div>
|
375
|
+
<div class="section">
|
376
|
+
<h2><a id="functions" name="functions">Functions</a></h2>
|
377
|
+
<p>
|
378
|
+
<a name="fn-arrayequal"></a>
|
379
|
+
<a class="mochidef reference" href="#fn-arrayequal">arrayEqual(self, arr)</a>:</p>
|
380
|
+
<blockquote>
|
381
|
+
<p>Compare the arrays <tt class="docutils literal"><span class="pre">self</span></tt> and <tt class="docutils literal"><span class="pre">arr</span></tt> for equality using
|
382
|
+
<tt class="docutils literal"><span class="pre">compare</span></tt> on each element. Uses a fast-path for length
|
383
|
+
differences.</p>
|
384
|
+
<dl class="docutils">
|
385
|
+
<dt><em>Availability</em>:</dt>
|
386
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
387
|
+
</dl>
|
388
|
+
</blockquote>
|
389
|
+
<p>
|
390
|
+
<a name="fn-average"></a>
|
391
|
+
<a class="mochidef reference" href="#fn-average">average(lst[, ...])</a>:</p>
|
392
|
+
<blockquote>
|
393
|
+
<p>This function is an alias of <a class="mochiref reference" href="#fn-mean">mean()</a>.</p>
|
394
|
+
<dl class="docutils">
|
395
|
+
<dt><em>Availability</em>:</dt>
|
396
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
397
|
+
</dl>
|
398
|
+
</blockquote>
|
399
|
+
<p>
|
400
|
+
<a name="fn-bind"></a>
|
401
|
+
<a class="mochidef reference" href="#fn-bind">bind(func, self[, arg, ...])</a>:</p>
|
402
|
+
<blockquote>
|
403
|
+
<p>Return a copy of <tt class="docutils literal"><span class="pre">func</span></tt> bound to <tt class="docutils literal"><span class="pre">self</span></tt>. This means whenever
|
404
|
+
and however the returned function is called, <tt class="docutils literal"><span class="pre">this</span></tt> will always
|
405
|
+
reference the given <tt class="docutils literal"><span class="pre">self</span></tt>. <tt class="docutils literal"><span class="pre">func</span></tt> may be either a function
|
406
|
+
object, or a string. If it is a string, then <tt class="docutils literal"><span class="pre">self[func]</span></tt> will
|
407
|
+
be used, making these two statements equivalent:</p>
|
408
|
+
<pre class="literal-block">
|
409
|
+
bind("method", self);
|
410
|
+
bind(self.method, self);
|
411
|
+
</pre>
|
412
|
+
<p>Calling <a class="mochiref reference" href="#fn-bind">bind(func, self)</a> on an already bound function
|
413
|
+
will return a new function that is bound to the new <tt class="docutils literal"><span class="pre">self</span></tt>! If
|
414
|
+
<tt class="docutils literal"><span class="pre">self</span></tt> is <tt class="docutils literal"><span class="pre">undefined</span></tt>, then the previous <tt class="docutils literal"><span class="pre">self</span></tt> is used. If
|
415
|
+
<tt class="docutils literal"><span class="pre">self</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, then the <tt class="docutils literal"><span class="pre">this</span></tt> object is used (which may
|
416
|
+
or may not be the global object). To force binding to the global
|
417
|
+
object, you should pass it explicitly.</p>
|
418
|
+
<p>Additional arguments, if given, will be partially applied to the
|
419
|
+
function. These three expressions are equivalent and return
|
420
|
+
equally efficient functions (<a class="mochiref reference" href="#fn-bind">bind</a> and
|
421
|
+
<a class="mochiref reference" href="#fn-partial">partial</a> share the same code path):</p>
|
422
|
+
<ul class="simple">
|
423
|
+
<li><a class="mochiref reference" href="#fn-bind">bind(oldfunc, self, arg1, arg2)</a></li>
|
424
|
+
<li><a class="mochiref reference" href="#fn-bind">bind(partial(oldfunc, arg1, arg2), self)</a></li>
|
425
|
+
<li><a class="mochiref reference" href="#fn-partial">partial(bind(oldfunc, self), arg1, arg2)</a></li>
|
426
|
+
</ul>
|
427
|
+
<dl class="docutils">
|
428
|
+
<dt><em>Availability</em>:</dt>
|
429
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
430
|
+
</dl>
|
431
|
+
</blockquote>
|
432
|
+
<p>
|
433
|
+
<a name="fn-bindlate"></a>
|
434
|
+
<a class="mochidef reference" href="#fn-bindlate">bindLate(func, self[, arg, ...])</a>:</p>
|
435
|
+
<blockquote>
|
436
|
+
<p>Alternate version of <a class="mochiref reference" href="#fn-bind">bind</a> that uses late lookup of
|
437
|
+
the <tt class="docutils literal"><span class="pre">func</span></tt> parameter in <tt class="docutils literal"><span class="pre">self</span></tt>. I.e, the <tt class="docutils literal"><span class="pre">self[func]</span></tt>
|
438
|
+
function lookup will occur on each call to the returned function,
|
439
|
+
not when <tt class="docutils literal"><span class="pre">bindLate</span></tt> is called. Note that this difference is
|
440
|
+
only applicable when <tt class="docutils literal"><span class="pre">func</span></tt> is a string, otherwise <tt class="docutils literal"><span class="pre">bindLate</span></tt>
|
441
|
+
and <tt class="docutils literal"><span class="pre">bind</span></tt> are identical.</p>
|
442
|
+
<dl class="docutils">
|
443
|
+
<dt><em>Availability</em>:</dt>
|
444
|
+
<dd>Available in MochiKit 1.4+</dd>
|
445
|
+
</dl>
|
446
|
+
</blockquote>
|
447
|
+
<p>
|
448
|
+
<a name="fn-bindmethods"></a>
|
449
|
+
<a class="mochidef reference" href="#fn-bindmethods">bindMethods(self)</a>:</p>
|
450
|
+
<blockquote>
|
451
|
+
<p>Replace all functions <tt class="docutils literal"><span class="pre">meth</span></tt> on <tt class="docutils literal"><span class="pre">self</span></tt> with
|
452
|
+
<a class="mochiref reference" href="#fn-bind">bind(meth, self)</a>. This emulates Python's bound
|
453
|
+
instance methods, where there is no need to worry about preserving
|
454
|
+
<tt class="docutils literal"><span class="pre">this</span></tt> when the method is used as a callback.</p>
|
455
|
+
<dl class="docutils">
|
456
|
+
<dt><em>Availability</em>:</dt>
|
457
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
458
|
+
</dl>
|
459
|
+
</blockquote>
|
460
|
+
<p>
|
461
|
+
<a name="fn-camelize"></a>
|
462
|
+
<a class="mochidef reference" href="#fn-camelize">camelize(str)</a>:</p>
|
463
|
+
<blockquote>
|
464
|
+
<p>Converts hyphenated strings to camelCase:</p>
|
465
|
+
<pre class="literal-block">
|
466
|
+
assert( camelize("border-left") == "borderLeft" );
|
467
|
+
</pre>
|
468
|
+
<dl class="docutils">
|
469
|
+
<dt><em>Availability</em>:</dt>
|
470
|
+
<dd>Available in MochiKit 1.4+</dd>
|
471
|
+
</dl>
|
472
|
+
</blockquote>
|
473
|
+
<p>
|
474
|
+
<a name="fn-clone"></a>
|
475
|
+
<a class="mochidef reference" href="#fn-clone">clone(obj)</a>:</p>
|
476
|
+
<blockquote>
|
477
|
+
<p>Return a new object using <tt class="docutils literal"><span class="pre">obj</span></tt> as its prototype. Use this if
|
478
|
+
you want to return a mutable object (e.g. instance state), but
|
479
|
+
don't want the user to mutate it. If they do, it won't have any
|
480
|
+
effect on the original <tt class="docutils literal"><span class="pre">obj</span></tt>.</p>
|
481
|
+
<p>Note that this is a shallow clone, so mutable properties will have
|
482
|
+
to be cloned separately if you want to "protect" them.</p>
|
483
|
+
<dl class="docutils">
|
484
|
+
<dt><em>Availability</em>:</dt>
|
485
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
486
|
+
</dl>
|
487
|
+
</blockquote>
|
488
|
+
<p>
|
489
|
+
<a name="fn-compare"></a>
|
490
|
+
<a class="mochidef reference" href="#fn-compare">compare(a, b)</a>:</p>
|
491
|
+
<blockquote>
|
492
|
+
<p>Compare two objects in a sensible manner. Currently this is:</p>
|
493
|
+
<ol class="arabic simple">
|
494
|
+
<li><tt class="docutils literal"><span class="pre">undefined</span></tt> and <tt class="docutils literal"><span class="pre">null</span></tt> compare equal to each other</li>
|
495
|
+
<li><tt class="docutils literal"><span class="pre">undefined</span></tt> and <tt class="docutils literal"><span class="pre">null</span></tt> are less than anything else</li>
|
496
|
+
<li>If JavaScript says <tt class="docutils literal"><span class="pre">a</span> <span class="pre">==</span> <span class="pre">b</span></tt>, then we trust it</li>
|
497
|
+
<li>comparators registered with registerComparator are used to
|
498
|
+
find a good comparator. Built-in comparators are currently
|
499
|
+
available for <tt class="docutils literal"><span class="pre">Array</span></tt>-like and <tt class="docutils literal"><span class="pre">Date</span></tt>-like objects.</li>
|
500
|
+
<li>Otherwise hope that the built-in comparison operators do
|
501
|
+
something useful, which should work for numbers and strings.</li>
|
502
|
+
<li>If neither <tt class="docutils literal"><span class="pre">a</span> <span class="pre"><</span> <span class="pre">b</span></tt> or <tt class="docutils literal"><span class="pre">a</span> <span class="pre">></span> <span class="pre">b</span></tt>, then throw a <tt class="docutils literal"><span class="pre">TypeError</span></tt></li>
|
503
|
+
</ol>
|
504
|
+
<p>Returns what one would expect from a comparison function:</p>
|
505
|
+
<table border="1" class="docutils">
|
506
|
+
<colgroup>
|
507
|
+
<col width="42%" />
|
508
|
+
<col width="58%" />
|
509
|
+
</colgroup>
|
510
|
+
<tbody valign="top">
|
511
|
+
<tr><td>Value</td>
|
512
|
+
<td>Condition</td>
|
513
|
+
</tr>
|
514
|
+
<tr><td><tt class="docutils literal"><span class="pre">0</span></tt></td>
|
515
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">==</span> <span class="pre">b</span></tt></td>
|
516
|
+
</tr>
|
517
|
+
<tr><td><tt class="docutils literal"><span class="pre">1</span></tt></td>
|
518
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">></span> <span class="pre">b</span></tt></td>
|
519
|
+
</tr>
|
520
|
+
<tr><td><tt class="docutils literal"><span class="pre">-1</span></tt></td>
|
521
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre"><</span> <span class="pre">b</span></tt></td>
|
522
|
+
</tr>
|
523
|
+
</tbody>
|
524
|
+
</table>
|
525
|
+
<dl class="docutils">
|
526
|
+
<dt><em>Availability</em>:</dt>
|
527
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
528
|
+
</dl>
|
529
|
+
</blockquote>
|
530
|
+
<p>
|
531
|
+
<a name="fn-compose"></a>
|
532
|
+
<a class="mochidef reference" href="#fn-compose">compose(f1, f2, ..., fN)</a>:</p>
|
533
|
+
<blockquote>
|
534
|
+
<p>Return a new function as the combination of the given function
|
535
|
+
arguments, equivalent to <tt class="docutils literal"><span class="pre">f1(f2(arguments))</span></tt>.</p>
|
536
|
+
<dl class="docutils">
|
537
|
+
<dt><em>Availability</em>:</dt>
|
538
|
+
<dd>Available in MochiKit 1.4+</dd>
|
539
|
+
</dl>
|
540
|
+
</blockquote>
|
541
|
+
<p>
|
542
|
+
<a name="fn-concat"></a>
|
543
|
+
<a class="mochidef reference" href="#fn-concat">concat(lst[, ...])</a>:</p>
|
544
|
+
<blockquote>
|
545
|
+
<p>Concatenates all given <tt class="docutils literal"><span class="pre">Array</span></tt>-like arguments and returns
|
546
|
+
a new <tt class="docutils literal"><span class="pre">Array</span></tt>:</p>
|
547
|
+
<pre class="literal-block">
|
548
|
+
var lst = concat(["1","3","5"], ["2","4","6"]);
|
549
|
+
assert( lst.toString() == "1,3,5,2,4,6" );
|
550
|
+
</pre>
|
551
|
+
<dl class="docutils">
|
552
|
+
<dt><em>Availability</em>:</dt>
|
553
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
554
|
+
</dl>
|
555
|
+
</blockquote>
|
556
|
+
<p>
|
557
|
+
<a name="fn-counter"></a>
|
558
|
+
<a class="mochidef reference" href="#fn-counter">counter(n=1)</a>:</p>
|
559
|
+
<blockquote>
|
560
|
+
<p>Returns a function that will return a number one greater than
|
561
|
+
the previous returned value, starting at <tt class="docutils literal"><span class="pre">n</span></tt>. For example:</p>
|
562
|
+
<pre class="literal-block">
|
563
|
+
nextId = counter()
|
564
|
+
assert( nextId() == 1 )
|
565
|
+
assert( nextId() == 2 )
|
566
|
+
</pre>
|
567
|
+
<p>For an iterator with this behavior, see
|
568
|
+
<a class="mochiref reference" href="Iter.html#fn-count">MochiKit.Iter.count</a>.</p>
|
569
|
+
<dl class="docutils">
|
570
|
+
<dt><em>Availability</em>:</dt>
|
571
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
572
|
+
</dl>
|
573
|
+
</blockquote>
|
574
|
+
<p>
|
575
|
+
<a name="fn-extend"></a>
|
576
|
+
<a class="mochidef reference" href="#fn-extend">extend(self, obj, skip=0)</a>:</p>
|
577
|
+
<blockquote>
|
578
|
+
<p>Mutate the array <tt class="docutils literal"><span class="pre">self</span></tt> by extending it with an <tt class="docutils literal"><span class="pre">Array</span></tt>-like
|
579
|
+
<tt class="docutils literal"><span class="pre">obj</span></tt>, starting from index <tt class="docutils literal"><span class="pre">skip</span></tt>. If <tt class="docutils literal"><span class="pre">null</span></tt> is given as the
|
580
|
+
initial array, a new one will be created.</p>
|
581
|
+
<p>This mutates <em>and returns</em> <tt class="docutils literal"><span class="pre">self</span></tt>, be warned.</p>
|
582
|
+
<dl class="docutils">
|
583
|
+
<dt><em>Availability</em>:</dt>
|
584
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
585
|
+
</dl>
|
586
|
+
</blockquote>
|
587
|
+
<p>
|
588
|
+
<a name="fn-evaljson"></a>
|
589
|
+
<a class="mochidef reference" href="#fn-evaljson">evalJSON(aJSONString)</a>:</p>
|
590
|
+
<blockquote>
|
591
|
+
<p>Unserialize a JSON <a class="footnote-reference" href="#id7" id="id4" name="id4">[1]</a> represenation of an object.</p>
|
592
|
+
<p>Note that this uses the <tt class="docutils literal"><span class="pre">eval</span></tt> function of the interpreter, and
|
593
|
+
therefore trusts the contents of <tt class="docutils literal"><span class="pre">aJSONString</span></tt> to be safe. This
|
594
|
+
is acceptable when the JSON and JavaScript application originate
|
595
|
+
from the same server, but in other scenarios it may not be the
|
596
|
+
appropriate security model. Currently, a validating JSON parser is
|
597
|
+
beyond the scope of MochiKit, but there is one available from
|
598
|
+
json.org <a class="footnote-reference" href="#id7" id="id5" name="id5">[1]</a>.</p>
|
599
|
+
<dl class="docutils">
|
600
|
+
<dt><em>Availability</em>:</dt>
|
601
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
602
|
+
</dl>
|
603
|
+
</blockquote>
|
604
|
+
<p>
|
605
|
+
<a name="fn-filter"></a>
|
606
|
+
<a class="mochidef reference" href="#fn-filter">filter(fn, lst)</a>:</p>
|
607
|
+
<blockquote>
|
608
|
+
<p>Returns a new <tt class="docutils literal"><span class="pre">Array</span></tt> composed of all elements from <tt class="docutils literal"><span class="pre">lst</span></tt>
|
609
|
+
where <tt class="docutils literal"><span class="pre">fn(lst[i])</span></tt> returns a true value.</p>
|
610
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, <tt class="docutils literal"><span class="pre">operator.truth</span></tt> will be used.</p>
|
611
|
+
<dl class="docutils">
|
612
|
+
<dt><em>Availability</em>:</dt>
|
613
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
614
|
+
</dl>
|
615
|
+
</blockquote>
|
616
|
+
<p>
|
617
|
+
<a name="fn-findvalue"></a>
|
618
|
+
<a class="mochidef reference" href="#fn-findvalue">findValue(lst, value, start=0, end=lst.length)</a>:</p>
|
619
|
+
<blockquote>
|
620
|
+
<p>Finds the index of <tt class="docutils literal"><span class="pre">value</span></tt> in the <tt class="docutils literal"><span class="pre">Array</span></tt>-like object <tt class="docutils literal"><span class="pre">lst</span></tt>
|
621
|
+
using <a class="mochiref reference" href="#fn-compare">compare</a>. The search starts at the index
|
622
|
+
<tt class="docutils literal"><span class="pre">start</span></tt>, and ends at the index <tt class="docutils literal"><span class="pre">end</span> <span class="pre">-</span> <span class="pre">1</span></tt>. If <tt class="docutils literal"><span class="pre">value</span></tt> is not
|
623
|
+
found in <tt class="docutils literal"><span class="pre">lst</span></tt>, it will return <tt class="docutils literal"><span class="pre">-1</span></tt>.</p>
|
624
|
+
<p>For example:</p>
|
625
|
+
<pre class="literal-block">
|
626
|
+
assert( findValue([1, 2, 3, 2, 1], 2) == 1 )
|
627
|
+
assert( findValue([1, 2, 3, 2, 1], 2, 2) == 3 )
|
628
|
+
</pre>
|
629
|
+
<dl class="docutils">
|
630
|
+
<dt><em>Availability</em>:</dt>
|
631
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
632
|
+
</dl>
|
633
|
+
</blockquote>
|
634
|
+
<p>
|
635
|
+
<a name="fn-findidentical"></a>
|
636
|
+
<a class="mochidef reference" href="#fn-findidentical">findIdentical(lst, value, start=0, end=lst.length)</a>:</p>
|
637
|
+
<blockquote>
|
638
|
+
<p>Finds the index of <tt class="docutils literal"><span class="pre">value</span></tt> in the <tt class="docutils literal"><span class="pre">Array</span></tt>-like object <tt class="docutils literal"><span class="pre">lst</span></tt>
|
639
|
+
using the <tt class="docutils literal"><span class="pre">===</span></tt> operator. The search starts at the index
|
640
|
+
<tt class="docutils literal"><span class="pre">start</span></tt>, and ends at the index <tt class="docutils literal"><span class="pre">end</span> <span class="pre">-</span> <span class="pre">1</span></tt>. If <tt class="docutils literal"><span class="pre">value</span></tt> is not
|
641
|
+
found in <tt class="docutils literal"><span class="pre">lst</span></tt>, it will return <tt class="docutils literal"><span class="pre">-1</span></tt>.</p>
|
642
|
+
<p>You should use this function instead of <a class="mochiref reference" href="#fn-findvalue">findValue</a> if
|
643
|
+
<tt class="docutils literal"><span class="pre">lst</span></tt> may be comprised of objects for which no comparator is
|
644
|
+
defined and all you care about is finding an identical object
|
645
|
+
(e.g. the same instance), or if <tt class="docutils literal"><span class="pre">lst</span></tt> is comprised of just
|
646
|
+
numbers or strings and performance is important.</p>
|
647
|
+
<p>For example:</p>
|
648
|
+
<pre class="literal-block">
|
649
|
+
assert( findIdentical([1, 2, 3, 2, 1], 2) == 1 )
|
650
|
+
assert( findIdentical([1, 2, 3, 2, 1], 2, 2) == 3 )
|
651
|
+
</pre>
|
652
|
+
<dl class="docutils">
|
653
|
+
<dt><em>Availability</em>:</dt>
|
654
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
655
|
+
</dl>
|
656
|
+
</blockquote>
|
657
|
+
<p>
|
658
|
+
<a name="fn-flattenarguments"></a>
|
659
|
+
<a class="mochidef reference" href="#fn-flattenarguments">flattenArguments(arg[, ...])</a>:</p>
|
660
|
+
<blockquote>
|
661
|
+
<p>Given a bunch of arguments, return a single <tt class="docutils literal"><span class="pre">Array</span></tt> containing
|
662
|
+
all of those arguments. Any <tt class="docutils literal"><span class="pre">Array</span></tt>-like argument will be extended
|
663
|
+
in-place, e.g.:</p>
|
664
|
+
<pre class="literal-block">
|
665
|
+
compare(flattenArguments(1, [2, 3, [4, 5]]), [1, 2, 3, 4, 5]) == 0
|
666
|
+
</pre>
|
667
|
+
<dl class="docutils">
|
668
|
+
<dt><em>Availability</em>:</dt>
|
669
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
670
|
+
</dl>
|
671
|
+
</blockquote>
|
672
|
+
<p>
|
673
|
+
<a name="fn-flattenarray"></a>
|
674
|
+
<a class="mochidef reference" href="#fn-flattenarray">flattenArray(lst)</a>:</p>
|
675
|
+
<blockquote>
|
676
|
+
<p>Return a new <tt class="docutils literal"><span class="pre">Array</span></tt> consisting of every item in lst with <tt class="docutils literal"><span class="pre">Array</span></tt>
|
677
|
+
items expanded in-place recursively. This differs from
|
678
|
+
<a class="mochiref reference" href="#fn-flattenarguments">flattenArguments</a> in that it only takes one argument and
|
679
|
+
it only flattens items that are <tt class="docutils literal"><span class="pre">instanceof</span> <span class="pre">Array</span></tt>.</p>
|
680
|
+
<blockquote>
|
681
|
+
compare(flattenArray([1, [2, 3, [4, 5]]]), [1, 2, 3, 4, 5]) == 0</blockquote>
|
682
|
+
<dl class="docutils">
|
683
|
+
<dt><em>Availability</em>:</dt>
|
684
|
+
<dd>Available in MochiKit 1.4+</dd>
|
685
|
+
</dl>
|
686
|
+
</blockquote>
|
687
|
+
<p>
|
688
|
+
<a name="fn-forwardcall"></a>
|
689
|
+
<a class="mochidef reference" href="#fn-forwardcall">forwardCall(name)</a>:</p>
|
690
|
+
<blockquote>
|
691
|
+
<p>Returns a function that forwards a method call to
|
692
|
+
<tt class="docutils literal"><span class="pre">this.name(...)</span></tt></p>
|
693
|
+
<dl class="docutils">
|
694
|
+
<dt><em>Availability</em>:</dt>
|
695
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
696
|
+
</dl>
|
697
|
+
</blockquote>
|
698
|
+
<p>
|
699
|
+
<a name="fn-isarraylike"></a>
|
700
|
+
<a class="mochidef reference" href="#fn-isarraylike">isArrayLike(obj[, ...])</a>:</p>
|
701
|
+
<blockquote>
|
702
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all given arguments are <tt class="docutils literal"><span class="pre">Array</span></tt>-like (have a
|
703
|
+
<tt class="docutils literal"><span class="pre">.length</span></tt> property and <tt class="docutils literal"><span class="pre">typeof(obj)</span> <span class="pre">==</span> <span class="pre">'object'</span></tt>)</p>
|
704
|
+
<dl class="docutils">
|
705
|
+
<dt><em>Availability</em>:</dt>
|
706
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
707
|
+
</dl>
|
708
|
+
</blockquote>
|
709
|
+
<p>
|
710
|
+
<a name="fn-isdatelike"></a>
|
711
|
+
<a class="mochidef reference" href="#fn-isdatelike">isDateLike(obj[, ...])</a>:</p>
|
712
|
+
<blockquote>
|
713
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all given arguments are <tt class="docutils literal"><span class="pre">Date</span></tt>-like (have a
|
714
|
+
<tt class="docutils literal"><span class="pre">.getTime()</span></tt> method)</p>
|
715
|
+
<dl class="docutils">
|
716
|
+
<dt><em>Availability</em>:</dt>
|
717
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
718
|
+
</dl>
|
719
|
+
</blockquote>
|
720
|
+
<p>
|
721
|
+
<a name="fn-isempty"></a>
|
722
|
+
<a class="mochidef reference" href="#fn-isempty">isEmpty(obj[, ...])</a>:</p>
|
723
|
+
<blockquote>
|
724
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all the given <tt class="docutils literal"><span class="pre">Array</span></tt>-like or string
|
725
|
+
arguments are empty <tt class="docutils literal"><span class="pre">(obj.length</span> <span class="pre">==</span> <span class="pre">0)</span></tt></p>
|
726
|
+
<dl class="docutils">
|
727
|
+
<dt><em>Availability</em>:</dt>
|
728
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
729
|
+
</dl>
|
730
|
+
</blockquote>
|
731
|
+
<p>
|
732
|
+
<a name="fn-isnotempty"></a>
|
733
|
+
<a class="mochidef reference" href="#fn-isnotempty">isNotEmpty(obj[, ...])</a>:</p>
|
734
|
+
<blockquote>
|
735
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all the given <tt class="docutils literal"><span class="pre">Array</span></tt>-like or string
|
736
|
+
arguments are not empty <tt class="docutils literal"><span class="pre">(obj.length</span> <span class="pre">></span> <span class="pre">0)</span></tt></p>
|
737
|
+
<dl class="docutils">
|
738
|
+
<dt><em>Availability</em>:</dt>
|
739
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
740
|
+
</dl>
|
741
|
+
</blockquote>
|
742
|
+
<p>
|
743
|
+
<a name="fn-isnull"></a>
|
744
|
+
<a class="mochidef reference" href="#fn-isnull">isNull(obj[, ...])</a>:</p>
|
745
|
+
<blockquote>
|
746
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all arguments are <tt class="docutils literal"><span class="pre">null</span></tt>.</p>
|
747
|
+
<dl class="docutils">
|
748
|
+
<dt><em>Availability</em>:</dt>
|
749
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
750
|
+
</dl>
|
751
|
+
</blockquote>
|
752
|
+
<p>
|
753
|
+
<a name="fn-isundefinedornull"></a>
|
754
|
+
<a class="mochidef reference" href="#fn-isundefinedornull">isUndefinedOrNull(obj[, ...])</a>:</p>
|
755
|
+
<blockquote>
|
756
|
+
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> if all arguments are undefined or <tt class="docutils literal"><span class="pre">null</span></tt></p>
|
757
|
+
<dl class="docutils">
|
758
|
+
<dt><em>Availability</em>:</dt>
|
759
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
760
|
+
</dl>
|
761
|
+
</blockquote>
|
762
|
+
<p>
|
763
|
+
<a name="fn-itemgetter"></a>
|
764
|
+
<a class="mochidef reference" href="#fn-itemgetter">itemgetter(name)</a>:</p>
|
765
|
+
<blockquote>
|
766
|
+
<p>Returns a <tt class="docutils literal"><span class="pre">function(obj)</span></tt> that returns <tt class="docutils literal"><span class="pre">obj[name]</span></tt></p>
|
767
|
+
<dl class="docutils">
|
768
|
+
<dt><em>Availability</em>:</dt>
|
769
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
770
|
+
</dl>
|
771
|
+
</blockquote>
|
772
|
+
<p>
|
773
|
+
<a name="fn-items"></a>
|
774
|
+
<a class="mochidef reference" href="#fn-items">items(obj)</a>:</p>
|
775
|
+
<blockquote>
|
776
|
+
<p>Return an <tt class="docutils literal"><span class="pre">Array</span></tt> of <tt class="docutils literal"><span class="pre">[propertyName,</span> <span class="pre">propertyValue]</span></tt> pairs for
|
777
|
+
the given <tt class="docutils literal"><span class="pre">obj</span></tt> (in the order determined by <tt class="docutils literal"><span class="pre">for</span> <span class="pre">propName</span> <span class="pre">in</span>
|
778
|
+
<span class="pre">obj</span></tt>).</p>
|
779
|
+
<dl class="docutils">
|
780
|
+
<dt><em>Availability</em>:</dt>
|
781
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
782
|
+
</dl>
|
783
|
+
</blockquote>
|
784
|
+
<p>
|
785
|
+
<a name="fn-keycomparator"></a>
|
786
|
+
<a class="mochidef reference" href="#fn-keycomparator">keyComparator(key[, ...])</a>:</p>
|
787
|
+
<blockquote>
|
788
|
+
<p>A comparator factory that compares <tt class="docutils literal"><span class="pre">a[key]</span></tt> with <tt class="docutils literal"><span class="pre">b[key]</span></tt>.
|
789
|
+
e.g.:</p>
|
790
|
+
<pre class="literal-block">
|
791
|
+
var lst = ["a", "bbb", "cc"];
|
792
|
+
lst.sort(keyComparator("length"));
|
793
|
+
assert( lst.toString() == "a,cc,bbb" );
|
794
|
+
</pre>
|
795
|
+
<dl class="docutils">
|
796
|
+
<dt><em>Availability</em>:</dt>
|
797
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
798
|
+
</dl>
|
799
|
+
</blockquote>
|
800
|
+
<p>
|
801
|
+
<a name="fn-keys"></a>
|
802
|
+
<a class="mochidef reference" href="#fn-keys">keys(obj)</a>:</p>
|
803
|
+
<blockquote>
|
804
|
+
<p>Return an <tt class="docutils literal"><span class="pre">Array</span></tt> of the property names of an object (in the
|
805
|
+
order determined by <tt class="docutils literal"><span class="pre">for</span> <span class="pre">propName</span> <span class="pre">in</span> <span class="pre">obj</span></tt>).</p>
|
806
|
+
<dl class="docutils">
|
807
|
+
<dt><em>Availability</em>:</dt>
|
808
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
809
|
+
</dl>
|
810
|
+
</blockquote>
|
811
|
+
<p>
|
812
|
+
<a name="fn-listmax"></a>
|
813
|
+
<a class="mochidef reference" href="#fn-listmax">listMax(lst)</a>:</p>
|
814
|
+
<blockquote>
|
815
|
+
<p>Return the largest element of an <tt class="docutils literal"><span class="pre">Array</span></tt>-like object, as
|
816
|
+
determined by <a class="mochiref reference" href="#fn-compare">compare</a>. This is a special form of
|
817
|
+
<a class="mochiref reference" href="#fn-listminmax">listMinMax</a>, specifically
|
818
|
+
<a class="mochiref reference" href="#fn-partial">partial(listMinMax, 1)</a>.</p>
|
819
|
+
<dl class="docutils">
|
820
|
+
<dt><em>Availability</em>:</dt>
|
821
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
822
|
+
</dl>
|
823
|
+
</blockquote>
|
824
|
+
<p>
|
825
|
+
<a name="fn-listmin"></a>
|
826
|
+
<a class="mochidef reference" href="#fn-listmin">listMin(lst)</a>:</p>
|
827
|
+
<blockquote>
|
828
|
+
<p>Return the smallest element of an <tt class="docutils literal"><span class="pre">Array</span></tt>-like object, as
|
829
|
+
determined by <a class="mochiref reference" href="#fn-compare">compare</a>. This is a special form of
|
830
|
+
<a class="mochiref reference" href="#fn-listminmax">listMinMax</a>, specifically
|
831
|
+
<a class="mochiref reference" href="#fn-partial">partial(listMinMax, -1)</a>.</p>
|
832
|
+
<dl class="docutils">
|
833
|
+
<dt><em>Availability</em>:</dt>
|
834
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
835
|
+
</dl>
|
836
|
+
</blockquote>
|
837
|
+
<p>
|
838
|
+
<a name="fn-listminmax"></a>
|
839
|
+
<a class="mochidef reference" href="#fn-listminmax">listMinMax(which, lst)</a>:</p>
|
840
|
+
<blockquote>
|
841
|
+
<p>If <tt class="docutils literal"><span class="pre">which</span> <span class="pre">==</span> <span class="pre">-1</span></tt> then it will return the smallest element of the
|
842
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like <tt class="docutils literal"><span class="pre">lst</span></tt>. This is also available as
|
843
|
+
<a class="mochiref reference" href="#fn-listmin">listMin(lst)</a>.</p>
|
844
|
+
<p>If <tt class="docutils literal"><span class="pre">which</span> <span class="pre">==</span> <span class="pre">1</span></tt> then it will return the largest element of the
|
845
|
+
<tt class="docutils literal"><span class="pre">Array</span></tt>-like <tt class="docutils literal"><span class="pre">lst</span></tt>. This is also available as
|
846
|
+
<a class="mochiref reference" href="#fn-listmax">listMax(list)</a>.</p>
|
847
|
+
<dl class="docutils">
|
848
|
+
<dt><em>Availability</em>:</dt>
|
849
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
850
|
+
</dl>
|
851
|
+
</blockquote>
|
852
|
+
<p>
|
853
|
+
<a name="fn-map"></a>
|
854
|
+
<a class="mochidef reference" href="#fn-map">map(fn, lst[, ...])</a>:</p>
|
855
|
+
<blockquote>
|
856
|
+
<p>Return a new array composed of the results of <tt class="docutils literal"><span class="pre">fn(x)</span></tt> for every
|
857
|
+
<tt class="docutils literal"><span class="pre">x</span></tt> in <tt class="docutils literal"><span class="pre">lst</span></tt>.</p>
|
858
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, and only one sequence argument is given the
|
859
|
+
identity function is used.</p>
|
860
|
+
<blockquote>
|
861
|
+
<a class="mochiref reference" href="#fn-map">map(null, lst)</a> -> <tt class="docutils literal"><span class="pre">lst.slice()</span></tt>;</blockquote>
|
862
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is not <tt class="docutils literal"><span class="pre">null</span></tt> and more than one sequence argument is
|
863
|
+
given, then one element from each sequence is used to build the
|
864
|
+
argument list for <tt class="docutils literal"><span class="pre">fn</span></tt>.</p>
|
865
|
+
<blockquote>
|
866
|
+
<dl class="docutils">
|
867
|
+
<dt><a class="mochiref reference" href="#fn-map">map(fn, p, q, ...)</a></dt>
|
868
|
+
<dd>-> <tt class="docutils literal"><span class="pre">[fn(p[0],</span> <span class="pre">q[0],</span> <span class="pre">..),</span> <span class="pre">fn(p[1],</span> <span class="pre">q[1],</span> <span class="pre">...),</span> <span class="pre">...]</span></tt></dd>
|
869
|
+
</dl>
|
870
|
+
</blockquote>
|
871
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, and more than one sequence is given as
|
872
|
+
arguments, then the <tt class="docutils literal"><span class="pre">Array</span></tt> function is used.</p>
|
873
|
+
<blockquote>
|
874
|
+
<dl class="docutils">
|
875
|
+
<dt><a class="mochiref reference" href="#fn-map">map(null, p, q, ...)</a></dt>
|
876
|
+
<dd>-> <a class="mochiref reference" href="Iter.html#fn-zip">MochiKit.Iter.zip(p, q, ...)</a>
|
877
|
+
-> <tt class="docutils literal"><span class="pre">[[p0,</span> <span class="pre">q0,</span> <span class="pre">...],</span> <span class="pre">[p1,</span> <span class="pre">q1,</span> <span class="pre">...],</span> <span class="pre">...];</span></tt></dd>
|
878
|
+
</dl>
|
879
|
+
</blockquote>
|
880
|
+
<p>Since this is a common idiom, <a class="mochiref reference" href="#fn-zip">zip(p, q, ...)</a>
|
881
|
+
is actually a shortcut for this.</p>
|
882
|
+
<dl class="docutils">
|
883
|
+
<dt><em>Availability</em>:</dt>
|
884
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
885
|
+
</dl>
|
886
|
+
</blockquote>
|
887
|
+
<p>
|
888
|
+
<a name="fn-mean"></a>
|
889
|
+
<a class="mochidef reference" href="#fn-mean">mean(lst[, ...])</a>:</p>
|
890
|
+
<blockquote>
|
891
|
+
<p>Returns the arithmetic mean (average) of the argument list, or an array.
|
892
|
+
This function applies <a class="mochiref reference" href="#fn-flattenarguments">flattenArguments()</a> to the argument list.</p>
|
893
|
+
<dl class="docutils">
|
894
|
+
<dt><em>Availability</em>:</dt>
|
895
|
+
<dd>Available in MochiKit 1.4+</dd>
|
896
|
+
</dl>
|
897
|
+
</blockquote>
|
898
|
+
<p>
|
899
|
+
<a name="fn-median"></a>
|
900
|
+
<a class="mochidef reference" href="#fn-median">median(lst[, ...])</a>:</p>
|
901
|
+
<blockquote>
|
902
|
+
<p>Returns the median of the argument list, or an array. This function
|
903
|
+
applies <a class="mochiref reference" href="#fn-flattenarguments">flattenArguments()</a> to the argument list.</p>
|
904
|
+
<dl class="docutils">
|
905
|
+
<dt><em>Availability</em>:</dt>
|
906
|
+
<dd>Available in MochiKit 1.4+</dd>
|
907
|
+
</dl>
|
908
|
+
</blockquote>
|
909
|
+
<p>
|
910
|
+
<a name="fn-merge"></a>
|
911
|
+
<a class="mochidef reference" href="#fn-merge">merge(obj[, ...])</a>:</p>
|
912
|
+
<blockquote>
|
913
|
+
<p>Create a new instance of <tt class="docutils literal"><span class="pre">Object</span></tt> that contains every property
|
914
|
+
from all given objects. If a property is defined on more than one
|
915
|
+
of the objects, the last property is used.</p>
|
916
|
+
<p>This is a special form of <a class="mochiref reference" href="#fn-update">update(self, obj[, ...])</a>,
|
917
|
+
specifically, it is defined as <a class="mochiref reference" href="#fn-partial">partial(update, null)</a>.</p>
|
918
|
+
<dl class="docutils">
|
919
|
+
<dt><em>Availability</em>:</dt>
|
920
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
921
|
+
</dl>
|
922
|
+
</blockquote>
|
923
|
+
<p>
|
924
|
+
<a name="fn-method"></a>
|
925
|
+
<a class="mochidef reference" href="#fn-method">method(self, func, ...)</a>:</p>
|
926
|
+
<blockquote>
|
927
|
+
<p>Alternate form of <a class="mochiref reference" href="#fn-bind">bind</a> that takes the object before
|
928
|
+
the function. These two calls are equivalent:</p>
|
929
|
+
<pre class="literal-block">
|
930
|
+
bind("method", myobject)
|
931
|
+
method(myobject, "method")
|
932
|
+
</pre>
|
933
|
+
<dl class="docutils">
|
934
|
+
<dt><em>Availability</em>:</dt>
|
935
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
936
|
+
</dl>
|
937
|
+
</blockquote>
|
938
|
+
<p>
|
939
|
+
<a name="fn-methodcaller"></a>
|
940
|
+
<a class="mochidef reference" href="#fn-methodcaller">methodcaller(name[, args...])</a>:</p>
|
941
|
+
<blockquote>
|
942
|
+
<p>Return a new function that calls a method on its argument,
|
943
|
+
for example:</p>
|
944
|
+
<pre class="literal-block">
|
945
|
+
lst = map(methodcaller("toLowerCase"), ["THIS", "is", "LoWeRCaSe"]);
|
946
|
+
assert( lst.join(" ") == "this is lowercase" );
|
947
|
+
</pre>
|
948
|
+
<dl class="docutils">
|
949
|
+
<dt><em>Availability</em>:</dt>
|
950
|
+
<dd>Available in MochiKit 1.4+</dd>
|
951
|
+
</dl>
|
952
|
+
</blockquote>
|
953
|
+
<p>
|
954
|
+
<a name="fn-namefunctions"></a>
|
955
|
+
<a class="mochidef reference" href="#fn-namefunctions">nameFunctions(namespace)</a>:</p>
|
956
|
+
<blockquote>
|
957
|
+
<p>Given a <tt class="docutils literal"><span class="pre">namespace</span></tt> (object or function) with a <tt class="docutils literal"><span class="pre">NAME</span></tt>
|
958
|
+
property, find all methods in it and give them nice <tt class="docutils literal"><span class="pre">NAME</span></tt>
|
959
|
+
properties too (for use with <a class="mochiref reference" href="#fn-repr">repr</a>). e.g.:</p>
|
960
|
+
<pre class="literal-block">
|
961
|
+
namespace = {
|
962
|
+
NAME: "Awesome",
|
963
|
+
Dude: function () {}
|
964
|
+
}
|
965
|
+
nameFunctions(namespace);
|
966
|
+
assert( namespace.Dude.NAME == 'Awesome.Dude' );
|
967
|
+
</pre>
|
968
|
+
<dl class="docutils">
|
969
|
+
<dt><em>Availability</em>:</dt>
|
970
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
971
|
+
</dl>
|
972
|
+
</blockquote>
|
973
|
+
<p>
|
974
|
+
<a name="fn-noop"></a>
|
975
|
+
<a class="mochidef reference" href="#fn-noop">noop()</a>:</p>
|
976
|
+
<blockquote>
|
977
|
+
<p>A function that performs no operation. Use this where you would
|
978
|
+
otherwise use <tt class="docutils literal"><span class="pre">(function</span> <span class="pre">()</span> <span class="pre">{})</span></tt> in order to avoid Internet
|
979
|
+
Explorer cyclic garbage leakage.</p>
|
980
|
+
<dl class="docutils">
|
981
|
+
<dt><em>Availability</em>:</dt>
|
982
|
+
<dd>Available in MochiKit 1.4</dd>
|
983
|
+
</dl>
|
984
|
+
</blockquote>
|
985
|
+
<p>
|
986
|
+
<a name="fn-objequal"></a>
|
987
|
+
<a class="mochidef reference" href="#fn-objequal">objEqual(a, b)</a>:</p>
|
988
|
+
<blockquote>
|
989
|
+
<p>Return <tt class="docutils literal"><span class="pre">true</span></tt> if <tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">==</span> <span class="pre">0</span></tt></p>
|
990
|
+
<dl class="docutils">
|
991
|
+
<dt><em>Availability</em>:</dt>
|
992
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
993
|
+
</dl>
|
994
|
+
</blockquote>
|
995
|
+
<p>
|
996
|
+
<a name="fn-nodewalk"></a>
|
997
|
+
<a class="mochidef reference" href="#fn-nodewalk">nodeWalk(node, visitor)</a>:</p>
|
998
|
+
<blockquote>
|
999
|
+
<p>Non-recursive generic node walking function (e.g. for a DOM).</p>
|
1000
|
+
<p>The walk order for nodeWalk is breadth first, meaning that all
|
1001
|
+
siblings will be visited before any children.</p>
|
1002
|
+
<dl class="docutils">
|
1003
|
+
<dt><tt class="docutils literal"><span class="pre">node</span></tt>:</dt>
|
1004
|
+
<dd>The initial node to be searched.</dd>
|
1005
|
+
<dt><tt class="docutils literal"><span class="pre">visitor</span></tt>:</dt>
|
1006
|
+
<dd>The visitor function, will be called as <tt class="docutils literal"><span class="pre">visitor(node)</span></tt>, and
|
1007
|
+
should return an <tt class="docutils literal"><span class="pre">Array</span></tt>-like of nodes to be searched next
|
1008
|
+
(e.g. <tt class="docutils literal"><span class="pre">node.childNodes</span></tt>). Leaf nodes may return <tt class="docutils literal"><span class="pre">null</span></tt> or
|
1009
|
+
<tt class="docutils literal"><span class="pre">undefined</span></tt>.</dd>
|
1010
|
+
<dt><em>Availability</em>:</dt>
|
1011
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1012
|
+
</dl>
|
1013
|
+
</blockquote>
|
1014
|
+
<p>
|
1015
|
+
<a name="fn-objmax"></a>
|
1016
|
+
<a class="mochidef reference" href="#fn-objmax">objMax(obj[, ...])</a>:</p>
|
1017
|
+
<blockquote>
|
1018
|
+
<p>Return the maximum object according to <a class="mochiref reference" href="#fn-compare">compare</a> out of
|
1019
|
+
the given arguments. This is similar to <a class="mochiref reference" href="#fn-listmax">listMax</a>,
|
1020
|
+
except is uses the arguments instead of a given <tt class="docutils literal"><span class="pre">Array</span></tt>-like.</p>
|
1021
|
+
<dl class="docutils">
|
1022
|
+
<dt><em>Availability</em>:</dt>
|
1023
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1024
|
+
</dl>
|
1025
|
+
</blockquote>
|
1026
|
+
<p>
|
1027
|
+
<a name="fn-objmin"></a>
|
1028
|
+
<a class="mochidef reference" href="#fn-objmin">objMin(obj[, ...])</a>:</p>
|
1029
|
+
<blockquote>
|
1030
|
+
<p>Return the minimum object according to <a class="mochiref reference" href="#fn-compare">compare</a> out of
|
1031
|
+
the given arguments. This is similar to <a class="mochiref reference" href="#fn-listmin">listMin</a>,
|
1032
|
+
except it uses the arguments instead of a given <tt class="docutils literal"><span class="pre">Array</span></tt>-like.</p>
|
1033
|
+
<dl class="docutils">
|
1034
|
+
<dt><em>Availability</em>:</dt>
|
1035
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1036
|
+
</dl>
|
1037
|
+
</blockquote>
|
1038
|
+
<p>
|
1039
|
+
<a name="fn-operator"></a>
|
1040
|
+
<a class="mochidef reference" href="#fn-operator">operator</a>:</p>
|
1041
|
+
<blockquote>
|
1042
|
+
<p>A table of JavaScript's operators for usage with <a class="mochiref reference" href="#fn-map">map</a>,
|
1043
|
+
<a class="mochiref reference" href="#fn-filter">filter</a>, etc.</p>
|
1044
|
+
<p>Unary Logic Operators:</p>
|
1045
|
+
<blockquote>
|
1046
|
+
<table border="1" class="docutils">
|
1047
|
+
<colgroup>
|
1048
|
+
<col width="31%" />
|
1049
|
+
<col width="40%" />
|
1050
|
+
<col width="29%" />
|
1051
|
+
</colgroup>
|
1052
|
+
<thead valign="bottom">
|
1053
|
+
<tr><th class="head">Operator</th>
|
1054
|
+
<th class="head">Implementation</th>
|
1055
|
+
<th class="head">Description</th>
|
1056
|
+
</tr>
|
1057
|
+
</thead>
|
1058
|
+
<tbody valign="top">
|
1059
|
+
<tr><td><tt class="docutils literal"><span class="pre">truth(a)</span></tt></td>
|
1060
|
+
<td><tt class="docutils literal"><span class="pre">!!a</span></tt></td>
|
1061
|
+
<td>Logical truth</td>
|
1062
|
+
</tr>
|
1063
|
+
<tr><td><tt class="docutils literal"><span class="pre">lognot(a)</span></tt></td>
|
1064
|
+
<td><tt class="docutils literal"><span class="pre">!a</span></tt></td>
|
1065
|
+
<td>Logical not</td>
|
1066
|
+
</tr>
|
1067
|
+
<tr><td><tt class="docutils literal"><span class="pre">identity(a)</span></tt></td>
|
1068
|
+
<td><tt class="docutils literal"><span class="pre">a</span></tt></td>
|
1069
|
+
<td>Logical identity</td>
|
1070
|
+
</tr>
|
1071
|
+
</tbody>
|
1072
|
+
</table>
|
1073
|
+
</blockquote>
|
1074
|
+
<p>Unary Math Operators:</p>
|
1075
|
+
<blockquote>
|
1076
|
+
<table border="1" class="docutils">
|
1077
|
+
<colgroup>
|
1078
|
+
<col width="33%" />
|
1079
|
+
<col width="43%" />
|
1080
|
+
<col width="25%" />
|
1081
|
+
</colgroup>
|
1082
|
+
<thead valign="bottom">
|
1083
|
+
<tr><th class="head">Operator</th>
|
1084
|
+
<th class="head">Implementation</th>
|
1085
|
+
<th class="head">Description</th>
|
1086
|
+
</tr>
|
1087
|
+
</thead>
|
1088
|
+
<tbody valign="top">
|
1089
|
+
<tr><td><tt class="docutils literal"><span class="pre">not(a)</span></tt></td>
|
1090
|
+
<td><tt class="docutils literal"><span class="pre">~a</span></tt></td>
|
1091
|
+
<td>Bitwise not</td>
|
1092
|
+
</tr>
|
1093
|
+
<tr><td><tt class="docutils literal"><span class="pre">neg(a)</span></tt></td>
|
1094
|
+
<td><tt class="docutils literal"><span class="pre">-a</span></tt></td>
|
1095
|
+
<td>Negation</td>
|
1096
|
+
</tr>
|
1097
|
+
</tbody>
|
1098
|
+
</table>
|
1099
|
+
</blockquote>
|
1100
|
+
<p>Binary Operators:</p>
|
1101
|
+
<blockquote>
|
1102
|
+
<table border="1" class="docutils">
|
1103
|
+
<colgroup>
|
1104
|
+
<col width="28%" />
|
1105
|
+
<col width="28%" />
|
1106
|
+
<col width="45%" />
|
1107
|
+
</colgroup>
|
1108
|
+
<thead valign="bottom">
|
1109
|
+
<tr><th class="head">Operator</th>
|
1110
|
+
<th class="head">Implementation</th>
|
1111
|
+
<th class="head">Description</th>
|
1112
|
+
</tr>
|
1113
|
+
</thead>
|
1114
|
+
<tbody valign="top">
|
1115
|
+
<tr><td><tt class="docutils literal"><span class="pre">add(a,</span> <span class="pre">b)</span></tt></td>
|
1116
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></tt></td>
|
1117
|
+
<td>Addition</td>
|
1118
|
+
</tr>
|
1119
|
+
<tr><td><tt class="docutils literal"><span class="pre">sub(a,</span> <span class="pre">b)</span></tt></td>
|
1120
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></tt></td>
|
1121
|
+
<td>Subtraction</td>
|
1122
|
+
</tr>
|
1123
|
+
<tr><td><tt class="docutils literal"><span class="pre">div(a,</span> <span class="pre">b)</span></tt></td>
|
1124
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">/</span> <span class="pre">b</span></tt></td>
|
1125
|
+
<td>Division</td>
|
1126
|
+
</tr>
|
1127
|
+
<tr><td><tt class="docutils literal"><span class="pre">mod(a,</span> <span class="pre">b)</span></tt></td>
|
1128
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">%</span> <span class="pre">b</span></tt></td>
|
1129
|
+
<td>Modulus</td>
|
1130
|
+
</tr>
|
1131
|
+
<tr><td><tt class="docutils literal"><span class="pre">mul(a,</span> <span class="pre">b)</span></tt></td>
|
1132
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></tt></td>
|
1133
|
+
<td>Multiplication</td>
|
1134
|
+
</tr>
|
1135
|
+
<tr><td><tt class="docutils literal"><span class="pre">and(a,</span> <span class="pre">b)</span></tt></td>
|
1136
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">&</span> <span class="pre">b</span></tt></td>
|
1137
|
+
<td>Bitwise and</td>
|
1138
|
+
</tr>
|
1139
|
+
<tr><td><tt class="docutils literal"><span class="pre">or(a,</span> <span class="pre">b)</span></tt></td>
|
1140
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">|</span> <span class="pre">b</span></tt></td>
|
1141
|
+
<td>Bitwise or</td>
|
1142
|
+
</tr>
|
1143
|
+
<tr><td><tt class="docutils literal"><span class="pre">xor(a,</span> <span class="pre">b)</span></tt></td>
|
1144
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">^</span> <span class="pre">b</span></tt></td>
|
1145
|
+
<td>Bitwise exclusive or</td>
|
1146
|
+
</tr>
|
1147
|
+
<tr><td><tt class="docutils literal"><span class="pre">lshift(a,</span> <span class="pre">b)</span></tt></td>
|
1148
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre"><<</span> <span class="pre">b</span></tt></td>
|
1149
|
+
<td>Bitwise left shift</td>
|
1150
|
+
</tr>
|
1151
|
+
<tr><td><tt class="docutils literal"><span class="pre">rshift(a,</span> <span class="pre">b)</span></tt></td>
|
1152
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">>></span> <span class="pre">b</span></tt></td>
|
1153
|
+
<td>Bitwise signed right shift</td>
|
1154
|
+
</tr>
|
1155
|
+
<tr><td><tt class="docutils literal"><span class="pre">zrshift(a,</span> <span class="pre">b)</span></tt></td>
|
1156
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">>>></span> <span class="pre">b</span></tt></td>
|
1157
|
+
<td>Bitwise unsigned right shift</td>
|
1158
|
+
</tr>
|
1159
|
+
</tbody>
|
1160
|
+
</table>
|
1161
|
+
</blockquote>
|
1162
|
+
<p>Built-in Comparators:</p>
|
1163
|
+
<blockquote>
|
1164
|
+
<table border="1" class="docutils">
|
1165
|
+
<colgroup>
|
1166
|
+
<col width="25%" />
|
1167
|
+
<col width="31%" />
|
1168
|
+
<col width="44%" />
|
1169
|
+
</colgroup>
|
1170
|
+
<thead valign="bottom">
|
1171
|
+
<tr><th class="head">Operator</th>
|
1172
|
+
<th class="head">Implementation</th>
|
1173
|
+
<th class="head">Description</th>
|
1174
|
+
</tr>
|
1175
|
+
</thead>
|
1176
|
+
<tbody valign="top">
|
1177
|
+
<tr><td><tt class="docutils literal"><span class="pre">eq(a,</span> <span class="pre">b)</span></tt></td>
|
1178
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">==</span> <span class="pre">b</span></tt></td>
|
1179
|
+
<td>Equals</td>
|
1180
|
+
</tr>
|
1181
|
+
<tr><td><tt class="docutils literal"><span class="pre">ne(a,</span> <span class="pre">b)</span></tt></td>
|
1182
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">!=</span> <span class="pre">b</span></tt></td>
|
1183
|
+
<td>Not equals</td>
|
1184
|
+
</tr>
|
1185
|
+
<tr><td><tt class="docutils literal"><span class="pre">gt(a,</span> <span class="pre">b)</span></tt></td>
|
1186
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">></span> <span class="pre">b</span></tt></td>
|
1187
|
+
<td>Greater than</td>
|
1188
|
+
</tr>
|
1189
|
+
<tr><td><tt class="docutils literal"><span class="pre">ge(a,</span> <span class="pre">b)</span></tt></td>
|
1190
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">>=</span> <span class="pre">b</span></tt></td>
|
1191
|
+
<td>Greater than or equal to</td>
|
1192
|
+
</tr>
|
1193
|
+
<tr><td><tt class="docutils literal"><span class="pre">lt(a,</span> <span class="pre">b)</span></tt></td>
|
1194
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre"><</span> <span class="pre">b</span></tt></td>
|
1195
|
+
<td>Less than</td>
|
1196
|
+
</tr>
|
1197
|
+
<tr><td><tt class="docutils literal"><span class="pre">le(a,</span> <span class="pre">b)</span></tt></td>
|
1198
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre"><=</span> <span class="pre">b</span></tt></td>
|
1199
|
+
<td>Less than or equal to</td>
|
1200
|
+
</tr>
|
1201
|
+
</tbody>
|
1202
|
+
</table>
|
1203
|
+
</blockquote>
|
1204
|
+
<p>Strict Built-in Comparators:</p>
|
1205
|
+
<blockquote>
|
1206
|
+
<table border="1" class="docutils">
|
1207
|
+
<colgroup>
|
1208
|
+
<col width="25%" />
|
1209
|
+
<col width="31%" />
|
1210
|
+
<col width="44%" />
|
1211
|
+
</colgroup>
|
1212
|
+
<thead valign="bottom">
|
1213
|
+
<tr><th class="head">Operator</th>
|
1214
|
+
<th class="head">Implementation</th>
|
1215
|
+
<th class="head">Description</th>
|
1216
|
+
</tr>
|
1217
|
+
</thead>
|
1218
|
+
<tbody valign="top">
|
1219
|
+
<tr><td><tt class="docutils literal"><span class="pre">seq(a,</span> <span class="pre">b)</span></tt></td>
|
1220
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">===</span> <span class="pre">b</span></tt></td>
|
1221
|
+
<td>Strict equals</td>
|
1222
|
+
</tr>
|
1223
|
+
<tr><td><tt class="docutils literal"><span class="pre">sne(a,</span> <span class="pre">b)</span></tt></td>
|
1224
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">!==</span> <span class="pre">b</span></tt></td>
|
1225
|
+
<td>Strict not equals</td>
|
1226
|
+
</tr>
|
1227
|
+
</tbody>
|
1228
|
+
</table>
|
1229
|
+
</blockquote>
|
1230
|
+
<p>Extended Comparators (uses <a class="mochiref reference" href="#fn-compare">compare</a>):</p>
|
1231
|
+
<blockquote>
|
1232
|
+
<table border="1" class="docutils">
|
1233
|
+
<colgroup>
|
1234
|
+
<col width="22%" />
|
1235
|
+
<col width="39%" />
|
1236
|
+
<col width="39%" />
|
1237
|
+
</colgroup>
|
1238
|
+
<thead valign="bottom">
|
1239
|
+
<tr><th class="head">Operator</th>
|
1240
|
+
<th class="head">Implementation</th>
|
1241
|
+
<th class="head">Description</th>
|
1242
|
+
</tr>
|
1243
|
+
</thead>
|
1244
|
+
<tbody valign="top">
|
1245
|
+
<tr><td><tt class="docutils literal"><span class="pre">ceq(a,</span> <span class="pre">b)</span></tt></td>
|
1246
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">==</span> <span class="pre">0</span></tt></td>
|
1247
|
+
<td>Equals</td>
|
1248
|
+
</tr>
|
1249
|
+
<tr><td><tt class="docutils literal"><span class="pre">cne(a,</span> <span class="pre">b)</span></tt></td>
|
1250
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">!=</span> <span class="pre">0</span></tt></td>
|
1251
|
+
<td>Not equals</td>
|
1252
|
+
</tr>
|
1253
|
+
<tr><td><tt class="docutils literal"><span class="pre">cgt(a,</span> <span class="pre">b)</span></tt></td>
|
1254
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">==</span> <span class="pre">1</span></tt></td>
|
1255
|
+
<td>Greater than</td>
|
1256
|
+
</tr>
|
1257
|
+
<tr><td><tt class="docutils literal"><span class="pre">cge(a,</span> <span class="pre">b)</span></tt></td>
|
1258
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">!=</span> <span class="pre">-1</span></tt></td>
|
1259
|
+
<td>Greater than or equal to</td>
|
1260
|
+
</tr>
|
1261
|
+
<tr><td><tt class="docutils literal"><span class="pre">clt(a,</span> <span class="pre">b)</span></tt></td>
|
1262
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">==</span> <span class="pre">-1</span></tt></td>
|
1263
|
+
<td>Less than</td>
|
1264
|
+
</tr>
|
1265
|
+
<tr><td><tt class="docutils literal"><span class="pre">cle(a,</span> <span class="pre">b)</span></tt></td>
|
1266
|
+
<td><tt class="docutils literal"><span class="pre">compare(a,</span> <span class="pre">b)</span> <span class="pre">!=</span> <span class="pre">1</span></tt></td>
|
1267
|
+
<td>Less than or equal to</td>
|
1268
|
+
</tr>
|
1269
|
+
</tbody>
|
1270
|
+
</table>
|
1271
|
+
</blockquote>
|
1272
|
+
<p>Binary Logical Operators:</p>
|
1273
|
+
<blockquote>
|
1274
|
+
<table border="1" class="docutils">
|
1275
|
+
<colgroup>
|
1276
|
+
<col width="33%" />
|
1277
|
+
<col width="28%" />
|
1278
|
+
<col width="39%" />
|
1279
|
+
</colgroup>
|
1280
|
+
<thead valign="bottom">
|
1281
|
+
<tr><th class="head">Operator</th>
|
1282
|
+
<th class="head">Implementation</th>
|
1283
|
+
<th class="head">Description</th>
|
1284
|
+
</tr>
|
1285
|
+
</thead>
|
1286
|
+
<tbody valign="top">
|
1287
|
+
<tr><td><tt class="docutils literal"><span class="pre">logand(a,</span> <span class="pre">b)</span></tt></td>
|
1288
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">&&</span> <span class="pre">b</span></tt></td>
|
1289
|
+
<td>Logical and</td>
|
1290
|
+
</tr>
|
1291
|
+
<tr><td><tt class="docutils literal"><span class="pre">logor(a,</span> <span class="pre">b)</span></tt></td>
|
1292
|
+
<td><tt class="docutils literal"><span class="pre">a</span> <span class="pre">||</span> <span class="pre">b</span></tt></td>
|
1293
|
+
<td>Logical or</td>
|
1294
|
+
</tr>
|
1295
|
+
<tr><td><tt class="docutils literal"><span class="pre">contains(a,</span> <span class="pre">b)</span></tt></td>
|
1296
|
+
<td><tt class="docutils literal"><span class="pre">b</span> <span class="pre">in</span> <span class="pre">a</span></tt></td>
|
1297
|
+
<td>Has property (note order)</td>
|
1298
|
+
</tr>
|
1299
|
+
</tbody>
|
1300
|
+
</table>
|
1301
|
+
</blockquote>
|
1302
|
+
<dl class="docutils">
|
1303
|
+
<dt><em>Availability</em>:</dt>
|
1304
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1305
|
+
</dl>
|
1306
|
+
</blockquote>
|
1307
|
+
<p>
|
1308
|
+
<a name="fn-parsequerystring"></a>
|
1309
|
+
<a class="mochidef reference" href="#fn-parsequerystring">parseQueryString(encodedString[, useArrays=false])</a>:</p>
|
1310
|
+
<blockquote>
|
1311
|
+
<p>Parse a name=value pair URL query string into an object with a
|
1312
|
+
property for each pair. e.g.:</p>
|
1313
|
+
<pre class="literal-block">
|
1314
|
+
var args = parseQueryString("foo=value%20one&bar=two");
|
1315
|
+
assert( args.foo == "value one" && args.bar == "two" );
|
1316
|
+
</pre>
|
1317
|
+
<p>If you expect that the query string will reuse the same name, then
|
1318
|
+
give <tt class="docutils literal"><span class="pre">true</span></tt> as a second argument, which will use arrays to store
|
1319
|
+
the values. e.g.:</p>
|
1320
|
+
<pre class="literal-block">
|
1321
|
+
var args = parseQueryString("foo=one&foo=two", true);
|
1322
|
+
assert( args.foo[0] == "one" && args.foo[1] == "two" );
|
1323
|
+
</pre>
|
1324
|
+
<dl class="docutils">
|
1325
|
+
<dt><em>Availability</em>:</dt>
|
1326
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1327
|
+
</dl>
|
1328
|
+
</blockquote>
|
1329
|
+
<p>
|
1330
|
+
<a name="fn-partial"></a>
|
1331
|
+
<a class="mochidef reference" href="#fn-partial">partial(func, arg[, ...])</a>:</p>
|
1332
|
+
<blockquote>
|
1333
|
+
<p>Return a partially applied function, e.g.:</p>
|
1334
|
+
<pre class="literal-block">
|
1335
|
+
addNumbers = function (a, b) {
|
1336
|
+
return a + b;
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
addOne = partial(addNumbers, 1);
|
1340
|
+
|
1341
|
+
assert(addOne(2) == 3);
|
1342
|
+
</pre>
|
1343
|
+
<p><a class="mochiref reference" href="#fn-partial">partial</a> is a special form of <a class="mochiref reference" href="#fn-bind">bind</a> that
|
1344
|
+
does not alter the bound <tt class="docutils literal"><span class="pre">self</span></tt> (if any). It is equivalent to
|
1345
|
+
calling:</p>
|
1346
|
+
<pre class="literal-block">
|
1347
|
+
bind(func, undefined, arg[, ...]);
|
1348
|
+
</pre>
|
1349
|
+
<p>See the documentation for <a class="mochiref reference" href="#fn-bind">bind</a> for more details about
|
1350
|
+
this facility.</p>
|
1351
|
+
<p>This could be used to implement, but is NOT currying.</p>
|
1352
|
+
<dl class="docutils">
|
1353
|
+
<dt><em>Availability</em>:</dt>
|
1354
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1355
|
+
</dl>
|
1356
|
+
</blockquote>
|
1357
|
+
<p>
|
1358
|
+
<a name="fn-querystring"></a>
|
1359
|
+
<a class="mochidef reference" href="#fn-querystring">queryString(names, values)</a>:</p>
|
1360
|
+
<blockquote>
|
1361
|
+
<p>Creates a URL query string from a pair of <tt class="docutils literal"><span class="pre">Array</span></tt>-like objects
|
1362
|
+
representing <tt class="docutils literal"><span class="pre">names</span></tt> and <tt class="docutils literal"><span class="pre">values</span></tt>. Each name=value pair will
|
1363
|
+
be URL encoded by <a class="mochiref reference" href="#fn-urlencode">urlEncode</a>. name=value pairs with a
|
1364
|
+
value of <tt class="docutils literal"><span class="pre">undefined</span></tt> or <tt class="docutils literal"><span class="pre">null</span></tt> will be skipped. e.g.:</p>
|
1365
|
+
<pre class="literal-block">
|
1366
|
+
var keys = ["foo", "bar"];
|
1367
|
+
var values = ["value one", "two"];
|
1368
|
+
assert( queryString(keys, values) == "foo=value%20one&bar=two" );
|
1369
|
+
</pre>
|
1370
|
+
<dl class="docutils">
|
1371
|
+
<dt>Alternate form 1:</dt>
|
1372
|
+
<dd><a class="mochiref reference" href="#fn-querystring">queryString(domElement)</a></dd>
|
1373
|
+
</dl>
|
1374
|
+
<p>If <a class="mochiref reference" href="DOM.html">MochiKit.DOM</a> is loaded, one argument is given, and
|
1375
|
+
that argument is either a string or has a <tt class="docutils literal"><span class="pre">nodeType</span></tt> property
|
1376
|
+
greater than zero, then <tt class="docutils literal"><span class="pre">names</span></tt> and <tt class="docutils literal"><span class="pre">values</span></tt> will be the
|
1377
|
+
result of <a class="mochiref reference" href="DOM.html#fn-formcontents">MochiKit.DOM.formContents(domElement)</a>.</p>
|
1378
|
+
<dl class="docutils">
|
1379
|
+
<dt>Alternate form 2:</dt>
|
1380
|
+
<dd><a class="mochiref reference" href="#fn-querystring">queryString({name: value, ...})</a></dd>
|
1381
|
+
</dl>
|
1382
|
+
<p>Note that when using the alternate form, the order of the
|
1383
|
+
name=value pairs in the resultant query string is dependent on how
|
1384
|
+
the particular JavaScript implementation handles <tt class="docutils literal"><span class="pre">for</span> <span class="pre">(..in..)</span></tt>
|
1385
|
+
property enumeration.</p>
|
1386
|
+
<p>When using the second alternate form, name=value pairs with
|
1387
|
+
<tt class="docutils literal"><span class="pre">typeof(value)</span> <span class="pre">==</span> <span class="pre">"function"</span></tt> are ignored. This is a workaround
|
1388
|
+
for the case where a poorly designed library has modified
|
1389
|
+
<tt class="docutils literal"><span class="pre">Object.prototype</span></tt> and inserted "convenience functions".</p>
|
1390
|
+
<p>Values that are Array-like will be expanded as if they were multiply
|
1391
|
+
defined HTML elements. For example:</p>
|
1392
|
+
<pre class="literal-block">
|
1393
|
+
assert( queryString({a: [1,2]}) === "a=1&a=2" );
|
1394
|
+
</pre>
|
1395
|
+
<dl class="docutils">
|
1396
|
+
<dt>Alternate form 2 (MochiKit 1.4+):</dt>
|
1397
|
+
<dd><a class="mochiref reference" href="#fn-querystring">queryString([names, values])</a></dd>
|
1398
|
+
</dl>
|
1399
|
+
<p>This form behaves identically to <a class="mochiref reference" href="#fn-querystring">queryString(names, values)</a>,
|
1400
|
+
except it takes both arguments as a single Array. This mirrors the
|
1401
|
+
return value of <a class="mochiref reference" href="DOM.html#fn-formcontents">MochiKit.DOM.formContents</a>.</p>
|
1402
|
+
<dl class="docutils">
|
1403
|
+
<dt><em>Availability</em>:</dt>
|
1404
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1405
|
+
</dl>
|
1406
|
+
</blockquote>
|
1407
|
+
<p>
|
1408
|
+
<a name="fn-registercomparator"></a>
|
1409
|
+
<a class="mochidef reference" href="#fn-registercomparator">registerComparator(name, check, comparator[, override])</a>:</p>
|
1410
|
+
<blockquote>
|
1411
|
+
<p>Register a comparator for use with <a class="mochiref reference" href="#fn-compare">compare</a>.</p>
|
1412
|
+
<dl class="docutils">
|
1413
|
+
<dt><tt class="docutils literal"><span class="pre">name</span></tt>:</dt>
|
1414
|
+
<dd>unique identifier describing the comparator.</dd>
|
1415
|
+
<dt><tt class="docutils literal"><span class="pre">check</span></tt>:</dt>
|
1416
|
+
<dd><tt class="docutils literal"><span class="pre">function(a,</span> <span class="pre">b)</span></tt> that returns <tt class="docutils literal"><span class="pre">true</span></tt> if <tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">b</span></tt>
|
1417
|
+
can be compared with <tt class="docutils literal"><span class="pre">comparator</span></tt>.</dd>
|
1418
|
+
<dt><tt class="docutils literal"><span class="pre">comparator</span></tt>:</dt>
|
1419
|
+
<dd><p class="first"><tt class="docutils literal"><span class="pre">function(a,</span> <span class="pre">b)</span></tt> that returns:</p>
|
1420
|
+
<table border="1" class="docutils">
|
1421
|
+
<colgroup>
|
1422
|
+
<col width="39%" />
|
1423
|
+
<col width="61%" />
|
1424
|
+
</colgroup>
|
1425
|
+
<tbody valign="top">
|
1426
|
+
<tr><td>Value</td>
|
1427
|
+
<td>Condition</td>
|
1428
|
+
</tr>
|
1429
|
+
<tr><td>0</td>
|
1430
|
+
<td>a == b</td>
|
1431
|
+
</tr>
|
1432
|
+
<tr><td>1</td>
|
1433
|
+
<td>a > b</td>
|
1434
|
+
</tr>
|
1435
|
+
<tr><td>-1</td>
|
1436
|
+
<td>a < b</td>
|
1437
|
+
</tr>
|
1438
|
+
</tbody>
|
1439
|
+
</table>
|
1440
|
+
<p class="last"><tt class="docutils literal"><span class="pre">comparator</span></tt> is guaranteed to only be called if <tt class="docutils literal"><span class="pre">check(a,</span>
|
1441
|
+
<span class="pre">b)</span></tt> returns a <tt class="docutils literal"><span class="pre">true</span></tt> value.</p>
|
1442
|
+
</dd>
|
1443
|
+
<dt><tt class="docutils literal"><span class="pre">override</span></tt>:</dt>
|
1444
|
+
<dd>if <tt class="docutils literal"><span class="pre">true</span></tt>, then this will be made the highest precedence
|
1445
|
+
comparator. Otherwise, the lowest.</dd>
|
1446
|
+
<dt><em>Availability</em>:</dt>
|
1447
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1448
|
+
</dl>
|
1449
|
+
</blockquote>
|
1450
|
+
<p>
|
1451
|
+
<a name="fn-registerjson"></a>
|
1452
|
+
<a class="mochidef reference" href="#fn-registerjson">registerJSON(name, check, simplifier[, override])</a>:</p>
|
1453
|
+
<blockquote>
|
1454
|
+
<p>Register a simplifier function for use with
|
1455
|
+
<a class="mochiref reference" href="#fn-serializejson">serializeJSON</a>.</p>
|
1456
|
+
<dl class="docutils">
|
1457
|
+
<dt><tt class="docutils literal"><span class="pre">name</span></tt>:</dt>
|
1458
|
+
<dd>unique identifier describing the serialization.</dd>
|
1459
|
+
<dt><tt class="docutils literal"><span class="pre">check</span></tt>:</dt>
|
1460
|
+
<dd><tt class="docutils literal"><span class="pre">function(obj)</span></tt> that returns <tt class="docutils literal"><span class="pre">true</span></tt> if <tt class="docutils literal"><span class="pre">obj</span></tt> can
|
1461
|
+
can be simplified for serialization by <tt class="docutils literal"><span class="pre">simplifier</span></tt>.</dd>
|
1462
|
+
<dt><tt class="docutils literal"><span class="pre">simplifier</span></tt>:</dt>
|
1463
|
+
<dd><p class="first"><tt class="docutils literal"><span class="pre">function(obj)</span></tt> that returns a simpler object that can be
|
1464
|
+
further serialized by <a class="mochiref reference" href="#fn-serializejson">serializeJSON</a>. For example,
|
1465
|
+
you could simplify <tt class="docutils literal"><span class="pre">Date</span></tt>-like objects to ISO 8601 timestamp
|
1466
|
+
strings with the following simplifier:</p>
|
1467
|
+
<pre class="literal-block">
|
1468
|
+
var simplifyDateAsISO = function (obj) {
|
1469
|
+
return toISOTimestamp(obj, true);
|
1470
|
+
};
|
1471
|
+
registerJSON("DateLike", isDateLike, simplifyDateAsISO);
|
1472
|
+
</pre>
|
1473
|
+
<p class="last"><tt class="docutils literal"><span class="pre">simplifier</span></tt> is guaranteed to only be called if
|
1474
|
+
<tt class="docutils literal"><span class="pre">check(obj)</span></tt> returns a <tt class="docutils literal"><span class="pre">true</span></tt> value.</p>
|
1475
|
+
</dd>
|
1476
|
+
<dt><tt class="docutils literal"><span class="pre">override</span></tt>:</dt>
|
1477
|
+
<dd>if <tt class="docutils literal"><span class="pre">true</span></tt>, then this will be made the highest precedence
|
1478
|
+
serialization. Otherwise, the lowest.</dd>
|
1479
|
+
<dt><em>Availability</em>:</dt>
|
1480
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1481
|
+
</dl>
|
1482
|
+
</blockquote>
|
1483
|
+
<p>
|
1484
|
+
<a name="fn-registerrepr"></a>
|
1485
|
+
<a class="mochidef reference" href="#fn-registerrepr">registerRepr(name, check, wrap[, override])</a>:</p>
|
1486
|
+
<blockquote>
|
1487
|
+
<p>Register a programmer representation function. <a class="mochiref reference" href="#fn-repr">repr</a>
|
1488
|
+
functions should take one argument and return a string
|
1489
|
+
representation of it suitable for developers, primarily used when
|
1490
|
+
debugging.</p>
|
1491
|
+
<p>If <tt class="docutils literal"><span class="pre">override</span></tt> is given, it is used as the highest priority repr,
|
1492
|
+
otherwise it will be used as the lowest.</p>
|
1493
|
+
<dl class="docutils">
|
1494
|
+
<dt><em>Availability</em>:</dt>
|
1495
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1496
|
+
</dl>
|
1497
|
+
</blockquote>
|
1498
|
+
<p>
|
1499
|
+
<a name="fn-repr"></a>
|
1500
|
+
<a class="mochidef reference" href="#fn-repr">repr(obj)</a>:</p>
|
1501
|
+
<blockquote>
|
1502
|
+
<p>Return a programmer representation for <tt class="docutils literal"><span class="pre">obj</span></tt>. See the
|
1503
|
+
<a class="reference" href="#programmer-representation">Programmer Representation</a> overview for more information about
|
1504
|
+
this function.</p>
|
1505
|
+
<dl class="docutils">
|
1506
|
+
<dt><em>Availability</em>:</dt>
|
1507
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1508
|
+
</dl>
|
1509
|
+
</blockquote>
|
1510
|
+
<p>
|
1511
|
+
<a name="fn-reversekeycomparator"></a>
|
1512
|
+
<a class="mochidef reference" href="#fn-reversekeycomparator">reverseKeyComparator(key)</a>:</p>
|
1513
|
+
<blockquote>
|
1514
|
+
<p>A comparator factory that compares <tt class="docutils literal"><span class="pre">a[key]</span></tt> with <tt class="docutils literal"><span class="pre">b[key]</span></tt> in
|
1515
|
+
reverse. e.g.:</p>
|
1516
|
+
<pre class="literal-block">
|
1517
|
+
var lst = ["a", "bbb", "cc"];
|
1518
|
+
lst.sort(reverseKeyComparator("length"));
|
1519
|
+
assert(lst.toString() == "bbb,cc,a");
|
1520
|
+
</pre>
|
1521
|
+
<dl class="docutils">
|
1522
|
+
<dt><em>Availability</em>:</dt>
|
1523
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1524
|
+
</dl>
|
1525
|
+
</blockquote>
|
1526
|
+
<p>
|
1527
|
+
<a name="fn-serializejson"></a>
|
1528
|
+
<a class="mochidef reference" href="#fn-serializejson">serializeJSON(anObject)</a>:</p>
|
1529
|
+
<blockquote>
|
1530
|
+
<p>Serialize <tt class="docutils literal"><span class="pre">anObject</span></tt> in the JSON <a class="footnote-reference" href="#id7" id="id6" name="id6">[1]</a> format, see <a class="reference" href="#json-serialization">JSON
|
1531
|
+
Serialization</a> for the coercion rules. For unserializable objects
|
1532
|
+
(functions that do not have an adapter, <tt class="docutils literal"><span class="pre">__json__</span></tt> method, or
|
1533
|
+
<tt class="docutils literal"><span class="pre">json</span></tt> method), this will return <tt class="docutils literal"><span class="pre">undefined</span></tt>.</p>
|
1534
|
+
<p>For those familiar with Python, JSON is similar in scope to
|
1535
|
+
pickle, but it can not handle recursive object graphs.</p>
|
1536
|
+
<dl class="docutils">
|
1537
|
+
<dt><em>Availability</em>:</dt>
|
1538
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1539
|
+
</dl>
|
1540
|
+
</blockquote>
|
1541
|
+
<p>
|
1542
|
+
<a name="fn-setdefault"></a>
|
1543
|
+
<a class="mochidef reference" href="#fn-setdefault">setdefault(self, obj[, ...])</a>:</p>
|
1544
|
+
<blockquote>
|
1545
|
+
<p>Mutate <tt class="docutils literal"><span class="pre">self</span></tt> by adding all properties from other object(s) that
|
1546
|
+
it does not already have set.</p>
|
1547
|
+
<p>If <tt class="docutils literal"><span class="pre">self</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, a new <tt class="docutils literal"><span class="pre">Object</span></tt> instance will be created
|
1548
|
+
and returned.</p>
|
1549
|
+
<p>This mutates <em>and returns</em> <tt class="docutils literal"><span class="pre">self</span></tt>, be warned.</p>
|
1550
|
+
<dl class="docutils">
|
1551
|
+
<dt><em>Availability</em>:</dt>
|
1552
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1553
|
+
</dl>
|
1554
|
+
</blockquote>
|
1555
|
+
<p>
|
1556
|
+
<a name="fn-typematcher"></a>
|
1557
|
+
<a class="mochidef reference" href="#fn-typematcher">typeMatcher(typ[, ...])</a>:</p>
|
1558
|
+
<blockquote>
|
1559
|
+
<p>Given a set of types (as string arguments), returns a
|
1560
|
+
<tt class="docutils literal"><span class="pre">function(obj[,</span> <span class="pre">...])</span></tt> that will return <tt class="docutils literal"><span class="pre">true</span></tt> if the types of
|
1561
|
+
the given arguments are all members of that set.</p>
|
1562
|
+
<dl class="docutils">
|
1563
|
+
<dt><em>Availability</em>:</dt>
|
1564
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1565
|
+
</dl>
|
1566
|
+
</blockquote>
|
1567
|
+
<p>
|
1568
|
+
<a name="fn-update"></a>
|
1569
|
+
<a class="mochidef reference" href="#fn-update">update(self, obj[, ...])</a>:</p>
|
1570
|
+
<blockquote>
|
1571
|
+
<p>Mutate <tt class="docutils literal"><span class="pre">self</span></tt> by replacing its key:value pairs with those from
|
1572
|
+
other object(s). Key:value pairs from later objects will overwrite
|
1573
|
+
those from earlier objects.</p>
|
1574
|
+
<p>If <tt class="docutils literal"><span class="pre">self</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, a new <tt class="docutils literal"><span class="pre">Object</span></tt> instance will be created
|
1575
|
+
and returned.</p>
|
1576
|
+
<p>This mutates <em>and returns</em> <tt class="docutils literal"><span class="pre">self</span></tt>, be warned.</p>
|
1577
|
+
<p>A version of this function that creates a new object is available
|
1578
|
+
as <a class="mochiref reference" href="#fn-merge">merge(a, b[, ...])</a></p>
|
1579
|
+
<dl class="docutils">
|
1580
|
+
<dt><em>Availability</em>:</dt>
|
1581
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1582
|
+
</dl>
|
1583
|
+
</blockquote>
|
1584
|
+
<p>
|
1585
|
+
<a name="fn-updatetree"></a>
|
1586
|
+
<a class="mochidef reference" href="#fn-updatetree">updatetree(self, obj[, ...])</a>:</p>
|
1587
|
+
<blockquote>
|
1588
|
+
<p>Mutate <tt class="docutils literal"><span class="pre">self</span></tt> by replacing its key:value pairs with those from
|
1589
|
+
other object(s). If a given key has an object value in both
|
1590
|
+
<tt class="docutils literal"><span class="pre">self</span></tt> and <tt class="docutils literal"><span class="pre">obj</span></tt>, then this function will be called
|
1591
|
+
recursively, updating instead of replacing that object.</p>
|
1592
|
+
<p>If <tt class="docutils literal"><span class="pre">self</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, a new <tt class="docutils literal"><span class="pre">Object</span></tt> instance will be created
|
1593
|
+
and returned.</p>
|
1594
|
+
<p>This mutates <em>and returns</em> <tt class="docutils literal"><span class="pre">self</span></tt>, be warned.</p>
|
1595
|
+
<dl class="docutils">
|
1596
|
+
<dt><em>Availability</em>:</dt>
|
1597
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1598
|
+
</dl>
|
1599
|
+
</blockquote>
|
1600
|
+
<p>
|
1601
|
+
<a name="fn-urlencode"></a>
|
1602
|
+
<a class="mochidef reference" href="#fn-urlencode">urlEncode(unencoded)</a>:</p>
|
1603
|
+
<blockquote>
|
1604
|
+
<p>Converts <tt class="docutils literal"><span class="pre">unencoded</span></tt> into a URL-encoded string. In this
|
1605
|
+
implementation, spaces are converted to %20 instead of "+". e.g.:</p>
|
1606
|
+
<pre class="literal-block">
|
1607
|
+
assert( URLencode("1+2=2") == "1%2B2%3D2");
|
1608
|
+
</pre>
|
1609
|
+
<dl class="docutils">
|
1610
|
+
<dt><em>Availability</em>:</dt>
|
1611
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1612
|
+
</dl>
|
1613
|
+
</blockquote>
|
1614
|
+
<p>
|
1615
|
+
<a name="fn-values"></a>
|
1616
|
+
<a class="mochidef reference" href="#fn-values">values(obj)</a>:</p>
|
1617
|
+
<blockquote>
|
1618
|
+
<p>Return an <tt class="docutils literal"><span class="pre">Array</span></tt> of the property values of an object (in the
|
1619
|
+
order determined by <tt class="docutils literal"><span class="pre">for</span> <span class="pre">propName</span> <span class="pre">in</span> <span class="pre">obj</span></tt>).</p>
|
1620
|
+
<dl class="docutils">
|
1621
|
+
<dt><em>Availability</em>:</dt>
|
1622
|
+
<dd>Available in MochiKit 1.4+</dd>
|
1623
|
+
</dl>
|
1624
|
+
</blockquote>
|
1625
|
+
<p>
|
1626
|
+
<a name="fn-xfilter"></a>
|
1627
|
+
<a class="mochidef reference" href="#fn-xfilter">xfilter(fn, obj[, ...])</a>:</p>
|
1628
|
+
<blockquote>
|
1629
|
+
<p>Returns a new <tt class="docutils literal"><span class="pre">Array</span></tt> composed of the arguments where
|
1630
|
+
<tt class="docutils literal"><span class="pre">fn(obj)</span></tt> returns a true value.</p>
|
1631
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, <tt class="docutils literal"><span class="pre">operator.truth</span></tt> will be used.</p>
|
1632
|
+
<dl class="docutils">
|
1633
|
+
<dt><em>Availability</em>:</dt>
|
1634
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1635
|
+
</dl>
|
1636
|
+
</blockquote>
|
1637
|
+
<p>
|
1638
|
+
<a name="fn-xmap"></a>
|
1639
|
+
<a class="mochidef reference" href="#fn-xmap">xmap(fn, obj[, ...)</a>:</p>
|
1640
|
+
<blockquote>
|
1641
|
+
<p>Return a new <tt class="docutils literal"><span class="pre">Array</span></tt> composed of <tt class="docutils literal"><span class="pre">fn(obj)</span></tt> for every <tt class="docutils literal"><span class="pre">obj</span></tt>
|
1642
|
+
given as an argument.</p>
|
1643
|
+
<p>If <tt class="docutils literal"><span class="pre">fn</span></tt> is <tt class="docutils literal"><span class="pre">null</span></tt>, <tt class="docutils literal"><span class="pre">operator.identity</span></tt> is used.</p>
|
1644
|
+
<dl class="docutils">
|
1645
|
+
<dt><em>Availability</em>:</dt>
|
1646
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1647
|
+
</dl>
|
1648
|
+
</blockquote>
|
1649
|
+
<p>
|
1650
|
+
<a name="fn-zip"></a>
|
1651
|
+
<a class="mochidef reference" href="#fn-zip">zip(p, q, ...)</a>:</p>
|
1652
|
+
<blockquote>
|
1653
|
+
<p>Returns an array where the n-th element is an array of the n-th
|
1654
|
+
elements from each of the arrays p, q, ...</p>
|
1655
|
+
<p>This is equivalent to calling <a class="mochiref reference" href="#fn-map">map(fn, p, q, ...)</a> with
|
1656
|
+
<tt class="docutils literal"><span class="pre">null</span></tt> as the first argument.</p>
|
1657
|
+
<blockquote>
|
1658
|
+
<dl class="docutils">
|
1659
|
+
<dt><a class="mochiref reference" href="#fn-zip">zip(p, q, ...)</a></dt>
|
1660
|
+
<dd>-> <a class="mochiref reference" href="#fn-map">map(null, p, q, ...)</a>
|
1661
|
+
-> <tt class="docutils literal"><span class="pre">[[p0,</span> <span class="pre">q0,</span> <span class="pre">...],</span> <span class="pre">[p1,</span> <span class="pre">q1,</span> <span class="pre">...],</span> <span class="pre">...];</span></tt></dd>
|
1662
|
+
</dl>
|
1663
|
+
</blockquote>
|
1664
|
+
<dl class="docutils">
|
1665
|
+
<dt><em>Availability</em>:</dt>
|
1666
|
+
<dd>Available in MochiKit 1.3.1+</dd>
|
1667
|
+
</dl>
|
1668
|
+
</blockquote>
|
1669
|
+
</div>
|
1670
|
+
</div>
|
1671
|
+
<div class="section">
|
1672
|
+
<h1><a id="see-also" name="see-also">See Also</a></h1>
|
1673
|
+
<table class="docutils footnote" frame="void" id="id7" rules="none">
|
1674
|
+
<colgroup><col class="label" /><col /></colgroup>
|
1675
|
+
<tbody valign="top">
|
1676
|
+
<tr><td class="label"><a name="id7">[1]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>, <a class="fn-backref" href="#id4">3</a>, <a class="fn-backref" href="#id5">4</a>, <a class="fn-backref" href="#id6">5</a>)</em> JSON, JavaScript Object Notation: <a class="reference" href="http://json.org/">http://json.org/</a></td></tr>
|
1677
|
+
</tbody>
|
1678
|
+
</table>
|
1679
|
+
<table class="docutils footnote" frame="void" id="id8" rules="none">
|
1680
|
+
<colgroup><col class="label" /><col /></colgroup>
|
1681
|
+
<tbody valign="top">
|
1682
|
+
<tr><td class="label"><a class="fn-backref" href="#id3" name="id8">[2]</a></td><td>Python's itertools
|
1683
|
+
module: <a class="reference" href="http://docs.python.org/lib/module-itertools.html">http://docs.python.org/lib/module-itertools.html</a></td></tr>
|
1684
|
+
</tbody>
|
1685
|
+
</table>
|
1686
|
+
</div>
|
1687
|
+
<div class="section">
|
1688
|
+
<h1><a id="authors" name="authors">Authors</a></h1>
|
1689
|
+
<ul class="simple">
|
1690
|
+
<li>Bob Ippolito <<a class="reference" href="mailto:bob@redivi.com">bob@redivi.com</a>></li>
|
1691
|
+
</ul>
|
1692
|
+
</div>
|
1693
|
+
<div class="section">
|
1694
|
+
<h1><a id="copyright" name="copyright">Copyright</a></h1>
|
1695
|
+
<p>Copyright 2005 Bob Ippolito <<a class="reference" href="mailto:bob@redivi.com">bob@redivi.com</a>>. This program is
|
1696
|
+
dual-licensed free software; you can redistribute it and/or modify it
|
1697
|
+
under the terms of the <a class="reference" href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> or the <a class="reference" href="http://www.opensource.org/licenses/afl-2.1.php">Academic Free License
|
1698
|
+
v2.1</a>.</p>
|
1699
|
+
</div>
|
1700
|
+
</div>
|
1701
|
+
|
1702
|
+
</body>
|
1703
|
+
</html>
|