Simon Hunt | 1eecfa2 | 2014-12-16 14:46:29 -0800 | [diff] [blame] | 1 | /* |
| 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 Hunt | dc6362a | 2014-12-18 19:55:23 -0800 | [diff] [blame] | 18 | ONOS GUI -- Util -- General Purpose Functions |
Simon Hunt | 1eecfa2 | 2014-12-16 14:46:29 -0800 | [diff] [blame] | 19 | |
| 20 | @author Simon Hunt |
| 21 | */ |
Simon Hunt | dc6362a | 2014-12-18 19:55:23 -0800 | [diff] [blame] | 22 | (function () { |
Simon Hunt | 1eecfa2 | 2014-12-16 14:46:29 -0800 | [diff] [blame] | 23 | 'use strict'; |
| 24 | |
Simon Hunt | 59df0b2 | 2014-12-17 10:32:25 -0800 | [diff] [blame] | 25 | 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 Hunt | dc6362a | 2014-12-18 19:55:23 -0800 | [diff] [blame] | 45 | 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 Hunt | 1eecfa2 | 2014-12-16 14:46:29 -0800 | [diff] [blame] | 54 | }]); |
| 55 | |
Simon Hunt | dc6362a | 2014-12-18 19:55:23 -0800 | [diff] [blame] | 56 | }()); |