How to use hash method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

keys.js

Source:keys.js Github

copy

Full Screen

1var predefinedDecHash = new Map();2var predefinedEncHash = new Map();34predefinedDecHash.set(0, "D");5predefinedDecHash.set(1, "q");6predefinedDecHash.set(2, "6");7predefinedDecHash.set(3, "/");8predefinedDecHash.set(4, "V");9predefinedDecHash.set(5, "G");10predefinedDecHash.set(6, "h");11predefinedDecHash.set(7, "l");12predefinedDecHash.set(8, "I");13predefinedDecHash.set(9, "F");14predefinedDecHash.set(10, "F");15predefinedDecHash.set(11, "1");16predefinedDecHash.set(12, "a");17predefinedDecHash.set(13, "W");18predefinedDecHash.set(14, "N");19predefinedDecHash.set(15, "r");20predefinedDecHash.set(16, "I");21predefinedDecHash.set(17, "F");22predefinedDecHash.set(18, "J");23predefinedDecHash.set(19, "l");24predefinedDecHash.set(20, "Z");25predefinedDecHash.set(21, "C");26predefinedDecHash.set(22, "B");27predefinedDecHash.set(23, "G");28predefinedDecHash.set(24, "b");29predefinedDecHash.set(25, "3");30predefinedDecHash.set(26, "g");31predefinedDecHash.set(27, "g");32predefinedDecHash.set(28, "S");33predefinedDecHash.set(29, "n");34predefinedDecHash.set(30, "V");35predefinedDecHash.set(31, "t");36predefinedDecHash.set(32, "c");37predefinedDecHash.set(33, "G");38predefinedDecHash.set(34, "V");39predefinedDecHash.set(35, "k");40predefinedDecHash.set(36, "I");41predefinedDecHash.set(37, "E");42predefinedDecHash.set(38, "9");43predefinedDecHash.set(39, "2");44predefinedDecHash.set(40, "Z");45predefinedDecHash.set(41, "X");46predefinedDecHash.set(42, "I");47predefinedDecHash.set(43, "g");48predefinedDecHash.set(44, "d");49predefinedDecHash.set(45, "G");50predefinedDecHash.set(46, "h");51predefinedDecHash.set(47, "l");52predefinedDecHash.set(48, "I");53predefinedDecHash.set(49, "E");54predefinedDecHash.set(50, "x");55predefinedDecHash.set(51, "h");56predefinedDecHash.set(52, "e");57predefinedDecHash.set(53, "n");58predefinedDecHash.set(54, "k");59predefinedDecHash.set(55, "g");60predefinedDecHash.set(56, "Q");61predefinedDecHash.set(57, "n");62predefinedDecHash.set(58, "J");63predefinedDecHash.set(59, "v");64predefinedDecHash.set(60, "d");65predefinedDecHash.set(61, "2");66predefinedDecHash.set(62, "4");67predefinedDecHash.set(63, "g");68predefinedDecHash.set(64, "R");69predefinedDecHash.set(65, "G");70predefinedDecHash.set(66, "9");71predefinedDecHash.set(67, "n");72predefinedDecHash.set(68, "L");73predefinedDecHash.set(69, "i");74predefinedDecHash.set(70, "A");75predefinedDecHash.set(71, "8");76predefinedDecHash.set(72, "P");77predefinedDecHash.set(73, "i");78predefinedDecHash.set(74, "w");79predefinedDecHash.set(75, "u");80predefinedDecHash.set(76, "P");81predefinedDecHash.set(77, "z");82predefinedDecHash.set(78, "o");83predefinedDecHash.set(79, "7");84predefinedDecHash.set(80, "f");85predefinedDecHash.set(81, "H");86predefinedDecHash.set(82, "t");87predefinedDecHash.set(83, "9");88predefinedDecHash.set(84, "W");89predefinedDecHash.set(85, "1");90predefinedDecHash.set(86, "1");91predefinedDecHash.set(87, "+");92predefinedDecHash.set(88, "I");93predefinedDecHash.set(89, "U");94predefinedDecHash.set(90, "A");95predefinedDecHash.set(91, "j");96predefinedDecHash.set(92, "J");97predefinedDecHash.set(93, "C");98predefinedDecHash.set(94, "V");99predefinedDecHash.set(95, "e");100predefinedDecHash.set(96, "J");101predefinedDecHash.set(97, "i");102predefinedDecHash.set(98, "o");103predefinedDecHash.set(99, "o");104predefinedDecHash.set(100, "K");105predefinedDecHash.set(101, "V");106predefinedDecHash.set(102, "8");107predefinedDecHash.set(103, "r");108predefinedDecHash.set(104, "P");109predefinedDecHash.set(105, "S");110predefinedDecHash.set(106, "0");111predefinedDecHash.set(107, "w");112predefinedDecHash.set(108, "O");113predefinedDecHash.set(109, "T");114predefinedDecHash.set(110, "g");115predefinedDecHash.set(111, "3");116predefinedDecHash.set(112, "N");117predefinedDecHash.set(113, "j");118predefinedDecHash.set(114, "U");119predefinedDecHash.set(115, "0");120predefinedDecHash.set(116, "M");121predefinedDecHash.set(117, "z");122predefinedDecHash.set(118, "I");123predefinedDecHash.set(119, "x");124predefinedDecHash.set(120, "Y");125predefinedDecHash.set(121, "E");126predefinedDecHash.set(122, "x");127predefinedDecHash.set(123, "v");128predefinedDecHash.set(124, "c");129predefinedDecHash.set(125, "m");130predefinedDecHash.set(126, "V");131predefinedDecHash.set(127, "t");132predefinedDecHash.set(128, "I");133predefinedDecHash.set(129, "G");134predefinedDecHash.set(130, "l");135predefinedDecHash.set(131, "w");136predefinedDecHash.set(132, "c");137predefinedDecHash.set(133, "3");138predefinedDecHash.set(134, "V");139predefinedDecHash.set(135, "t");140predefinedDecHash.set(136, "I");141predefinedDecHash.set(137, "G");142predefinedDecHash.set(138, "R");143predefinedDecHash.set(139, "v");144predefinedDecHash.set(140, "b");145predefinedDecHash.set(141, "G");146predefinedDecHash.set(142, "9");147predefinedDecHash.set(143, "y");148predefinedDecHash.set(144, "I");149predefinedDecHash.set(145, "H");150predefinedDecHash.set(146, "N");151predefinedDecHash.set(147, "p");152predefinedDecHash.set(148, "d");153predefinedDecHash.set(149, "C");154predefinedDecHash.set(150, "B");155predefinedDecHash.set(151, "h");156predefinedDecHash.set(152, "b");157predefinedDecHash.set(153, "W");158predefinedDecHash.set(154, "V");159predefinedDecHash.set(155, "0");160predefinedDecHash.set(156, "L");161predefinedDecHash.set(157, "C");162predefinedDecHash.set(158, "B");163predefinedDecHash.set(159, "j");164predefinedDecHash.set(160, "b");165predefinedDecHash.set(161, "2");166predefinedDecHash.set(162, "5");167predefinedDecHash.set(163, "z");168predefinedDecHash.set(164, "Z");169predefinedDecHash.set(165, "W");170predefinedDecHash.set(166, "N");171predefinedDecHash.set(167, "0");172predefinedDecHash.set(168, "Z");173predefinedDecHash.set(169, "X");174predefinedDecHash.set(170, "R");175predefinedDecHash.set(171, "1");176predefinedDecHash.set(172, "c");177predefinedDecHash.set(173, "i");178predefinedDecHash.set(174, "B");179predefinedDecHash.set(175, "h");180predefinedDecHash.set(176, "Z");181predefinedDecHash.set(177, "G");182predefinedDecHash.set(178, "l");183predefinedDecHash.set(179, "w");184predefinedDecHash.set(180, "a");185predefinedDecHash.set(181, "X");186predefinedDecHash.set(182, "N");187predefinedDecHash.set(183, "j");188predefinedDecHash.set(184, "a");189predefinedDecHash.set(185, "W");190predefinedDecHash.set(186, "5");191predefinedDecHash.set(187, "n");192predefinedDecHash.set(188, "I");193predefinedDecHash.set(189, "G");194predefinedDecHash.set(190, "V");195predefinedDecHash.set(191, "s");196predefinedDecHash.set(192, "a");197predefinedDecHash.set(193, "X");198predefinedDecHash.set(194, "Q");199predefinedDecHash.set(195, "s");200predefinedDecHash.set(196, "I");201predefinedDecHash.set(197, "H");202predefinedDecHash.set(198, "N");203predefinedDecHash.set(199, "l");204predefinedDecHash.set(200, "Z");205predefinedDecHash.set(201, "C");206predefinedDecHash.set(202, "B");207predefinedDecHash.set(203, "k");208predefinedDecHash.set(204, "b");209predefinedDecHash.set(205, "y");210predefinedDecHash.set(206, "B");211predefinedDecHash.set(207, "l");212predefinedDecHash.set(208, "a");213predefinedDecHash.set(209, "X");214predefinedDecHash.set(210, "V");215predefinedDecHash.set(211, "z");216predefinedDecHash.set(212, "b");217predefinedDecHash.set(213, "W");218predefinedDecHash.set(214, "9");219predefinedDecHash.set(215, "k");220predefinedDecHash.set(216, "I");221predefinedDecHash.set(217, "H");222predefinedDecHash.set(218, "R");223predefinedDecHash.set(219, "l");224predefinedDecHash.set(220, "b");225predefinedDecHash.set(221, "X");226predefinedDecHash.set(222, "B");227predefinedDecHash.set(223, "v");228predefinedDecHash.set(224, "c");229predefinedDecHash.set(225, "i");230predefinedDecHash.set(226, "B");231predefinedDecHash.set(227, "p");232predefinedDecHash.set(228, "b");233predefinedDecHash.set(229, "m");234predefinedDecHash.set(230, "N");235predefinedDecHash.set(231, "p");236predefinedDecHash.set(232, "Z");237predefinedDecHash.set(233, "G");238predefinedDecHash.set(234, "l");239predefinedDecHash.set(235, "k");240predefinedDecHash.set(236, "d");241predefinedDecHash.set(237, "W");242predefinedDecHash.set(238, "5");243predefinedDecHash.set(239, "0");244predefinedDecHash.set(240, "I");245predefinedDecHash.set(241, "H");246predefinedDecHash.set(242, "V");247predefinedDecHash.set(243, "0");248predefinedDecHash.set(244, "I");249predefinedDecHash.set(245, "G");250predefinedDecHash.set(246, "x");251predefinedDecHash.set(247, "h");252predefinedDecHash.set(248, "Y");253predefinedDecHash.set(249, "m");254predefinedDecHash.set(250, "9");255predefinedDecHash.set(251, "y");256predefinedDecHash.set(252, "Z");257predefinedDecHash.set(253, "S");258predefinedDecHash.set(254, "B");259predefinedDecHash.set(255, "l");260predefinedDecHash.set(256, "d");261predefinedDecHash.set(257, "C");262predefinedDecHash.set(258, "B");263predefinedDecHash.set(259, "k");264predefinedDecHash.set(260, "b");265predefinedDecHash.set(261, "2");266predefinedDecHash.set(262, "x");267predefinedDecHash.set(263, "v");268predefinedDecHash.set(264, "c");269predefinedDecHash.set(265, "m");270predefinedDecHash.set(266, "U");271predefinedDecHash.set(267, "g");272predefinedDecHash.set(268, "b");273predefinedDecHash.set(269, "W");274predefinedDecHash.set(270, "F");275predefinedDecHash.set(271, "n");276predefinedDecHash.set(272, "b");277predefinedDecHash.set(273, "m");278predefinedDecHash.set(274, "E");279predefinedDecHash.set(275, "g");280predefinedDecHash.set(276, "Y");281predefinedDecHash.set(277, "W");282predefinedDecHash.set(278, "x");283predefinedDecHash.set(279, "p");284predefinedDecHash.set(280, "c");285predefinedDecHash.set(281, "X");286predefinedDecHash.set(282, "V");287predefinedDecHash.set(283, "h");288predefinedDecHash.set(284, "L");289predefinedDecHash.set(285, "i");290predefinedDecHash.set(286, "B");291predefinedDecHash.set(287, "V");292predefinedDecHash.set(288, "d");293predefinedDecHash.set(289, "C");294predefinedDecHash.set(290, "B");295predefinedDecHash.set(291, "l");296predefinedDecHash.set(292, "b");297predefinedDecHash.set(293, "m");298predefinedDecHash.set(294, "l");299predefinedDecHash.set(295, "t");300predefinedDecHash.set(296, "I");301predefinedDecHash.set(297, "G");302predefinedDecHash.set(298, "F");303predefinedDecHash.set(299, "k");304predefinedDecHash.set(300, "I");305predefinedDecHash.set(301, "G");306predefinedDecHash.set(302, "1");307predefinedDecHash.set(303, "p");308predefinedDecHash.set(304, "b");309predefinedDecHash.set(305, "m");310predefinedDecHash.set(306, "l");311predefinedDecHash.set(307, "t");312predefinedDecHash.set(308, "I");313predefinedDecHash.set(309, "H");314predefinedDecHash.set(310, "Z");315predefinedDecHash.set(311, "l");316predefinedDecHash.set(312, "b");317predefinedDecHash.set(313, "m");318predefinedDecHash.set(314, "l");319predefinedDecHash.set(315, "h");320predefinedDecHash.set(316, "b");321predefinedDecHash.set(317, "S");322predefinedDecHash.set(318, "w");323predefinedDecHash.set(319, "g");324predefinedDecHash.set(320, "c");325predefinedDecHash.set(321, "X");326predefinedDecHash.set(322, "V");327predefinedDecHash.set(323, "p");328predefinedDecHash.set(324, "c");329predefinedDecHash.set(325, "y");330predefinedDecHash.set(326, "B");331predefinedDecHash.set(327, "u");332predefinedDecHash.set(328, "b");333predefinedDecHash.set(329, "3");334predefinedDecHash.set(330, "N");335predefinedDecHash.set(331, "0");336predefinedDecHash.set(332, "c");337predefinedDecHash.set(333, "n");338predefinedDecHash.set(334, "V");339predefinedDecHash.set(335, "k");340predefinedDecHash.set(336, "I");341predefinedDecHash.set(337, "G");342predefinedDecHash.set(338, "V");343predefinedDecHash.set(339, "4");344predefinedDecHash.set(340, "Z");345predefinedDecHash.set(341, "X");346predefinedDecHash.set(342, "J");347predefinedDecHash.set(343, "j");348predefinedDecHash.set(344, "a");349predefinedDecHash.set(345, "X");350predefinedDecHash.set(346, "R");351predefinedDecHash.set(347, "h");352predefinedDecHash.set(348, "d");353predefinedDecHash.set(349, "G");354predefinedDecHash.set(350, "l");355predefinedDecHash.set(351, "v");356predefinedDecHash.set(352, "b");357predefinedDecHash.set(353, "i");358predefinedDecHash.set(354, "B");359predefinedDecHash.set(355, "1");360predefinedDecHash.set(356, "b");361predefinedDecHash.set(357, "G");362predefinedDecHash.set(358, "x");363predefinedDecHash.set(359, "h");364predefinedDecHash.set(360, "b");365predefinedDecHash.set(361, "W");366predefinedDecHash.set(362, "N");367predefinedDecHash.set(363, "v");368predefinedDecHash.set(364, "I");369predefinedDecHash.set(365, "G");370predefinedDecHash.set(366, "x");371predefinedDecHash.set(367, "h");372predefinedDecHash.set(368, "Y");373predefinedDecHash.set(369, "m");374predefinedDecHash.set(370, "9");375predefinedDecHash.set(371, "y");376predefinedDecHash.set(372, "a");377predefinedDecHash.set(373, "X");378predefinedDecHash.set(374, "M");379predefinedDecHash.set(375, "g");380predefinedDecHash.set(376, "b");381predefinedDecHash.set(377, "m");382predefinedDecHash.set(378, "l");383predefinedDecHash.set(379, "z");384predefinedDecHash.set(380, "a");385predefinedDecHash.set(381, "S");386predefinedDecHash.set(382, "B");387predefinedDecHash.set(383, "1");388predefinedDecHash.set(384, "d");389predefinedDecHash.set(385, "C");390predefinedDecHash.set(386, "B");391predefinedDecHash.set(387, "h");392predefinedDecHash.set(388, "b");393predefinedDecHash.set(389, "G");394predefinedDecHash.set(390, "l");395predefinedDecHash.set(391, "x");396predefinedDecHash.set(392, "d");397predefinedDecHash.set(393, "W");398predefinedDecHash.set(394, "l");399predefinedDecHash.set(395, "w");400predefinedDecHash.set(396, "I");401predefinedDecHash.set(397, "G");402predefinedDecHash.set(398, "V");403predefinedDecHash.set(399, "4");404predefinedDecHash.set(400, "I");405predefinedDecHash.set(401, "G");406predefinedDecHash.set(402, "V");407predefinedDecHash.set(403, "h");408predefinedDecHash.set(404, "I");409predefinedDecHash.set(405, "G");410predefinedDecHash.set(406, "N");411predefinedDecHash.set(407, "v");412predefinedDecHash.set(408, "b");413predefinedDecHash.set(409, "W");414predefinedDecHash.set(410, "1");415predefinedDecHash.set(411, "v");416predefinedDecHash.set(412, "Z");417predefinedDecHash.set(413, "G");418predefinedDecHash.set(414, "8");419predefinedDecHash.set(415, "g");420predefinedDecHash.set(416, "Y");421predefinedDecHash.set(417, "2");422predefinedDecHash.set(418, "9");423predefinedDecHash.set(419, "u");424predefinedDecHash.set(420, "c");425predefinedDecHash.set(421, "2");426predefinedDecHash.set(422, "V");427predefinedDecHash.set(423, "x");428predefinedDecHash.set(424, "d");429predefinedDecHash.set(425, "W");430predefinedDecHash.set(426, "F");431predefinedDecHash.set(427, "0");432predefinedDecHash.set(428, "L");433predefinedDecHash.set(429, "i");434predefinedDecHash.set(430, "B");435predefinedDecHash.set(431, "E");436predefinedDecHash.set(432, "d");437predefinedDecHash.set(433, "W");438predefinedDecHash.set(434, "l");439predefinedDecHash.set(435, "z");440predefinedDecHash.set(436, "I");441predefinedDecHash.set(437, "G");442predefinedDecHash.set(438, "F");443predefinedDecHash.set(439, "1");444predefinedDecHash.set(440, "d");445predefinedDecHash.set(441, "G");446predefinedDecHash.set(442, "U");447predefinedDecHash.set(443, "g");448predefinedDecHash.set(444, "a");449predefinedDecHash.set(445, "X");450predefinedDecHash.set(446, "J");451predefinedDecHash.set(447, "1");452predefinedDecHash.set(448, "c");453predefinedDecHash.set(449, "m");454predefinedDecHash.set(450, "U");455predefinedDecHash.set(451, "g");456predefinedDecHash.set(452, "Z");457predefinedDecHash.set(453, "G");458predefinedDecHash.set(454, "9");459predefinedDecHash.set(455, "s");460predefinedDecHash.set(456, "b");461predefinedDecHash.set(457, "3");462predefinedDecHash.set(458, "I");463predefinedDecHash.set(459, "g");464predefinedDecHash.set(460, "a");465predefinedDecHash.set(461, "W");466predefinedDecHash.set(462, "4");467predefinedDecHash.set(463, "g");468predefinedDecHash.set(464, "c");469predefinedDecHash.set(465, "m");470predefinedDecHash.set(466, "V");471predefinedDecHash.set(467, "w");472predefinedDecHash.set(468, "c");473predefinedDecHash.set(469, "m");474predefinedDecHash.set(470, "V");475predefinedDecHash.set(471, "o");476predefinedDecHash.set(472, "Z");477predefinedDecHash.set(473, "W");478predefinedDecHash.set(474, "5");479predefinedDecHash.set(475, "k");480predefinedDecHash.set(476, "Z");481predefinedDecHash.set(477, "X");482predefinedDecHash.set(478, "J");483predefinedDecHash.set(479, "p");484predefinedDecHash.set(480, "d");485predefinedDecHash.set(481, "C");486predefinedDecHash.set(482, "B");487predefinedDecHash.set(483, "p");488predefinedDecHash.set(484, "b");489predefinedDecHash.set(485, "i");490predefinedDecHash.set(486, "B");491predefinedDecHash.set(487, "2");492predefinedDecHash.set(488, "b");493predefinedDecHash.set(489, "2");494predefinedDecHash.set(490, "x");495predefinedDecHash.set(491, "1");496predefinedDecHash.set(492, "c");497predefinedDecHash.set(493, "H");498predefinedDecHash.set(494, "R");499predefinedDecHash.set(495, "h");500predefinedDecHash.set(496, "d");501predefinedDecHash.set(497, "G");502predefinedDecHash.set(498, "U");503predefinedDecHash.set(499, "g");504predefinedDecHash.set(500, "d");505predefinedDecHash.set(501, "m");506predefinedDecHash.set(502, "V");507predefinedDecHash.set(503, "s");508predefinedDecHash.set(504, "a");509predefinedDecHash.set(505, "X");510predefinedDecHash.set(506, "Q");511predefinedDecHash.set(507, "g");512predefinedDecHash.set(508, "Z");513predefinedDecHash.set(509, "X");514predefinedDecHash.set(510, "N");515predefinedDecHash.set(511, "z");516predefinedDecHash.set(512, "Z");517predefinedDecHash.set(513, "S");518predefinedDecHash.set(514, "B");519predefinedDecHash.set(515, "j");520predefinedDecHash.set(516, "a");521predefinedDecHash.set(517, "W");522predefinedDecHash.set(518, "x");523predefinedDecHash.set(519, "s");524predefinedDecHash.set(520, "d");525predefinedDecHash.set(521, "W");526predefinedDecHash.set(522, "0");527predefinedDecHash.set(523, "g");528predefinedDecHash.set(524, "Z");529predefinedDecHash.set(525, "G");530predefinedDecHash.set(526, "9");531predefinedDecHash.set(527, "s");532predefinedDecHash.set(528, "b");533predefinedDecHash.set(529, "3");534predefinedDecHash.set(530, "J");535predefinedDecHash.set(531, "l");536predefinedDecHash.set(532, "I");537predefinedDecHash.set(533, "G");538predefinedDecHash.set(534, "V");539predefinedDecHash.set(535, "1");540predefinedDecHash.set(536, "I");541predefinedDecHash.set(537, "G");542predefinedDecHash.set(538, "Z");543predefinedDecHash.set(539, "1");544predefinedDecHash.set(540, "Z");545predefinedDecHash.set(541, "2");546predefinedDecHash.set(542, "l");547predefinedDecHash.set(543, "h");548predefinedDecHash.set(544, "d");549predefinedDecHash.set(545, "C");550predefinedDecHash.set(546, "B");551predefinedDecHash.set(547, "u");552predefinedDecHash.set(548, "d");553predefinedDecHash.set(549, "W");554predefinedDecHash.set(550, "x");555predefinedDecHash.set(551, "s");556predefinedDecHash.set(552, "Y");557predefinedDecHash.set(553, "S");558predefinedDecHash.set(554, "B");559predefinedDecHash.set(555, "w");560predefinedDecHash.set(556, "Y");561predefinedDecHash.set(557, "X");562predefinedDecHash.set(558, "J");563predefinedDecHash.set(559, "p");564predefinedDecHash.set(560, "Y");565predefinedDecHash.set(561, "X");566predefinedDecHash.set(562, "R");567predefinedDecHash.set(563, "1");568predefinedDecHash.set(564, "c");569predefinedDecHash.set(565, "i");570predefinedDecHash.set(566, "4");571predefinedDecHash.set(567, "g");572predefinedDecHash.set(568, "R");573predefinedDecHash.set(569, "X");574predefinedDecHash.set(570, "h");575predefinedDecHash.set(571, "j");576predefinedDecHash.set(572, "Z");577predefinedDecHash.set(573, "X");578predefinedDecHash.set(574, "B");579predefinedDecHash.set(575, "0");580predefinedDecHash.set(576, "Z");581predefinedDecHash.set(577, "X");582predefinedDecHash.set(578, "V");583predefinedDecHash.set(579, "y");584predefinedDecHash.set(580, "I");585predefinedDecHash.set(581, "H");586predefinedDecHash.set(582, "N");587predefinedDecHash.set(583, "p");588predefinedDecHash.set(584, "b");589predefinedDecHash.set(585, "n");590predefinedDecHash.set(586, "Q");591predefinedDecHash.set(587, "g");592predefinedDecHash.set(588, "b");593predefinedDecHash.set(589, "2");594predefinedDecHash.set(590, "N");595predefinedDecHash.set(591, "j");596predefinedDecHash.set(592, "Y");597predefinedDecHash.set(593, "W");598predefinedDecHash.set(594, "V");599predefinedDecHash.set(595, "j");600predefinedDecHash.set(596, "Y");601predefinedDecHash.set(597, "X");602predefinedDecHash.set(598, "Q");603predefinedDecHash.set(599, "g");604predefinedDecHash.set(600, "Y");605predefinedDecHash.set(601, "3");606predefinedDecHash.set(602, "V");607predefinedDecHash.set(603, "w");608predefinedDecHash.set(604, "a");609predefinedDecHash.set(605, "W");610predefinedDecHash.set(606, "R");611predefinedDecHash.set(607, "h");612predefinedDecHash.set(608, "d");613predefinedDecHash.set(609, "G");614predefinedDecHash.set(610, "F");615predefinedDecHash.set(611, "0");616predefinedDecHash.set(612, "I");617predefinedDecHash.set(613, "G");618predefinedDecHash.set(614, "5");619predefinedDecHash.set(615, "v");620predefinedDecHash.set(616, "b");621predefinedDecHash.set(617, "i");622predefinedDecHash.set(618, "B");623predefinedDecHash.set(619, "w");624predefinedDecHash.set(620, "c");625predefinedDecHash.set(621, "m");626predefinedDecHash.set(622, "9");627predefinedDecHash.set(623, "p");628predefinedDecHash.set(624, "Z");629predefinedDecHash.set(625, "G");630predefinedDecHash.set(626, "V");631predefinedDecHash.set(627, "u");632predefinedDecHash.set(628, "d");633predefinedDecHash.set(629, "C");634predefinedDecHash.set(630, "w");635predefinedDecHash.set(631, "g");636predefinedDecHash.set(632, "c");637predefinedDecHash.set(633, "3");638predefinedDecHash.set(634, "V");639predefinedDecHash.set(635, "u");640predefinedDecHash.set(636, "d");641predefinedDecHash.set(637, "C");642predefinedDecHash.set(638, "B");643predefinedDecHash.set(639, "p");644predefinedDecHash.set(640, "b");645predefinedDecHash.set(641, "i");646predefinedDecHash.set(642, "B");647predefinedDecHash.set(643, "j");648predefinedDecHash.set(644, "d");649predefinedDecHash.set(645, "W");650predefinedDecHash.set(646, "x");651predefinedDecHash.set(647, "w");652predefinedDecHash.set(648, "Y");653predefinedDecHash.set(649, "S");654predefinedDecHash.set(650, "B");655predefinedDecHash.set(651, "x");656predefinedDecHash.set(652, "d");657predefinedDecHash.set(653, "W");658predefinedDecHash.set(654, "k");659predefinedDecHash.set(655, "g");660predefinedDecHash.set(656, "b");661predefinedDecHash.set(657, "2");662predefinedDecHash.set(658, "Z");663predefinedDecHash.set(659, "m");664predefinedDecHash.set(660, "a");665predefinedDecHash.set(661, "W");666predefinedDecHash.set(662, "N");667predefinedDecHash.set(663, "p");668predefinedDecHash.set(664, "Y");669predefinedDecHash.set(665, "S");670predefinedDecHash.set(666, "B");671predefinedDecHash.set(667, "k");672predefinedDecHash.set(668, "Z");673predefinedDecHash.set(669, "X");674predefinedDecHash.set(670, "N");675predefinedDecHash.set(671, "l");676predefinedDecHash.set(672, "c");677predefinedDecHash.set(673, "n");678predefinedDecHash.set(674, "V");679predefinedDecHash.set(675, "u");680predefinedDecHash.set(676, "d");681predefinedDecHash.set(677, "C");682predefinedDecHash.set(678, "B");683predefinedDecHash.set(679, "t");684predefinedDecHash.set(680, "b");685predefinedDecHash.set(681, "2");686predefinedDecHash.set(682, "x");687predefinedDecHash.set(683, "s");688predefinedDecHash.set(684, "a");689predefinedDecHash.set(685, "X");690predefinedDecHash.set(686, "Q");691predefinedDecHash.set(687, "g");692predefinedDecHash.set(688, "Y");693predefinedDecHash.set(689, "W");694predefinedDecHash.set(690, "5");695predefinedDecHash.set(691, "p");696predefinedDecHash.set(692, "b");697predefinedDecHash.set(693, "S");698predefinedDecHash.set(694, "B");699predefinedDecHash.set(695, "p");700predefinedDecHash.set(696, "Z");701predefinedDecHash.set(697, "C");702predefinedDecHash.set(698, "B");703predefinedDecHash.set(699, "l");704predefinedDecHash.set(700, "c");705predefinedDecHash.set(701, "3");706predefinedDecHash.set(702, "Q");707predefinedDecHash.set(703, "g");708predefinedDecHash.set(704, "b");709predefinedDecHash.set(705, "G");710predefinedDecHash.set(706, "F");711predefinedDecHash.set(707, "i");712predefinedDecHash.set(708, "b");713predefinedDecHash.set(709, "3");714predefinedDecHash.set(710, "J");715predefinedDecHash.set(711, "1");716predefinedDecHash.set(712, "b");717predefinedDecHash.set(713, "S");718predefinedDecHash.set(714, "4");719predefinedDecHash.set(715, "D");720predefinedDecHash.set(716, "q");721predefinedDecHash.set(717, "6");722predefinedDecHash.set(718, "/");723724predefinedEncHash.set("A", [70,90]);725predefinedEncHash.set("B", [22,150,158,174,202,206,222,226,254,258,286,290,326,354,382,386,430,482,486,514,546,554,574,618,638,642,650,666,678,694,698]);726predefinedEncHash.set("C", [21,93,149,157,201,257,289,385,481,545,629,637,677,697]);727predefinedEncHash.set("D", [0,715]);728predefinedEncHash.set("E", [37,49,121,274,431]);729predefinedEncHash.set("F", [9,10,17,270,298,426,438,610,706]);730predefinedEncHash.set("G", [5,23,33,45,65,129,137,141,177,189,233,245,297,301,337,349,357,365,389,397,401,405,413,437,441,453,497,525,533,537,609,613,625,705]);731predefinedEncHash.set("H", [81,145,197,217,241,309,493,581]);732predefinedEncHash.set("I", [8,16,36,42,48,88,118,128,136,144,188,196,216,240,244,296,300,308,336,364,396,400,404,436,458,532,536,580,612]);733predefinedEncHash.set("J", [18,58,92,96,342,446,478,530,558,710]);734predefinedEncHash.set("K", [100]);735predefinedEncHash.set("L", [68,156,284,428]);736predefinedEncHash.set("M", [116,374]);737predefinedEncHash.set("N", [14,112,146,166,182,198,230,330,362,406,510,582,590,662,670]);738predefinedEncHash.set("O", [108]);739predefinedEncHash.set("P", [72,76,104]);740predefinedEncHash.set("Q", [56,194,506,586,598,686,702]);741predefinedEncHash.set("R", [64,138,170,218,346,494,562,568,606]);742predefinedEncHash.set("S", [28,105,253,317,381,513,553,649,665,693,713]);743predefinedEncHash.set("T", [109]);744predefinedEncHash.set("U", [89,114,266,442,450,498]);745predefinedEncHash.set("V", [4,30,34,94,101,126,134,154,190,210,242,282,287,322,334,338,398,402,422,466,470,502,534,578,594,602,626,634,674]);746predefinedEncHash.set("W", [13,84,153,165,185,213,237,269,277,361,393,409,425,433,461,473,517,521,549,593,605,645,653,661,689]);747predefinedEncHash.set("X", [41,169,181,193,209,221,281,321,341,345,373,445,477,505,509,557,561,569,573,577,597,669,685]);748predefinedEncHash.set("Y", [120,248,276,368,416,552,556,560,592,596,600,648,664,688]);749predefinedEncHash.set("Z", [20,40,164,168,176,200,232,252,310,340,412,452,472,476,508,512,524,538,540,572,576,624,658,668,696]);750predefinedEncHash.set("a", [12,180,184,192,208,344,372,380,444,460,504,516,604,660,684]);751predefinedEncHash.set("b", [24,140,152,160,204,212,220,228,260,268,272,292,304,312,316,328,352,356,360,376,388,408,456,484,488,528,584,588,616,640,656,680,692,704,708,712]);752predefinedEncHash.set("c", [32,124,132,172,224,264,280,320,324,332,420,448,464,468,492,564,620,632,672,700]);753predefinedEncHash.set("d", [44,60,148,236,256,288,348,384,392,424,432,440,480,496,500,520,544,548,608,628,636,644,652,676]);754predefinedEncHash.set("e", [52,95]);755predefinedEncHash.set("f", [80]);756predefinedEncHash.set("g", [26,27,43,55,63,110,267,275,319,375,415,443,451,459,463,499,507,523,567,587,599,631,655,687,703]);757predefinedEncHash.set("h", [6,46,51,151,175,247,283,315,347,359,367,387,403,495,543,570,607]);758predefinedEncHash.set("i", [69,73,97,173,225,285,353,429,485,565,617,641,707]);759predefinedEncHash.set("j", [91,113,159,183,343,515,571,591,595,643]);760predefinedEncHash.set("k", [35,54,203,215,235,259,299,335,475,654,667]);761predefinedEncHash.set("l", [7,19,47,130,178,199,207,219,234,255,291,294,306,311,314,350,378,390,394,434,531,542,671,699]);762predefinedEncHash.set("m", [125,229,249,265,273,293,305,313,369,377,449,465,469,501,621,659]);763predefinedEncHash.set("n", [29,53,57,67,187,271,333,585,673]);764predefinedEncHash.set("o", [78,98,99,471]);765predefinedEncHash.set("p", [147,227,231,279,303,323,479,483,559,583,623,639,663,691,695]);766predefinedEncHash.set("q", [1,716]);767predefinedEncHash.set("r", [15,103]);768predefinedEncHash.set("s", [191,195,455,503,519,527,551,683]);769predefinedEncHash.set("t", [31,82,127,135,295,307,679]);770predefinedEncHash.set("u", [75,327,419,547,627,635,675]);771predefinedEncHash.set("v", [59,123,139,223,263,351,363,407,411,615]);772predefinedEncHash.set("w", [74,107,131,179,318,395,467,555,603,619,630,647]);773predefinedEncHash.set("x", [50,119,122,246,262,278,358,366,391,423,490,518,550,646,651,682]);774predefinedEncHash.set("y", [143,205,251,325,371,579]);775predefinedEncHash.set("z", [77,117,163,211,379,435,511]);776predefinedEncHash.set("0", [106,115,155,167,239,243,331,427,522,575,611]);777predefinedEncHash.set("1", [11,85,86,171,302,355,383,410,439,447,491,535,539,563,711]);778predefinedEncHash.set("2", [39,61,161,261,417,421,487,489,541,589,657,681]);779predefinedEncHash.set("3", [25,111,133,329,457,529,601,633,701,709]);780predefinedEncHash.set("4", [62,339,399,462,566,714]);781predefinedEncHash.set("5", [162,186,238,474,614,690]);782predefinedEncHash.set("6", [2,717]);783predefinedEncHash.set("7", [79]);784predefinedEncHash.set("8", [71,102,414]);785predefinedEncHash.set("9", [38,66,83,142,214,250,370,418,454,526,622]);786predefinedEncHash.set("+", [87]); ...

Full Screen

Full Screen

history-hash-debug.js

Source:history-hash-debug.js Github

copy

Full Screen

1/*2YUI 3.17.2 (build 9c3c78e)3Copyright 2014 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7YUI.add('history-hash', function (Y, NAME) {8/**9 * Provides browser history management backed by10 * <code>window.location.hash</code>, as well as convenience methods for working11 * with the location hash and a synthetic <code>hashchange</code> event that12 * normalizes differences across browsers.13 *14 * @module history15 * @submodule history-hash16 * @since 3.2.017 * @class HistoryHash18 * @extends HistoryBase19 * @constructor20 * @param {Object} config (optional) Configuration object. See the HistoryBase21 * documentation for details.22 */23var HistoryBase = Y.HistoryBase,24 Lang = Y.Lang,25 YArray = Y.Array,26 YObject = Y.Object,27 GlobalEnv = YUI.namespace('Env.HistoryHash'),28 SRC_HASH = 'hash',29 hashNotifiers,30 oldHash,31 oldUrl,32 win = Y.config.win,33 useHistoryHTML5 = Y.config.useHistoryHTML5;34function HistoryHash() {35 HistoryHash.superclass.constructor.apply(this, arguments);36}37Y.extend(HistoryHash, HistoryBase, {38 // -- Initialization -------------------------------------------------------39 _init: function (config) {40 var bookmarkedState = HistoryHash.parseHash();41 // If an initialState was provided, merge the bookmarked state into it42 // (the bookmarked state wins).43 config = config || {};44 this._initialState = config.initialState ?45 Y.merge(config.initialState, bookmarkedState) : bookmarkedState;46 // Subscribe to the synthetic hashchange event (defined below) to handle47 // changes.48 Y.after('hashchange', Y.bind(this._afterHashChange, this), win);49 HistoryHash.superclass._init.apply(this, arguments);50 },51 // -- Protected Methods ----------------------------------------------------52 _change: function (src, state, options) {53 // Stringify all values to ensure that comparisons don't fail after54 // they're coerced to strings in the location hash.55 YObject.each(state, function (value, key) {56 if (Lang.isValue(value)) {57 state[key] = value.toString();58 }59 });60 return HistoryHash.superclass._change.call(this, src, state, options);61 },62 _storeState: function (src, newState) {63 var decode = HistoryHash.decode,64 newHash = HistoryHash.createHash(newState);65 HistoryHash.superclass._storeState.apply(this, arguments);66 // Update the location hash with the changes, but only if the new hash67 // actually differs from the current hash (this avoids creating multiple68 // history entries for a single state).69 //70 // We always compare decoded hashes, since it's possible that the hash71 // could be set incorrectly to a non-encoded value outside of72 // HistoryHash.73 if (src !== SRC_HASH && decode(HistoryHash.getHash()) !== decode(newHash)) {74 HistoryHash[src === HistoryBase.SRC_REPLACE ? 'replaceHash' : 'setHash'](newHash);75 }76 },77 // -- Protected Event Handlers ---------------------------------------------78 /**79 * Handler for hashchange events.80 *81 * @method _afterHashChange82 * @param {Event} e83 * @protected84 */85 _afterHashChange: function (e) {86 this._resolveChanges(SRC_HASH, HistoryHash.parseHash(e.newHash), {});87 }88}, {89 // -- Public Static Properties ---------------------------------------------90 NAME: 'historyHash',91 /**92 * Constant used to identify state changes originating from93 * <code>hashchange</code> events.94 *95 * @property SRC_HASH96 * @type String97 * @static98 * @final99 */100 SRC_HASH: SRC_HASH,101 /**102 * <p>103 * Prefix to prepend when setting the hash fragment. For example, if the104 * prefix is <code>!</code> and the hash fragment is set to105 * <code>#foo=bar&baz=quux</code>, the final hash fragment in the URL will106 * become <code>#!foo=bar&baz=quux</code>. This can be used to help make an107 * Ajax application crawlable in accordance with Google's guidelines at108 * <a href="http://code.google.com/web/ajaxcrawling/">http://code.google.com/web/ajaxcrawling/</a>.109 * </p>110 *111 * <p>112 * Note that this prefix applies to all HistoryHash instances. It's not113 * possible for individual instances to use their own prefixes since they114 * all operate on the same URL.115 * </p>116 *117 * @property hashPrefix118 * @type String119 * @default ''120 * @static121 */122 hashPrefix: '',123 // -- Protected Static Properties ------------------------------------------124 /**125 * Regular expression used to parse location hash/query strings.126 *127 * @property _REGEX_HASH128 * @type RegExp129 * @protected130 * @static131 * @final132 */133 _REGEX_HASH: /([^\?#&=]+)=?([^&=]*)/g,134 // -- Public Static Methods ------------------------------------------------135 /**136 * Creates a location hash string from the specified object of key/value137 * pairs.138 *139 * @method createHash140 * @param {Object} params object of key/value parameter pairs141 * @return {String} location hash string142 * @static143 */144 createHash: function (params) {145 var encode = HistoryHash.encode,146 hash = [];147 YObject.each(params, function (value, key) {148 if (Lang.isValue(value)) {149 hash.push(encode(key) + '=' + encode(value));150 }151 });152 return hash.join('&');153 },154 /**155 * Wrapper around <code>decodeURIComponent()</code> that also converts +156 * chars into spaces.157 *158 * @method decode159 * @param {String} string string to decode160 * @return {String} decoded string161 * @static162 */163 decode: function (string) {164 return decodeURIComponent(string.replace(/\+/g, ' '));165 },166 /**167 * Wrapper around <code>encodeURIComponent()</code> that converts spaces to168 * + chars.169 *170 * @method encode171 * @param {String} string string to encode172 * @return {String} encoded string173 * @static174 */175 encode: function (string) {176 return encodeURIComponent(string).replace(/%20/g, '+');177 },178 /**179 * Gets the raw (not decoded) current location hash, minus the preceding '#'180 * character and the hashPrefix (if one is set).181 *182 * @method getHash183 * @return {String} current location hash184 * @static185 */186 getHash: (Y.UA.gecko ? function () {187 // Gecko's window.location.hash returns a decoded string and we want all188 // encoding untouched, so we need to get the hash value from189 // window.location.href instead. We have to use UA sniffing rather than190 // feature detection, since the only way to detect this would be to191 // actually change the hash.192 var location = Y.getLocation(),193 matches = /#(.*)$/.exec(location.href),194 hash = matches && matches[1] || '',195 prefix = HistoryHash.hashPrefix;196 return prefix && hash.indexOf(prefix) === 0 ?197 hash.replace(prefix, '') : hash;198 } : function () {199 var location = Y.getLocation(),200 hash = location.hash.substring(1),201 prefix = HistoryHash.hashPrefix;202 // Slight code duplication here, but execution speed is of the essence203 // since getHash() is called every 50ms to poll for changes in browsers204 // that don't support native onhashchange. An additional function call205 // would add unnecessary overhead.206 return prefix && hash.indexOf(prefix) === 0 ?207 hash.replace(prefix, '') : hash;208 }),209 /**210 * Gets the current bookmarkable URL.211 *212 * @method getUrl213 * @return {String} current bookmarkable URL214 * @static215 */216 getUrl: function () {217 return location.href;218 },219 /**220 * Parses a location hash string into an object of key/value parameter221 * pairs. If <i>hash</i> is not specified, the current location hash will222 * be used.223 *224 * @method parseHash225 * @param {String} hash (optional) location hash string226 * @return {Object} object of parsed key/value parameter pairs227 * @static228 */229 parseHash: function (hash) {230 var decode = HistoryHash.decode,231 i,232 len,233 match,234 matches,235 param,236 params = {},237 prefix = HistoryHash.hashPrefix,238 prefixIndex;239 hash = Lang.isValue(hash) ? hash : HistoryHash.getHash();240 if (prefix) {241 prefixIndex = hash.indexOf(prefix);242 if (prefixIndex === 0 || (prefixIndex === 1 && hash.charAt(0) === '#')) {243 hash = hash.replace(prefix, '');244 }245 }246 matches = hash.match(HistoryHash._REGEX_HASH) || [];247 for (i = 0, len = matches.length; i < len; ++i) {248 match = matches[i];249 param = match.split('=');250 if (param.length > 1) {251 params[decode(param[0])] = decode(param[1]);252 } else {253 params[decode(match)] = '';254 }255 }256 return params;257 },258 /**259 * Replaces the browser's current location hash with the specified hash260 * and removes all forward navigation states, without creating a new browser261 * history entry. Automatically prepends the <code>hashPrefix</code> if one262 * is set.263 *264 * @method replaceHash265 * @param {String} hash new location hash266 * @static267 */268 replaceHash: function (hash) {269 var location = Y.getLocation(),270 base = location.href.replace(/#.*$/, '');271 if (hash.charAt(0) === '#') {272 hash = hash.substring(1);273 }274 location.replace(base + '#' + (HistoryHash.hashPrefix || '') + hash);275 },276 /**277 * Sets the browser's location hash to the specified string. Automatically278 * prepends the <code>hashPrefix</code> if one is set.279 *280 * @method setHash281 * @param {String} hash new location hash282 * @static283 */284 setHash: function (hash) {285 var location = Y.getLocation();286 if (hash.charAt(0) === '#') {287 hash = hash.substring(1);288 }289 location.hash = (HistoryHash.hashPrefix || '') + hash;290 }291});292// -- Synthetic hashchange Event -----------------------------------------------293// TODO: YUIDoc currently doesn't provide a good way to document synthetic DOM294// events. For now, we're just documenting the hashchange event on the YUI295// object, which is about the best we can do until enhancements are made to296// YUIDoc.297/**298Synthetic <code>window.onhashchange</code> event that normalizes differences299across browsers and provides support for browsers that don't natively support300<code>onhashchange</code>.301This event is provided by the <code>history-hash</code> module.302@example303 YUI().use('history-hash', function (Y) {304 Y.on('hashchange', function (e) {305 // Handle hashchange events on the current window.306 }, Y.config.win);307 });308@event hashchange309@param {EventFacade} e Event facade with the following additional310 properties:311<dl>312 <dt>oldHash</dt>313 <dd>314 Previous hash fragment value before the change.315 </dd>316 <dt>oldUrl</dt>317 <dd>318 Previous URL (including the hash fragment) before the change.319 </dd>320 <dt>newHash</dt>321 <dd>322 New hash fragment value after the change.323 </dd>324 <dt>newUrl</dt>325 <dd>326 New URL (including the hash fragment) after the change.327 </dd>328</dl>329@for YUI330@since 3.2.0331**/332hashNotifiers = GlobalEnv._notifiers;333if (!hashNotifiers) {334 hashNotifiers = GlobalEnv._notifiers = [];335}336Y.Event.define('hashchange', {337 on: function (node, subscriber, notifier) {338 // Ignore this subscription if the node is anything other than the339 // window or document body, since those are the only elements that340 // should support the hashchange event. Note that the body could also be341 // a frameset, but that's okay since framesets support hashchange too.342 if (node.compareTo(win) || node.compareTo(Y.config.doc.body)) {343 hashNotifiers.push(notifier);344 }345 },346 detach: function (node, subscriber, notifier) {347 var index = YArray.indexOf(hashNotifiers, notifier);348 if (index !== -1) {349 hashNotifiers.splice(index, 1);350 }351 }352});353oldHash = HistoryHash.getHash();354oldUrl = HistoryHash.getUrl();355if (HistoryBase.nativeHashChange) {356 // Wrap the browser's native hashchange event if there's not already a357 // global listener.358 if (!GlobalEnv._hashHandle) {359 GlobalEnv._hashHandle = Y.Event.attach('hashchange', function (e) {360 var newHash = HistoryHash.getHash(),361 newUrl = HistoryHash.getUrl();362 // Iterate over a copy of the hashNotifiers array since a subscriber363 // could detach during iteration and cause the array to be re-indexed.364 YArray.each(hashNotifiers.concat(), function (notifier) {365 notifier.fire({366 _event : e,367 oldHash: oldHash,368 oldUrl : oldUrl,369 newHash: newHash,370 newUrl : newUrl371 });372 });373 oldHash = newHash;374 oldUrl = newUrl;375 }, win);376 }377} else {378 // Begin polling for location hash changes if there's not already a global379 // poll running.380 if (!GlobalEnv._hashPoll) {381 GlobalEnv._hashPoll = Y.later(50, null, function () {382 var newHash = HistoryHash.getHash(),383 facade, newUrl;384 if (oldHash !== newHash) {385 newUrl = HistoryHash.getUrl();386 facade = {387 oldHash: oldHash,388 oldUrl : oldUrl,389 newHash: newHash,390 newUrl : newUrl391 };392 oldHash = newHash;393 oldUrl = newUrl;394 YArray.each(hashNotifiers.concat(), function (notifier) {395 notifier.fire(facade);396 });397 }398 }, null, true);399 }400}401Y.HistoryHash = HistoryHash;402// HistoryHash will never win over HistoryHTML5 unless useHistoryHTML5 is false.403if (useHistoryHTML5 === false || (!Y.History && useHistoryHTML5 !== true &&404 (!HistoryBase.html5 || !Y.HistoryHTML5))) {405 Y.History = HistoryHash;406}...

Full Screen

Full Screen

history-hash.js

Source:history-hash.js Github

copy

Full Screen

1/*2YUI 3.17.2 (build 9c3c78e)3Copyright 2014 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7YUI.add('history-hash', function (Y, NAME) {8/**9 * Provides browser history management backed by10 * <code>window.location.hash</code>, as well as convenience methods for working11 * with the location hash and a synthetic <code>hashchange</code> event that12 * normalizes differences across browsers.13 *14 * @module history15 * @submodule history-hash16 * @since 3.2.017 * @class HistoryHash18 * @extends HistoryBase19 * @constructor20 * @param {Object} config (optional) Configuration object. See the HistoryBase21 * documentation for details.22 */23var HistoryBase = Y.HistoryBase,24 Lang = Y.Lang,25 YArray = Y.Array,26 YObject = Y.Object,27 GlobalEnv = YUI.namespace('Env.HistoryHash'),28 SRC_HASH = 'hash',29 hashNotifiers,30 oldHash,31 oldUrl,32 win = Y.config.win,33 useHistoryHTML5 = Y.config.useHistoryHTML5;34function HistoryHash() {35 HistoryHash.superclass.constructor.apply(this, arguments);36}37Y.extend(HistoryHash, HistoryBase, {38 // -- Initialization -------------------------------------------------------39 _init: function (config) {40 var bookmarkedState = HistoryHash.parseHash();41 // If an initialState was provided, merge the bookmarked state into it42 // (the bookmarked state wins).43 config = config || {};44 this._initialState = config.initialState ?45 Y.merge(config.initialState, bookmarkedState) : bookmarkedState;46 // Subscribe to the synthetic hashchange event (defined below) to handle47 // changes.48 Y.after('hashchange', Y.bind(this._afterHashChange, this), win);49 HistoryHash.superclass._init.apply(this, arguments);50 },51 // -- Protected Methods ----------------------------------------------------52 _change: function (src, state, options) {53 // Stringify all values to ensure that comparisons don't fail after54 // they're coerced to strings in the location hash.55 YObject.each(state, function (value, key) {56 if (Lang.isValue(value)) {57 state[key] = value.toString();58 }59 });60 return HistoryHash.superclass._change.call(this, src, state, options);61 },62 _storeState: function (src, newState) {63 var decode = HistoryHash.decode,64 newHash = HistoryHash.createHash(newState);65 HistoryHash.superclass._storeState.apply(this, arguments);66 // Update the location hash with the changes, but only if the new hash67 // actually differs from the current hash (this avoids creating multiple68 // history entries for a single state).69 //70 // We always compare decoded hashes, since it's possible that the hash71 // could be set incorrectly to a non-encoded value outside of72 // HistoryHash.73 if (src !== SRC_HASH && decode(HistoryHash.getHash()) !== decode(newHash)) {74 HistoryHash[src === HistoryBase.SRC_REPLACE ? 'replaceHash' : 'setHash'](newHash);75 }76 },77 // -- Protected Event Handlers ---------------------------------------------78 /**79 * Handler for hashchange events.80 *81 * @method _afterHashChange82 * @param {Event} e83 * @protected84 */85 _afterHashChange: function (e) {86 this._resolveChanges(SRC_HASH, HistoryHash.parseHash(e.newHash), {});87 }88}, {89 // -- Public Static Properties ---------------------------------------------90 NAME: 'historyHash',91 /**92 * Constant used to identify state changes originating from93 * <code>hashchange</code> events.94 *95 * @property SRC_HASH96 * @type String97 * @static98 * @final99 */100 SRC_HASH: SRC_HASH,101 /**102 * <p>103 * Prefix to prepend when setting the hash fragment. For example, if the104 * prefix is <code>!</code> and the hash fragment is set to105 * <code>#foo=bar&baz=quux</code>, the final hash fragment in the URL will106 * become <code>#!foo=bar&baz=quux</code>. This can be used to help make an107 * Ajax application crawlable in accordance with Google's guidelines at108 * <a href="http://code.google.com/web/ajaxcrawling/">http://code.google.com/web/ajaxcrawling/</a>.109 * </p>110 *111 * <p>112 * Note that this prefix applies to all HistoryHash instances. It's not113 * possible for individual instances to use their own prefixes since they114 * all operate on the same URL.115 * </p>116 *117 * @property hashPrefix118 * @type String119 * @default ''120 * @static121 */122 hashPrefix: '',123 // -- Protected Static Properties ------------------------------------------124 /**125 * Regular expression used to parse location hash/query strings.126 *127 * @property _REGEX_HASH128 * @type RegExp129 * @protected130 * @static131 * @final132 */133 _REGEX_HASH: /([^\?#&=]+)=?([^&=]*)/g,134 // -- Public Static Methods ------------------------------------------------135 /**136 * Creates a location hash string from the specified object of key/value137 * pairs.138 *139 * @method createHash140 * @param {Object} params object of key/value parameter pairs141 * @return {String} location hash string142 * @static143 */144 createHash: function (params) {145 var encode = HistoryHash.encode,146 hash = [];147 YObject.each(params, function (value, key) {148 if (Lang.isValue(value)) {149 hash.push(encode(key) + '=' + encode(value));150 }151 });152 return hash.join('&');153 },154 /**155 * Wrapper around <code>decodeURIComponent()</code> that also converts +156 * chars into spaces.157 *158 * @method decode159 * @param {String} string string to decode160 * @return {String} decoded string161 * @static162 */163 decode: function (string) {164 return decodeURIComponent(string.replace(/\+/g, ' '));165 },166 /**167 * Wrapper around <code>encodeURIComponent()</code> that converts spaces to168 * + chars.169 *170 * @method encode171 * @param {String} string string to encode172 * @return {String} encoded string173 * @static174 */175 encode: function (string) {176 return encodeURIComponent(string).replace(/%20/g, '+');177 },178 /**179 * Gets the raw (not decoded) current location hash, minus the preceding '#'180 * character and the hashPrefix (if one is set).181 *182 * @method getHash183 * @return {String} current location hash184 * @static185 */186 getHash: (Y.UA.gecko ? function () {187 // Gecko's window.location.hash returns a decoded string and we want all188 // encoding untouched, so we need to get the hash value from189 // window.location.href instead. We have to use UA sniffing rather than190 // feature detection, since the only way to detect this would be to191 // actually change the hash.192 var location = Y.getLocation(),193 matches = /#(.*)$/.exec(location.href),194 hash = matches && matches[1] || '',195 prefix = HistoryHash.hashPrefix;196 return prefix && hash.indexOf(prefix) === 0 ?197 hash.replace(prefix, '') : hash;198 } : function () {199 var location = Y.getLocation(),200 hash = location.hash.substring(1),201 prefix = HistoryHash.hashPrefix;202 // Slight code duplication here, but execution speed is of the essence203 // since getHash() is called every 50ms to poll for changes in browsers204 // that don't support native onhashchange. An additional function call205 // would add unnecessary overhead.206 return prefix && hash.indexOf(prefix) === 0 ?207 hash.replace(prefix, '') : hash;208 }),209 /**210 * Gets the current bookmarkable URL.211 *212 * @method getUrl213 * @return {String} current bookmarkable URL214 * @static215 */216 getUrl: function () {217 return location.href;218 },219 /**220 * Parses a location hash string into an object of key/value parameter221 * pairs. If <i>hash</i> is not specified, the current location hash will222 * be used.223 *224 * @method parseHash225 * @param {String} hash (optional) location hash string226 * @return {Object} object of parsed key/value parameter pairs227 * @static228 */229 parseHash: function (hash) {230 var decode = HistoryHash.decode,231 i,232 len,233 match,234 matches,235 param,236 params = {},237 prefix = HistoryHash.hashPrefix,238 prefixIndex;239 hash = Lang.isValue(hash) ? hash : HistoryHash.getHash();240 if (prefix) {241 prefixIndex = hash.indexOf(prefix);242 if (prefixIndex === 0 || (prefixIndex === 1 && hash.charAt(0) === '#')) {243 hash = hash.replace(prefix, '');244 }245 }246 matches = hash.match(HistoryHash._REGEX_HASH) || [];247 for (i = 0, len = matches.length; i < len; ++i) {248 match = matches[i];249 param = match.split('=');250 if (param.length > 1) {251 params[decode(param[0])] = decode(param[1]);252 } else {253 params[decode(match)] = '';254 }255 }256 return params;257 },258 /**259 * Replaces the browser's current location hash with the specified hash260 * and removes all forward navigation states, without creating a new browser261 * history entry. Automatically prepends the <code>hashPrefix</code> if one262 * is set.263 *264 * @method replaceHash265 * @param {String} hash new location hash266 * @static267 */268 replaceHash: function (hash) {269 var location = Y.getLocation(),270 base = location.href.replace(/#.*$/, '');271 if (hash.charAt(0) === '#') {272 hash = hash.substring(1);273 }274 location.replace(base + '#' + (HistoryHash.hashPrefix || '') + hash);275 },276 /**277 * Sets the browser's location hash to the specified string. Automatically278 * prepends the <code>hashPrefix</code> if one is set.279 *280 * @method setHash281 * @param {String} hash new location hash282 * @static283 */284 setHash: function (hash) {285 var location = Y.getLocation();286 if (hash.charAt(0) === '#') {287 hash = hash.substring(1);288 }289 location.hash = (HistoryHash.hashPrefix || '') + hash;290 }291});292// -- Synthetic hashchange Event -----------------------------------------------293// TODO: YUIDoc currently doesn't provide a good way to document synthetic DOM294// events. For now, we're just documenting the hashchange event on the YUI295// object, which is about the best we can do until enhancements are made to296// YUIDoc.297/**298Synthetic <code>window.onhashchange</code> event that normalizes differences299across browsers and provides support for browsers that don't natively support300<code>onhashchange</code>.301This event is provided by the <code>history-hash</code> module.302@example303 YUI().use('history-hash', function (Y) {304 Y.on('hashchange', function (e) {305 // Handle hashchange events on the current window.306 }, Y.config.win);307 });308@event hashchange309@param {EventFacade} e Event facade with the following additional310 properties:311<dl>312 <dt>oldHash</dt>313 <dd>314 Previous hash fragment value before the change.315 </dd>316 <dt>oldUrl</dt>317 <dd>318 Previous URL (including the hash fragment) before the change.319 </dd>320 <dt>newHash</dt>321 <dd>322 New hash fragment value after the change.323 </dd>324 <dt>newUrl</dt>325 <dd>326 New URL (including the hash fragment) after the change.327 </dd>328</dl>329@for YUI330@since 3.2.0331**/332hashNotifiers = GlobalEnv._notifiers;333if (!hashNotifiers) {334 hashNotifiers = GlobalEnv._notifiers = [];335}336Y.Event.define('hashchange', {337 on: function (node, subscriber, notifier) {338 // Ignore this subscription if the node is anything other than the339 // window or document body, since those are the only elements that340 // should support the hashchange event. Note that the body could also be341 // a frameset, but that's okay since framesets support hashchange too.342 if (node.compareTo(win) || node.compareTo(Y.config.doc.body)) {343 hashNotifiers.push(notifier);344 }345 },346 detach: function (node, subscriber, notifier) {347 var index = YArray.indexOf(hashNotifiers, notifier);348 if (index !== -1) {349 hashNotifiers.splice(index, 1);350 }351 }352});353oldHash = HistoryHash.getHash();354oldUrl = HistoryHash.getUrl();355if (HistoryBase.nativeHashChange) {356 // Wrap the browser's native hashchange event if there's not already a357 // global listener.358 if (!GlobalEnv._hashHandle) {359 GlobalEnv._hashHandle = Y.Event.attach('hashchange', function (e) {360 var newHash = HistoryHash.getHash(),361 newUrl = HistoryHash.getUrl();362 // Iterate over a copy of the hashNotifiers array since a subscriber363 // could detach during iteration and cause the array to be re-indexed.364 YArray.each(hashNotifiers.concat(), function (notifier) {365 notifier.fire({366 _event : e,367 oldHash: oldHash,368 oldUrl : oldUrl,369 newHash: newHash,370 newUrl : newUrl371 });372 });373 oldHash = newHash;374 oldUrl = newUrl;375 }, win);376 }377} else {378 // Begin polling for location hash changes if there's not already a global379 // poll running.380 if (!GlobalEnv._hashPoll) {381 GlobalEnv._hashPoll = Y.later(50, null, function () {382 var newHash = HistoryHash.getHash(),383 facade, newUrl;384 if (oldHash !== newHash) {385 newUrl = HistoryHash.getUrl();386 facade = {387 oldHash: oldHash,388 oldUrl : oldUrl,389 newHash: newHash,390 newUrl : newUrl391 };392 oldHash = newHash;393 oldUrl = newUrl;394 YArray.each(hashNotifiers.concat(), function (notifier) {395 notifier.fire(facade);396 });397 }398 }, null, true);399 }400}401Y.HistoryHash = HistoryHash;402// HistoryHash will never win over HistoryHTML5 unless useHistoryHTML5 is false.403if (useHistoryHTML5 === false || (!Y.History && useHistoryHTML5 !== true &&404 (!HistoryBase.html5 || !Y.HistoryHTML5))) {405 Y.History = HistoryHash;406}...

Full Screen

Full Screen

html.js

Source:html.js Github

copy

Full Screen

1/*==================================================2 * HTML Utility Functions3 *==================================================4 */5SimileAjax.HTML = new Object();6SimileAjax.HTML._e2uHash = {};7(function() {8 var e2uHash = SimileAjax.HTML._e2uHash;9 e2uHash['nbsp']= '\u00A0[space]';10 e2uHash['iexcl']= '\u00A1';11 e2uHash['cent']= '\u00A2';12 e2uHash['pound']= '\u00A3';13 e2uHash['curren']= '\u00A4';14 e2uHash['yen']= '\u00A5';15 e2uHash['brvbar']= '\u00A6';16 e2uHash['sect']= '\u00A7';17 e2uHash['uml']= '\u00A8';18 e2uHash['copy']= '\u00A9';19 e2uHash['ordf']= '\u00AA';20 e2uHash['laquo']= '\u00AB';21 e2uHash['not']= '\u00AC';22 e2uHash['shy']= '\u00AD';23 e2uHash['reg']= '\u00AE';24 e2uHash['macr']= '\u00AF';25 e2uHash['deg']= '\u00B0';26 e2uHash['plusmn']= '\u00B1';27 e2uHash['sup2']= '\u00B2';28 e2uHash['sup3']= '\u00B3';29 e2uHash['acute']= '\u00B4';30 e2uHash['micro']= '\u00B5';31 e2uHash['para']= '\u00B6';32 e2uHash['middot']= '\u00B7';33 e2uHash['cedil']= '\u00B8';34 e2uHash['sup1']= '\u00B9';35 e2uHash['ordm']= '\u00BA';36 e2uHash['raquo']= '\u00BB';37 e2uHash['frac14']= '\u00BC';38 e2uHash['frac12']= '\u00BD';39 e2uHash['frac34']= '\u00BE';40 e2uHash['iquest']= '\u00BF';41 e2uHash['Agrave']= '\u00C0';42 e2uHash['Aacute']= '\u00C1';43 e2uHash['Acirc']= '\u00C2';44 e2uHash['Atilde']= '\u00C3';45 e2uHash['Auml']= '\u00C4';46 e2uHash['Aring']= '\u00C5';47 e2uHash['AElig']= '\u00C6';48 e2uHash['Ccedil']= '\u00C7';49 e2uHash['Egrave']= '\u00C8';50 e2uHash['Eacute']= '\u00C9';51 e2uHash['Ecirc']= '\u00CA';52 e2uHash['Euml']= '\u00CB';53 e2uHash['Igrave']= '\u00CC';54 e2uHash['Iacute']= '\u00CD';55 e2uHash['Icirc']= '\u00CE';56 e2uHash['Iuml']= '\u00CF';57 e2uHash['ETH']= '\u00D0';58 e2uHash['Ntilde']= '\u00D1';59 e2uHash['Ograve']= '\u00D2';60 e2uHash['Oacute']= '\u00D3';61 e2uHash['Ocirc']= '\u00D4';62 e2uHash['Otilde']= '\u00D5';63 e2uHash['Ouml']= '\u00D6';64 e2uHash['times']= '\u00D7';65 e2uHash['Oslash']= '\u00D8';66 e2uHash['Ugrave']= '\u00D9';67 e2uHash['Uacute']= '\u00DA';68 e2uHash['Ucirc']= '\u00DB';69 e2uHash['Uuml']= '\u00DC';70 e2uHash['Yacute']= '\u00DD';71 e2uHash['THORN']= '\u00DE';72 e2uHash['szlig']= '\u00DF';73 e2uHash['agrave']= '\u00E0';74 e2uHash['aacute']= '\u00E1';75 e2uHash['acirc']= '\u00E2';76 e2uHash['atilde']= '\u00E3';77 e2uHash['auml']= '\u00E4';78 e2uHash['aring']= '\u00E5';79 e2uHash['aelig']= '\u00E6';80 e2uHash['ccedil']= '\u00E7';81 e2uHash['egrave']= '\u00E8';82 e2uHash['eacute']= '\u00E9';83 e2uHash['ecirc']= '\u00EA';84 e2uHash['euml']= '\u00EB';85 e2uHash['igrave']= '\u00EC';86 e2uHash['iacute']= '\u00ED';87 e2uHash['icirc']= '\u00EE';88 e2uHash['iuml']= '\u00EF';89 e2uHash['eth']= '\u00F0';90 e2uHash['ntilde']= '\u00F1';91 e2uHash['ograve']= '\u00F2';92 e2uHash['oacute']= '\u00F3';93 e2uHash['ocirc']= '\u00F4';94 e2uHash['otilde']= '\u00F5';95 e2uHash['ouml']= '\u00F6';96 e2uHash['divide']= '\u00F7';97 e2uHash['oslash']= '\u00F8';98 e2uHash['ugrave']= '\u00F9';99 e2uHash['uacute']= '\u00FA';100 e2uHash['ucirc']= '\u00FB';101 e2uHash['uuml']= '\u00FC';102 e2uHash['yacute']= '\u00FD';103 e2uHash['thorn']= '\u00FE';104 e2uHash['yuml']= '\u00FF';105 e2uHash['quot']= '\u0022';106 e2uHash['amp']= '\u0026';107 e2uHash['lt']= '\u003C';108 e2uHash['gt']= '\u003E';109 e2uHash['OElig']= '';110 e2uHash['oelig']= '\u0153';111 e2uHash['Scaron']= '\u0160';112 e2uHash['scaron']= '\u0161';113 e2uHash['Yuml']= '\u0178';114 e2uHash['circ']= '\u02C6';115 e2uHash['tilde']= '\u02DC';116 e2uHash['ensp']= '\u2002';117 e2uHash['emsp']= '\u2003';118 e2uHash['thinsp']= '\u2009';119 e2uHash['zwnj']= '\u200C';120 e2uHash['zwj']= '\u200D';121 e2uHash['lrm']= '\u200E';122 e2uHash['rlm']= '\u200F';123 e2uHash['ndash']= '\u2013';124 e2uHash['mdash']= '\u2014';125 e2uHash['lsquo']= '\u2018';126 e2uHash['rsquo']= '\u2019';127 e2uHash['sbquo']= '\u201A';128 e2uHash['ldquo']= '\u201C';129 e2uHash['rdquo']= '\u201D';130 e2uHash['bdquo']= '\u201E';131 e2uHash['dagger']= '\u2020';132 e2uHash['Dagger']= '\u2021';133 e2uHash['permil']= '\u2030';134 e2uHash['lsaquo']= '\u2039';135 e2uHash['rsaquo']= '\u203A';136 e2uHash['euro']= '\u20AC';137 e2uHash['fnof']= '\u0192';138 e2uHash['Alpha']= '\u0391';139 e2uHash['Beta']= '\u0392';140 e2uHash['Gamma']= '\u0393';141 e2uHash['Delta']= '\u0394';142 e2uHash['Epsilon']= '\u0395';143 e2uHash['Zeta']= '\u0396';144 e2uHash['Eta']= '\u0397';145 e2uHash['Theta']= '\u0398';146 e2uHash['Iota']= '\u0399';147 e2uHash['Kappa']= '\u039A';148 e2uHash['Lambda']= '\u039B';149 e2uHash['Mu']= '\u039C';150 e2uHash['Nu']= '\u039D';151 e2uHash['Xi']= '\u039E';152 e2uHash['Omicron']= '\u039F';153 e2uHash['Pi']= '\u03A0';154 e2uHash['Rho']= '\u03A1';155 e2uHash['Sigma']= '\u03A3';156 e2uHash['Tau']= '\u03A4';157 e2uHash['Upsilon']= '\u03A5';158 e2uHash['Phi']= '\u03A6';159 e2uHash['Chi']= '\u03A7';160 e2uHash['Psi']= '\u03A8';161 e2uHash['Omega']= '\u03A9';162 e2uHash['alpha']= '\u03B1';163 e2uHash['beta']= '\u03B2';164 e2uHash['gamma']= '\u03B3';165 e2uHash['delta']= '\u03B4';166 e2uHash['epsilon']= '\u03B5';167 e2uHash['zeta']= '\u03B6';168 e2uHash['eta']= '\u03B7';169 e2uHash['theta']= '\u03B8';170 e2uHash['iota']= '\u03B9';171 e2uHash['kappa']= '\u03BA';172 e2uHash['lambda']= '\u03BB';173 e2uHash['mu']= '\u03BC';174 e2uHash['nu']= '\u03BD';175 e2uHash['xi']= '\u03BE';176 e2uHash['omicron']= '\u03BF';177 e2uHash['pi']= '\u03C0';178 e2uHash['rho']= '\u03C1';179 e2uHash['sigmaf']= '\u03C2';180 e2uHash['sigma']= '\u03C3';181 e2uHash['tau']= '\u03C4';182 e2uHash['upsilon']= '\u03C5';183 e2uHash['phi']= '\u03C6';184 e2uHash['chi']= '\u03C7';185 e2uHash['psi']= '\u03C8';186 e2uHash['omega']= '\u03C9';187 e2uHash['thetasym']= '\u03D1';188 e2uHash['upsih']= '\u03D2';189 e2uHash['piv']= '\u03D6';190 e2uHash['bull']= '\u2022';191 e2uHash['hellip']= '\u2026';192 e2uHash['prime']= '\u2032';193 e2uHash['Prime']= '\u2033';194 e2uHash['oline']= '\u203E';195 e2uHash['frasl']= '\u2044';196 e2uHash['weierp']= '\u2118';197 e2uHash['image']= '\u2111';198 e2uHash['real']= '\u211C';199 e2uHash['trade']= '\u2122';200 e2uHash['alefsym']= '\u2135';201 e2uHash['larr']= '\u2190';202 e2uHash['uarr']= '\u2191';203 e2uHash['rarr']= '\u2192';204 e2uHash['darr']= '\u2193';205 e2uHash['harr']= '\u2194';206 e2uHash['crarr']= '\u21B5';207 e2uHash['lArr']= '\u21D0';208 e2uHash['uArr']= '\u21D1';209 e2uHash['rArr']= '\u21D2';210 e2uHash['dArr']= '\u21D3';211 e2uHash['hArr']= '\u21D4';212 e2uHash['forall']= '\u2200';213 e2uHash['part']= '\u2202';214 e2uHash['exist']= '\u2203';215 e2uHash['empty']= '\u2205';216 e2uHash['nabla']= '\u2207';217 e2uHash['isin']= '\u2208';218 e2uHash['notin']= '\u2209';219 e2uHash['ni']= '\u220B';220 e2uHash['prod']= '\u220F';221 e2uHash['sum']= '\u2211';222 e2uHash['minus']= '\u2212';223 e2uHash['lowast']= '\u2217';224 e2uHash['radic']= '\u221A';225 e2uHash['prop']= '\u221D';226 e2uHash['infin']= '\u221E';227 e2uHash['ang']= '\u2220';228 e2uHash['and']= '\u2227';229 e2uHash['or']= '\u2228';230 e2uHash['cap']= '\u2229';231 e2uHash['cup']= '\u222A';232 e2uHash['int']= '\u222B';233 e2uHash['there4']= '\u2234';234 e2uHash['sim']= '\u223C';235 e2uHash['cong']= '\u2245';236 e2uHash['asymp']= '\u2248';237 e2uHash['ne']= '\u2260';238 e2uHash['equiv']= '\u2261';239 e2uHash['le']= '\u2264';240 e2uHash['ge']= '\u2265';241 e2uHash['sub']= '\u2282';242 e2uHash['sup']= '\u2283';243 e2uHash['nsub']= '\u2284';244 e2uHash['sube']= '\u2286';245 e2uHash['supe']= '\u2287';246 e2uHash['oplus']= '\u2295';247 e2uHash['otimes']= '\u2297';248 e2uHash['perp']= '\u22A5';249 e2uHash['sdot']= '\u22C5';250 e2uHash['lceil']= '\u2308';251 e2uHash['rceil']= '\u2309';252 e2uHash['lfloor']= '\u230A';253 e2uHash['rfloor']= '\u230B';254 e2uHash['lang']= '\u2329';255 e2uHash['rang']= '\u232A';256 e2uHash['loz']= '\u25CA';257 e2uHash['spades']= '\u2660';258 e2uHash['clubs']= '\u2663';259 e2uHash['hearts']= '\u2665';260 e2uHash['diams']= '\u2666'; 261})();262SimileAjax.HTML.deEntify = function(s) {263 var e2uHash = SimileAjax.HTML._e2uHash;264 265 var re = /&(\w+?);/;266 while (re.test(s)) {267 var m = s.match(re);268 s = s.replace(re, e2uHash[m[1]]);269 }270 return s;...

Full Screen

Full Screen

hash.spec.js

Source:hash.spec.js Github

copy

Full Screen

1'use strict'2/*3 * adonis-framework4 *5 * (c) Harminder Virk <virk@adonisjs.com>6 *7 * For the full copyright and license information, please view the LICENSE8 * file that was distributed with this source code.9*/10const test = require('japa')11const { ioc } = require('@adonisjs/fold')12const { Config } = require('@adonisjs/sink')13const BcryptDriver = require('../../src/Hash/Drivers').bcrypt14const ArgonDriver = require('../../src/Hash/Drivers').argon15const Hash = require('../../src/Hash')16const HashManager = require('../../src/Hash/Manager')17const HashFacade = require('../../src/Hash/Facade')18const HashMock = require('../../src/Hash/Mock')19test.group('Hash | Bcrypt Driver', (group) => {20 test('hash value', async (assert) => {21 const Hash = new BcryptDriver()22 const hashed = await Hash.make('foo')23 assert.isDefined(hashed)24 })25 test('return true when hash matches', async (assert) => {26 const Hash = new BcryptDriver()27 const hashed = await Hash.make('foo')28 const verified = await Hash.verify('foo', hashed)29 assert.isTrue(verified)30 })31 test('return false when hash does not match', async (assert) => {32 const Hash = new BcryptDriver()33 const hashed = await Hash.make('foo')34 const verified = await Hash.verify('bar', hashed)35 assert.isFalse(verified)36 })37 test('return false instead of throwing exception', async (assert) => {38 const Hash = new BcryptDriver()39 const hashed = await Hash.make('foo')40 const verified = await Hash.verify(undefined, hashed)41 assert.isFalse(verified)42 })43})44test.group('Hash | Argon Driver', (group) => {45 test('hash value', async (assert) => {46 const Hash = new ArgonDriver()47 const hashed = await Hash.make('foo')48 assert.isDefined(hashed)49 })50 test('return true when hash matches', async (assert) => {51 const Hash = new ArgonDriver()52 const hashed = await Hash.make('foo')53 const verified = await Hash.verify('foo', hashed)54 assert.isTrue(verified)55 })56 test('return false when hash does not match', async (assert) => {57 const Hash = new ArgonDriver()58 const hashed = await Hash.make('foo')59 const verified = await Hash.verify('bar', hashed)60 assert.isFalse(verified)61 })62 test('return false instead of throwing exception', async (assert) => {63 const Hash = new ArgonDriver()64 const hashed = await Hash.make('foo')65 const verified = await Hash.verify(undefined, hashed)66 assert.isFalse(verified)67 })68})69test.group('Hash | Fake', () => {70 test('return string as it is from mock', async (assert) => {71 const hashed = await HashMock.make('foo')72 assert.equal(hashed, 'foo')73 })74 test('return false when strings aren\'t equal', async (assert) => {75 const verified = await HashMock.verify('foo', 'bar')76 assert.isFalse(verified)77 })78 test('return true when strings are equal', async (assert) => {79 const verified = await HashMock.verify('foo', 'foo')80 assert.isTrue(verified)81 })82})83test.group('Hash | Instance', () => {84 test('hash password using defined driver', async (assert) => {85 const Bcrypt = new BcryptDriver()86 const hash = new Hash(Bcrypt)87 const hashed = await hash.make('foo')88 assert.isDefined(hashed)89 })90 test('verify hash using defined driver', async (assert) => {91 const Bcrypt = new BcryptDriver()92 const hash = new Hash(Bcrypt)93 const hashed = await hash.make('foo')94 const verified = await hash.verify('foo', hashed)95 assert.isTrue(verified)96 })97})98test.group('Hash | Manager', (group) => {99 group.before(() => {100 ioc.fake('Adonis/Src/Config', () => new Config())101 })102 test('extend hasher by adding drivers', (assert) => {103 const myDriver = {}104 HashManager.extend('myDriver', myDriver)105 assert.deepEqual(HashManager._drivers, { myDriver })106 })107 test('throw error when trying to access invalid driver', (assert) => {108 const fn = () => HashManager.driver('foo')109 assert.throw(fn, 'E_INVALID_HASHER_DRIVER: Hash driver foo does not exists')110 })111 test('return driver instance for a given driver', (assert) => {112 const bcryptDriver = HashManager.driver('bcrypt')113 assert.instanceOf(bcryptDriver, BcryptDriver)114 })115})116test.group('Hash | Facade', (group) => {117 group.before(() => {118 ioc.fake('Adonis/Src/Config', () => new Config())119 })120 test('return hasher instance with selected driver', (assert) => {121 const config = new Config()122 config.set('hash', {123 driver: 'bcrypt',124 bcrypt: {}125 })126 const hasher = new HashFacade(config)127 assert.instanceOf(hasher.driver('bcrypt'), Hash)128 assert.instanceOf(hasher.driver('bcrypt').driver, BcryptDriver)129 })130 test('return hasher instance with extended driver', (assert) => {131 const myDriver = {132 make () {},133 setConfig () {}134 }135 HashManager.extend('mydriver', myDriver)136 const config = new Config()137 config.set('hash', {138 driver: 'mydriver',139 mydriver: {}140 })141 const hasher = new HashFacade(config)142 assert.instanceOf(hasher.driver('mydriver'), Hash)143 assert.deepEqual(hasher.driver('mydriver').driver, myDriver)144 })145 test('create singleton hasher instances', (assert) => {146 const config = new Config()147 config.set('hash', {148 driver: 'bcrypt',149 bcrypt: {},150 anotherFile: {}151 })152 const hasher = new HashFacade(config)153 hasher.driver('bcrypt')154 assert.lengthOf(Object.keys(hasher._hasherInstances), 1)155 hasher.driver('bcrypt')156 assert.lengthOf(Object.keys(hasher._hasherInstances), 1)157 })158 test('create different instance when hasher is different', (assert) => {159 const config = new Config()160 config.set('hash', {161 driver: 'bcrypt',162 bcrypt: {},163 argon: {}164 })165 const hasher = new HashFacade(config)166 hasher.driver('bcrypt')167 assert.lengthOf(Object.keys(hasher._hasherInstances), 1)168 hasher.driver('argon')169 assert.lengthOf(Object.keys(hasher._hasherInstances), 2)170 })171 test('proxy hasher instance methods', async (assert) => {172 const config = new Config()173 config.set('hash', {174 driver: 'bcrypt',175 bcrypt: {176 round: 10177 }178 })179 const hasher = new HashFacade(config)180 const hashed = await hasher.make('foo')181 assert.isDefined(hashed)182 })183 test('use bcrypt when no driver is defined', async (assert) => {184 const config = new Config()185 config.set('hash', {186 })187 const hasher = new HashFacade(config)188 const hashed = await hasher.make('foo')189 assert.isDefined(hashed)190 })...

Full Screen

Full Screen

history-hash-ie-debug.js

Source:history-hash-ie-debug.js Github

copy

Full Screen

1/*2YUI 3.17.2 (build 9c3c78e)3Copyright 2014 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7YUI.add('history-hash-ie', function (Y, NAME) {8/**9 * Improves IE6/7 support in history-hash by using a hidden iframe to create10 * entries in IE's browser history. This module is only needed if IE6/7 support11 * is necessary; it's not needed for any other browser.12 *13 * @module history14 * @submodule history-hash-ie15 * @since 3.2.016 */17// Combination of a UA sniff to ensure this is IE (or a browser that wants us to18// treat it like IE) and feature detection for native hashchange support (false19// for IE < 8 or IE8/9 in IE7 mode).20if (Y.UA.ie && !Y.HistoryBase.nativeHashChange) {21 var Do = Y.Do,22 GlobalEnv = YUI.namespace('Env.HistoryHash'),23 HistoryHash = Y.HistoryHash,24 iframe = GlobalEnv._iframe,25 win = Y.config.win;26 /**27 * Gets the raw (not decoded) current location hash from the IE iframe,28 * minus the preceding '#' character and the hashPrefix (if one is set).29 *30 * @method getIframeHash31 * @return {String} current iframe hash32 * @static33 */34 HistoryHash.getIframeHash = function () {35 if (!iframe || !iframe.contentWindow) {36 return '';37 }38 var prefix = HistoryHash.hashPrefix,39 hash = iframe.contentWindow.location.hash.substr(1);40 return prefix && hash.indexOf(prefix) === 0 ?41 hash.replace(prefix, '') : hash;42 };43 /**44 * Updates the history iframe with the specified hash.45 *46 * @method _updateIframe47 * @param {String} hash location hash48 * @param {Boolean} replace (optional) if <code>true</code>, the current49 * history state will be replaced without adding a new history entry50 * @protected51 * @static52 * @for HistoryHash53 */54 HistoryHash._updateIframe = function (hash, replace) {55 var iframeDoc = iframe && iframe.contentWindow && iframe.contentWindow.document,56 iframeLocation = iframeDoc && iframeDoc.location;57 if (!iframeDoc || !iframeLocation) {58 return;59 }60 Y.log('updating history iframe: ' + hash + ', replace: ' + !!replace, 'info', 'history');61 if (replace) {62 iframeLocation.replace(hash.charAt(0) === '#' ? hash : '#' + hash);63 } else {64 iframeDoc.open().close();65 iframeLocation.hash = hash;66 }67 };68 Do.before(HistoryHash._updateIframe, HistoryHash, 'replaceHash', HistoryHash, true);69 if (!iframe) {70 Y.on('domready', function () {71 var lastUrlHash = HistoryHash.getHash();72 // Create a hidden iframe to store history state, following the73 // iframe-hiding recommendations from74 // http://www.paciellogroup.com/blog/?p=604.75 //76 // This iframe will allow history navigation within the current page77 // context. After navigating to another page, all but the most78 // recent history state will be lost.79 //80 // Earlier versions of the YUI History Utility attempted to work81 // around this limitation by having the iframe load a static82 // resource. This workaround was extremely fragile and tended to83 // break frequently (and silently) since it was entirely dependent84 // on IE's inconsistent handling of iframe history.85 //86 // Since this workaround didn't work much of the time anyway and87 // added significant complexity, it has been removed, and IE6 and 788 // now get slightly degraded history support.89 Y.log('creating dynamic history iframe', 'info', 'history');90 iframe = GlobalEnv._iframe = Y.Node.getDOMNode(Y.Node.create(91 '<iframe src="javascript:0" style="display:none" height="0" width="0" tabindex="-1" title="empty"/>'92 ));93 // Append the iframe to the documentElement rather than the body.94 // Keeping it outside the body prevents scrolling on the initial95 // page load (hat tip to Ben Alman and jQuery BBQ for this96 // technique).97 Y.config.doc.documentElement.appendChild(iframe);98 // Update the iframe with the initial location hash, if any. This99 // will create an initial history entry that the user can return to100 // after the state has changed.101 HistoryHash._updateIframe(lastUrlHash || '#');102 // Listen for hashchange events and keep the iframe's hash in sync103 // with the parent frame's hash.104 Y.on('hashchange', function (e) {105 lastUrlHash = e.newHash;106 if (HistoryHash.getIframeHash() !== lastUrlHash) {107 Y.log('updating iframe hash to match URL hash', 'info', 'history');108 HistoryHash._updateIframe(lastUrlHash);109 }110 }, win);111 // Watch the iframe hash in order to detect back/forward navigation.112 Y.later(50, null, function () {113 var iframeHash = HistoryHash.getIframeHash();114 if (iframeHash !== lastUrlHash) {115 Y.log('updating URL hash to match iframe hash', 'info', 'history');116 HistoryHash.setHash(iframeHash);117 }118 }, null, true);119 });120 }121}...

Full Screen

Full Screen

HashTable.js

Source:HashTable.js Github

copy

Full Screen

1//-------------------------------------------------------------------------------2// Requires3//-------------------------------------------------------------------------------4var Class = require('./Class');5var HashTableNode = require('./HashTableNode');6var Obj = require('./Obj');7//-------------------------------------------------------------------------------8// Declare Class9//-------------------------------------------------------------------------------10var HashTable = Class.extend(Obj, {11 //-------------------------------------------------------------------------------12 // Constructor13 //-------------------------------------------------------------------------------14 _constructor: function() {15 this._super();16 //-------------------------------------------------------------------------------17 // Declare Variables18 //-------------------------------------------------------------------------------19 /**20 * @private21 * @type {number}22 */23 this.count = 0;24 /**25 * @private26 * @type {Object}27 */28 this.hashTableNodeObject = {};29 },30 //-------------------------------------------------------------------------------31 // Getters and Setters32 //-------------------------------------------------------------------------------33 /**34 * @return {number}35 */36 getCount: function() {37 return this.count;38 },39 //-------------------------------------------------------------------------------40 // Public Methods41 //-------------------------------------------------------------------------------42 /**43 * @param {*} key44 * @return {boolean}45 */46 containsKey: function(key) {47 var keyHashCode = Obj.hashCode(key);48 var hashTableNode = this.hashTableNodeObject[keyHashCode];49 if (hashTableNode) {50 return hashTableNode.containsKey(key);51 }52 return false;53 },54 /**55 * @param {*} value56 * @return {boolean}57 */58 containsValue: function(value) {59 // NOTE BRN: The for in operator will only enumerate over our own properties, not the object's built in60 // properties. So it should be safe to access this.valueObject[key]61 for (var keyHashCode in this.hashTableNodeObject) {62 var hashTableNode = this.hashTableNodeObject[keyHashCode];63 if (hashTableNode.containsValue(value)) {64 return true;65 }66 }67 return false;68 },69 /**70 * @param {function(*)} func71 */72 forEach: function(func) {73 for (var keyHashCode in this.hashTableNodeObject) {74 var hashTableNode = this.hashTableNodeObject[keyHashCode];75 hashTableNode.getValueArray().forEach(function(value) {76 func(value);77 });78 }79 },80 /**81 * @param {*} key82 * @return {*}83 */84 get: function(key) {85 var keyHashCode = Obj.hashCode(key);86 var hashTableNode = this.hashTableNodeObject[keyHashCode];87 if (hashTableNode) {88 return hashTableNode.get(key);89 }90 return undefined;91 },92 /**93 * @return {Array<*>}94 */95 getKeyArray: function() {96 var keysArray = [];97 for (var keyHashCode in this.hashTableNodeObject) {98 var hashTableNode = this.hashTableNodeObject[keyHashCode];99 keysArray = keysArray.concat(hashTableNode.getKeyArray());100 }101 return keysArray;102 },103 /**104 * @return {Array<*>}105 */106 getValueArray: function() {107 var valuesArray = [];108 for (var keyHashCode in this.hashTableNodeObject) {109 var hashTableNode = this.hashTableNodeObject[keyHashCode];110 valuesArray = valuesArray.concat(hashTableNode.getValueArray());111 }112 return valuesArray;113 },114 /**115 * @return {boolean}116 */117 isEmpty: function() {118 return (this.count === 0);119 },120 /**121 * @param {*} key122 * @param {*} value123 * @return {*} Returns undefined if no value already existed at this key124 */125 put: function(key, value) {126 var keyHashCode = Obj.hashCode(key);127 var hashTableNode = this.hashTableNodeObject[keyHashCode];128 if (!hashTableNode) {129 hashTableNode = new HashTableNode();130 this.hashTableNodeObject[keyHashCode] = hashTableNode;131 }132 var returnValue = hashTableNode.put(key, value);133 if (returnValue === undefined) {134 this.count++;135 }136 return returnValue;137 },138 /**139 * @param {*} key140 * @return {*} Returns undefined if no value already existed at this key141 */142 remove: function(key) {143 var keyHashCode = Obj.hashCode(key);144 var hashTableNode = this.hashTableNodeObject[keyHashCode];145 var returnValue = undefined;146 if (hashTableNode) {147 returnValue = hashTableNode.remove(key);148 if (returnValue !== undefined) {149 this.count--;150 if (hashTableNode.getCount() === 0) {151 delete this.hashTableNodeObject[keyHashCode];152 }153 }154 }155 return returnValue;156 }157});158//-------------------------------------------------------------------------------159// Module Export160//-------------------------------------------------------------------------------...

Full Screen

Full Screen

HashStore.js

Source:HashStore.js Github

copy

Full Screen

1//-------------------------------------------------------------------------------2// Requires3//-------------------------------------------------------------------------------4var Class = require('./Class');5var HashStoreNode = require('./HashStoreNode');6var Obj = require('./Obj');7//-------------------------------------------------------------------------------8// Declare Class9//-------------------------------------------------------------------------------10var HashStore = Class.extend(Obj, {11 //-------------------------------------------------------------------------------12 // Constructor13 //-------------------------------------------------------------------------------14 _constructor: function() {15 this._super();16 //-------------------------------------------------------------------------------17 // Declare Variables18 //-------------------------------------------------------------------------------19 this.hashStoreNodeObject = {};20 },21 //-------------------------------------------------------------------------------22 // Public Methods23 //-------------------------------------------------------------------------------24 /**25 * @param {*} value26 */27 addValue: function(value) {28 var valueHashCode = Obj.hashCode(value);29 var hashStoreNode = this.hashStoreNodeObject[valueHashCode];30 if (!hashStoreNode) {31 hashStoreNode = new HashStoreNode();32 this.hashStoreNodeObject[valueHashCode] = hashStoreNode;33 }34 hashStoreNode.addValue(value);35 },36 /**37 * @param {function(*)} func38 */39 forEach: function(func) {40 for (var valueHashCode in this.hashStoreNodeObject) {41 var hashStoreNode = this.hashStoreNodeObject[valueHashCode];42 hashStoreNode.getValueArray().forEach(function(value) {43 func(value);44 });45 }46 },47 /**48 * @return {Array}49 */50 getValueArray: function() {51 var valueArray = [];52 for (var valueHashCode in this.hashStoreNodeObject) {53 var hashStoreNode = this.hashStoreNodeObject[valueHashCode];54 valueArray = valueArray.concat(hashStoreNode.getValueArray());55 }56 return valueArray;57 },58 /**59 * @param {*} value60 * @return {boolean}61 */62 hasValue: function(value) {63 var valueHashCode = Obj.hashCode(value);64 var hashStoreNode = this.hashStoreNodeObject[valueHashCode];65 if (hashStoreNode) {66 return hashStoreNode.containsValue(value);67 }68 return false;69 },70 /**71 * @param {*} value72 * @return {boolean}73 */74 removeValue: function(value) {75 var valueHashCode = Obj.hashCode(value);76 var hashStoreNode = this.hashStoreNodeObject[valueHashCode];77 var result = false;78 if (hashStoreNode) {79 result = hashStoreNode.removeValue(value);80 if (result) {81 if (hashStoreNode.getCount() === 0) {82 delete this.hashStoreNodeObject[valueHashCode];83 }84 }85 }86 return result;87 }88});89//-------------------------------------------------------------------------------90// Module Export91//-------------------------------------------------------------------------------...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { hash } from 'fast-check';2const hash1 = hash({ a: 1, b: 2 });3const hash2 = hash({ b: 2, a: 1 });4const hash3 = hash({ a: 1, b: 2, c: [1, 2, 3] });5const hash4 = hash({ b: 2, a: 1, c: [3, 2, 1] });6const hash5 = hash([1, 2, 3]);7const hash6 = hash([1, 2, 3]);8const hash7 = hash([1, 2, 3]);9const hash8 = hash([3, 2, 1]);10const hash9 = hash(new Set([1, 2, 3]));11const hash10 = hash(new Set([1, 2, 3]));12const hash11 = hash(new Set([1, 2, 3]));13const hash12 = hash(new Set([3, 2, 1]));14const hash13 = hash(new Map([['a', 1], ['b', 2]]));15const hash14 = hash(new Map([['b', 2], ['a', 1]]));16const hash15 = hash(new Map([['a', 1], ['b', 2]]));17const hash16 = hash(new Map([['a', 1], ['b', 3]]));18const hash17 = hash(new Map([['a', 1], ['b', 2]]));19const hash18 = hash(new Map([['a', 1], ['b', 2], ['c', 3]]));20const hash19 = hash(new Map([['a', 1], ['b', 2]]));21const hash20 = hash(new Map([['a', 1], ['b', 2], ['c', 3]]));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hash } = require('fast-check');2const { hash } = require('fast-check/lib/esm/hash');3const { hash } = require('fast-check/lib/cjs/hash');4const { hash } = require('fast-check');5const { hash } = require('fast-check/lib/esm/hash');6const { hash } = require('fast-check/lib/cjs/hash');7const { hash } = require('fast-check');8const { hash } = require('fast-check/lib/esm/hash');9const { hash } = require('fast-check/lib/cjs/hash');10const { hash } = require('fast-check');11const { hash } = require('fast-check/lib/esm/hash');12const { hash } = require('fast-check/lib/cjs/hash');13const { hash } = require('fast-check');14const { hash } = require('fast-check/lib/esm/hash');15const { hash } = require('fast-check/lib/cjs/hash');16const { hash } = require('fast-check');17const { hash } = require('fast-check/lib/esm/hash');18const { hash } = require('fast-check/lib/cjs/hash');19const { hash } = require('fast-check');20const { hash } = require('fast-check/lib/esm/hash');21const { hash } = require('fast-check/lib/cjs/hash');22const { hash } = require('fast-check');23const { hash } = require('fast-check/lib/esm/hash');24const { hash } = require('fast-check/lib/cjs/hash');25const { hash } = require('fast-check');26const { hash } = require('fast-check/lib/esm/hash');27const { hash } = require('fast-check/lib

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hash } = require('fast-check');2const { assert } = require('chai');3describe('hash', () => {4 it('should return a hash of 32 bytes', () => {5 assert.equal(hash(Buffer.from('Hello World')).length, 32);6 });7});8const { hash } = require('fast-check');9const { assert } = require('chai');10describe('hash', () => {11 it('should return a hash of 32 bytes', () => {12 assert.equal(hash(Buffer.from('Hello World')).length, 32);13 });14});15const { hash } = require('fast-check');16const { assert } = require('chai');17describe('hash', () => {18 it('should return a hash of 32 bytes', () => {19 assert.equal(hash(Buffer.from('Hello World')).length, 32);20 });21});22const { hash } = require('fast-check');23const { assert } = require('chai');24describe('hash', () => {25 it('should return a hash of 32 bytes', () => {26 assert.equal(hash(Buffer.from('Hello World')).length, 32);27 });28});29const { hash } = require('fast-check');30const { assert } = require('chai');31describe('hash', () => {32 it('should return a hash of 32 bytes', () => {33 assert.equal(hash(Buffer.from('Hello World')).length, 32);34 });35});36const { hash } = require('fast-check');37const { assert } = require('chai');38describe('hash', () => {39 it('should return a hash of 32 bytes', () => {40 assert.equal(hash(Buffer.from('Hello World')).length, 32);41 });42});43const { hash } = require('fast-check');44const { assert } = require('chai');45describe('hash', ()

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hash } = require('fast-check');2const { myGenerator } = require('./myGenerator');3const { myShrinker } = require('./myShrinker');4const seed = 42;5const arb = myGenerator().noShrink();6const value1 = arb.generate(seed);7const value2 = arb.generate(seed, myShrinker);8const value3 = arb.generate(seed);9const value4 = arb.generate(seed, myShrinker);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { hash } = require('fast-check-monorepo');3const hashCheck = fc.property(fc.string(), (str) => {4 return hash(str) === hash(str);5});6fc.assert(hashCheck, { verbose: true });

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful