blob: 4cdd0f019557532932b4d74b3c08e2d9f3eeb66d [file] [log] [blame]
Simon Hunt1eecfa22014-12-16 14:46:29 -08001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
Simon Huntdc6362a2014-12-18 19:55:23 -080018 ONOS GUI -- Util -- General Purpose Functions
Simon Hunt1eecfa22014-12-16 14:46:29 -080019
20 @author Simon Hunt
21 */
Simon Huntdc6362a2014-12-18 19:55:23 -080022(function () {
Simon Hunt1eecfa22014-12-16 14:46:29 -080023 'use strict';
24
Simon Hunt59df0b22014-12-17 10:32:25 -080025 function isF(f) {
26 return $.isFunction(f) ? f : null;
27 }
28
29 function isA(a) {
30 return $.isArray(a) ? a : null;
31 }
32
33 function isS(s) {
34 return typeof s === 'string' ? s : null;
35 }
36
37 function isO(o) {
38 return $.isPlainObject(o) ? o : null;
39 }
40
41 function contains(a, x) {
42 return isA(a) && a.indexOf(x) > -1;
43 }
44
Simon Huntdc6362a2014-12-18 19:55:23 -080045 angular.module('onosUtil')
46 .factory('FnService', [function () {
47 return {
48 isF: isF,
49 isA: isA,
50 isS: isS,
51 isO: isO,
52 contains: contains
53 };
Simon Hunt1eecfa22014-12-16 14:46:29 -080054 }]);
55
Simon Huntdc6362a2014-12-18 19:55:23 -080056}());